original_string: public function dispatch(ServerRequest $request, Response $response)
      {
          if (Router::getRequest(true) !== $request) {
              Router::pushRequest($request);
          }
          $beforeEvent = $this->dispatchEvent('Dispatcher.beforeDispatch', compact('request', 'response'));
  
          $request = $beforeEvent->getData('request');
          if ($beforeEvent->getResult() instanceof Response) {
              return $beforeEvent->getResult();
          }
  
          // Use the controller built by an beforeDispatch
          // event handler if there is one.
          if ($beforeEvent->getData('controller') instanceof Controller) {
              $controller = $beforeEvent->getData('controller');
          } else {
              $controller = $this->factory->create($request, $response);
          }
  
          $response = $this->_invoke($controller);
          if ($request->getParam('return')) {
              return $response;
          }
  
          $afterEvent = $this->dispatchEvent('Dispatcher.afterDispatch', compact('request', 'response'));
  
          return $afterEvent->getData('response');
      }
code: public function dispatch(ServerRequest $request, Response $response)
      {
          if (Router::getRequest(true) !== $request) {
              Router::pushRequest($request);
          }
          $beforeEvent = $this->dispatchEvent('Dispatcher.beforeDispatch', compact('request', 'response'));
  
          $request = $beforeEvent->getData('request');
          if ($beforeEvent->getResult() instanceof Response) {
              return $beforeEvent->getResult();
          }
  
          // Use the controller built by an beforeDispatch
          // event handler if there is one.
          if ($beforeEvent->getData('controller') instanceof Controller) {
              $controller = $beforeEvent->getData('controller');
          } else {
              $controller = $this->factory->create($request, $response);
          }
  
          $response = $this->_invoke($controller);
          if ($request->getParam('return')) {
              return $response;
          }
  
          $afterEvent = $this->dispatchEvent('Dispatcher.afterDispatch', compact('request', 'response'));
  
          return $afterEvent->getData('response');
      }
code_tokens: public function dispatch ( ServerRequest $ request , Response $ response ) { if ( Router :: getRequest ( true ) !== $ request ) { Router :: pushRequest ( $ request ) ; } $ beforeEvent = $ this -> dispatchEvent ( 'Dispatcher.beforeDispatch' , compact ( 'request' , 'response' ) ) ; $ request = $ beforeEvent -> getData ( 'request' ) ; if ( $ beforeEvent -> getResult ( ) instanceof Response ) { return $ beforeEvent -> getResult ( ) ; } // Use the controller built by an beforeDispatch // event handler if there is one. if ( $ beforeEvent -> getData ( 'controller' ) instanceof Controller ) { $ controller = $ beforeEvent -> getData ( 'controller' ) ; } else { $ controller = $ this -> factory -> create ( $ request , $ response ) ; } $ response = $ this -> _invoke ( $ controller ) ; if ( $ request -> getParam ( 'return' ) ) { return $ response ; } $ afterEvent = $ this -> dispatchEvent ( 'Dispatcher.afterDispatch' , compact ( 'request' , 'response' ) ) ; return $ afterEvent -> getData ( 'response' ) ; }
docstring: Dispatches a Request & Response
  
  @param \Cake\Http\ServerRequest $request The request to dispatch.
  @param \Cake\Http\Response $response The response to dispatch.
  @return \Cake\Http\Response A modified/replaced response.
  @throws \ReflectionException
docstring_tokens: Dispatches a Request & Response