Skip to content

[2.0.x] Fix readonly false positive in DependencySerializationTraitPropertyRule - #1017

Merged
mglaman merged 2 commits into
2.0.xfrom
backport-1010-2.0.x
Jul 17, 2026
Merged

[2.0.x] Fix readonly false positive in DependencySerializationTraitPropertyRule#1017
mglaman merged 2 commits into
2.0.xfrom
backport-1010-2.0.x

Conversation

@mglaman

@mglaman mglaman commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Cherry-pick of #1010 (28f3f46) to 2.0.x. Fixes #1009 / #889 for the 2.0.x line.

One deviation from the original commit: the .github/workflows/php.yml hunk (adding a PHP 8.4 matrix leg) was dropped. The 2.0.x matrix still includes ~11.2.0, which is no longer installable due to unfixed core security advisories (see #1011), so new 8.4 legs would fail for unrelated reasons. The rule tests construct PhpVersion with 8.3 and 8.4 directly, so both analyzed-version code paths are covered on every runtime without the extra CI leg.

Rule + full suite and phpstan pass on 2.0.x.

Note for release notes: the error message/tip text changed, so ignoreErrors entries matching on message text will become unmatched (identifier is unchanged).

🤖 Generated with Claude Code

…le (#1010)

* Fix readonly false positive in DependencySerializationTraitPropertyRule

The rule flagged every readonly property on classes using
DependencySerializationTrait. The trait's __sleep() never mutates
properties, and __wakeup() initializes an excluded readonly property
from the trait's composing class scope, which PHP allows. The check
now only reports readonly properties that can hold an object when the
trait comes from a parent class on PHP < 8.4, where the parent-scope
initialization in __wakeup() throws.

Fixes #1009

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Run test suite on PHP 8.4

The DependencySerializationTraitPropertyRule readonly check now
branches on PHP < 8.4 vs 8.4+, so the test matrix should exercise
both runtimes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@mglaman
mglaman merged commit 98b4222 into 2.0.x Jul 17, 2026
11 of 12 checks passed
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