mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
d877d18676
This error was already thrown if __get() was used -- however not if it returned by reference. This is incorrect, because the reference return makes no difference to a by-reference assignment, which has reference-breaking semantics. The result was that the assignment was accepted silently, even though it didn't do anything (not even the value was assigned, let alone the reference).
24 lines
417 B
PHP
24 lines
417 B
PHP
--TEST--
|
|
Cannot assign by reference to overloaded object, even if __get() returns by-ref
|
|
--FILE--
|
|
<?php
|
|
|
|
class Test {
|
|
private $x;
|
|
public function &__get($name) {
|
|
return $this->x;
|
|
}
|
|
}
|
|
|
|
$test = new Test;
|
|
$y = 5;
|
|
$test->x =& $y;
|
|
var_dump($test->x);
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Fatal error: Uncaught Error: Cannot assign by reference to overloaded object in %s:%d
|
|
Stack trace:
|
|
#0 {main}
|
|
thrown in %s on line %d
|