TomasVotruba / class-leak

Find leaking classes that you never use... and get rid of them.
https://tomasvotruba.com/blog/how-to-avoid-maintaining-classes-you-dont-use
MIT License
75 stars 6 forks source link

Provide better error message after syntax error #46

Closed staabm closed 4 hours ago

staabm commented 4 hours ago

After this PR we get a better error message, which contains a reference to the filename.

Before this PR

$ /c/tools/php83/php vendor/bin/class-leak.php check src tests 
    0/1840 [>---------------------------]   0%
  920/1840 [==============>-------------]  50%
In ParserAbstract.php line 272:

  Syntax error, unexpected '{', expecting ';' on line 14  

check [--skip-type SKIP-TYPE] [--skip-suffix SKIP-SUFFIX] [--skip-attribute SKIP-ATTRIBUTE] [--file-extension FILE-EXTENSION] [--json] [--] <paths>...

After this PR

$ /c/tools/php83/php vendor/bin/class-leak.php check src tests 
    0/1840 [>---------------------------]   0%
  920/1840 [==============>-------------]  50%
In ParserAbstract.php line 272:

  Could not parse file "C:\dvl\Workspace\phpunit\tests\_files\mock-object\ExtendableClassWithPropertyWithGetHook.php": Syntax error, unexpected '{', expecting ';' on line 14  

check [--skip-type SKIP-TYPE] [--skip-suffix SKIP-SUFFIX] [--skip-attribute SKIP-ATTRIBUTE] [--file-extension FILE-EXTENSION] [--json] [--] <paths>...

refs https://github.com/TomasVotruba/class-leak/issues/45

TomasVotruba commented 4 hours ago

Awesome :partying_face: thank you

staabm commented 4 hours ago

hopefully its good to go now. contributing from a windows box is always a bit more challenging :)

staabm commented 4 hours ago

(to actually fix the underlying problem, we would need to update the php-parser lib)

TomasVotruba commented 4 hours ago

Running this script does the job :)

composer fix-cs --ansi


(to actually fix the underlying problem, we would need to update the php-parser lib)

Makes sense :+1:

TomasVotruba commented 4 hours ago

Merging to move forward :+1: thank you