Closed almeidaz closed 8 months ago
Hi @almeidaz based on the code, it looks like this is a WordPress plugin file.
I just tested your sample code on my setup, and I cannot replicate the error, so it looks like there's either something on your local Windows environment that's causing this, or the version of phpcbf you have installed.
Can you tell me what your local development environment set up is, and how you installed phpcs and phpcbf.
Win10
install via composer global require squizlabs/php_codesniffer
composer -V
Composer version 2.7.1 2024-02-09 15:26:28
phpcs --version
# PHP_CodeSniffer version 3.9.0 (stable) by Squiz and PHPCSStandards
my settings.json
"php.validate.executablePath": "C:\\wamp64\\bin\\php\\php7.4.33\\php.exe",
"php.executablePath": "C:\\wamp64\\bin\\php\\php7.4.33\\php.exe",
"phpsab.standard": "WordPress",
// "phpsab.standard": "PSR2",
"phpsab.executablePathCS": "C:\\Users\\jinx\\AppData\\Roaming\\Composer\\vendor\\bin\\phpcs.bat",
"phpsab.executablePathCBF": "C:\\Users\\jinx\\AppData\\Roaming\\Composer\\vendor\\bin\\phpcbf.bat",
"phpsab.debug": true,
"[php]": {
"editor.defaultFormatter": "valeryanm.vscode-phpsab"
// "editor.formatOnSave": true
},
where phpcs
C:\Users\jinx\AppData\Roaming\Composer\vendor\bin\phpcs
C:\Users\jinx\AppData\Roaming\Composer\vendor\bin\phpcs.bat
where phpcbf
C:\Users\jinx\AppData\Roaming\Composer\vendor\bin\phpcbf
C:\Users\jinx\AppData\Roaming\Composer\vendor\bin\phpcbf.bat
Do you have also the # when you type phpcs --version like :
# PHP_CodeSniffer version 3.9.0 (stable)...
Do you have also the # when you type phpcs --version like :
No, when I run phpcs --version I don't get the #
PHP_CodeSniffer version 3.9.0 (stable) by Squiz and PHPCSStandards
Do you get the # when you run any other terminal command in Windows, or only phpcs --version
Thanks for your response and your help.
Edit: Then i have finally found my mistake. I had too much play with Codesniffer.conf file. I had left an error with bad commented code starting with #.
Haha that's funny, I was just about to ask if you'd been editing your phpcs config...glad you found it.
When i run PHPCBF : fix this file in vscode
it's fixing my file but add a '#' at start of my file.
Example :
will result :
If i run the command line : C:\Users\jinx\AppData\Roaming\Composer\vendor\bin\phpcbf.bat -q --standard=WordPress "c:\wamp64\www\projects\php-test\test.php"
file is fixed without # but there is my log :
We can see a # above PHPCBF RESULT SUMMARY
Do you have any idea where the problem comes from?