Closed alikon closed 4 years ago
@alikon I never could decide on if it was appropriate or correct to put that guide here.
that guide is based off tommcfarlin/phpcs-wpcs-vscode and I haven't keep up with any changes to that repo or to VS code platform (seems VS code is getting super popular).
vscode is fully compatible with phpcs ... well, you only have to install one of this extension: https://marketplace.visualstudio.com/items?itemName=ikappas.phpcs
By default, it loads the PSR2 standard. But, you can change it to use Joomla as standard.
"phpcs.standard": "Joomla"
Of course, you have to install phpcs and configure the Joomla standard locally. So, if it works running phpcs by hand, then vscode will work in the same way.
I think that there is no need to create a vscode extension to install the Joomla standard.
In my opinion, it would be a better idea to adopt the PSR2 standard :+1: php cs fixer does wonders for PSR2 https://marketplace.visualstudio.com/items?itemName=junstyle.php-cs-fixer
In my opinion, it would be a better idea to adopt the PSR2 standard
That ship has sailed, if Joomla's coding standard were closer to PSR2 it'd be a more sane discussion but fact of the matter is the structures are so vastly different that trying to implement it would be hugely disruptive with minimal benefit.
Personally, I'm not a fan of a few items in PSR2/12 I like brackets on a new line and indenting for readability which is in a different fashion from PSR2/12... (basically PSR2/12 with brackets the way we currently have them in the repo)
Also note that PSR2/12 does not cover all code style cases, much of what we have here are things that go beyond the PSR2/12 guidelines.
For a great explanation of why brackets should not follow PSR2/12, an explanation better than I can do, see this talk by Kevlin Henney at about 10 minutes in he starts going over the indenting and brackets and very clearly illustrates the point. I highly recommend watching the whole video as he touches on a lot of little things which if done right make code better.
I agree with @mbabker making a hard shift to PSR2/12 will be disruptive, have minimal benefits and still would not cover all of the code styles items. we will continue to need custom code style enforcement.
Also the argument for php cs fixer over PHPCS because of PSR2 is kinda a mute thing since PHPCS includes and auto fixes PSR2 and is working to add PSR12.
PHP-CS-Fixer is a good supplement to PHPCS but not a replacement either. I'm actually using a rather opinionated configuration for the fixer on the Framework apps (https://github.com/joomla/framework.joomla.org/blob/master/.php_cs as an example (optimized toward PHP 7.2), if you need one that's PHP 5.3 friendly then https://gist.github.com/mbabker/6c940497fb863d4ac21f21f8d4c2248f is what I used last year to bulk re-format files in the Framework repos on the 1.x branches, and the 2.0 definition is pretty close to the Framework website version just considering the PHP 7.0 minimum still in use). For the most part, it works well with the Joomla coding standards but there are still a couple of quirks that I've never bothered looking into a way to fix.
@photodude
seems VS code is getting super popular
yes it seems :smile: ....
BTW I've published an extension for vscode with a few snippets https://marketplace.visualstudio.com/items?itemName=AnibalSanchez.vs-code-joomla-snippets
works great thanks @anibalsanchez 👍
can we have some support for different IDE like vscode instead of only Eclipse PDT or PHPStorm https://github.com/photodude/phpcs-vscode