Skip to content

Conversation

@carlos-granados
Copy link
Contributor

This rule adds the #[\Override] attribute to properties that override parent class properties. PHP 8.5 extends the Override attribute to support properties in addition to methods.

The rule:

  • Adds #[\Override] to public/protected properties that override parent properties
  • Skips private properties (cannot truly override)
  • Skips properties where parent is private (not visible to child)
  • Skips properties that already have the attribute

Fixes rectorphp/rector#9579

@carlos-granados carlos-granados force-pushed the add-override-attribute-to-overridden-properties branch from f0fd451 to b971816 Compare February 4, 2026 12:17
This rule adds the #[\Override] attribute to properties that override
parent class properties. PHP 8.5 extends the Override attribute to
support properties in addition to methods.

The rule:
- Adds #[\Override] to public/protected properties that override parent properties
- Skips private properties (cannot truly override)
- Skips properties where parent is private (not visible to child)
- Skips properties that already have the attribute
@carlos-granados carlos-granados force-pushed the add-override-attribute-to-overridden-properties branch from b971816 to f4d45e2 Compare February 4, 2026 12:38
@carlos-granados
Copy link
Contributor Author

@samsonasik thanks for your review, all updated with your suggestions

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.

AddOverrideAttributeToOverriddenMethodsRector for properties

2 participants