Skip to content

Skip overridden methods in DocblockReturnArrayFromDirectArrayInstanceRector#9656

Closed
Copilot wants to merge 3 commits intomainfrom
copilot/find-fix-issue-rector
Closed

Skip overridden methods in DocblockReturnArrayFromDirectArrayInstanceRector#9656
Copilot wants to merge 3 commits intomainfrom
copilot/find-fix-issue-rector

Conversation

Copy link

Copilot AI commented Feb 17, 2026

DocblockReturnArrayFromDirectArrayInstanceRector was adding @return docblocks to methods overriding parent/interface methods, creating conflicting documentation.

interface FooInterface {
    /** @return int[] */
    public function getCodes(): iterable;
}

class Foo implements FooInterface {
    public function getCodes(): iterable {
        return [200, 201];
    }
    // Rector was incorrectly adding: @return array{200, 201}
    // Should inherit parent's @return int[] instead
}

Changes

  • Added ParentClassMethodTypeOverrideGuard dependency to detect overridden methods
  • Skip docblock generation when hasParentClassMethod() returns true
  • Follows pattern used in AddParamArrayDocblockFromDimFetchAccessRector and similar rectors

Child methods now properly inherit parent documentation per LSP principles.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 17, 2026 21:43
Co-authored-by: TomasVotruba <924196+TomasVotruba@users.noreply.github.com>
Co-authored-by: TomasVotruba <924196+TomasVotruba@users.noreply.github.com>
Copilot AI changed the title [WIP] Find and fix issue in rectorphp/rector-src Skip overridden methods in DocblockReturnArrayFromDirectArrayInstanceRector Feb 17, 2026
Copilot AI requested a review from TomasVotruba February 17, 2026 21:46
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.

2 participants

Comments