diff --git a/src/Dispatching/DispatchStack.php b/src/Dispatching/DispatchStack.php index 76cdc01..17ae0e2 100644 --- a/src/Dispatching/DispatchStack.php +++ b/src/Dispatching/DispatchStack.php @@ -26,7 +26,7 @@ class DispatchStack implements DispatchStackInterface * Push a new middleware onto the stack. * * @param mixed $middleware Middleware to dispatch in sequence - * @return self + * @return static */ public function add($middleware) { diff --git a/src/Message/Message.php b/src/Message/Message.php index 8d88645..0bdd913 100644 --- a/src/Message/Message.php +++ b/src/Message/Message.php @@ -101,7 +101,7 @@ abstract class Message implements MessageInterface * While header names are not case-sensitive, getHeaders() will preserve the * exact case in which headers were originally specified. * - * @return array Returns an associative array of the message's headers. + * @return string[][] Returns an associative array of the message's headers. */ public function getHeaders() { diff --git a/src/Message/NullStream.php b/src/Message/NullStream.php index bfbc3de..468ad36 100644 --- a/src/Message/NullStream.php +++ b/src/Message/NullStream.php @@ -51,9 +51,10 @@ class NullStream implements StreamInterface } /** - * Returns 0 + * Returns the current position of the file read/write pointer * - * @return int|bool Position of the file pointer or false on error. + * @return int Position of the file pointer + * @throws \RuntimeException on error. */ public function tell() { diff --git a/src/Message/Request.php b/src/Message/Request.php index 114c9f3..2a95ae6 100644 --- a/src/Message/Request.php +++ b/src/Message/Request.php @@ -212,7 +212,7 @@ class Request extends Message implements RequestInterface /** * @param string $method - * @return static + * @return string * @throws \InvalidArgumentException */ private function getValidatedMethod($method) diff --git a/src/Message/Stream.php b/src/Message/Stream.php index 54ba4e6..a37df74 100644 --- a/src/Message/Stream.php +++ b/src/Message/Stream.php @@ -67,7 +67,9 @@ class Stream implements StreamInterface */ public function close() { - fclose($this->resource); + $resource = $this->resource; + fclose($resource); + $this->resource = null; } /** @@ -79,9 +81,9 @@ class Stream implements StreamInterface */ public function detach() { - $stream = $this->resource; + $resource = $this->resource; $this->resource = null; - return $stream; + return $resource; } /** diff --git a/src/Routing/Router.php b/src/Routing/Router.php index d18d337..4ac8164 100644 --- a/src/Routing/Router.php +++ b/src/Routing/Router.php @@ -203,7 +203,7 @@ class Router } /** - * @param DispatcherInterface + * @param DispatcherInterface $dispatcher * @return RouteFactoryInterface */ protected function getRouteFactory($dispatcher) @@ -266,21 +266,21 @@ class Router } ); - if ($matches) { - if (count($matches) > 0) { - // If there are multiple matches, sort them to find the one with - // the longest string length. - $compareByLength = function ($a, $b) { - return strlen($b) - strlen($a); - }; - usort($matches, $compareByLength); - } - /** @var string $bestMatch */ - $bestMatch = $matches[0]; - $route = $this->prefixRoutes[$bestMatch]; - return $route; + if (!$matches) { + return null; } - return null; + + // If there are multiple matches, sort them to find the one with the + // longest string length. + if (count($matches) > 1) { + $compareByLength = function ($a, $b) { + return strlen($b) - strlen($a); + }; + usort($matches, $compareByLength); + } + + $bestMatch = $matches[0]; + return $this->prefixRoutes[$bestMatch]; } private function startsWith($haystack, $needle)