Edit report at https://bugs.php.net/bug.php?id=64755&edit=1
ID: 64755 Comment by: guy at syntheticwebapps dot com Reported by: eth at ethaniel dot com Summary: Only variables should be passed by reference Status: Not a bug Type: Bug Package: Scripting Engine problem Operating System: Debian 7.0 PHP Version: 5.4.14 Block user comment: N Private report: N New Comment: I have a different example than the one given. Consider: function myfunc( &$refvar ) { ... } $horse = myfunc( $value = array() ); The code example above also gets the same exception, however, this does not seem correct. This suggests that the type of "$value = array()" is expression and not a variable. But this violates an assumption in the language. Is this assumption incorrect? Should it be incorrect? As in the original reported form of the problem, I believe there should be some forgiveness in the call-by-reference receiver. I can understand why NOT to do that, but there are safe ways to do it anyway, like create a new zval for local use. But it's more important to me that $value = array() evaluates to the VARIABLE $value and NOT an expression. What expression could it possibly represent? The supposed expression in such a case is meaningless, whereas the variable is meaningful and useful. Any chance this could be fixed in future? Previous Comments: ------------------------------------------------------------------------ [2013-05-02 08:25:11] paj...@php.net See www.php.net/array_pop. Using: array_pop(array_keys($a)); array_keys($a) is an expression while array_pop expects a variable. ($k = array_keys($a);...). ------------------------------------------------------------------------ [2013-05-02 08:03:55] eth at ethaniel dot com Description: ------------ I get a "PHP Strict Standards: Only variables should be passed by reference in" error where there should be none. Test script: --------------- echo array_pop(array_keys(array("erwre"))); Expected result: ---------------- Result: 0. Actual result: -------------- The script returns the result (0), but also a "PHP Strict Standards: Only variables should be passed by reference in" in my error log. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=64755&edit=1