Skip to content

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

Merged
njoubert-cleverage merged 1 commit into
mainfrom
35
Oct 15, 2026
Merged

njoubert-cleverage merged 1 commit into
mainfrom
35

Conversation

@njoubert-cleverage

Copy link
Copy Markdown
Member

Fixes #35

Description

Same change as cleverage/process-bundle#299 (cleverage/process-bundle#300): 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: 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 is a ceiling and skips them);
    • LevelSetList::UP_TO_PHP_82 removed (redundant with withPhpSets()), and its use.
  • Rector applied (2.7.0): no rule applies to the current code (--dry-run empty).
  • Pre-existing uses of PHP 8.3+ functions: none in src/ nor tests/ (array_any, array_find, array_first, json_validate, mb_trim...). The #[\Override] attribute (PHP 8.3) is already used; it is a plain attribute, ignored on PHP 8.2, and its class is now also provided by symfony/polyfill-php83.
  • Manual analysis of src/: nothing to replace. Candidates rejected:
    • ZipTask: rtrim() / ltrim() of DIRECTORY_SEPARATOR on paths → mb_rtrim() / mb_ltrim(): no gain, and file paths are not necessarily valid UTF-8 (byte-wise trim is the right one);
    • ZipTask: the foreach on the files adds each file to the archive (side effects, exceptions), not a search / any / all;
    • CleverAgeArchiveProcessExtension::findServices(): foreach on a Finder (iterator, not an array) loading each file.
    • No reset() / current() / end() / key(), no json_decode(), no ucfirst() in src/.
  • CONTRIBUTING: new "PHP version" section (PHP 8.2 syntax, PHP 8.3 to 8.5 functions through the polyfills).
  • CHANGELOG (Latest).

Checks

  • 31 tests OK on PHP 8.5 (highest), also with coverage (pcov, no risky test, lines 98.78%);
  • 31 tests OK on PHP 8.2 with --prefer-lowest (symfony/polyfill-php83, -php84 and -php85 installed);
  • PHPStan, PHP-CS-Fixer, Rector OK.

Requirements

  • Documentation updates
    • Reference
    • Changelog
  • Unit tests

Breaking changes

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

🤖 Generated with Claude Code

…olyfills, and configure Rector accordingly

- Require symfony/polyfill-php83, symfony/polyfill-php84 and symfony/polyfill-php85 (^1.33)
- Rector: withPhpVersion(PHP_82) instead of PHP_85, withPhpSets() read from composer.json (adds the PHP_POLYFILLS set), remove the redundant LevelSetList::UP_TO_PHP_82
- No Rector rule nor manual replacement applies to the current code
- CONTRIBUTING: new "PHP version" section
- CHANGELOG

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@njoubert-cleverage
njoubert-cleverage merged commit f0501f1 into main Oct 15, 2026
18 checks passed
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