php-language-extensions icon indicating copy to clipboard operation
php-language-extensions copied to clipboard

Allow TestTag on classes

Open doppynl opened this issue 11 months ago • 2 comments

I would like to put the TestTag attribute on a class-level. Marking the entire class as intended for use in tests only.

I sometimes write extremely simple implementations of interfaces that only exist for making writing tests that interact with the interface simpler. Instead of configuring a mock, you can just create an instance of this class with a couple of constructor arguments.

It is sometimes useful that these classes are available in the library for other code that depends on this library. So writing tests there becomes easier.

What do you think of this change? Would you accept a pull-request to adjust the attribute for this? And an additional pull-request in DaveLiddament/phpstan-php-language-extensions for the implementation?

doppynl avatar Feb 29 '24 14:02 doppynl

Yes, that change sounds like a great idea.

If you're happy to give the implementation a go then please send through a PR. Otherwise I can take a look in the next couple of weeks.

Thanks for your interest in this project.

DaveLiddament avatar Feb 29 '24 18:02 DaveLiddament

See https://github.com/DaveLiddament/php-language-extensions/pull/26. Probably best to wait with merge untill implemenation of the rules is done.

doppynl avatar Mar 01 '24 09:03 doppynl

Implemented by #26

DaveLiddament avatar Aug 12 '24 16:08 DaveLiddament