Skip to content

Support PHP 7.4+ via native source downgrade - #96

Merged
TomasVotruba merged 1 commit into
mainfrom
php-74-support
Oct 5, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
php-74-support

Conversation

@TomasVotruba

Copy link
Copy Markdown
Owner

Lower the minimum PHP from 8.4 to 7.4, so the package can run on legacy projects. The source is natively downgraded (the same approach as rectorphp/swiss-knife#153), no PHAR/scoper build.

Source downgrade (src + packages/type-perfect/src)

Produced with Rector downgrade sets (withDowngradeSets(php74: true)), then committed:

  • readonly properties/classes to @readonly docblocks
  • constructor promotion expanded to explicit properties + assignments
  • typed class constants to untyped
  • str_contains() rewritten to strpos()
  • union return/param types moved from native declarations to docblocks

rector.php keeps withPhpSets(), which now resolves to 7.4 from composer.json, so the source stays at this level.

composer.json

  • require.php: ^8.4 to >=7.4 (phpstan/phpstan ^2.2 and webmozart/assert ^1.11 both support 7.4)

Self type-coverage thresholds (phpstan.neon)

The package measures its own type coverage. On 7.4, native union types and typed constants are impossible, so the strict thresholds are no longer reachable:

  • return_type 99.9 to 96, param_type 100 to 99, constant_type 100 to 0
  • removed the smaller.alwaysFalse ignore (the PHP_VERSION_ID < 80300 guards are real branches now, not always-false)

CI

  • added bare_run.yaml: lints the source and installs prod deps on PHP 7.4, 8.2, 8.5
  • removed various_php_install.yaml (its 7.2 target is below the new minimum; bare_run validates the actual branch source instead)

Docs

  • README: "PHP 7.2+" to "PHP 7.4+"

Checks pass locally: PHPStan, ECS, Rector (stable at 7.4), composer-dependency-analyser, 88 tests.

@TomasVotruba
TomasVotruba merged commit afcfc6f into main Oct 5, 2026
9 checks passed
@TomasVotruba
TomasVotruba deleted the php-74-support branch October 5, 2026 20:07
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.

1 participant