[CodingStyle] Deprecate ArraySpreadInsteadOfArrayMergeRector - #8277
Conversation
…onal preference that makes array merges harder to read
|
People have to get used to newer PHP syntax sooner or later. PHP 8.5 introduces the pipe operator $uniqueEmails = $userRepository->findAll()
|> array_filter(?, fn($u) => $u->isActive())
|> array_map(fn($u) => $u->getEmail(), ?)
|> array_map(strtolower(...), ?)
|> array_unique(...);array_merge is slow and the spread operator is the better way to use so I'm sad this rule got deprecated. |
|
Pipe operators have also drawbacks based on PHP version - https://stitcher.io/blog/php-86-partial-function-application, so they should be used willingly. Same was for spread operator |
This rule caused troubles as far as I can remember. Also, it makes code harder to read in half of the cases.
Not a rule we can apply generaly.
Deprecates
ArraySpreadInsteadOfArrayMergeRector.The rule turns readable
array_merge()calls into spread arrays. That is a personal preference, not a fix: the result is harder to read and the...in the middle of an array literal looks dangerous to reviewers.The rule was not part of any set or level, so nothing else changes. It now implements
DeprecatedInterfaceand throws on use; its tests and fixtures are removed.