Skip to content

[TypeDeclaration] Skip TypedPropertyFromStrictConstructorRector on protected property redeclared in child class - #8503

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-fix-9899-typed-property-child-override
Sep 17, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
tv-fix-9899-typed-property-child-override

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Fixes rectorphp/rector#9899

When a parent class assigns a protected property in its constructor, the rule typed it, but a child class that redeclares the same property and only delegates via parent::__construct() was left untyped. This produced a fatal error:

Type of SimpleTextFrameReflower::$_frame must be Frame (as in class FrameReflower)

A protected property on a non-final class can be redeclared untyped in a child, so typing only the parent breaks covariance. The guard now runs the stricter check for protected properties - they are typed only when the class is final (no child can redeclare). Public and private properties keep their current behavior.

@TomasVotruba
TomasVotruba merged commit 2f0f649 into main Sep 17, 2026
45 checks passed
@TomasVotruba
TomasVotruba deleted the tv-fix-9899-typed-property-child-override branch September 17, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant