Req #70364 [Opn]: foreach type hinting
| From: | untuned20 at gmail dot com | Date: | Thu, 03 Sep 2015 01:52:05 +0000 |
| Subject: | Req #70364 [Opn]: foreach type hinting | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-195726@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70364&edit=1
ID: 70364
User updated by: untuned20 at gmail dot com
Reported by: untuned20 at gmail dot com
Summary: foreach type hinting
Status: Open
Type: Feature/Change Request
Package: Scripting Engine problem
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
I am seeing that php is trying to get more and more into type hinting, and that it would be nice to
have type hinting in foreach loops as well as in functions. Not only would it give the same
functionality as when declaring a function, but it would also allow IDE's to autocomplete
nicely.
Previous Comments:
------------------------------------------------------------------------
[2015-09-03 01:37:28] yohgaki@php.net
@untuned20
Do you have problem with
foreach($classList as $class) {
assert($class instanceof MyClass);
}
or something like this?
------------------------------------------------------------------------
[2015-08-26 16:21:23] untuned20 at gmail dot com
Description:
------------
Allow for the ability to type hint a foreach loop.
Test script:
---------------
<?php
$classList = [/* List of classes */];
foreach($classList as $index => MyClass $class){}
foreach($classList as MyClass $class){}
class MyClass{
/* Methods and Properties */
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70364&edit=1