TomasVotruba / unused-public

Find Unused Public Elements in Your Code
https://tomasvotruba.com/blog/can-phpstan-find-dead-public-methods/
MIT License
151 stars 12 forks source link

Skip local only public method, when used from test #103

Closed staabm closed 7 months ago

staabm commented 8 months ago

Sometimes methods are declared public, just to be easy testable. from implementation side these might only be called privately.

I think we should not report such public methods, as these have valid calls from a test-case, as

Public method "%s::%s()" is used only locally and should be turned protected/private

because turning these methods private will lead to failling tests

TomasVotruba commented 7 months ago

While being useful to keep "public methods only for tests" skipped, this is a code smell. Test should never enforce source code to change. The API should be either updated or test redone to test the public API.

The goal of this package is to avoid such code smells.