Как переопределить типа данных и избежать ошибки "Declaration of should be compatible with" в CarFactory?
class Factory
{
public $objects = [];
public function addObject(Object $object)
{
$this->objects[] = $object;
}
public function build()
{
/** do something */
}
}
class Car
{
public $name;
public $model;
public $color;
public function __construct($name,$model, $color)
{
$this->name = $name;
$this->model = $model;
$this->color = $color;
}
}
class CarFactory extends Factory
{
public function addObject(Car $object)
{
/** do something */
}
}