xref: /PHP-5.5/Zend/tests/030.phpt (revision 669a441b)
1--TEST--
2Overriding $this in catch and checking the object properties later.
3--FILE--
4<?php
5
6class foo {
7	public $test = 0;
8	private $test_2 = 1;
9	protected $test_3 = 2;
10
11	public function bar() {
12		try {
13			throw new Exception('foo');
14		} catch (Exception $this) {
15			var_dump($this);
16		}
17
18		$this->baz();
19	}
20
21	public function baz() {
22		foreach ($this as $k => $v) {
23			printf("'%s' => '%s'\n", $k, $v);
24		}
25		print "ok\n";
26	}
27}
28
29$test = new foo;
30$test->bar();
31
32?>
33--EXPECTF--
34object(Exception)#%d (7) {
35  ["message":protected]=>
36  string(3) "foo"
37  ["string":"Exception":private]=>
38  string(0) ""
39  ["code":protected]=>
40  int(0)
41  ["file":protected]=>
42  string(%d) "%s030.php"
43  ["line":protected]=>
44  int(%d)
45  ["trace":"Exception":private]=>
46  array(1) {
47    [0]=>
48    array(6) {
49      ["file"]=>
50      string(%d) "%s030.php"
51      ["line"]=>
52      int(%d)
53      ["function"]=>
54      string(3) "bar"
55      ["class"]=>
56      string(3) "foo"
57      ["type"]=>
58      string(2) "->"
59      ["args"]=>
60      array(0) {
61      }
62    }
63  }
64  ["previous":"Exception":private]=>
65  NULL
66}
67'test' => '0'
68'test_2' => '1'
69'test_3' => '2'
70ok
71