$instance = new class ($this->createMock(YourInterface::class)) extends \Exception implements YourInterface {
private $mock;
public function __construct(YourInterface $mock, $message = "", $code = 0, Throwable $previous = null) {
parent::__construct($message, $code, $previous);
$this->mock = $mock;
}
public function interfaceMethod($parameter)
{
return $this->mock->interfaceMethod($parameter);
}
}; Controller (FooService будет заинжектен в него, тут все как обычно)__invoke у полученного объекта, передав туда все нужные параметрыBarService будет вытащен из контейнераid возьмется из переданных параметров$response = $invoker->call(/**/)setLogger, во-вторых, передать туда какие-то свои параметры, которые пришли из реквеста. class Controller
{
public function __construct(FooService $fooService)
{
}
public function __invoke(BarService $barService, $id)
{
}
}
$invoker->call('Controller::__invoke', [
'id' => 'id',
]);FooService, но не BarService $invoker = new Invoker\Invoker(null, $container);
$callable = $route_info[1];
$vars = $route_info[2];
$response = $invoker->call($callable, $vars);
\Throwable