Why Nostr? What is Njump?
2024-08-31 00:38:06

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
Author Public Key
npub168zhw4ady2ey6c4qx4lnskunreqzqulzq28n4q2zuz2td0udr3hsezznhn