Skip to content

[TypeDeclarationDocblocks] Skip docblock already defined in parent on DocblockVarArrayFromPropertyDefaultsRector#8085

Open
samsonasik wants to merge 4 commits into
mainfrom
skip-from-parent
Open

[TypeDeclarationDocblocks] Skip docblock already defined in parent on DocblockVarArrayFromPropertyDefaultsRector#8085
samsonasik wants to merge 4 commits into
mainfrom
skip-from-parent

Conversation

@samsonasik

Copy link
Copy Markdown
Member

@samsonasik samsonasik changed the title [TypeDeclarationDocblocks] Skip child with parent property docblock on DocblockVarArrayFromPropertyDefaultsRector [TypeDeclarationDocblocks] Skip docblock already defined in parent on DocblockVarArrayFromPropertyDefaultsRector Jun 25, 2026
@samsonasik

Copy link
Copy Markdown
Member Author

Fixed 🎉 /cc @BackEndTea

@samsonasik samsonasik requested a review from TomasVotruba June 25, 2026 00:32
@samsonasik

Copy link
Copy Markdown
Member Author

@TomasVotruba ready 👍

return false;
}

$classReflection = $this->reflectionResolver->resolveClassReflection($class);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Here, the $scope can be used instead. I prefer it over service, as we're closer to PHPStan logic.

        $scope = ScopeFetcher::fetch($classMethod);

        $classReflection = $scope->getClassReflection();
        if (! $classReflection instanceof ClassReflection) {
            return null;
        }

        $parentClassReflection = $classReflection->getParentClass();
        if (! $parentClassReflection instanceof ClassReflection) {
            return null;
        }

@samsonasik samsonasik Jun 25, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

updated to use ScopeFetcher, the loop is still needed since it lookup parent that has the docblock, if parent redefine on grand parent and only grand parent that has docblock, that follow that.

90e9217

@samsonasik samsonasik requested a review from TomasVotruba June 25, 2026 11:56
@samsonasik

Copy link
Copy Markdown
Member Author

@TomasVotruba ready 👍

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.

DocblockVarArrayFromPropertyDefaultsRector should not add types when they are already defined on parent

3 participants