Bug #68625 [Com]: By-ref parameters with array/callable typehints should be permitted
| From: | levim@php.net | Date: | Sun, 28 Dec 2014 17:21:57 +0000 |
| Subject: | Bug #68625 [Com]: By-ref parameters with array/callable typehints should be permitted | ||
| References: | 1 | Groups: | php.standards |
| Request: | Send a blank email to standards-+get-644@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68625&edit=1
ID: 68625
Comment by: levim@php.net
Reported by: ajf at ajf dot me
Summary: By-ref parameters with array/callable typehints
should be permitted
Status: Open
Type: Bug
Package: PHP Language Specification
PHP Version: 5.6.4
Block user comment: N
Private report: N
New Comment:
I'm not sure that taking a callable by reference has any kind of logical sense to it. Taking
arrays by reference is definitely valid, though.
Previous Comments:
------------------------------------------------------------------------
[2014-12-19 03:11:53] ajf at ajf dot me
Description:
------------
The language spec states this in spec/13-functions.md:
*parameter-declaration* must not contain
& if *type-hint* is array
or
callable.
Yet PHP allows this:
$ php -r 'function a(array &$foo) {} $a = []; a($a);'
$ php -r 'function a(callable &$foo) {} $a = "strlen"; a($a);'
$
Why, then, is it prohibited in the spec?
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68625&edit=1