IBX-12606: Replaced the Symfony deprecation thresholds with PHPUnit's native deprecation gate - #837
Conversation
b599ce9 to
eb20cbe
Compare
eb20cbe to
2ad69a3
Compare
| @@ -0,0 +1,79 @@ | |||
| <?xml version="1.0"?> | |||
There was a problem hiding this comment.
Can this be in some different format than XML? Asking due to readability reasons.
There was a problem hiding this comment.
no, as everything in phpunit, xml only.
bnowak
left a comment
There was a problem hiding this comment.
That's weird, but don't we have any deprecations in integration test suites?
|
Update: CI caught a real gap — The earlier back-and-forth in this thread about Baseline is single-file per suite, not per-PHP-version — this job's matrix is |
… native deprecation gate
…HPUnit 9 convert*ToExceptions strictness
… PHPUnit's expectUserDeprecationMessage()
…me way as the unit suite
….4, matching CI's matrix
7c1fd5b to
7d6249a
Compare
…ader() deprecation, triggered on MySQL/PostgreSQL but not the SQLite fixture
| @@ -1,17 +1,15 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="bootstrap.php" processIsolation="false" beStrictAboutTestsThatDoNotTestAnything="false" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false"> | |||
| <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="bootstrap.php" processIsolation="false" beStrictAboutTestsThatDoNotTestAnything="false" colors="true" failOnWarning="true" failOnNotice="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false"> | |||
There was a problem hiding this comment.
Can we get this in multiline instead?
It will be easier for readability/git operations.
|



