Summary
The php-tests CI job fails at collection time (before any test runs) with a PHP fatal:
PHP Fatal error: Cannot override final method
PHPUnit\Framework\Assert::assertMatchesRegularExpression()
in tests/unit/SirusTestCase.php on line 26
Observed on php-tests (8.2) / php-tests (8.3) for PR #96 (commit c675b39), but the cause is independent of that PR's phpcs work — it is a test-harness / dependency-version issue.
Root cause
The project now resolves PHPUnit 11.5.55 (via yoast/phpunit-polyfills 4.0.0). In PHPUnit 10+/11, assertMatchesRegularExpression() is a built-in, final assertion. tests/unit/SirusTestCase.php:26 declares its own assertMatchesRegularExpression() — historically a polyfill for the old assertRegExp() — which PHP rejects as an override of a final method, aborting the whole run with exit code 255.
Fix options
- Delete the custom polyfill in
SirusTestCase and rely on PHPUnit 11's native assertMatchesRegularExpression() (and/or the Yoast polyfills, which already cover older runtimes). Likely the cleanest fix.
- If a shim is still wanted for backward compat, rename it so it no longer collides with the
final method, or gate it behind a method_exists() check.
- Verify no other
SirusTestCase helpers shadow now-final PHPUnit 11 assertions (e.g. assertStringContainsString, assertEqualsCanonicalizing).
Acceptance criteria
composer run test:unit (vendor/bin/phpunit --configuration=phpunit.xml.dist) collects and runs without a fatal.
php-tests (8.2) and php-tests (8.3) jobs pass.
Scope note
Tracked separately from PR #96 (phpcs/code-quality triage) per maintainer direction — that PR is intentionally not mixing in the test-harness fatal.
https://claude.ai/code/session_017eY7AtjnwGHErQbDNzGxzt
Summary
The
php-testsCI job fails at collection time (before any test runs) with a PHP fatal:Observed on
php-tests (8.2)/php-tests (8.3)for PR #96 (commitc675b39), but the cause is independent of that PR's phpcs work — it is a test-harness / dependency-version issue.Root cause
The project now resolves PHPUnit 11.5.55 (via
yoast/phpunit-polyfills 4.0.0). In PHPUnit 10+/11,assertMatchesRegularExpression()is a built-in,finalassertion.tests/unit/SirusTestCase.php:26declares its ownassertMatchesRegularExpression()— historically a polyfill for the oldassertRegExp()— which PHP rejects as an override of afinalmethod, aborting the whole run with exit code 255.Fix options
SirusTestCaseand rely on PHPUnit 11's nativeassertMatchesRegularExpression()(and/or the Yoast polyfills, which already cover older runtimes). Likely the cleanest fix.finalmethod, or gate it behind amethod_exists()check.SirusTestCasehelpers shadow now-finalPHPUnit 11 assertions (e.g.assertStringContainsString,assertEqualsCanonicalizing).Acceptance criteria
composer run test:unit(vendor/bin/phpunit --configuration=phpunit.xml.dist) collects and runs without a fatal.php-tests (8.2)andphp-tests (8.3)jobs pass.Scope note
Tracked separately from PR #96 (phpcs/code-quality triage) per maintainer direction — that PR is intentionally not mixing in the test-harness fatal.
https://claude.ai/code/session_017eY7AtjnwGHErQbDNzGxzt