| Newsgroups |
php.standards |
| Message-ID |
<[email protected]> |
Edit report at https://bugs.php.net/bug.php?id=68625&edit=1
ID: 68625
Comment by: [email protected]
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