Req #66814 [NEW]: Make typing hinting arrays use the new shorthand syntax

From: Date: Mon, 03 Mar 2014 10:04:34 +0000
Subject: Req #66814 [NEW]: Make typing hinting arrays use the new shorthand syntax
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184502@lists.php.net to get a copy of this message
From: tom at r dot je Operating system: Any PHP version: 5.5.9 Package: *General Issues Bug Type: Feature/Change Request Bug description:Make typing hinting arrays use the new shorthand syntax Description: ------------ Since the shorthand array syntax was introduced in PHP5.4, array type hints have been a little inconsistent. It would be preferable and more consistent if this worked: function expectsArray([] $arr) { } expectsArray(['a', 'b']); As it stands, you can set the default value using [], this is valid code: function expectsArray(array $arr = []) { } expectsArray(['a', 'b']); It would make more sense to also type-hint an array using the shorthand notation. -- Edit bug report at https://bugs.php.net/bug.php?id=66814&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66814&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66814&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66814&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=66814&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=66814&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=66814&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=66814&r=needscript Try newer version: https://bugs.php.net/fix.php?id=66814&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=66814&r=support Expected behavior: https://bugs.php.net/fix.php?id=66814&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=66814&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=66814&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=66814&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66814&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=66814&r=dst IIS Stability: https://bugs.php.net/fix.php?id=66814&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=66814&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=66814&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=66814&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=66814&r=mysqlcfg

« previous php.bugs (#184502) next »