wongjn / vscode-php-sniffer

Visual Studio Code extension for PHP_Codesniffer validation and formatting.
https://marketplace.visualstudio.com/items?itemName=wongjn.php-sniffer
MIT License
46 stars 7 forks source link

Parse error: syntax error, unexpected '=' in... #72

Closed AlekseiGrigorev closed 11 months ago

AlekseiGrigorev commented 11 months ago

Dear Sirs! When I open any PHP file I get an error: Parse error: syntax error, unexpected '=' in C:\OSPanel543\userdata\composer\vendor\symfony\string\Resources\functions.php on line 34 Source: PHP Sniffer (Extension)

The C:\OSPanel543\userdata\composer\ folder is the global composer installation folder. My project is located in a completely different folder. I'm trying to disable checking this file in .phpcs.xml with `

ruleset C:/OSPanel543/userdata/composer/vendor/symfony/string/Resources/functions.php` ... but it doesn't help Why does the sniffer check files outside the project folder and how to disable it?
wongjn commented 11 months ago

I don't think it's checking it the file mentioned. It seems like you may have the symfony/string package installed globally and you are running PHP Sniffer globally too. When PHP Sniffer runs, it loads composer packages in some way and then trips up with that file. Perhaps there is some discrepancy in PHP version compatibility?

AlekseiGrigorev commented 11 months ago

Thank you, wongjn! You are absolutely right. I tried to run phpcs -i and got the same error. The plugin has nothing to do with it.