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:

Even worse, the following no longer works in PHP 5.4+ and this is an ERROR 
exception: 

$dbentry = array_shift(array_splice($dbents, $x, 1)))

This is why some leeway is appropriate on this error. I you can't chain 
together 
such logical progressions without INVENTING a variable in the code which has no 
other purpose than to avoid this ERROR exception, the language is headed the 
wrong direction and causing limitations for no cause.

I really think this needs to be fixed.


Previous Comments:
------------------------------------------------------------------------
[2013-09-11 22:59:26] guy at syntheticwebapps dot com

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?

------------------------------------------------------------------------
[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

Reply via email to