You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use the PHP 8.3 to 8.5 functions through the Symfony polyfills, and configure Rector accordingly #51
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
Merge pull request #52 from cleverage/51