Open charlesroper opened 1 year ago
Note, I found this which seems like it might be related: https://stackoverflow.com/a/50908446/1944
After some great support on the project gitter page: https://gitter.im/PHP-CS-Fixer/Lobby, it turns out the issue was that the way I was calling things on the command line was overwriting the path information in my config file.
A clue was the CLI message that read
Paths from configuration file have been overridden by paths provided as command arguments.
My original command was...
php php-cs-fixer fix /path/to/project/folder --config /path/to/config/file/.php_cs.dist
Two options that should have been used:
Skip the
/path/to/project/folder
Correct command =php php-cs-fixer fix --config /path/to/config/file/.php_cs.dist
. According to the devs, this could have a drawback in that one may not be able to run the tool with sub paths of the root project.Add a
-path-mode=intersection
flag to the CLI statement to make things play nice with each other. Correct command =php php-cs-fixer fix /path/to/project/folder --config /path/to/config/file/.php_cs.dist --path-mode=intersection
Another thing to note:
If I enable the HTML formatting setting, then fix and format operations fail on on files that contain HTML. However, the diff
operation works fine and reports the changes I would expect. Here are two screenshots to illustrate:
Fix this file:
Diff (there are no complaints here about configuration file paths being overridden):
it's a bug, when your file content ends with <?php Sniopet('footer')?>
, i remove the last closed tag ?>
.
fixed https://github.com/junstyle/vscode-php-cs-fixer/commit/fc7803c1a961bf1410763d74ddefbbc17e9264c9
and the fix
command output directly from php-cs-fixer, no matter formatHtml
option true or false,
Thank you for this - it seems to work better now.
There are still a couple of problems I have found:
"editor.formatOnSave": true
then this extension doesn't fire - nothing happens. If I set to false
it works again.I think I found part of the problem with the formatter. I have Intelephense set as the default formatter. If I change the default to be junstyle.php-cs-fixer
then your formatter works for most files, and format on save also works.
These are my workspace settings:
{
"editor.formatOnSave": true,
"php-cs-fixer.allowRisky": true,
"php-cs-fixer.formatHtml": true,
"php-cs-fixer.onsave": true,
"[php]": {
"editor.defaultFormatter": "junstyle.php-cs-fixer"
},
}
However, formatting HTML does not seem to work at all. Here's a video to show what I mean:
I'm just getting started with PHP CS Fixer and this extension - thanks for all your efforts on it @junstyle!
I'm having a strange problem. I'm on Windows 10 with PHP 8.1.11 installed. VS Code 1.72.2.
PHP CS Fixer is installed globally via Composer:
The plugin seems to work fine if there are changes to make. The
fix
,format
anddiff
commands all work as expected.Here is an example output (I'll copy my
.php-cs-fixer.dist.php
file in at the bottom here):However, if there are no changes to make when I run one of the php-cs-fixer commands, there seems to be an error. See the last two lines here:
This doesn't cause problems for the
fix
command - it even works fine when I have the fixer run on save. Thediff
command doesn't seem to show the error at all. So the problem goes largely unnoticed.Where this issue is more of an actual problem is when using the formatter. VS Code shows me the following error dialog:
Here is the output log:
And here is a screenshot of my devtools log:
Finally, here's the content of my
.php-cs-fixer.dist.php
(it's just copied in from the Kirby repo - see here):