mansoorkhan96 / php-cs-fixer

PHP CS Fixer extension for VS Code with zero config
https://marketplace.visualstudio.com/items?itemName=mansoorkhan96.php-cs-fixer
MIT License
12 stars 4 forks source link

Config option "ignoreEnv" not working #25

Open pvettori opened 1 month ago

pvettori commented 1 month ago

VsCode PHP CS Fixer is one of my most used VSCode extensions. I now have installed php 8.3 on my system, but the current version of uses a builtin php-cs-fixer that allows php 8.2 as maximum version. I know there is a somewhat "hidden" configuration setting called "ignoreEnv" that allows running the fixer with the env option PHP_CS_FIXER_IGNORE_ENV = 1, but it actually does not work properly.

There is an easy fix to this issue which consists in changing the line 22 of "extension.js" to something like this:

    opts.env = { PHP_CS_FIXER_IGNORE_ENV: 1 };

I hope you can integrate this fix.

mansoorkhan96 commented 1 month ago

@pvettori Have you tried and confirm this works on windows then?

I am on macs and if even remove that line, it still works.

mansoorkhan96 commented 1 month ago

I have updated. lets see if it works for you.

pvettori commented 1 month ago

I have updated. lets see if it works for you.

Thank you, it now seems to be working on both Windows and Ubuntu. I see that you have updated the php-cs-fixer source file and it now supports php 8.3 by default, that is maybe the reason you find that it works even if you remove that line.

I doug a bit deeper and found out from documentation (child_process.execFile()) that a better solution would be to write line (now) 23 as follows:

opts.env = { ...process.env, PHP_CS_FIXER_IGNORE_ENV: 1 }