original_string: public function addRoute(string $method, string $uri, RequestHandler $requestHandler, Middleware ...$middlewares) {
          if ($this->running) {
              throw new \Error(
                  "Cannot add routes once the server has started"
              );
          }
  
          if ($method === "") {
              throw new \Error(
                  __METHOD__ . "() requires a non-empty string HTTP method at Argument 1"
              );
          }
  
          if ($requestHandler instanceof ServerObserver) {
              $this->observers->attach($requestHandler);
          }
  
          if (!empty($middlewares)) {
              foreach ($middlewares as $middleware) {
                  if ($middleware instanceof ServerObserver) {
                      $this->observers->attach($middleware);
                  }
              }
  
              $requestHandler = Middleware\stack($requestHandler, ...$middlewares);
          }
  
          $this->routes[] = [$method, \ltrim($uri, "/"), $requestHandler];
      }
code: public function addRoute(string $method, string $uri, RequestHandler $requestHandler, Middleware ...$middlewares) {
          if ($this->running) {
              throw new \Error(
                  "Cannot add routes once the server has started"
              );
          }
  
          if ($method === "") {
              throw new \Error(
                  __METHOD__ . "() requires a non-empty string HTTP method at Argument 1"
              );
          }
  
          if ($requestHandler instanceof ServerObserver) {
              $this->observers->attach($requestHandler);
          }
  
          if (!empty($middlewares)) {
              foreach ($middlewares as $middleware) {
                  if ($middleware instanceof ServerObserver) {
                      $this->observers->attach($middleware);
                  }
              }
  
              $requestHandler = Middleware\stack($requestHandler, ...$middlewares);
          }
  
          $this->routes[] = [$method, \ltrim($uri, "/"), $requestHandler];
      }
code_tokens: public function addRoute ( string $ method , string $ uri , RequestHandler $ requestHandler , Middleware ... $ middlewares ) { if ( $ this -> running ) { throw new \ Error ( "Cannot add routes once the server has started" ) ; } if ( $ method === "" ) { throw new \ Error ( __METHOD__ . "() requires a non-empty string HTTP method at Argument 1" ) ; } if ( $ requestHandler instanceof ServerObserver ) { $ this -> observers -> attach ( $ requestHandler ) ; } if ( ! empty ( $ middlewares ) ) { foreach ( $ middlewares as $ middleware ) { if ( $ middleware instanceof ServerObserver ) { $ this -> observers -> attach ( $ middleware ) ; } } $ requestHandler = Middleware \ stack ( $ requestHandler , ... $ middlewares ) ; } $ this -> routes [ ] = [ $ method , \ ltrim ( $ uri , "/" ) , $ requestHandler ] ; }
docstring: Define an application route.
  
  Matched URI route arguments are made available to request handlers as a request attribute
  which may be accessed with:
  
  $request->getAttribute(Router::class)
  
  Route URIs ending in "/?" (without the quotes) allow a URI match with or without
  the trailing slash. Temporary redirects are used to redirect to the canonical URI
  (with a trailing slash) to avoid search engine duplicate content penalties.
  
  @param string    $method The HTTP method verb for which this route applies.
  @param string    $uri The string URI.
  @param RequestHandler $requestHandler Request handler invoked on a route match.
  @param Middleware[] ...$middlewares
  
  @throws \Error If the server has started, or if $method is empty.
docstring_tokens: Define an application route .