bug49719.phpt 739 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. --TEST--
  2. Bug #49719 (ReflectionClass::hasProperty returns true for a private property in base class)
  3. --FILE--
  4. <?php
  5. class A {
  6. private $a;
  7. }
  8. class B extends A {
  9. private $b;
  10. }
  11. try {
  12. $b = new B;
  13. $ref = new ReflectionClass($b);
  14. var_dump(property_exists('b', 'a'));
  15. var_dump(property_exists($b, 'a'));
  16. var_dump($ref->hasProperty('a'));
  17. var_dump($ref->getProperty('a'));
  18. } catch (Exception $e) {
  19. var_dump($e->getMessage());
  20. }
  21. class A2 {
  22. private $a = 1;
  23. }
  24. class B2 extends A2 {
  25. private $a = 2;
  26. }
  27. $b2 = new ReflectionClass('B2');
  28. $prop = $b2->getProperty('a');
  29. var_dump($prop->getValue(new b2));
  30. ?>
  31. --EXPECT--
  32. bool(false)
  33. bool(false)
  34. bool(false)
  35. string(29) "Property B::$a does not exist"
  36. int(2)