Php-cs-fixer: Proposal for the constants casing fixer

Created on 5 Nov 2017  路  7Comments  路  Source: FriendsOfPHP/PHP-CS-Fixer

Just wanna run this by you guys. How do you feel about the lowercase constants fixer becoming just a constants casing fixer, with config to select between upper and lower? For BC, we can make the existing fixer proxy to the new one, with lowercase config.

kinfeature request

Most helpful comment

Closing as there are no known (big) communities that have the lower-casing constant rule.
Making and maintaining a custom fixer for this is (relative) easy, so as long as there is no active user support for it here I think it does not belong to the core of the fixer.

All 7 comments

Uppercase goes against PSR2 iirc

Yes, I know, but not everybody follows PSR-2 (unfortunately). Drupal for example (https://www.drupal.org/docs/develop/standards/coding-standards#naming). PHP-CS-Fixer isn't PSR-2 only, since it has config for things that aren't PSR-2 already.

+1 for this proposal
PHP_CodeSniffer also offers sniffs for both variants of constants.

@ntzm If someone prefers uppercase constants, then there is no way to configure php-cs-fixer to enforce consistency.

Is Drupal the only FOSS community we known uses this standard? Do they plan on updating their CS to PSR in the future?

Drupal does not follow PSR2, yet when it comes to constants:

Constants should always be all-uppercase

so Drupal's example is not valid here.

PHP-CS-Fixer isn't PSR-2 only

is there a fixer to break PSR2?

We've a few fixers not following PSR (sometimes only through configuration).
If Drupal is moving to PSR standard, than I'm :-1: to add a fixer that is not PSR compat, _unless_ there is another big community following this PSR exception.

Closing as there are no known (big) communities that have the lower-casing constant rule.
Making and maintaining a custom fixer for this is (relative) easy, so as long as there is no active user support for it here I think it does not belong to the core of the fixer.

Was this page helpful?
0 / 5 - 0 ratings