Elektrine lite

← Feed

@dseguy@phpc.social

Post #3506000

2026-07-01 07:16 UTC

@gmazzap@phpc.social Indeed, good answer. And my framing of the question was vague enough, so it applies here. There is no way to forbid a class (anonymous or not) to extend an abstract class (can't be final, right?) so this is a classic and useful trick (think tests). Now, I was considering reaching A::foo() from C. That happens when the class hierarchies grows a bit too much.

Replies (1)

  • @gmazzap@phpc.social 2026-07-01 08:21

    @dseguy@phpc.social It's all about knowledge and coupling. For `C` to call `A`, it needs to know `A` well enough to decide it _really_ wants to call that particular ancestor behavior instead of its direct parent. This level of knowledge (coupling) is quite bad, and it's widely accepted that inheritance is bad for this, right? Honestly, the fact the language makes calling arbitrary ancestors behavior with shared state (because if the method contains `$this` it will resolve to C) it is a good thing IMO :)

    Open ##3883195