dispatch() публичный Метод

$controller can be one of three types but based on the type you can infer what the controller actually is: - string (controller is a named function) - array (controller is a class method [0 => ClassName, 1 => MethodName]) - \Closure (controller is an anonymous function)
public dispatch ( string | array | Closure $controller, array $vars ) : mixed
$controller string | array | Closure
$vars array - named wildcard segments of the matched route
Результат mixed
Пример #1
0
 public function testDispatchWithClassAndMethodAndResponseObject()
 {
     $this->setRequestParameters('phprest-test', 1, '*/*');
     $result = $this->strategy->dispatch('Phprest\\Stub\\Controller\\Simple::getSampleResponse', []);
     $this->assertInstanceOf('Phprest\\HttpFoundation\\Response', $result);
     if ($result instanceof \Phprest\HttpFoundation\Response) {
         $this->assertEquals(json_encode('sample'), $result->getContent());
     }
 }