Repository navigation
#299 - Use the PHP 8.3 to 8.5 functions through the Symfony polyfills, and configure Rector accordingly - #300
Merged
Merged
Conversation
…, and configure Rector accordingly - Require symfony/polyfill-php83, symfony/polyfill-php84 and symfony/polyfill-php85: the functions of PHP 8.3 to 8.5 can be used while supporting PHP 8.2. - Rector: withPhpVersion(PHP_82), the minimum supported version, so that no newer syntax is used; withPhpSets() without explicit version (read from composer.json), which adds the PHP_POLYFILLS set: the rules using a newer function apply when its polyfill is required (an explicit php82 would be a ceiling). Remove the redundant LevelSetList::UP_TO_PHP_82. - Apply Rector: ProcessConfiguration uses array_any() again (ForeachToArrayAnyRector). - CONTRIBUTING: PHP version section. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- ProcessConfiguration::getMainTask(): array_first() returns null with an empty array, the false check is no longer needed. - ConstraintLoader: array_first() / array_key_first() instead of current() / key() on the single constraint node. - ProcessHelpCommand: array_first() instead of current() on the single previous task. No internal array pointer used or moved, same results. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Oct 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #299: use the functions of PHP 8.3 to 8.5 safely while supporting PHP 8.2, and align the Rector configuration with the minimum PHP version.
Changes
symfony/polyfill-php83,symfony/polyfill-php84andsymfony/polyfill-php85(^1.33). They are empty on the PHP versions having the functions natively.withPhpVersion(PhpVersion::PHP_82)instead ofPHP_85(which introducedarray_any()without its polyfill in Fix php-cs-fixer run #185): no syntax above PHP 8.2;withPhpSets()without explicit version (read fromcomposer.json): Rector adds itsPHP_POLYFILLSset, so the rules using a newer function apply whencomposer.jsonrequires the matchingsymfony/polyfill-phpXX(an explicitphp82: truewould be a ceiling and skip them);LevelSetList::UP_TO_PHP_82removed (redundant withwithPhpSets()).ForeachToArrayAnyRector,ProcessConfiguration::getDependencyGroups()usesarray_any()again (the loop of #269 - Make process, stopwatch, var-dumper and monolog-bundle optional dependencies #296), now with its polyfill. The PHP 8.5 ruleArrayFirstLastRectoris not polyfill-aware in Rector 2.7: the PHP 8.5 functions (array_first(),array_last()…) can only be used manually for now.array_first()(PHP 8.5) used manually where it gives the same result without the internal array pointer:ProcessConfiguration::getMainTask():array_first()instead ofreset(), it returnsnullwith an empty array, so thefalsecheck is removed;ConstraintLoader::buildConstraints():array_first()/array_key_first()instead ofcurrent()/key()on the single constraint node;ProcessHelpCommand:array_first()instead ofcurrent()on the single previous task.Not changed on purpose:
ArrayFirstTransformer(reset()returnsfalsefor an empty array,array_first()would returnnull: behaviour change, and ArrayFirstTransformer: the allow_not_iterable option is inverted since v4.0 #234 changes this transformer),trim()→mb_trim()(other whitespace set, noa..zranges in the characters).Checks
957 tests OK on PHP 8.5, and on PHP 8.2 with
--prefer-lowest(the three polyfills installed). PHPStan, PHP-CS-Fixer, Rector OK.The bridge bundles will follow, one ticket each.
Requirements
Breaking changes
None: three new small dependencies (polyfills), no change of the minimum PHP version.
🤖 Generated with Claude Code