Skip to content

[TypeDeclarationDocblocks] Deprecate AddReturnDocblockFromMethodCallDocblockRector - #8239

Merged
TomasVotruba merged 1 commit into
mainfrom
deprecate-add-return-docblock-from-method-call-docblock
Jul 31, 2026
Merged

[TypeDeclarationDocblocks] Deprecate AddReturnDocblockFromMethodCallDocblockRector#8239
TomasVotruba merged 1 commit into
mainfrom
deprecate-add-return-docblock-from-method-call-docblock

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

AddReturnDocblockFromMethodCallDocblockRector was experimental and never made it into any set - it sat commented out in TypeDeclarationDocblocksLevel behind a @todo test first note.

The rule copies the @return docblock of the called method onto the caller. That is risky: the source docblock is unverified, and if it is incorrect or outdated, the rule spreads the wrong type further into the codebase.

 final class SomeController
 {
+    /**
+     * @return SomeEntity[]
+     */
     public function getAll(): array
     {
         return $this->repository->findAll();
     }
 }

 final class Repository
 {
     /**
      * @return SomeEntity[]
      */
     public function findAll(): array
     {
         // ...
     }
 }

If Repository::findAll() docblock lies, the lie is now in two places.

Rule now implements DeprecatedInterface and throws on refactor(), same as the recently deprecated data provider docblock rules (#8235). Tests and fixtures removed.

…ocblockRector

The rule was experimental and never part of any set. It copies a @return docblock from the called method, which is risky: the source docblock can be incorrect or outdated, and the rule spreads that error further.
@TomasVotruba
TomasVotruba merged commit 362b7c5 into main Jul 31, 2026
65 checks passed
@TomasVotruba
TomasVotruba deleted the deprecate-add-return-docblock-from-method-call-docblock branch July 31, 2026 11:35
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.

1 participant