KorvinSzanto / PHP-CS-Fixer

A tool to automatically fix PHP coding standards issues
http://cs.sensiolabs.org
Other
5 stars 0 forks source link

All PHP reserved keywords and types [1][2] MUST be in lower case. #1

Open KorvinSzanto opened 6 years ago

KorvinSzanto commented 6 years ago

Most reserved types are covered, but iterable and scalar type hints are not. This likely needs a new fixer that can parse the T_STRING values and detect these missing types and lowercase them. From what I can tell, the SPL tokenizer doesn't recognize them.

mlocati commented 5 years ago

~See https://mlocati.github.io/php-cs-fixer-configurator/#fixer:lowercase_keywords~

See https://mlocati.github.io/php-cs-fixer-configurator/#fixer:native_function_casing

KorvinSzanto commented 5 years ago

These keywords aren't functions and afaict they aren't effected by that fixer. For example:

<?php

function foo(String $bar, Iterable $list)
{
    ...
}

should become foo(string $bar, iterable $list).

From what I was able to find out last year is that the SPL tokenizer doesn't recognize those keywords

mlocati commented 5 years ago

What about https://mlocati.github.io/php-cs-fixer-configurator/#fixer:native_function_type_declaration_casing ?

mlocati commented 5 years ago

I think we have to wait for concrete5 version 9 in order to use the native_function_type_declaration_casing fixer, since it has been introduced in PHP-CS-Fixer 2.15, which requires PHP 5.6+.

What I'd do is to adopt the rules defined in https://github.com/concrete5/concrete5/pull/7810 which cover many rules (see here) that we currently don't follow.

When we'll be able to use a newer PHP-CS-Fixer option, we can add more rules there.