From: mega-squall at caramail dot com Operating system: ALL PHP version: 5.1.4 PHP Bug Type: Feature/Change Request Bug description: Type Hinting with Array of Objects
Description: ------------ Type Hinting is compatible with array and objects, but not with array containing ONLY instances of single chosen class (array of instances). This would be appreciated, if relevant with the structure of arrays. Reproduce code: --------------- class B { public $field; public __construct ($param) { $this->field = $param; } } class A { public function method (B[] $parameters){ foreach ($parameters as $object) { echo $object->field . "\n"; } } } $b = Array (); for ($count=0; $count<10; $count++) { $b[] = new B ($count); } $a = new A (); $a->method ($b); Expected result: ---------------- 0 1 2 3 4 5 6 7 8 9 Actual result: -------------- Parse error: syntax error, unexpected '[', expecting '&' or T_VARIABLE in __FILE__ on line __LINE__ -- Edit bug report at http://bugs.php.net/?id=37450&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37450&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37450&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37450&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=37450&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=37450&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=37450&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=37450&r=needscript Try newer version: http://bugs.php.net/fix.php?id=37450&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=37450&r=support Expected behavior: http://bugs.php.net/fix.php?id=37450&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=37450&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=37450&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=37450&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37450&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=37450&r=dst IIS Stability: http://bugs.php.net/fix.php?id=37450&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=37450&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=37450&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=37450&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=37450&r=mysqlcfg