Skip to content

Skip constructor defaults on extensible classes - #8281

Open
Junaid-PK wants to merge 1 commit into
rectorphp:mainfrom
Junaid-PK:fix/inline-constructor-non-final
Open

Skip constructor defaults on extensible classes#8281
Junaid-PK wants to merge 1 commit into
rectorphp:mainfrom
Junaid-PK:fix/inline-constructor-non-final

Conversation

@Junaid-PK

Copy link
Copy Markdown

Fixes rectorphp/rector#9837

Summary

  • skip InlineConstructorDefaultToPropertyRector for non-final classes
  • preserve a declared property default when a child class bypasses the parent constructor
  • add a regression fixture covering that inheritance path

The transformation moves initialization from runtime constructor flow to object creation. For an extensible class, a child can omit parent::__construct(), so moving the assignment changes observable behavior. The rule documentation and existing positive fixtures already use final classes; this makes that safety boundary explicit.

Verification

  • targeted rule suite: 20 tests, 21 assertions
  • full PHPUnit suite: 5,407 tests, 6,926 assertions, 2 skipped
  • full PHPStan analysis: no errors
  • ECS on both changed files: no errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect behavior of InlineConstructorDefaultToPropertyRector

1 participant