Php-cs-fixer: Support for Wordpress

Created on 21 Mar 2014  Â·  11Comments  Â·  Source: FriendsOfPHP/PHP-CS-Fixer

It's possible add the wordpress support?
For PHP CodeSniffer there is https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards ma for PHP CodeSniffer Fixer i have found nothing.

Most helpful comment

Wordpress is too "mature" to adopt external coding styles.

Discussed and marked _WONTFIX_ at: https://core.trac.wordpress.org/ticket/23357

All 11 comments

The PHP Coding Standards Fixer tool fixes most issues in your code when you want to follow the PHP coding standards as defined in the PSR-1 and PSR-2 documents.

The Wordpress coding standards do not seem to be compatible with PSR-2
http://make.wordpress.org/core/handbook/coding-standards/php/#brace-style

Dammit!
There is no way for add this support?

You can create your own fixers - but these will not be included in the core.
See https://github.com/fabpot/PHP-CS-Fixer/tree/master/Symfony/CS/Fixer for examples.

You then need to extend the https://github.com/fabpot/PHP-CS-Fixer/blob/master/Symfony/CS/Console/Application.php and pass in your own Symfony\CS\Fixer instance to FixCommand().

It's not a simple job, it's needed to study the difference between the wordpress tandard and the psr.
when i have some tme i can try it.
thanks for the help!

I don't really see how you'd ever make a Wordpress codebase PSR compliant since Wordpress itself goes pretty much against all the PSR stands for.

Wordpress is too "mature" to adopt external coding styles.

Discussed and marked _WONTFIX_ at: https://core.trac.wordpress.org/ticket/23357

I think the general feature request itself has merit, though. Namely, how can developers inject their own "Fixers" into php-cs-fixer and have those run as first-class citizens like PSR-1/2.

For example, php_codesniffer sets up a "Standards" directory with sub-directories in it, one per standard. You can add a symlink to your "MyStandard" standard and call it from the command line w/ --standard=MyStandard. I don't see a way to achieve a similar thing for php-cs-fixer, though. AFAICS, you'd have to put your MyStandardFooBar.php Fixer files in alongside the rest of "core's," which would get pretty messy.

Discussion is dead for months. Closing.

BTW @Mte90 we have now Contrib namespace/fixer level, so if you want to add fixers for WP feel free.

I saw, if I understand correctly now is possible create a config file.
I'll see the configuration of Wordpress settings for CodeSniffer.

Ok i've written this config (for my plugin bolierplate so the path excluded is different for others) https://github.com/Mte90/WordPress-Plugin-Boilerplate-Powered/blob/master/plugin-name/.php_cs

@Mte90 You can add Config for WP in PHP-CS-Fixer project, then nobody need to create .php_cs file to configure it.

If you want, then:

  • provide paths for pure WP
  • pack it into Config class
  • make PR with that config

and then community will decide ;)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

grachevko picture grachevko  Â·  3Comments

kcloze picture kcloze  Â·  3Comments

sennewood picture sennewood  Â·  3Comments

BackEndTea picture BackEndTea  Â·  3Comments

OskarStark picture OskarStark  Â·  3Comments