Bug #74690 [Nab]: PHP throws reference notice when using namespaces.

From: Date: Fri, 02 Jun 2017 10:02:04 +0000
Subject: Bug #74690 [Nab]: PHP throws reference notice when using namespaces.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209358@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74690&edit=1 ID: 74690 Updated by: nikic@php.net Reported by: contact at greg dot md Summary: PHP throws reference notice when using namespaces. Status: Not a bug Type: Bug Package: Scripting Engine problem Operating System: Mac PHP Version: 7.1.5 Block user comment: N Private report: N New Comment: The bug here is that the notice does not occur in the non-namespaced case. Previous Comments: ------------------------------------------------------------------------ [2017-06-02 09:53:34] danack@php.net The error is about the weird extra ampersand that is in front of the "&call_user_func_array" . It is complaining that you're trying to reference the return value of the function by reference. ------------------------------------------------------------------------ [2017-06-02 09:14:15] contact at greg dot md Description: ------------ When a namespace is defined in a file and you want to return a reference, the "PHP Notice: Only variables should be assigned by reference" is thrown. If I delete the namespace, then it works good. Test script: --------------- <?php namespace Bar; $foo = 'foo'; $bar = &call_user_func_array(function &() use (&$foo) { return $foo; }, []); $bar = 'bar'; echo $foo . PHP_EOL; Expected result: ---------------- bar Actual result: -------------- PHP Notice: Only variables should be assigned by reference in /htdocs/php-app/vendor/greg-md/php-framework/test.php on line 9 PHP Stack trace: PHP 1. {main}() /htdocs/php-app/vendor/greg-md/php-framework/test.php:0 Notice: Only variables should be assigned by reference in /htdocs/php-app/vendor/greg-md/php-framework/test.php on line 9 Call Stack: 0.0002 353152 1. {main}() /htdocs/php-app/vendor/greg-md/php-framework/test.php:0 foo ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74690&edit=1

« previous php.bugs (#209358) next »