1--TEST-- 2Bug #28444 (Cannot access undefined property for object with overloaded property access) 3--FILE-- 4<?php 5 6function my_error_handler($errno, $errstr, $errfile, $errline) { 7 var_dump($errstr); 8} 9 10set_error_handler('my_error_handler'); 11 12class ObjectOne 13{ 14 public $x; 15 16 function __construct($x) 17 { 18 $this->x = $x; 19 } 20} 21 22class Overloaded 23{ 24 public $props = array(); 25 public $x; 26 27 function __construct($x) 28 { 29 $this->x = new ObjectOne($x); 30 } 31 32 function __get($prop) 33 { 34 echo __METHOD__ . "($prop)\n"; 35 return $this->props[$prop]; 36 } 37 38 function __set($prop, $val) 39 { 40 echo __METHOD__ . "($prop,$val)\n"; 41 $this->props[$prop] = $val; 42 } 43} 44$y = new Overloaded(2); 45var_dump($y->x); 46var_dump($y->x->x); 47var_dump($y->x->x = 3); 48var_dump($y->y = 3); 49var_dump($y->y); 50var_dump($y->z = new ObjectOne(4)); 51var_dump($y->z->x); 52$t = $y->z; 53var_dump($t->x = 5); 54var_dump($y->z->x = 6); 55 56?> 57===DONE=== 58--EXPECTF-- 59object(ObjectOne)#%d (1) { 60 ["x"]=> 61 int(2) 62} 63int(2) 64int(3) 65Overloaded::__set(y,3) 66int(3) 67Overloaded::__get(y) 68int(3) 69string(58) "Object of class ObjectOne could not be converted to string" 70Overloaded::__set(z,) 71object(ObjectOne)#%d (1) { 72 ["x"]=> 73 int(4) 74} 75Overloaded::__get(z) 76int(4) 77Overloaded::__get(z) 78int(5) 79Overloaded::__get(z) 80int(6) 81===DONE=== 82