Description:
phpunit.xmlsetSYMFONY_DEPRECATIONS_HELPER="max[self]=82&max[direct]=855&max[indirect]=14&verbose=0", but this is a no-op under PHPUnit ≥10: the Symfony bridge'sbootstrap.phpreturns early when it detects the modern PHPUnit event system, andSymfonyExtensionnever registers aDeprecationErrorHandler. The three integration configs already carriedSYMFONY_DEPRECATIONS_HELPER=disabled(one of them twice, duplicated), equally dead.composer unitwas silently ignoring every deprecation regardless of threshold.This PR replaces the dead bridge gate with PHPUnit 11's native deprecation handling on the unit suite:
failOnDeprecation="true"on<phpunit>— the suite now fails when an un-baselined deprecation is triggered.displayDetailsOnTestsThatTriggerDeprecations="true"— prints the triggering test + message for every deprecation.<source baseline="phpunit.baseline.xml" ignoreIndirectDeprecations="false" ignoreSuppressionOfDeprecations="true"><include><directory>src</directory></include></source>:ignoreIndirectDeprecations="false"— a deprecation triggered entirely inside third-party code (vendor calling vendor) does not fail the build; only deprecations touched by our ownsrc/ortests/code do. Measured empirically: toggling this flag made no difference on the current unit suite (no purely-indirect deprecations exist today), and was proven with a temporary synthetic probe (file outsidesrc//tests/, so classified third-party-to-third-party) that failed the build with the flag off and passed with it on.ignoreSuppressionOfDeprecations="true"— Symfony'strigger_deprecation()calls@trigger_error(E_USER_DEPRECATED); PHPUnit ignores@-silenced issues by default, so without this flag every BC-layer deprecation Ibexa ships would be invisible to the gate.baseline="phpunit.baseline.xml"— the "fail on NEW deprecations only" requirement. Existing deprecations are frozen into the baseline (generated withvendor/bin/phpunit -c phpunit.xml --generate-baseline phpunit.baseline.xml) and ignored; anything not already in it fails the build.SYMFONY_DEPRECATIONS_HELPERenv line fromphpunit.xmland the (duplicated)disabledenv lines fromphpunit-integration.xml,phpunit-integration-legacy.xml, andphpunit-integration-legacy-solr.xml(integration deprecation gating is out of scope here and staysdisabled, just without the redundant lines).Measured on
tests/lib+tests/bundle/*(7544 tests):ignoreIndirectDeprecations=true,ignoreSuppressionOfDeprecations=true): 7Deprecations(6 distinct messages),PHPUnit Deprecations: 2505(unrelated — PHPUnit's own internal deprecations, mostlygetMockForAbstractClass(), a separate topic).ignoreIndirectDeprecations=false: 7 — identical; no purely-indirect (third-party-calling-third-party) deprecations exist in this suite today.ignoreSelfDeprecations=true(deprecation triggered by our ownsrc/test code directly, not routed through a vendor helper): drops to 3 — the other 4 are "self" (e.g.ObjectStateGroup::$defaultLanguageCode,ObjectState::$defaultLanguageCode,ObjectStateLimitationType). Not applied in the final config — these should still gate.<line>entries, 19<issue>entries. 11 of the 19 issues are PHP-8.4-only (they don't fire under PHP 8.3): 9 are PHP-nativeleague/flysystem"implicitly marking parameter as nullable" deprecations (UnableToDeleteFile.php:22,UnableToReadFile.php:22,UnableToRetrieveMetadata.php:27/32/37/42/47,LocalFilesystemAdapter.php:84/87,Filesystem.php:24), plus 1 new entry (tests/lib/MVC/Symfony/Security/UserWrappedTest.php:61,UserWrapped::eraseCredentials() is deprecated). Verified clean on both PHP 8.4 (19 issues were ignored by baseline, full 7544-test suite, exit 0) and PHP 8.3 (8 issues were ignored by baseline— only the pre-existing entries fire there, exit 0). A PHP 8.4 CLI's defaultmemory_limit(128M) is too low for this suite and needs raising (e.g.-d memory_limit=4G) to avoid an unrelated OOM fatal error — not a code defect, just an environment default.Baseline brittleness: each entry keys on
(file, line, sha1-of-the-line-text, exact description string). A line-number shift anywhere above a baselined call site (an unrelated edit adding/removing lines earlier in the same file) moves the deprecation to a new line number and the entry stops matching — the deprecation reappears as "new" and fails the build until the baseline is regenerated. Same if the line's text changes without the line moving. This fails safe (a spurious "new deprecation" build failure, never a silently-swallowed one) but does mean routine refactors near a deprecated call site will occasionally require a baseline refresh.Refreshing the baseline:
vendor/bin/phpunit -c phpunit.xml --generate-baseline phpunit.baseline.xml, review the diff, commit it alongside the change that introduced the new deprecation(s)..github/workflows/*.yml— none of the 7 workflow files referenceSYMFONY_DEPRECATIONS_HELPER; nothing there needed changes.Second commit, restored PHP notice/warning strictness (all four configs): before the PHPUnit 11 migration every config carried
convertErrorsToExceptions,convertNoticesToExceptionsandconvertWarningsToExceptionsset totrue, so a PHP notice or warning inside a test failed the run. PHPUnit 10 removed those attributes and the migration dropped them; the PHPUnit 10+ equivalentsfailOnNoticeandfailOnWarningboth default tofalse, so notices and warnings became non-failing issues. Onlyphpunit-integration.xmlstill hadfailOnWarning="true". This commit setsfailOnWarning="true" failOnNotice="true"onphpunit.xml,phpunit-integration.xml,phpunit-integration-legacy.xmlandphpunit-integration-legacy-solr.xml. Unit suite with all three gates active: 7545 tests, exit 0, 19 issues ignored by baseline. The same two attributes are rolled out to every other repo of the wave together with the deprecation gate.Third commit, PHPUnit-native deprecation expectations:
DownloadControllerTestandContentDomainMapperTestused the bridge'sExpectDeprecationTrait::expectDeprecation(). Under PHPUnit 11 that method is inert: a probe with a deliberately wrong expected message still passed (exit 0, test flagged risky for having no assertions). Both call sites now useTestCase::expectUserDeprecationMessage(); the same probe fails (exit 1). The expected deprecation is reported to the gate as well, sophpunit.baseline.xmlgained the oneDownloadControllerentry (20 issues ignored by baseline, 7545 tests, exit 0). The bridge itself stays inrequire-dev:bootstrap.phpand 6 test files useClockMock, andSymfonyExtensionremains registered for it.For QA:
N/A
Documentation:
N/A