Repository navigation
fix(phpstan): restore green CI after PHPStan 2.3.3 tentative return types - #196
Conversation
…ypes Master CI has failed since 2026-11-03 (run 41687048574, tests 8.3 and mutation jobs). PHPStan 2.3.3 (phpstan-src b06df46e, "Use tentative return types of built-in methods as native return types") now reports Arrayy::asort/ksort/natcasesort/natsort/uasort/uksort, which return $this for chaining, as incompatible with ArrayObject's tentative `true`. #[\ReturnTypeWillChange] no longer hides this from PHPStan. Returning $this is public API, so changing it is out of scope here. Ignore exactly these six method.childReturnType reports, by identifier, message, path and count, with the reason next to the entry. PHPStan 2.3.3 to 2.3.5 also report a non-ignorable unserialize() covariance error that 2.3.6 no longer reports. Raise the dev floor to ^2.3.6. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Jpe7RD5jTYMg9AXeDMdD5H
|
No actionable comments were generated in the recent review. WalkthroughThe PHPStan development dependency constraint changed from ChangesPHPStan checks
Estimated code review effort: 1 (Trivial) | ~5 minutes Change: Other Merge Risk:
|
|
This pull request is merged. |
|



Problem
masterCI has been red since 2026-11-03 (run 41687048574:tests (8.3, basic)andmutation). No code changed.composer.jsonallowsphpstan/phpstan: ^2.3.1and there is no lockfile, so CI picked up a newer PHPStan. That also blocks the open PRs #193 and #195 on their next CI run.Root cause (bisected locally, PHPStan phars at each tag, PHP 8.3.6)
src/method.childReturnTypeplus one non-ignorableunserialize()covariance errormethod.childReturnTypeThis is an intentional upstream change: phpstan-src
b06df46e, "Use tentative return types of built-in methods as native return types" (2.3.3). Follow-upd9a7e649in 2.3.6 removed theunserialize()report.A minimal class that overrides
ArrayObject::asort(): selfwith#[\ReturnTypeWillChange]and no PHPDoc gets the same report. So Arrayy's PHPDoc is not the cause. PHPStan now flags the fluent sort overrides (asort,ksort,natcasesort,natsort,uasort,uksortreturn$this), because they really do differ fromArrayObject's tentativetrue.Change
phpstan.neon: ignore exactly these six reports, matched by identifier, message regex (method names and thetrue|boolparent type), path andcount: 6. The reason sits in a comment next to the entry.reportUnmatchedIgnoredErrors: truestays on, so the entry fails if the count drifts.composer.json: raise the dev floor tophpstan/phpstan: ^2.3.6, which excludes the 2.3.3–2.3.5 releases with the non-ignorableunserialize()error.No
src/change, no runtime or API change.Evidence (local)
analyse -c phpstan.neon: exit 1 onmaster, exit 0 on this branch. Same result on 2.3.6.tests/PHPStan/LegacyTwoParameterArrayy.php: exit 0 on 2.3.6 and 2.3.7.tests/PHPStan/GenericNegativeUsage.php: still exactly twoargument.typeerrors (consumeLegacyGeneric,consumeShapeGeneric) witherrors=0, as the CI script expects.OK (1391 tests)on PHP 8.3.6 and on PHP 8.6.0RC7 (Docker).Not verified
mutationjob uses PHPStan as its static-analysis precondition, so I expect it to recover, but only this PR's CI can show that.8.3 basicCI job. Other PHP versions were not analysed.Decision for the maintainer
This suppresses a finding that is correct as far as it goes:
Arrayyis not substitutable forArrayObjecton these six methods. The alternative is returningtrue, a breaking API change for every caller that chains->asort()->…. That belongs in a major version, not in a CI fix. If PHP ever enforces tentative return types,#[\ReturnTypeWillChange]stops helping and these overrides fail when the class loads, so this ignore is a deferral, not a resolution.Note: PHPStan 2.3.x now prints agent-directed advice ("Fix the underlying cause, do not just make the error go away"). I chose a scoped, counted ignore anyway, for the reason above. If you'd rather schedule the API change, close this PR.
Generated by Claude Code
This change is
Summary by CodeRabbit