bug46064.phpt 1.3 KB

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