Skip to content

#299 - Use the PHP 8.3 to 8.5 functions through the Symfony polyfills, and configure Rector accordingly - #300

Merged
njoubert-cleverage merged 2 commits into
mainfrom
299
Oct 15, 2026
Merged

njoubert-cleverage merged 2 commits into
mainfrom
299

Conversation

@njoubert-cleverage

@njoubert-cleverage njoubert-cleverage commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

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

  • composer.json: require symfony/polyfill-php83, symfony/polyfill-php84 and symfony/polyfill-php85 (^1.33). They are empty on the PHP versions having the functions natively.
  • rector.php:
    • withPhpVersion(PhpVersion::PHP_82) instead of PHP_85 (which introduced array_any() without its polyfill in Fix php-cs-fixer run #185): no syntax above PHP 8.2;
    • withPhpSets() without explicit version (read from composer.json): Rector adds its PHP_POLYFILLS set, so the rules using a newer function apply when composer.json requires the matching symfony/polyfill-phpXX (an explicit php82: true would be a ceiling and skip them);
    • LevelSetList::UP_TO_PHP_82 removed (redundant with withPhpSets()).
  • Rector applied: only ForeachToArrayAnyRector, ProcessConfiguration::getDependencyGroups() uses array_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 rule ArrayFirstLastRector is 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 of reset(), it returns null with an empty array, so the false check is removed;
    • ConstraintLoader::buildConstraints(): 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.
      Not changed on purpose: ArrayFirstTransformer (reset() returns false for an empty array, array_first() would return null: behaviour change, and ArrayFirstTransformer: the allow_not_iterable option is inverted since v4.0 #234 changes this transformer), trim() → mb_trim() (other whitespace set, no a..z ranges in the characters).
  • CONTRIBUTING: new "PHP version" section (PHP 8.2 syntax, PHP 8.3 to 8.5 functions through the polyfills).
  • CHANGELOG (Latest).

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

  • Documentation updates
    • Reference
    • Cookbooks
    • Changelog
  • Unit tests

Breaking changes

None: three new small dependencies (polyfills), no change of the minimum PHP version.

🤖 Generated with Claude Code

njoubert-cleverage and others added 2 commits October 15, 2026 15:19
…, 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use the PHP 8.3 to 8.5 functions through the Symfony polyfills, and configure Rector accordingly

1 participant