Courses

How to Structure Laravel 9 Projects

L: Liskov Substitution Principle - Type-Hint Everything

Previous: O: Open-Closed Principle - Eloquent Attribute with Salary Calculator
avatar

When you need to add a function for a class, can you just extend the interface to a new interface that adds that function and implement the new interface with the class?

avatar

Interface cannot extend other interfaces, from what I know.

avatar

The PHP manual says "Note: Interfaces can be extended like classes using the extends operator." https://www.php.net/manual/en/language.oop5.interfaces.php

Pretty cool

avatar

Hmm, sorry for misleading you. Maybe it's just me - I just haven't USED it in this way, never had practical need to make such extending.

avatar
You can use Markdown
avatar
You can use Markdown