diff --git a/.travis.yml b/.travis.yml index 32d71d3..01cfd22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ script: - if [[ "$TRAVIS_PHP_VERSION" == '7.0' ]]; then mkdir -p build/logs && phpunit --coverage-clover build/logs/clover.xml ; fi - if [[ "$TRAVIS_PHP_VERSION" != '7.0' ]]; then vendor/bin/phpunit ; fi - if [[ "$TRAVIS_PHP_VERSION" == '7.0' ]]; then vendor/bin/phpcs ; fi + - vendor/bin/phpstan analyse -l 3 src/ after_script: - if [[ "$TRAVIS_PHP_VERSION" == '7.0' ]]; then php vendor/bin/coveralls -v ; fi diff --git a/composer.json b/composer.json index b1c83e3..bd88413 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,8 @@ "require-dev": { "squizlabs/php_codesniffer": "^2.5", "phpunit/phpunit": "^6.0|^7.0", - "php-http/psr7-integration-tests": "dev-master" + "php-http/psr7-integration-tests": "dev-master", + "phpstan/phpstan": "^0.9" }, "provide": { "psr/http-message-implementation": "1.0" diff --git a/src/Cookies.php b/src/Cookies.php index a1c01df..2dfbad7 100644 --- a/src/Cookies.php +++ b/src/Cookies.php @@ -156,7 +156,7 @@ protected function toHeader($name, array $properties) * Parse HTTP request `Cookie:` header and extract * into a PHP associative array. * - * @param string $header The raw HTTP request `Cookie:` header + * @param string|string[] $header The raw HTTP request `Cookie:` header * * @return array Associative array of cookie names and values * diff --git a/src/Request.php b/src/Request.php index f6ff5f7..9144fe3 100644 --- a/src/Request.php +++ b/src/Request.php @@ -74,14 +74,14 @@ class Request extends Message implements ServerRequestInterface /** * The request attributes (route segment names and values) * - * @var \Slim\Collection + * @var Collection */ protected $attributes; /** * The request body parsed (if possible) into a PHP array or object * - * @var null|array|object + * @var null|array|object|false */ protected $bodyParsed = false; @@ -263,13 +263,13 @@ public function withMethod($method) * Validate the HTTP method * * @param null|string $method - * @return null|string + * @return string * @throws \InvalidArgumentException on invalid HTTP method. */ protected function filterMethod($method) { if ($method === null) { - return $method; + return ''; } if (!is_string($method)) { @@ -1051,7 +1051,7 @@ public function registerMediaTypeParser($mediaType, callable $callable) if ($callable instanceof Closure) { $callable = $callable->bindTo($this); } - $this->bodyParsers[(string)$mediaType] = $callable; + $this->bodyParsers[$mediaType] = $callable; } /******************************************************************************* diff --git a/src/Stream.php b/src/Stream.php index 5be9c96..f49d176 100644 --- a/src/Stream.php +++ b/src/Stream.php @@ -40,35 +40,35 @@ class Stream implements StreamInterface /** * The underlying stream resource * - * @var resource + * @var resource|null */ protected $stream; /** * Stream metadata * - * @var array + * @var array|null */ protected $meta; /** * Is this stream readable? * - * @var bool + * @var bool|null */ protected $readable; /** * Is this stream writable? * - * @var bool + * @var bool|null */ protected $writable; /** * Is this stream seekable? * - * @var bool + * @var bool|null */ protected $seekable; @@ -82,7 +82,7 @@ class Stream implements StreamInterface /** * Is this stream a pipe? * - * @var bool + * @var bool|null */ protected $isPipe; diff --git a/src/Uri.php b/src/Uri.php index 6712a5a..40ee88c 100644 --- a/src/Uri.php +++ b/src/Uri.php @@ -275,7 +275,7 @@ protected function filterScheme($scheme) throw new InvalidArgumentException('Uri scheme must be a string'); } - $scheme = str_replace('://', '', strtolower((string)$scheme)); + $scheme = str_replace('://', '', strtolower($scheme)); if (!isset($valid[$scheme])) { throw new InvalidArgumentException('Uri scheme must be one of: "", "https", "http"'); } @@ -656,7 +656,7 @@ public function withQuery($query) if (!is_string($query) && !method_exists($query, '__toString')) { throw new InvalidArgumentException('Uri query must be a string'); } - $query = ltrim((string)$query, '?'); + $query = ltrim($query, '?'); $clone = clone $this; $clone->query = $this->filterQuery($query); @@ -724,7 +724,7 @@ public function withFragment($fragment) if (!is_string($fragment) && !method_exists($fragment, '__toString')) { throw new InvalidArgumentException('Uri fragment must be a string'); } - $fragment = ltrim((string)$fragment, '#'); + $fragment = ltrim($fragment, '#'); $clone = clone $this; $clone->fragment = $this->filterQuery($fragment);