Just wondering why we have a E_STRICT/E_WARNING warning here:
class Node
{
public static function create($parent = null)
{
// ...
}
}
class NamedNode extends Node
{
public static function create($name, $parent = null)
{
// ...
}
}
As you can see in http://3v4l.org/n1s38, we have an E_STRICT (PHP < 7) or an E_WARNING (PHP ≥ 7). I really can't see any reason for this...
Furthermore, if we make the $name
argument optional (http://3v4l.org/V1WHC), no warning is thrown...
And that confuses me even more: if the method signatures must be the same (and as I said above I wonder why), why no warning is thrown?
EDIT: this is not a duplicate of Why is overriding method parameters a violation of strict standards in PHP? since here we are talking about static methods. I do think that non-static methods must have the same signature (since we'll work with instances in that case), but static methods are very different: we call the method statically, so we do know the class that get's called (eg Node::create()
or NamedNode::create()
).