---
title: "Final Classes: Open for Extension, Closed for Inheritance"
url: https://daily.dev/posts/final-classes-open-for-extension-closed-for-inheritance-kl8gt9ahg
source_url: https://verraes.net/2014/05/final-classes-in-php
type: article
source: "Mathias Verraes"
published: 2026-06-17T11:25:40.125Z
updated: 2026-06-17T11:29:12.244Z
tags: ["general-programming", "php", "design-patterns"]
reading_time: 4
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Final Classes: Open for Extension, Closed for Inheritance

**[Mathias Verraes](https://daily.dev/sources/verraes)** · 4 min read · 0 upvotes · 0 comments

## Summary

Making classes final by default enforces the Open/Closed Principle more precisely — 'open for extension' does not mean 'open for inheritance'. Composition, strategies, callbacks, and event listeners are preferred extension mechanisms. Final classes reduce coupling, clarify intent, and give developers freedom to refactor internals without breaking external code. In PHP, where mocking final classes is a limitation, @final annotations offer a softer alternative. The core argument: starting open makes it hard to close later, while starting closed makes it trivial to open when genuinely needed.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://verraes.net/2014/05/final-classes-in-php>

## Similar posts on daily.dev

- [The Open-Closed Principle](https://daily.dev/posts/the-open-closed-principle-kyj1lquzw) · Ruby Flow · 0 upvotes · 0 comments
- [Software Design Principles That Matter](https://daily.dev/posts/software-design-principles-that-matter-9m18waeqk) · The Polymathic Engineer · 125 upvotes · 4 comments

---

Tags: [#general-programming](https://daily.dev/tags/general-programming), [#php](https://daily.dev/tags/php), [#design-patterns](https://daily.dev/tags/design-patterns)

[View this post on daily.dev](https://daily.dev/posts/final-classes-open-for-extension-closed-for-inheritance-kl8gt9ahg)
