|
| 1 | +--TEST-- |
| 2 | +Exceptions providing object |
| 3 | +--FILE-- |
| 4 | +<?php |
| 5 | + |
| 6 | +class Test { |
| 7 | + public $random; |
| 8 | + |
| 9 | + function __construct() { |
| 10 | + $this->random = random_int(0, 100); |
| 11 | + } |
| 12 | + |
| 13 | + function doThrow(...$args) { |
| 14 | + throw new Exception(); |
| 15 | + } |
| 16 | + |
| 17 | + function funcDoThrow() { |
| 18 | + return fn(...$args) => $this->doThrow(...$args); |
| 19 | + } |
| 20 | +} |
| 21 | + |
| 22 | +function doThrow(...$args) { |
| 23 | + (new Test())->funcDoThrow()(...$args); |
| 24 | +} |
| 25 | + |
| 26 | +echo "zend.exception_ignore_args=0\n"; |
| 27 | +echo "zend.exception_provide_object=1\n"; |
| 28 | +ini_set("zend.exception_ignore_args", 0); |
| 29 | +ini_set("zend.exception_provide_object", 1); |
| 30 | + |
| 31 | +try { |
| 32 | + doThrow("foo", "bar"); |
| 33 | +} catch (Exception $e) { |
| 34 | + var_dump($e->getTrace()); |
| 35 | +} |
| 36 | + |
| 37 | +echo "zend.exception_ignore_args=1\n"; |
| 38 | +echo "zend.exception_provide_object=0\n"; |
| 39 | +ini_set("zend.exception_ignore_args", 1); |
| 40 | +ini_set("zend.exception_provide_object", 0); |
| 41 | + |
| 42 | +try { |
| 43 | + doThrow("foo", "bar"); |
| 44 | +} catch (Exception $e) { |
| 45 | + var_dump($e->getTrace()); |
| 46 | +} |
| 47 | + |
| 48 | +?> |
| 49 | +--EXPECTF-- |
| 50 | +zend.exception_ignore_args=0 |
| 51 | +zend.exception_provide_object=1 |
| 52 | +array(3) { |
| 53 | + [0]=> |
| 54 | + array(7) { |
| 55 | + ["file"]=> |
| 56 | + string(%d) "%sexception_provide_object.php" |
| 57 | + ["line"]=> |
| 58 | + int(%d) |
| 59 | + ["function"]=> |
| 60 | + string(7) "doThrow" |
| 61 | + ["class"]=> |
| 62 | + string(4) "Test" |
| 63 | + ["object"]=> |
| 64 | + object(Test)#%d (%d) { |
| 65 | + ["random"]=> |
| 66 | + int(%d) |
| 67 | + } |
| 68 | + ["type"]=> |
| 69 | + string(2) "->" |
| 70 | + ["args"]=> |
| 71 | + array(2) { |
| 72 | + [0]=> |
| 73 | + string(3) "foo" |
| 74 | + [1]=> |
| 75 | + string(3) "bar" |
| 76 | + } |
| 77 | + } |
| 78 | + [1]=> |
| 79 | + array(7) { |
| 80 | + ["file"]=> |
| 81 | + string(%d) "%sexception_provide_object.php" |
| 82 | + ["line"]=> |
| 83 | + int(%d) |
| 84 | + ["function"]=> |
| 85 | + string(%d) "{closure:Test::funcDoThrow():%d}" |
| 86 | + ["class"]=> |
| 87 | + string(4) "Test" |
| 88 | + ["object"]=> |
| 89 | + object(Test)#%d (%d) { |
| 90 | + ["random"]=> |
| 91 | + int(%d) |
| 92 | + } |
| 93 | + ["type"]=> |
| 94 | + string(2) "->" |
| 95 | + ["args"]=> |
| 96 | + array(2) { |
| 97 | + [0]=> |
| 98 | + string(3) "foo" |
| 99 | + [1]=> |
| 100 | + string(3) "bar" |
| 101 | + } |
| 102 | + } |
| 103 | + [2]=> |
| 104 | + array(4) { |
| 105 | + ["file"]=> |
| 106 | + string(%d) "%sexception_provide_object.php" |
| 107 | + ["line"]=> |
| 108 | + int(%d) |
| 109 | + ["function"]=> |
| 110 | + string(7) "doThrow" |
| 111 | + ["args"]=> |
| 112 | + array(2) { |
| 113 | + [0]=> |
| 114 | + string(3) "foo" |
| 115 | + [1]=> |
| 116 | + string(3) "bar" |
| 117 | + } |
| 118 | + } |
| 119 | +} |
| 120 | +zend.exception_ignore_args=1 |
| 121 | +zend.exception_provide_object=0 |
| 122 | +array(3) { |
| 123 | + [0]=> |
| 124 | + array(5) { |
| 125 | + ["file"]=> |
| 126 | + string(%d) "%sexception_provide_object.php" |
| 127 | + ["line"]=> |
| 128 | + int(%d) |
| 129 | + ["function"]=> |
| 130 | + string(7) "doThrow" |
| 131 | + ["class"]=> |
| 132 | + string(4) "Test" |
| 133 | + ["type"]=> |
| 134 | + string(2) "->" |
| 135 | + } |
| 136 | + [1]=> |
| 137 | + array(5) { |
| 138 | + ["file"]=> |
| 139 | + string(%d) "%sexception_provide_object.php" |
| 140 | + ["line"]=> |
| 141 | + int(%d) |
| 142 | + ["function"]=> |
| 143 | + string(%d) "{closure:Test::funcDoThrow():%d}" |
| 144 | + ["class"]=> |
| 145 | + string(4) "Test" |
| 146 | + ["type"]=> |
| 147 | + string(2) "->" |
| 148 | + } |
| 149 | + [2]=> |
| 150 | + array(3) { |
| 151 | + ["file"]=> |
| 152 | + string(%d) "%sexception_provide_object.php" |
| 153 | + ["line"]=> |
| 154 | + int(%d) |
| 155 | + ["function"]=> |
| 156 | + string(7) "doThrow" |
| 157 | + } |
| 158 | +} |
0 commit comments