Andrew Woods on Nostr: today in OOP in PHP: I have a base class Entity with a save method class foo extends ...
today in OOP in PHP:
I have a base class Entity with a save method
class foo extends Entity it redefines save() and calls parent::save() within.
Class Bar extends Foo
but I don’t like foo::save. I want to skip it entirely. So in Bar::save i try to call parent::parent::save(). This doesn’t work, but I wish it did. Instead i need to call Entity::save() the grandparent class
Is there a reason (eg performance, design) why parent::parent::save doesn’t work?
#PHP #OOP
I have a base class Entity with a save method
class foo extends Entity it redefines save() and calls parent::save() within.
Class Bar extends Foo
but I don’t like foo::save. I want to skip it entirely. So in Bar::save i try to call parent::parent::save(). This doesn’t work, but I wish it did. Instead i need to call Entity::save() the grandparent class
Is there a reason (eg performance, design) why parent::parent::save doesn’t work?
#PHP #OOP