Php-cs-fixer: [Meta] PHP 7.4 support

Created on 16 Apr 2019  Â·  10Comments  Â·  Source: FriendsOfPHP/PHP-CS-Fixer

(Syntax) changes that require new tests to make sure the tool is compatible with PHP 7.4:

  • [x] [Null Coalescing Assignment Operator](https://wiki.php.net/rfc/null_coalesce_equal_operator) (#4603)
  • [x] [Typed Properties 2.0](https://wiki.php.net/rfc/typed_properties_v2) (#4593)
  • [x] [Spread Operator in Array Expression](https://wiki.php.net/rfc/spread_operator_for_array) (#4602)
  • [x] [Arrow Functions 2.0](https://wiki.php.net/rfc/arrow_functions_v2) (#4600)
  • [x] [Change the precedence of the concatenation operator](https://wiki.php.net/rfc/concatenation_precedence) (couldn't find any issue with this on 2.15)
  • [x] [Numeric Literal Separator](https://wiki.php.net/rfc/numeric_literal_separator) (#4596)

Other:

  • [x] [Reflection for references](https://wiki.php.net/rfc/reference_reflection) (class casing) (couldn't find any issue with this on 2.15)
  • [x] [Password Hashing Registry](https://wiki.php.net/rfc/password_registry) (function casing) (couldn't find any issue with this on 2.15)
  • [x] [mb_str_split](https://wiki.php.net/rfc/mb_str_split) (#4380 -> #4534)
  • [x] [New custom object serialization mechanism](https://wiki.php.net/rfc/custom_object_serialization) (#4381)

TODO:

  • [x] PHP 7.4 integration test (#4637)
  • [x] do the same checks for rules added in v2.16 (#4638)
  • [x] do the same checks for rules added on master (couldn't find any issue with this on master)
  • [x] VisibilityRequiredFixer (#4641)

Sources:

Approved RFC's list for PHP7.4

kinmeta

Most helpful comment

It took us quite a while, but i'm supper happy we have it now, just before 7.4 official release at 28th of Nov

All 10 comments

Will it be possible to automatically add property typehints if constructor has assignment, but property itself doesn't have @var annotation?

Example:

class Product
{
    private $category;

    public function __construct(Category $category)
    {
        $this->category = $category;
    }
}

The reason is that I never put @var annotations, PHPStorm is smart enough to figure the type from constructor and give me autocomplete.

can be problematic in cases like

        private $foo;
    public function __construct(Category $category)
    {
        $this->foo = validateCategory($category) ? $category : createDummyCategory();
    }

i know, stupid code, but possible.

PHP CS Fixer is not going that deep into looking on code execution

I removed _Deprecate left-associative ternary operator_ item as I don't think we have anything to do for it (it does not introduce any syntax change).

I checked every item of the list: all seem ok to me or have a corresponding PR to improve support. Please review :)

Note that merging those PRs should allow us to claim support for PHP 7.4 on branch 2.15 only. We still need to do the same checks on master for new fixers that have been added.

can you take a look at higher branches, @julienfalque , please ?

It took us quite a while, but i'm supper happy we have it now, just before 7.4 official release at 28th of Nov

Is there any documentation available on how to use these new PHP 7.4 features?

i am also interested, how to use new features?

This issue was not about implementation of new features for PHP 7.4 but to make sure that existing features were compatible with new PHP 7.4 syntax changes.

see also https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/4834 for the introduction of the PHP7.4 rule sets to easy migration

Was this page helpful?
0 / 5 - 0 ratings