pdt icon indicating copy to clipboard operation
pdt copied to clipboard

CS-Fixer support

Open zulus opened this issue 4 years ago • 6 comments

As part of longer out-of-box experience, PDT should have built-in CS-fixer support. It's popular and very active project that allow developers simply fix code to follow desired code standards.

Read more here: https://github.com/FriendsOfPHP/PHP-CS-Fixer

zulus avatar May 14 '20 10:05 zulus

I don't think that PHP CS Fixer should be built into PDT. Some developers (myself included) use PHP_CodeSniffer.

It might make sense to have a generic way of integrating linting and static analysis tools into PDT/Eclipse. For example:

  • Enter a command with arguments.
  • Map the output to problems.

This would allow developers to integrate other tools like Psalm.

glen-84 avatar May 14 '20 10:05 glen-84

Correct during this ticket I would like to introduce some generic apis to register new tools. Manually and via plugins.

I'll be happy to have psalm and CS later. And this is why I added this to "out-of-box experience. User should be able to select which tools want to use on concrete project.

zulus avatar May 14 '20 10:05 zulus

It might make sense to have a generic way of integrating linting and static analysis tools into PDT/Eclipse. For example:

  • Enter a command with arguments.
  • Map the output to problems.

To be honest, this generic support already exists and sometimes I'm using it for CodeSniffer.

Go to preferences -> dynamic languages -> validator. You can configure external call, and how to interpret it. Unfortunately it have to be used globally for entire workspace.

zulus avatar May 14 '20 10:05 zulus

I do love PHP CS Fixer (see this tool I developed for it 😉 ). If I'm not wrong, phpstorm too has support for it.

mlocati avatar May 14 '20 10:05 mlocati

As far as I remember storm have central list of tools. And later you can use them in projects.

zulus avatar May 14 '20 10:05 zulus

To be honest, this generic support already exists and sometimes I'm using it for CodeSniffer.

Go to preferences -> dynamic languages -> validator. You can configure external call, and how to interpret it. Unfortunately it have to be used globally for entire workspace.

It is also cumbersome to setup for PHP_CodeSniffer because the "regular expression" of the output pattern rule is hard to match with the generated report. I got it working for parts of the report, but if the error/warning message also contains digits (e.g. "expected 4 spaces but found 1") then Eclipse does not parse it correctly. Did you have more luck with it?

A great benefit of both PHP CS Fixer and PHP_CodeSniffer, is that they allow team members to share a single set of rules, independent of the editors they use. So any stable mechanism to display their reports as errors and warnings in Eclipse adds great value. I would also be very much in favour of integrating popular static analyzers like Phan and PHPStan.

rhuijts avatar Jun 13 '20 03:06 rhuijts