phpinspectionsea icon indicating copy to clipboard operation
phpinspectionsea copied to clipboard

Do not trigger "Return type hint can be used" for impl of external interfaces

Open tlamy opened this issue 5 years ago • 5 comments

In a Symfony 3.4 project with PHP7.1, i get type hint warnings for methods not under my control - in this case overridden methods or implementations of abstract methods from Symfony's Symfony\Component\Console\Command\Command

Description (screenshot): image

I really like this inspection, but it would be nice if it can be muted if the declaration is not located in one of the sources folder.

tlamy avatar Apr 29 '19 07:04 tlamy

You can specify the return type. For example, specify void for the execute method and self for the configure. Why you don't want to add return types to the implemented methods?

funivan avatar May 02 '19 04:05 funivan

You are right; quick-fix (alt-space) suggests changing the signature in the interface, which is not under my control. So either close this issue, or suggest quick-fix like in non-inherited methods ("Add return type hint")

tlamy avatar May 08 '19 06:05 tlamy

I think QF should add return type only in the concrete method, not to the interface. I cant reproduce this behavior: Alt+enter-> hitenter. Then QF specifies :void` in my method and does not touch the parent method call :thinking:

funivan avatar May 08 '19 06:05 funivan

This is what it looks here (PhpStorm 2019.1.2 Preview Build #PS-191.7141.5 Windows 10 10.0) image

tlamy avatar May 08 '19 07:05 tlamy

Looks like QF to add the type-hint should be used instead of change signature suggestion. Hence bug.

kalessil avatar May 09 '19 11:05 kalessil