Skip to content

Drop support for PHP < 8.1#361

Merged
janedbal merged 1 commit into
masterfrom
modernize-php-8.1
May 18, 2026
Merged

Drop support for PHP < 8.1#361
janedbal merged 1 commit into
masterfrom
modernize-php-8.1

Conversation

@janedbal
Copy link
Copy Markdown
Member

@janedbal janedbal commented May 18, 2026

Summary

  • Bumps PHP requirement to ^8.1 (composer.json, phpstan/phpcs phpVersion, CI matrix).
  • Modernizes source and tests to use PHP 8.0/8.1 features that were previously avoided to keep PHP 7.4 compatibility.

Config changes

  • composer.json: "php": "^7.4 || ^8.0""^8.1"
  • phpstan.neon.dist: phpVersion.min: 7040080100; enable enforceClosureParamNativeTypehint; drop obsolete BC ignores (BackedEnum not found, isEnum() always false)
  • phpcs.xml.dist: php_version: 7040080100; drop DisallowTrailingCommaInDeclaration override (trailing commas are now required by the default coding standard)
  • .github/workflows/checks.yml: drop 7.4 / 8.0 from test matrix; remove the composer remove shipmonk/coverage-guard workaround (it requires PHP 8.1+ — same as us now)

Source modernization

  • Constructor property promotion with private readonly across rules (skipped where the constructor has mixed responsibilities, e.g. ForbidCustomFunctionsRule validates and transforms its input)
  • switch (\$node::class)match expressions (ForbidMethodCallOnMixedRule, ForbidFetchOnMixedRule, ForbidIncrementDecrementOnNonIntegerRule)
  • strpos(...) !== falsestr_contains(...) (ForbidCheckedExceptionInCallableRule)
  • substr_compare(\$a, \$b, -strlen(\$b)) === 0str_ends_with(\$a, \$b) (ClassSuffixNamingRule)
  • First-class callable syntax \$this->normalizeArgumentIndexes(...) in ForbidCheckedExceptionInCallableRule
  • phpcbf added trailing commas to all multi-line function declarations (now required)

Test modernization

  • Removed PHP_VERSION_ID < 80100 / < 80000 guards that are now always satisfied (kept < 80200 and < 80400 checks that are still relevant)
  • get_class(\$x)\$x::class in AllRulesInConfigTest

Test plan

  • composer check passes (composer normalize, phpcs, phpstan, phpunit, coverage-guard, dependency-analyser, name-collision-detector, inline-ignore verifier)
  • CI matrix passes across PHP 8.1 - 8.5 on Linux and Windows

@janedbal janedbal force-pushed the modernize-php-8.1 branch from 6309d14 to 4574d87 Compare May 18, 2026 10:07
- Bump PHP requirement to ^8.1 in composer.json
- Update phpVersion to 80100 in phpstan.neon.dist and phpcs.xml.dist
- Drop PHP 7.4 / 8.0 from CI test matrix
- Promote constructor parameters to private readonly across rules
- Convert switch ($node::class) to match expressions
- str_contains / str_ends_with for legacy strpos / substr_compare
- First-class callable syntax in ForbidCheckedExceptionInCallableRule
- Drop PHP_VERSION_ID < 80100 guards in tests that are now always satisfied
- Replace get_class() with ::class in tests
- Enable enforceClosureParamNativeTypehint (no longer needed PHP 7.4 escape)
- Remove obsolete BackedEnum / isEnum() BC ignores from phpstan.neon.dist
- Drop coverage-guard removal workaround in CI (it requires PHP 8.1+)
@janedbal janedbal force-pushed the modernize-php-8.1 branch from 4574d87 to d3aefe6 Compare May 18, 2026 10:09
@janedbal janedbal changed the title Modernize codebase to PHP 8.1+ Drop support for PHP < 8.1 May 18, 2026
@janedbal janedbal marked this pull request as ready for review May 18, 2026 10:15
@janedbal janedbal merged commit 638b024 into master May 18, 2026
22 checks passed
@janedbal janedbal deleted the modernize-php-8.1 branch May 18, 2026 10:16
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