Skip to content

Commit

Permalink
Handle getNextMeaningfulToken returning NULL (see #17)
Browse files Browse the repository at this point in the history
Description
-----------

The screenshotted file below currently fails the parser because there is no meaningful token after the chained method block. It results in a fail with message

```
[ERROR] System error: "Fixing of "./contao/dca/tl_settings.php" file by        
         "Contao\EasyCodingStandard\Fixer\ChainedMethodBlockFixer" failed:      
         Illegal offset type in file                                            
         tools/ecs/vendor/contao/easy-coding-stand
         ard/src/Fixer/ChainedMethodBlockFixer.php on line 121"Run ECS with     
         "--debug" option and post the report here: https://github.com/symplify/symplify/issues/new in
         ./contao/dca/tl_settings.php:159    
```

<img width="920" alt="Bildschirmfoto 2023-10-31 um 12 35 34" src="https://github.com/contao/easy-coding-standard/assets/1073273/af8d3693-e1a5-44af-aeb8-ae61836036da">

Commits
-------

1bf8bf5 Handle getNextMeaningfulToken returning NULL
  • Loading branch information
aschempp authored Nov 2, 2023
1 parent 4877d64 commit b297ff2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Fixer/ChainedMethodBlockFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void

$nextMeaningful = $tokens->getNextMeaningfulToken($end);

if ($tokens[$nextMeaningful]->equals('}')) {
if (null === $nextMeaningful || $tokens[$nextMeaningful]->equals('}')) {
$index = $end;
continue;
}
Expand Down

0 comments on commit b297ff2

Please sign in to comment.