030.phpt 1.1 KB

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