original_string: public function getResponse(\BearFramework\App\Request $request)
      {
          $requestPath = (string) $request->path;
          $requestMethod = $request->method;
          foreach ($this->data as $route) {
              foreach ($route[0] as $pattern) {
                  $matches = null;
                  preg_match('/^(?:(?:((?:[A-Z]+\|){0,}[A-Z]+) )?)(.*+)/', $pattern, $matches);
                  $patternMethods = '|' . ($matches[1] === '' ? 'GET' : $matches[1]) . '|';
                  if (strpos($patternMethods, '|' . $requestMethod . '|') === false) {
                      continue;
                  }
                  $patternPath = $matches[2];
                  if (preg_match('/^' . str_replace(['/', '?', '*'], ['\/', '[^\/]+?', '.+?'], $patternPath) . '$/u', $requestPath) === 1) {
                      foreach ($route[1] as $callable) {
                          ob_start();
                          try {
                              $response = call_user_func($callable, $request);
                              ob_end_clean();
                          } catch (\Exception $e) {
                              ob_end_clean();
                              throw $e;
                          }
                          if ($response instanceof App\Response) {
                              return $response;
                          }
                      }
                      // continue searching
                  }
              }
          }
          if ($request->method === 'HEAD') {
              $getRequest = clone($request);
              $getRequest->method = 'GET';
              $response = $this->getResponse($getRequest);
              if ($response instanceof App\Response) {
                  $response->content = '';
                  return $response;
              }
          }
          return null;
      }
code: public function getResponse(\BearFramework\App\Request $request)
      {
          $requestPath = (string) $request->path;
          $requestMethod = $request->method;
          foreach ($this->data as $route) {
              foreach ($route[0] as $pattern) {
                  $matches = null;
                  preg_match('/^(?:(?:((?:[A-Z]+\|){0,}[A-Z]+) )?)(.*+)/', $pattern, $matches);
                  $patternMethods = '|' . ($matches[1] === '' ? 'GET' : $matches[1]) . '|';
                  if (strpos($patternMethods, '|' . $requestMethod . '|') === false) {
                      continue;
                  }
                  $patternPath = $matches[2];
                  if (preg_match('/^' . str_replace(['/', '?', '*'], ['\/', '[^\/]+?', '.+?'], $patternPath) . '$/u', $requestPath) === 1) {
                      foreach ($route[1] as $callable) {
                          ob_start();
                          try {
                              $response = call_user_func($callable, $request);
                              ob_end_clean();
                          } catch (\Exception $e) {
                              ob_end_clean();
                              throw $e;
                          }
                          if ($response instanceof App\Response) {
                              return $response;
                          }
                      }
                      // continue searching
                  }
              }
          }
          if ($request->method === 'HEAD') {
              $getRequest = clone($request);
              $getRequest->method = 'GET';
              $response = $this->getResponse($getRequest);
              if ($response instanceof App\Response) {
                  $response->content = '';
                  return $response;
              }
          }
          return null;
      }
code_tokens: public function getResponse ( \ BearFramework \ App \ Request $ request ) { $ requestPath = ( string ) $ request -> path ; $ requestMethod = $ request -> method ; foreach ( $ this -> data as $ route ) { foreach ( $ route [ 0 ] as $ pattern ) { $ matches = null ; preg_match ( '/^(?:(?:((?:[A-Z]+\|){0,}[A-Z]+) )?)(.*+)/' , $ pattern , $ matches ) ; $ patternMethods = '|' . ( $ matches [ 1 ] === '' ? 'GET' : $ matches [ 1 ] ) . '|' ; if ( strpos ( $ patternMethods , '|' . $ requestMethod . '|' ) === false ) { continue ; } $ patternPath = $ matches [ 2 ] ; if ( preg_match ( '/^' . str_replace ( [ '/' , '?' , '*' ] , [ '\/' , '[^\/]+?' , '.+?' ] , $ patternPath ) . '$/u' , $ requestPath ) === 1 ) { foreach ( $ route [ 1 ] as $ callable ) { ob_start ( ) ; try { $ response = call_user_func ( $ callable , $ request ) ; ob_end_clean ( ) ; } catch ( \ Exception $ e ) { ob_end_clean ( ) ; throw $ e ; } if ( $ response instanceof App \ Response ) { return $ response ; } } // continue searching } } } if ( $ request -> method === 'HEAD' ) { $ getRequest = clone ( $ request ) ; $ getRequest -> method = 'GET' ; $ response = $ this -> getResponse ( $ getRequest ) ; if ( $ response instanceof App \ Response ) { $ response -> content = '' ; return $ response ; } } return null ; }
docstring: Finds the matching callback and returns its result.
  
  @param \BearFramework\App\Request $request The request object to match against.
  @return mixed The result of the matching callback. NULL if none.
docstring_tokens: Finds the matching callback and returns its result .