Conversation
| $foo1 = $this->bar1(); | ||
|
|
||
| /** @var Bar $foo2 */ | ||
| $foo2 = $this->bar2(); |
There was a problem hiding this comment.
@ondrejmirtes after using more and more @phpstan I now trust it much more than developers annotations: now I'm scared that in the future this kind of redundant annotation (::bar2 already returns Bar) will hide bugs if the related API change.
Is such a rule, NoRedundantInlineAnnotationsRule, feasable?
There was a problem hiding this comment.
Hi, first of all, make sure to run PHPStan with conf/bleedingEdge.neon (include it in phpstan.neon), it contains some additional rules around @var.
But the main problem is that you need to consider these things:
@varis sometimes used for more precise casting - I get object and I know it'sFoo.@varis sometimes used for fixing wrong 3rd party phpDoc - I getstringand I know it'sint. This point makes any type verification impossible.- Sometimes
@varis used because PHPStan understands the type, but IDE doesn't.
These points make any general rule impossible. But some more proprietary variant is possible to implement, very easily. I'd recommend you to look how those bleeding edge rules are implemented in 0.11.9 (https://github.com/phpstan/phpstan/releases/tag/0.11.9) - commits are linked in the release notes.
No description provided.