25
25
use const E_USER_NOTICE ;
26
26
use const E_USER_WARNING ;
27
27
use const E_WARNING ;
28
+ use function array_values ;
28
29
use function assert ;
29
30
use function debug_backtrace ;
30
31
use function error_reporting ;
@@ -237,21 +238,21 @@ private function trigger(TestMethod $test): IssueTrigger
237
238
return IssueTrigger::unknown ();
238
239
}
239
240
240
- $ trace = debug_backtrace ( DEBUG_BACKTRACE_IGNORE_ARGS , 4 );
241
+ $ trace = $ this -> cleanedTrace ( );
241
242
242
- assert (isset ($ trace [2 ]['file ' ]));
243
- assert (isset ($ trace [3 ]['file ' ]));
243
+ assert (isset ($ trace [0 ]['file ' ]));
244
+ assert (isset ($ trace [1 ]['file ' ]));
244
245
245
246
$ triggeredInFirstPartyCode = false ;
246
247
$ triggerCalledFromFirstPartyCode = false ;
247
248
248
- if ($ trace [2 ]['file ' ] === $ test ->file () ||
249
- $ this ->sourceFilter ->includes ($ this ->source , $ trace [2 ]['file ' ])) {
249
+ if ($ trace [0 ]['file ' ] === $ test ->file () ||
250
+ $ this ->sourceFilter ->includes ($ this ->source , $ trace [0 ]['file ' ])) {
250
251
$ triggeredInFirstPartyCode = true ;
251
252
}
252
253
253
- if ($ trace [3 ]['file ' ] === $ test ->file () ||
254
- $ this ->sourceFilter ->includes ($ this ->source , $ trace [3 ]['file ' ])) {
254
+ if ($ trace [1 ]['file ' ] === $ test ->file () ||
255
+ $ this ->sourceFilter ->includes ($ this ->source , $ trace [1 ]['file ' ])) {
255
256
$ triggerCalledFromFirstPartyCode = true ;
256
257
}
257
258
@@ -265,4 +266,14 @@ private function trigger(TestMethod $test): IssueTrigger
265
266
266
267
return IssueTrigger::indirect ();
267
268
}
269
+
270
+ private function cleanedTrace (): array
271
+ {
272
+ $ trace = debug_backtrace (DEBUG_BACKTRACE_IGNORE_ARGS );
273
+
274
+ // self::cleanedTrace(), self::trigger(), self::__invoke()
275
+ unset($ trace [0 ], $ trace [1 ], $ trace [2 ]);
276
+
277
+ return array_values ($ trace );
278
+ }
268
279
}
0 commit comments