Consider the following two classes:
class A {
...
testMethod($param = null) {
...
}
}
class B extends A {
...
testMethod($additionalParam, $param = null) {
... do something with $additionalParam ...
parent::testMethod($param);
}
}
intelephense
is raising me an error, that the two methods are not compatible (they are indeed not). My script although runs fine, nonetheless.
Could someone explain to me, why would intelephense
be bothered by this design? Wouldn't this design be considered valid? If not, if I would like to extend a method in a sub class, by storing additional information, which I didn't store in the base class, how should I proceed?