eclipse-pdt / pdt

PHP Development Tools project (PDT)
https://eclipse.org/pdt
Eclipse Public License 2.0
189 stars 46 forks source link

PSR-12 formatter profile #61

Open zulus opened 4 years ago

zulus commented 4 years ago

Filipus Klutiero:

Although PDT comes with a formatter profile implementing the deprecated PSR-2, it does not come with one implementing the newer PSR-12 "Extended Coding Style", also recommended by the PHP-FIG (PHP Framework Interop Group), in August 2019: https://www.php-fig.org/psr/psr-12/

Such support would be welcome, as PSR-12 is more complete than PSR-2, notably regarding prefix and postfix operators.

Original bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=559386

Differences between PSR-2 nad PSR-12: https://www.php-fig.org/psr/psr-12/meta/

CodeSniffer: https://github.com/squizlabs/PHP_CodeSniffer/tree/master/src/Standards/PSR12/Sniffs

bancer commented 4 years ago

Ideally PDT should be able to read phpcs.xml file (path to which would be provided by the user as configuration setting) and apply the code style rules from that file. Something similar is implemented in PHPStorm - https://www.twilio.com/blog/set-up-php-codesniffer-local-development-sublime-text-php-storm-vs-code.

Screenshot from 2020-06-02 16:26:24

zulus commented 4 years ago

This task is about formatting profile, you probably thinking about something similar to #51.

bancer commented 4 years ago

Yes, more or less. These issues are related. Although many projects (including ours) do not use PHP CS Fixer but use PHPCodeSniffer.

bancer commented 4 years ago

Just to clarify - what I meant is an option to import phpcs.xml file that would be converted to a new Eclipse's formatter xml file. F.ex. a new button "New From phpcs.xml" here:

Screenshot from 2020-06-02 17:11:26

haruka-7 commented 3 years ago

Hi, PSR2 is deprecated since 2019, can we expect to have a PSR12 formatter profile in PDT in a future release ? VSCode and PhpStorm already have this for mounths.

costeaalex commented 2 years ago

Hey guys, any news on this one? Also, if you would need help with the coding where can I sign up?

zulus commented 2 years ago

Hey guys, any news on this one? Also, if you would need help with the coding where can I sign up?

We support standard Github flow (pull requests), with one condition, you have to sign CLA. See our contribution.md

Hi, PSR2 is deprecated since 2019, can we expect to have a PSR12 formatter profile in PDT in a future release ? VSCode and PhpStorm already have this for mounths.

I'm concentrated now on PHP8 support, but formatter off course need some love ;)

whatever999 commented 2 years ago

Hi. As I also was in search for a PSR-12 profile I finally found this one from Dolibarr: https://github.com/Dolibarr/dolibarr/blob/develop/dev/setup/eclipse/PSR-12%20%5Bbuilt-in%5D.xml

Import in Eclipse was possible. Is there any problem with this? @zulus Maybe you'd like to implement this in the next PDT version?

ungeahnt commented 2 years ago

Hi. As I also was in search for a PSR-12 profile I finally found this one from Dolibarr: https://github.com/Dolibarr/dolibarr/blob/develop/dev/setup/eclipse/PSR-12%20%5Bbuilt-in%5D.xml

Import in Eclipse was possible. Is there any problem with this? @zulus Maybe you'd like to implement this in the next PDT version?

I've imported and configured the PSR-12 profile created by dolibarr. But it has no influence on 'Content Assistant' (e.g. the brackets formating is the same as before).

whatever999 commented 2 years ago

Thx @ungeahnt You are right, there are no big differences between in PSR-2 and PSR-12, however it was missing and PSR-12 is the standard in many projects by now.

ATTENTION: In meanwhile I realised the guys at dolibarr have not sticked to the PSR-12 standard. In their PSR-12 profile they use tab policy = tabs. According to PSR-12 it must be be 4 spaces. (see https://www.php-fig.org/psr/psr-12/ at 2.4) I edited the dolibarr profile in Eclipse and changed: Tab policy: Spaces Identation size: 4

I suggest to do the same for the PSR-12 profile in Eclipse, if you have not yet done so.