Fix issues detected by Psalm
This commit is contained in:
parent
2cf65def5c
commit
08ddb0aa2f
|
|
@ -26,7 +26,7 @@ class DispatchStack implements DispatchStackInterface
|
||||||
* Push a new middleware onto the stack.
|
* Push a new middleware onto the stack.
|
||||||
*
|
*
|
||||||
* @param mixed $middleware Middleware to dispatch in sequence
|
* @param mixed $middleware Middleware to dispatch in sequence
|
||||||
* @return self
|
* @return static
|
||||||
*/
|
*/
|
||||||
public function add($middleware)
|
public function add($middleware)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ abstract class Message implements MessageInterface
|
||||||
* While header names are not case-sensitive, getHeaders() will preserve the
|
* While header names are not case-sensitive, getHeaders() will preserve the
|
||||||
* exact case in which headers were originally specified.
|
* 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()
|
public function getHeaders()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -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()
|
public function tell()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -212,7 +212,7 @@ class Request extends Message implements RequestInterface
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $method
|
* @param string $method
|
||||||
* @return static
|
* @return string
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
private function getValidatedMethod($method)
|
private function getValidatedMethod($method)
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,9 @@ class Stream implements StreamInterface
|
||||||
*/
|
*/
|
||||||
public function close()
|
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()
|
public function detach()
|
||||||
{
|
{
|
||||||
$stream = $this->resource;
|
$resource = $this->resource;
|
||||||
$this->resource = null;
|
$this->resource = null;
|
||||||
return $stream;
|
return $resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -203,7 +203,7 @@ class Router
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param DispatcherInterface
|
* @param DispatcherInterface $dispatcher
|
||||||
* @return RouteFactoryInterface
|
* @return RouteFactoryInterface
|
||||||
*/
|
*/
|
||||||
protected function getRouteFactory($dispatcher)
|
protected function getRouteFactory($dispatcher)
|
||||||
|
|
@ -266,21 +266,21 @@ class Router
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($matches) {
|
if (!$matches) {
|
||||||
if (count($matches) > 0) {
|
return null;
|
||||||
// If there are multiple matches, sort them to find the one with
|
}
|
||||||
// the longest string length.
|
|
||||||
|
// If there are multiple matches, sort them to find the one with the
|
||||||
|
// longest string length.
|
||||||
|
if (count($matches) > 1) {
|
||||||
$compareByLength = function ($a, $b) {
|
$compareByLength = function ($a, $b) {
|
||||||
return strlen($b) - strlen($a);
|
return strlen($b) - strlen($a);
|
||||||
};
|
};
|
||||||
usort($matches, $compareByLength);
|
usort($matches, $compareByLength);
|
||||||
}
|
}
|
||||||
/** @var string $bestMatch */
|
|
||||||
$bestMatch = $matches[0];
|
$bestMatch = $matches[0];
|
||||||
$route = $this->prefixRoutes[$bestMatch];
|
return $this->prefixRoutes[$bestMatch];
|
||||||
return $route;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function startsWith($haystack, $needle)
|
private function startsWith($haystack, $needle)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue