[PHP-BUG] Bug #79218 [NEW]: inconsistent behavior since call time pass by reference was removed
[email protected] ("skullnobrains at gmail dot com") Tue, 04 Feb 2020 10:41:50 +0000
| Newsgroups | php.standards |
|---|---|
| Message-ID | <[email protected]> |
From: skullnobrains at gmail dot com
Operating system: linux and probably all
PHP version: 7.3.14
Package: PHP Language Specification
Bug Type: Bug
Bug description:inconsistent behavior since call time pass by reference was removed
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 bug report at https://bugs.php.net/bug.php?id=79218&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79218&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79218&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79218&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79218&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79218&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79218&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79218&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79218&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79218&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79218&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79218&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79218&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79218&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79218&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79218&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79218&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79218&r=mysqlcfg