php-src/Zend/tests/assign_ref_error_var_handling.phpt
Nikita Popov 95a0709935 Fix handling of ERROR zval in op1 of ASSIGN_REF
If op1 is ERROR the behavior is to not perform any assignment and
return NULL. However, if the RHS was a by-value returning function,
we'd instead emit a notice and return the RHS as the return value
(even though the value was not assigned to anything -- the temporary
is immediately destroyed).

This normalized the behavior to always check for an ERROR in op1
first.
2018-06-09 21:31:30 +02:00

25 lines
470 B
PHP

--TEST--
If the LHS of ref-assign ERRORs, that takes precendence over the "only variables" notice
--FILE--
<?php
function val() {
return 42;
}
$str = "foo";
$var = 24;
var_dump($str->foo =& $var);
var_dump($str);
var_dump($str->foo =& val());
var_dump($str);
?>
--EXPECTF--
Warning: Attempt to modify property 'foo' of non-object in %s on line %d
NULL
string(3) "foo"
Warning: Attempt to modify property 'foo' of non-object in %s on line %d
NULL
string(3) "foo"