I am refactoring a PHP OOP legacy website.
I am so tempted to start using 'final' on classes to "
make it explicit that the class is currently not extended by anything". This might save lots of time if I come to a class and I am wondering if I can rename/delete/modify a
protected property or method. If I really want to extend a class I can just remove the final keyword to unlock it for extending.
I.e If I come to a class that has no child classes I can record that knowledge by marking the class a final. The next time I come to it I would not have to re-search the codebase to see if it has children. Thus saving time during refactorings.
It all seems like a sensible time saving idea.... but I have often read that classes should only be made 'final' on rare/special occasions.
Maybe it screws up Mock object creation or has other side effects that I am not thinking of.
What am I missing?