r/PHPhelp • • Apr 07 '25

phpstan rule for trait method usage

I want to apply a rule that if a class uses a trait it also has to use some marked methods that are defined in that trait. Does anybody know/has a rule I could use?

Or any other qa tool extension for phpmd, phpcpd, phpcsfixer,psalm... Anything that I could use for a pre merge hook in gitlab.

A PhpStorm qa rule plugin would be my plan c.

TIA!

2 Upvotes

6 comments sorted by

View all comments

Show parent comment

1

u/Jutboy Apr 08 '25

That doesn't really answer many of my questions but I THINK you should be able to use one of these to do what you are trying to do

https://www.php.net/manual/en/function.class-uses.php

https://www.php.net/manual/en/function.property-exists.php