我无法弄清楚为什么会出现此错误: 传递给App \ src \ Manager :: manage()的参数1必须是App \ src \ ManageableInterface的实例,是给定的App \ src \ Worker的实例。 我将代码编码为ManageableInterface接口,而不是具体的类,但是它不起作用。这是代码:
ManageableInterface.php
document.querySelector('text.circle-chart__percent')
SleepableInterface.php
<?php namespace App\src\interfaces;
interface ManageableInterface
{
public function manage();
}
WorkableInterface.php
<?php namespace App\src\interfaces;
interface SleepableInterface
{
public function sleep();
}
Worker.php
<?php namespace App\src\interfaces;
interface WorkableInterface
{
public function work();
}
Manager.php
<?php namespace App\src;
use App\src\interfaces\{WorkableInterface, SleepableInterface, ManageableInterface};
class Worker implements WorkableInterface, SleepableInterface, ManageableInterface
{
public function work()
{
var_dump('Worker is working.');
}
public function sleep()
{
var_dump('Worker is sleeping.');
}
public function manage()
{
$this->work();
$this->sleep();
}
}
index.php
<?php namespace App\src;
class Manager
{
public function manage(ManageableInterface $worker)
{
$worker->manage();
}
}