website/errors/parameter.missing.md
<?php declare(strict_types = 1);
class Base
{
public function doFoo(string $name, int $age): void
{
}
}
class Child extends Base
{
public function doFoo(string $name): void
{
}
}
An overriding method is missing a parameter that exists in the parent method. When a child class overrides a method, it must accept at least the same parameters as the parent method. Removing a parameter from an overriding method violates the Liskov Substitution Principle -- code that calls the parent method with all its parameters would break when given an instance of the child class.
Add the missing parameter to the overriding method:
class Child extends Base
{
- public function doFoo(string $name): void
+ public function doFoo(string $name, int $age): void
{
}
}