xref: /PHP-7.3/Zend/tests/030.phpt (revision 782352c5)
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--
34Fatal error: Cannot re-assign $this in %s030.php on line 11
35