bug30162.phpt 761 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. ===DONE===
  36. --EXPECTF--
  37. Notice: Undefined variable: db in %sbug30162.php on line 35
  38. NULL
  39. object(hariCow)#%d (2) {
  40. ["x"]=>
  41. string(1) "x"
  42. ["y"]=>
  43. string(1) "y"
  44. }
  45. ===DONE===