bug76936.phpt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. --TEST--
  2. Bug #76936: Objects cannot access their private attributes while handling reflection errors
  3. --FILE--
  4. <?php
  5. class Foo {
  6. public $dummy1;
  7. public $dummy2;
  8. }
  9. class ErrorHandler {
  10. private $private = 'THIS IS PRIVATE'."\n";
  11. function __construct() {
  12. set_error_handler(
  13. function ($errno, $errstr, $errfile, $errline) {
  14. $this->handleError($errno, $errstr, $errfile, $errline);
  15. }
  16. );
  17. }
  18. private function handleError($errno, $errstr, $errfile, $errline, $errmodule = null) {
  19. echo __METHOD__. " dealing with error $errstr\n";
  20. // This attribute is no longer accessible in this object. Same for other
  21. // objects and their private attributes once we reach in this state.
  22. echo $this->private;
  23. }
  24. }
  25. $errorHandler = new ErrorHandler();
  26. $f = new Foo;
  27. unset($f->dummy2);
  28. foreach ((new ReflectionObject($f))->getProperties() as $p) {
  29. echo $p->getName() .' = '. $p->getValue($f) ."\n";
  30. }
  31. ?>
  32. --EXPECT--
  33. dummy1 =
  34. ErrorHandler::handleError dealing with error Undefined property: Foo::$dummy2
  35. THIS IS PRIVATE
  36. dummy2 =