kokororin / vscode-phpfmt

Integrates phpfmt into VS Code
https://marketplace.visualstudio.com/items?itemName=kokororin.vscode-phpfmt
BSD 3-Clause "New" or "Revised" License
130 stars 30 forks source link

Add supports to PHP8 and new ignore settings option #101

Closed lucasferreira closed 1 year ago

lucasferreira commented 1 year ago

Hi @kokororin

Thank you for this wonderful VSCode plugin.

Since last week I'm trying to switch from Sublime Text editor do VS Code in my daily work, so when I was configuring the VS Code to my work I was looking for some plugin like that => https://github.com/driade/phpfmt8 to VS code and I found yours very good to my needs.

But I missed a few things:

So I work a few hours in your extension to bring this features alive, and here we are with this PR!

To achieve the first idea I worked on update the version of PHPFMT.PHAR file used in this extension and I discover that was coming from other package of you (node-phpfmt but I didn't found this package on github anymore).

So I choose to create a new package to control (again) this phpfmt dependency of you VSCode extension and this new package (mine, called use-phpfmt) is now downloading from phpfmt from https://github.com/driade/phpfmt8 because this extension is very updated and supports PHP8.

And to continue this PR work, I've added a new ignore settings params to give to the dev the possibility to configure some patterns to ignore some files that doesn't need to be auto formatted.

To contextualize this need: I work with some projects like Laravel ou CakePHP project there are some "template files" that "mix" PHP and HTML a lot and sometimes when PHPFMT works in this files it will make lot of mess in source code, because VS Code still consider this files as PHP-files so the only way to ignore that files it's by their extensions, so this new ignore setting param works in this way:

"editor.formatOnSave": false,
"[php]": {
  "editor.defaultFormatter": "kokororin.vscode-phpfmt",
  "editor.formatOnSave": true
},
"phpfmt.ignore": [
  ".ctp",
  ".blade.php"
]

And to finish this PR I've made some automatic source format using Prettier JS in all TS files.

lucasferreira commented 1 year ago

A relevant observation: to get the last support of phpfmt and works with PHP8, I had to change de minimum version of php_bin used to run the script to PHP 7.0 and above.

I think that is fine in nowadays because the php.net made PHP 5.6 unsupported/obsolete/deprecated more than 4 years ago.

promatik commented 1 year ago

@kokororin please take a look at this PR, thousands are eager to have it 🙌

kokororin commented 1 year ago

Thank you. I will build it and publish