File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / Zend / tests / 030.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:47:52 2012 UTC (13 years, 10 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

    1: --TEST--
    2: Overriding $this in catch and checking the object properties later.
    3: --FILE--
    4: <?php
    5: 
    6: class 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--
   34: object(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'
   70: ok

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>