Skip to content

docs(phpstan): fluent wither over new ctor param on consistent-constructor DTOs#75

Merged
CybotTM merged 1 commit into
mainfrom
retro/consistent-constructor-fluent-setter
Jul 21, 2026
Merged

docs(phpstan): fluent wither over new ctor param on consistent-constructor DTOs#75
CybotTM merged 1 commit into
mainfrom
retro/consistent-constructor-fluent-setter

Conversation

@CybotTM

@CybotTM CybotTM commented Jul 21, 2026

Copy link
Copy Markdown
Member

What

Adds a Consistent-Constructor Subclass Collisions subsection to references/phpstan-compliance.md (under Common Error Fixes).

Why

Adding a new trailing parameter to a @phpstan-consistent-constructor base constructor collides with any subclass that already appends its own parameters — the same positional slot ends up with two different types, and PHPStan reports method.childParameterType (not contravariant). Encountered while adding a field to an option object whose subclass added its own trailing parameter.

Guidance added

Evolve state on a @phpstan-consistent-constructor type that has subclasses through a fluent with*() wither (private property + clone $this) instead of a new constructor parameter. The constructor signature stays stable, so there's no subclass collision, and the field stays immutable-by-clone. Cross-links to references/immutability-boundaries.md.

Docs-only; passes markdownlint (SKILL.md unchanged).

…uctor DTOs

Adding a trailing constructor parameter to a @phpstan-consistent-constructor
base class collides with subclasses that append their own parameters
(method.childParameterType). Document the symptom and the fix — evolve state
through a with*() wither instead of a new constructor parameter — as a new
"Consistent-Constructor Subclass Collisions" subsection under Common Error Fixes.

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
Copilot AI review requested due to automatic review settings July 21, 2026 06:48
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions github-actions Bot added documentation Improvements or additions to documentation skill labels Jul 21, 2026
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@CybotTM
CybotTM merged commit 3b8130a into main Jul 21, 2026
20 of 21 checks passed
@CybotTM
CybotTM deleted the retro/consistent-constructor-fluent-setter branch July 21, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation skill

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants