1--TEST-- 2Bug #46064 (Exception when creating ReflectionProperty object on dynamically created property) 3--FILE-- 4<?php 5 6#[AllowDynamicProperties] 7class x { 8 public $zzz = 2; 9} 10 11$o = new x; 12$o->z = 1000; 13$o->zzz = 3; 14 15var_dump($h = new reflectionproperty($o, 'z')); 16var_dump($h->isDefault()); 17var_dump($h->isPublic()); 18var_dump($h->isStatic()); 19var_dump($h->getName()); 20var_dump(Reflection::getModifierNames($h->getModifiers())); 21var_dump($h->getValue($o)); 22 23print "---------------------------\n"; 24try { 25 var_dump(new reflectionproperty($o, 'zz')); 26} catch (Exception $e) { 27 var_dump($e->getMessage()); 28} 29 30var_dump(new reflectionproperty($o, 'zzz')); 31 32class test { 33 protected $a = 1; 34} 35 36#[AllowDynamicProperties] 37class bar extends test { 38 public function __construct() { 39 $this->foobar = 2; 40 $this->a = 200; 41 42 $p = new reflectionproperty($this, 'foobar'); 43 var_dump($p->getValue($this), $p->isDefault(), $p->isPublic()); 44 } 45} 46 47new bar; 48 49?> 50--EXPECTF-- 51object(ReflectionProperty)#%d (2) { 52 ["name"]=> 53 string(1) "z" 54 ["class"]=> 55 string(1) "x" 56} 57bool(false) 58bool(true) 59bool(false) 60string(1) "z" 61array(1) { 62 [0]=> 63 string(6) "public" 64} 65int(1000) 66--------------------------- 67string(30) "Property x::$zz does not exist" 68object(ReflectionProperty)#%d (2) { 69 ["name"]=> 70 string(3) "zzz" 71 ["class"]=> 72 string(1) "x" 73} 74int(2) 75bool(false) 76bool(true) 77