File tree Expand file tree Collapse file tree 2 files changed +31
-17
lines changed Expand file tree Collapse file tree 2 files changed +31
-17
lines changed Original file line number Diff line number Diff line change 2323use function get_class ;
2424use function get_debug_type ;
2525use function implode ;
26- use function is_array ;
2726use function sprintf ;
2827
2928/**
@@ -134,25 +133,12 @@ private function processStmtNodes(
134133 } catch (Throwable $ e ) {
135134 $ stackTrace = [];
136135 foreach (array_merge ($ stack , [$ gen ]) as $ identifiedGenerator ) {
137- if ($ identifiedGenerator ->file === null && $ identifiedGenerator ->line === null ) {
138- continue ;
139- }
140- if (is_array ($ identifiedGenerator ->node )) {
141- $ stackTrace [] = sprintf (
142- "Stmts \n -> %s on line %d " ,
143- $ identifiedGenerator ->file ,
144- $ identifiedGenerator ->line ,
145- );
136+ $ string = (string ) $ identifiedGenerator ;
137+ if ($ string === '' ) {
146138 continue ;
147139 }
148140
149- $ stackTrace [] = sprintf (
150- "%s:%d \n -> %s on line %d " ,
151- $ identifiedGenerator ->file ,
152- $ identifiedGenerator ->line ,
153- get_class ($ identifiedGenerator ->node ),
154- $ identifiedGenerator ->node ->getStartLine (),
155- );
141+ $ stackTrace [] = $ string ;
156142 }
157143
158144 throw new TrampolineException (sprintf (
Original file line number Diff line number Diff line change 33namespace PHPStan \Analyser \Generator ;
44
55use Generator ;
6+ use Override ;
67use PhpParser \Node ;
8+ use function get_class ;
9+ use function is_array ;
10+ use function sprintf ;
711
812/**
913 * @phpstan-import-type GeneratorTValueType from GeneratorNodeScopeResolver
@@ -33,4 +37,28 @@ public function __construct(
3337 {
3438 }
3539
40+ #[Override]
41+ public function __toString (): string
42+ {
43+ if ($ this ->file === null || $ this ->line === null ) {
44+ return '' ;
45+ }
46+
47+ if (is_array ($ this ->node )) {
48+ return sprintf (
49+ "Stmts \n -> %s on line %d " ,
50+ $ this ->file ,
51+ $ this ->line ,
52+ );
53+ }
54+
55+ return sprintf (
56+ "%s:%d \n -> %s on line %d " ,
57+ $ this ->file ,
58+ $ this ->line ,
59+ get_class ($ this ->node ),
60+ $ this ->node ->getStartLine (),
61+ );
62+ }
63+
3664}
You can’t perform that action at this time.
0 commit comments