Skip to content

[perf] Skip scope fetch in ReturnTypeFromGetRepositoryDocblockRector without a docblock - #8632

Merged
TomasVotruba merged 2 commits into
mainfrom
perf-return-type-get-repository-skip-nondoc
Oct 11, 2026
Merged

TomasVotruba merged 2 commits into
mainfrom
perf-return-type-get-repository-skip-nondoc

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Follow-up to the RenameClassRector phpdoc-guard optimization.

ReturnTypeFromGetRepositoryDocblockRector reads the native return type from the @return docblock, but fetched a scope and ran the getRepository return check before touching the docblock. A method without a docblock has no @return to read, so it always ends in return null.

Add a getDocComment() !== null guard right after the already-typed check and before ScopeFetcher::fetch(), so doc-less methods skip the scope fetch. Behaviour identical.

Tests green, ECS + PHPStan level 8 clean.

TomasVotruba and others added 2 commits October 11, 2026 19:23
…without a docblock

The rule reads the native return type from the @return docblock, but fetched a scope and ran the getRepository check before touching the docblock. A method without a docblock has no @return to read, so it is a no-op. Add a getDocComment() guard before the scope fetch. Behaviour unchanged.
@TomasVotruba
TomasVotruba merged commit 892d404 into main Oct 11, 2026
49 checks passed
@TomasVotruba
TomasVotruba deleted the perf-return-type-get-repository-skip-nondoc branch October 11, 2026 17:40
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.

2 participants