-
@lcobucci I know that this is 100% intentional and that you probably have many reasons why you do not want others to extend your classes 😁 But......does every class really need to be marked as This is especially painful when trying to mock these classes in my unit tests as I get the following error from PHPUnit:
Any chance you could consider removing the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
@ol1s making my classes If I leave the class open for inheritance, it becomes an extension point and people may rely on its internals do do other things. That also means that if I decide to make chances to how these classes work, it will be a BC-break. The extension points in the library are explicitly defined with interfaces and you can surely mock these interfaces. The question is, though: when should you mock them? Mocking is great until it becomes extremely painful =) |
Beta Was this translation helpful? Give feedback.
@ol1s making my classes
final
is the best way to make my design choices explicit.If I leave the class open for inheritance, it becomes an extension point and people may rely on its internals do do other things. That also means that if I decide to make chances to how these classes work, it will be a BC-break.
I don't want that to happen because it creates more work for me in the end. So, no, I won't consider removing
final
from classes.The extension points in the library are explicitly defined with interfaces and you can surely mock these interfaces. The question is, though: when should you mock them? Mocking is great until it becomes extremely painful =)