File tree Expand file tree Collapse file tree 2 files changed +13
-22
lines changed Expand file tree Collapse file tree 2 files changed +13
-22
lines changed Original file line number Diff line number Diff line change @@ -137,29 +137,24 @@ private function computeReturns(): void
137
137
*/
138
138
private function getLines (NodeAbstract $ node , bool $ fromReturns ): array
139
139
{
140
- // ugly fix for non-fully AST based processing
141
- // self::afterTraverse()/self::computeReturns() should be rewritten using self::leaveNode()
142
- if ($ node instanceof Array_ && [] !== $ node ->items ) {
143
- $ parentNode = $ node ->getAttribute ('parent ' );
144
- if ($ parentNode instanceof Return_ ||
145
- $ parentNode instanceof Expression ||
146
- $ parentNode instanceof Assign ||
147
- $ parentNode instanceof Array_
148
- ) {
149
- return [];
150
- }
151
- }
152
-
153
- if (!$ fromReturns && (
154
- $ node instanceof Return_ ||
140
+ if ($ node instanceof Return_ ||
155
141
$ node instanceof Expression ||
156
142
$ node instanceof Assign ||
157
143
$ node instanceof Array_
158
- )
159
144
) {
160
- $ this ->returns [] = $ node ;
145
+ if (!$ fromReturns ) {
146
+ $ this ->returns [] = $ node ;
161
147
162
- return [];
148
+ return [];
149
+ }
150
+
151
+ // ugly fix for non-fully AST based processing
152
+ // self::afterTraverse()/self::computeReturns() should be rewritten using self::leaveNode()
153
+ foreach (range ($ node ->getStartLine (), $ node ->getEndLine ()) as $ index ) {
154
+ if (isset ($ this ->executableLines [$ index ])) {
155
+ return [];
156
+ }
157
+ }
163
158
}
164
159
165
160
if ($ node instanceof Return_) {
Original file line number Diff line number Diff line change @@ -483,15 +483,11 @@ public function testReturnStatementWithConstantExprOnlyReturnTheLineOfLast(): vo
483
483
327 ,
484
484
340 ,
485
485
351 ,
486
- 355 ,
487
486
370 ,
488
487
377 ,
489
488
390 ,
490
- 392 ,
491
489
402 ,
492
- 404 ,
493
490
414 ,
494
- 416 ,
495
491
425 ,
496
492
437 ,
497
493
442 ,
You can’t perform that action at this time.
0 commit comments