3.16. final Classes

Similar to final methods, you can also define a class as final. Doing so disallows inheriting from this class. The following code does not work:

final class MyBaseClass {
    ...
}

class MyConcreteClass extends MyBaseClass {
    ...
}

MyBaseClass has been declared as final; MyConcreteClass may not extend it and, therefore, execution of the script fails.

Get PHP 5 Power Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.