Skip to content

Commit d32338e

Browse files
committed
ext/reflection: fix bug 20873 - cannot assign by reference to overloaded object
1 parent 39bf7ed commit d32338e

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

ext/reflection/tests/bug20873.phpt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,16 @@ Lazy proxy with __get creating references and arithmetic
44
<?php
55
class A {
66
public $_;
7-
87
public function __get($n) {
98
global $obj;
10-
11-
// Create a reference to an uninitialized property
129
$obj->x =& $this->_;
13-
14-
// Static self-reference (edge case)
1510
static $a = $a;
16-
17-
// Arithmetic on reference
1811
$e =& $this->_ - $a;
1912
}
2013
}
21-
2214
$rc = new ReflectionClass(A::class);
2315
$obj = $rc->newLazyProxy(fn() => new A);
2416
$rc->initializeLazyObject($obj);
25-
2617
var_dump($obj->p);
2718
?>
2819
--EXPECTF--
@@ -32,8 +23,8 @@ Warning: Undefined property: A::$x in %s on line %d
3223

3324
Fatal error: Uncaught Error: Cannot assign by reference to overloaded object in %s:%d
3425
Stack trace:
35-
#0 %s(9): A->__get('x')
36-
#1 %s(23): A->__get('p')
26+
#0 %s(%d): A->__get('x')
27+
#1 %s(%d): A->__get('p')
3728
#2 {main}
3829
thrown in %s on line %d
3930

0 commit comments

Comments
 (0)