Skip to main content


I couldn't find the answer myself, so I'll ask here: in #PHP, why can't I override a class method with a more specific argument?

#programming #question #help

See snippet: https://3v4l.org/nikF1

Hi, PHP language does not allow this.
I guess it’s to respect the Liskov Substitution Principle.

Someone asks the same question as you in stackoverflow :https://stackoverflow.com/a/21656325.
Answers are interresting : )
@Valentin Nivuahc Thank you so much for the answer, my Stack Overflow search skill was defeated on this occasion!
Interresting! I think this comes down to that you should be able to call the method the same way (same parameter) on all classes having the same interface (parent class declaring the method). I would blame Liskov Substitution Principle.
⇧