0

Ok, check this out:

class MyParent
{
    public function myF($one, $two, $three)
    {
    }
}


class MyChild extends MyParent
{
    public function myF($one)
    {
    }
}

This throws the Strict standards: Declaration of MyChild::myF() should be compatible with MyParent::myF() - this is due to no overloading support in a weak-typed language, but the nice side effect is that it enforce LSP. No problem with that.

What puzzles me is that the following code doesn't throw the same error, even if \Exception's own __construct() takes three argument:

class MyChild extends \Exception
{
    public function __construct($first)
    {
    }
}

Why is that? why is the behavior for exception different? is this offically documented on the php.net site?

0 Answers0