Design Decisions: Why use final classes

This page summarizes the projects mentioned and recommended in the original post on /r/PHP

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • Serializer

    Library for (de-)serializing data of any complexity (supports JSON, and XML) (by schmittjoh)

  • Making a class "final" is always a bad decision IMO. You would never know how will other people use your library. For example, we used JMSSerializerBundle and wanted to extend DateHandler to make it not to throw exceptions if a date string is invalid. But the class is final. So we had to just copy-paste it :(

  • bypass-finals

    Removes `final` and `readonly` keywords from source code on-the-fly and allows mocking of final methods and classes. It can be used together with any test tool such as PHPUnit or Mockery.

  • Even with the keyword final it's still possible to extend by using the final disable library https://github.com/dg/bypass-finals but the fact you needed to disable it makes it very clear that it's unsupported behaviour.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts