`final` classes can't be mocked

Looking at the Yii 3 session package, the class is made final, which makes it impossible to mock by phpunit. The alternative is type-hint the interface instead and make a dummy session class implementing the interface (anonymous, for example), but then you have to implement all methods in the interface. This is by design, or? Just the price to pay by using the final keyword? Kinda makes the mock functionality of phpunit useless. :frowning:

Not being able to mock the class is a small price to pay for many more benefits like forcing composition over inheritance.

Not sure how that’s a benefit. honestly. :slight_smile: Inheritance only becomes a problem when the depth of the inheritance tree is 3+ levels, in my own experience.

This works for me in PHPUnit and Codeception.