Final classes, you either love them or hate them. Developers have been discussing composition over inheritance for years, and final classes are a perfect use case.

Before final classes, we would extend the Money class and use it as I need to.

class MoneyImplementation { private Money $money; public function __construct( int|string $amount, Currency $currency, ) { $this->money = new Money( amount: $amount, currency: $currency, ); }}

The next problem is how do we call class methods on the money class without extending the API we want to call.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners