[CodeQuality] Skip InlineConstructorDefaultToPropertyRector on non-final class - #8310
Open
TomasVotruba wants to merge 3 commits into
Open
[CodeQuality] Skip InlineConstructorDefaultToPropertyRector on non-final class#8310TomasVotruba wants to merge 3 commits into
TomasVotruba wants to merge 3 commits into
Conversation
TomasVotruba
force-pushed
the
skip-inline-constructor-on-non-final
branch
from
August 6, 2026 20:06
fe69cca to
adafe11
Compare
TomasVotruba
enabled auto-merge (squash)
August 6, 2026 21:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Continues #8281 by @Junaid-PK (rebased on
main, fixture restructured). Fixes rectorphp/rector#9837InlineConstructorDefaultToPropertyRectormoves initialization from runtime constructor flow to object creation. On a non-final class a child can omitparent::__construct()and still rely on the declared property default, so the move changes observable behavior.Previously the rule fired on any class:
class ValidatedBase { - private bool $validated = false; + private bool $validated = true; public function __construct() { $this->validate(); - $this->validated = true; } } final class SkipsParentConstructor extends ValidatedBase { // never calls parent::__construct(), so $validated used to stay false public function __construct() { } }Now non-final classes are left untouched;
finalclasses are inlined as before.The rule documentation and existing positive fixtures already use
finalclasses, so this makes that boundary explicit.Fixture follows the
Source/+ namespacedFixture/convention:Source/ValidatedBase.phpholds the parent,Fixture/skip_non_final_class.php.incthe non-final child that must stay unchanged.