Req #70364 [Opn]: foreach type hinting
| From: | yohgaki@php.net | Date: | Thu, 03 Sep 2015 01:37:28 +0000 |
| Subject: | Req #70364 [Opn]: foreach type hinting | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-195724@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
Updated by: yohgaki@php.net
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:
@untuned20
Do you have problem with
foreach($classList as $class) {
assert($class instanceof MyClass);
}
or something like this?
Previous Comments:
------------------------------------------------------------------------
[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