rector-src icon indicating copy to clipboard operation
rector-src copied to clipboard

Add failing test fixture for ReturnTypeDeclarationRector

Open rodion-k opened this issue 3 years ago • 7 comments

Failing Test for ReturnTypeDeclarationRector

Based on https://getrector.org/demo/a97ca4ba-526f-4d02-8e5c-c13cc7a82171

rodion-k avatar Aug 25 '22 17:08 rodion-k

That's won't work since you define @template T at different class, even on phpstan.org demo

https://phpstan.org/r/01f63b30-cd96-4f8a-b1e7-7afb8550e13a

For @return TypedResponse<string>, iirc, that's seems not supported yet.

samsonasik avatar Aug 26 '22 01:08 samsonasik

Hi @samsonasik, thanks for the reply. For example, in this case, there is a generic type in the return type hint (in this case string). This makes me think that Rector knows the generic type, but ignores it in the first case.

rodion-k avatar Aug 26 '22 13:08 rodion-k

Here is the case where you can see that phpstan knows the exact type. https://phpstan.org/r/0efd6b5f-cb60-41f5-8254-62628915f41d

rodion-k avatar Aug 26 '22 14:08 rodion-k

ReturnTypeDeclarationRector purpose is to not add @return docblock, so the @return won't be added, different new rule for it may be needed.

samsonasik avatar Aug 29 '22 10:08 samsonasik

ReturnTypeDeclarationRector purpose is to not add @return docblock, so the @return won't be added, different new rule for it may be needed.

But in this case, @return docblock is added. What is the difference?

rodion-k avatar Aug 29 '22 16:08 rodion-k

That's by AddArrayReturnDocTypeRector see the Applied Rules part.

samsonasik avatar Aug 29 '22 16:08 samsonasik

I see, I will try to implement the new rule using the AddArrayReturnDocTypeRector example.

rodion-k avatar Aug 29 '22 17:08 rodion-k

Closing for lack of feedback last 3 months. Feel free to resend the test and fix to right location :+1:

TomasVotruba avatar Nov 18 '22 21:11 TomasVotruba