bug30162.phpt 827 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. --TEST--
  2. Bug #30162 (Catching exception in constructor couses lose of $this)
  3. --FILE--
  4. <?php
  5. class FIIFO {
  6. public function __construct() {
  7. $this->x = "x";
  8. throw new Exception;
  9. }
  10. }
  11. class hariCow extends FIIFO {
  12. public function __construct() {
  13. try {
  14. parent::__construct();
  15. } catch(Exception $e) {
  16. }
  17. $this->y = "y";
  18. try {
  19. $this->z = new FIIFO;
  20. } catch(Exception $e) {
  21. }
  22. }
  23. public function __toString() {
  24. return "Rusticus in asino sedet.";
  25. }
  26. }
  27. try {
  28. $db = new FIIFO();
  29. } catch(Exception $e) {
  30. }
  31. var_dump($db);
  32. $db = new hariCow;
  33. var_dump($db);
  34. ?>
  35. --EXPECTF--
  36. Warning: Undefined variable $db in %s on line %d
  37. NULL
  38. object(hariCow)#%d (2) {
  39. ["x"]=>
  40. string(1) "x"
  41. ["y"]=>
  42. string(1) "y"
  43. }