Our choices to respect as much as possible the best practices, the SOLID principles, the Composition Over Inheritance approach and so on should never be affected by any issue with our test framework(s). As a developer, I should not remove a “final” statement just because “I don’t know how I will test a specific thing if I keep it”.
In this fictiv e application, we have a class User which takes as mandatory parameters an ID and a Currency.
We also decided to declare it as “final” because we don’t want to allow the rest of our application to extends it.
So if you have a lot of tests, you can also not use a PHPUnit Hook but, instead, calling the BypassFinals::enable() method in the specific tests where you need it, for instance in the setUp() method of the test class.