Skip to content

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

Closed

Description

@njoubert-cleverage

Description

Same change as cleverage/process-bundle#299, for this bridge.

The bundle supports PHP >=8.2, but the Rector configuration is inconsistent with it:

->withPhpVersion(PhpVersion::PHP_85)
->withPhpSets(php82: true)
->withSets([LevelSetList::UP_TO_PHP_82, /* ... */])

withPhpVersion(PHP_85) lets Rector use PHP 8.3+ features, e.g. introduce array_any() (PHP 8.4) or json_validate() (PHP 8.3), while composer.json does not require the matching polyfill: such code would only work on PHP 8.2 thanks to a polyfill installed transitively by another package, and break as soon as that package stops requiring it.

The goal is to use the functions of the latest PHP versions (8.3 to 8.5) safely, through the Symfony polyfills, while keeping PHP 8.2 as the minimum version for the syntax.

Proposed fix

  • composer.json: require symfony/polyfill-php83, symfony/polyfill-php84 and symfony/polyfill-php85 (^1.33). They are empty on the PHP versions that have the functions natively.
  • rector.php:
    • withPhpVersion(PhpVersion::PHP_82), the minimum supported version, so that no syntax above PHP 8.2 is used;
    • withPhpSets() without explicit version (read from composer.json): Rector then adds its PHP_POLYFILLS set, the rules using a function of a newer version are applied when composer.json requires the matching symfony/polyfill-phpXX package (an explicit php82: true is a ceiling and skips them);
    • remove LevelSetList::UP_TO_PHP_82, redundant with withPhpSets().
  • Apply Rector, and review the code for places where a PHP 8.3 to 8.5 function would replace existing code with an identical behaviour.
  • Document the rule in CONTRIBUTING.md.

Requirements

  • Documentation updates
    • Reference
    • Changelog
  • Unit tests

Breaking changes

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

Activity

  1. added a commit that references this issue on Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions