phpstan-phpunit
phpstan-phpunit copied to clipboard
Validate coverage tags point to real classes
Its easy to make typos or miss updating a covers tag during a refactor and this helps catch it earlier.
re: 1. Looking steeping back through the code my memory is being refreshed. I wasn't able to do that because FileTypeMapper(and PhpDocNodeResolver) only know about phpdoc tags and the covers tags are only part of PHPUnit. I guess we could create a phpunit specific NodeResolver though. There are quite a few annotations and there might be other things someone wants to assert. It might be kind of a rabbit hole but let me know if you want me to take that approach.
https://phpunit.readthedocs.io/en/9.5/annotations.html
I wasn't able to do that because FileTypeMapper(and PhpDocNodeResolver) only know about phpdoc tags and the covers tags are only part of PHPUnit
This is certainly possible, it's just that the @covers
tag will be represented by this node instead of something nicer: https://github.com/phpstan/phpdoc-parser/blob/master/src/Ast/PhpDoc/GenericTagValueNode.php but you can definitely work with that.
@neclimdul is this something you are interested in finishing or should i pick this up?
this was a custom rule we wrote into our previous static analysis tool that we lost since adopting phpstan and would love to see it completed
@mad-briller still interested but might be a while before I can finish it so if you've got some time to bring it home that would be awesome.
Superseded by https://github.com/phpstan/phpstan-phpunit/pull/137