Closed gtsiou closed 1 year ago
After a little bit of Reviewing I think the problem lies with token_get_all
(though I can't reproduce it on macOS)
@gtsiou could you run the following command in WSL:
php -r "var_dump(token_get_all('<?php @if ($nonFixableErrors->isNotEmpty()'));"
Does this throw a ParseError or do you get an array back?
``` array(9) { [0]=> array(3) { [0]=> int(389) [1]=> string(6) " int(1) } [1]=> string(1) "@" [2]=> array(3) { [0]=> int(287) [1]=> string(2) "if" [2]=> int(1) } [3]=> array(3) { [0]=> int(392) [1]=> string(1) " " [2]=> int(1) } [4]=> string(1) "(" [5]=> array(3) { [0]=> int(384) [1]=> string(2) "->" [2]=> int(1) } [6]=> array(3) { [0]=> int(262) [1]=> string(10) "isNotEmpty" [2]=> int(1) } [7]=> string(1) "(" [8]=> string(1) ")" } ```
Good catch @Jubeki!
You should escape the '$' character in the example you sent, since your CLI thinks it is a variable but I think even then it will work for you (php -r "var_dump(token_get_all('<?php @if (\$nonFixableErrors->isNotEmpty()'));"
)
I do indeed get an error:
I think it would be best to report this to PHP directly then, as Pint can not change this behaviour.
Closing as the issue seems to be irrelevant to this repo.
Pint Version
1.10.6
PHP Version
8.2.8
Description
This is a continuation of (and most likely the same issue as) #189 I can also confirm that the last version that did not had this issue, was 1.4.0
WSL on Windows 10
Running something like
./vendor/bin/pint --test -v
in a new Laravel installation throws the following parsing error.However, the command completes successfully and works as it should.
Looks like the token_get_all fails on
<?php @if ($nonFixableErrors->isNotEmpty()'
This seems to be thrown by the code added here so maybe not a Pint issue, but definitely the suppression does not work as it should in this instance, so it could be related to the PHP configuration in my system which has the following settings regarding error handling:
Steps To Reproduce
Create a new Laravel project
composer create-project laravel/laravel example-app
Run pint in the project
cd example-app; ./vendor/bin/pint --test -v