xref: /PHP-7.2/Zend/tests/bug30162.phpt (revision f1d7e3ca)
1--TEST--
2Bug #30162 (Catching exception in constructor couses lose of $this)
3--FILE--
4<?php
5class FIIFO {
6
7	public function __construct() {
8		$this->x = "x";
9		throw new Exception;
10	}
11
12}
13
14class hariCow extends FIIFO {
15
16	public function __construct() {
17		try {
18			parent::__construct();
19		} catch(Exception $e) {
20		}
21		$this->y = "y";
22		try {
23			$this->z = new FIIFO;
24		} catch(Exception $e) {
25		}
26	}
27
28	public function __toString() {
29		return "Rusticus in asino sedet.";
30	}
31
32}
33
34try {
35	$db = new FIIFO();
36} catch(Exception $e) {
37}
38var_dump($db);
39
40$db = new hariCow;
41
42var_dump($db);
43?>
44===DONE===
45--EXPECTF--
46Notice: Undefined variable: db in %sbug30162.php on line 35
47NULL
48object(hariCow)#%d (2) {
49  ["x"]=>
50  string(1) "x"
51  ["y"]=>
52  string(1) "y"
53}
54===DONE===
55