Bug #79218 [Nab]: inconsistent behavior since call time pass by reference was removed

From: Date: Tue, 04 Feb 2020 13:19:52 +0000
Subject: Bug #79218 [Nab]: inconsistent behavior since call time pass by reference was removed
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225348@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79218&edit=1 ID: 79218 User updated by: skullnobrains at gmail dot com Reported by: skullnobrains at gmail dot com Summary: inconsistent behavior since call time pass by reference was removed Status: Not a bug Type: Bug Package: Scripting Engine problem Operating System: linux and probably all PHP Version: 7.3.14 Block user comment: N Private report: N New Comment: it does : the code works and the array is modified by stream_select() as demonstrated. if stream_select is able to modify a non-reference, maybe this is a different bug. either it should not work at all, or there should be no notification. Previous Comments: ------------------------------------------------------------------------ [2020-02-04 10:43:11] nikic@php.net Assignment does not return a reference. ------------------------------------------------------------------------ [2020-02-04 10:41:50] skullnobrains at gmail dot com Description: ------------ creating a variable on the fly and passing it by reference produces a run-time notice which is inconsistent with the actual behavior, since it does work and the notice is not a deprecation. passing a value produces a compile-time fatal error both messages are hardly distinguishable i picked the php version at random but all php7 versions and possibly 6 are concerned Test script: --------------- $sock=stream_socket_client('tcp://www.php.net:80') or die(); $num=stream_select($R=array(),$W=array($sock),$O=array(),1) or die("selected : ".var_export($num,true)); var_dump($W); ------ $sock=stream_socket_client('tcp://www.php.net:80') or die(); $W=array($sock); $num=stream_select(null,$W,null,1) or die("selected : ".var_export($num,true)); var_dump($W); Expected result: ---------------- first script should just work : i am passing variables, not values. second script : i'd rather it worked ( preferably with the previous explicit, convenient, and backwards compatible '&$whatever' syntax ) but unfortunately can't file the behavior as a bug. Actual result: -------------- PHP Notice: Only variables should be passed by reference in /home/alex/bugreport.php on line 4 PHP Notice: Only variables should be passed by reference in /home/alex/bugreport.php on line 4 PHP Notice: Only variables should be passed by reference in /home/alex/bugreport.php on line 4 array(1) { [0]=> resource(5) of type (stream) } ------------------ PHP Fatal error: Only variables can be passed by reference in /home/alex/bugreport.php on line 7 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79218&edit=1

« previous php.bugs (#225348) next »