From 47e4384cb18a2ddd7a88bf09cf4630091ec1b8e1 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Mon, 30 Dec 2019 15:00:07 +0100 Subject: [PATCH 1/9] Add composer normalize --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b5b2cdd..c161768 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "ext-zlib": "*", "akeneo/phpspec-skip-example-extension": "^1.0", "coduo/phpspec-data-provider-extension": "^1.0", - "ergebnis/composer-normalize": "^2.1.1", + "ergebnis/composer-normalize": "^2.1", "guzzlehttp/psr7": "^1.0", "henrikbjorn/phpspec-code-coverage": "^1.0", "phpspec/phpspec": "^2.4", From 9a23e29ada1eca7485a5ff042d07f1d0202f960d Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Mon, 30 Dec 2019 15:03:40 +0100 Subject: [PATCH 2/9] Improve php cs fixer --- .gitattributes | 6 ++---- .gitignore | 3 ++- .php_cs | 13 ------------- .php_cs.dist | 17 +++++++++++++++++ 4 files changed, 21 insertions(+), 18 deletions(-) delete mode 100644 .php_cs create mode 100644 .php_cs.dist diff --git a/.gitattributes b/.gitattributes index c47225a..254f94a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,13 +1,11 @@ -.editorconfig export-ignore +.editorconfig export-ignore .gitattributes export-ignore /.github/ export-ignore .gitignore export-ignore -/.php_cs export-ignore +/.php_cs.dist export-ignore /.scrutinizer.yml export-ignore /.styleci.yml export-ignore /.travis.yml export-ignore -/behat.yml.dist export-ignore -/features/ export-ignore /phpspec.ci.yml export-ignore /phpspec.yml.dist export-ignore /phpunit.xml.dist export-ignore diff --git a/.gitignore b/.gitignore index 16b4a20..1029e28 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -/behat.yml +.php_cs +.php_cs.cache /build/ /composer.lock /phpspec.yml diff --git a/.php_cs b/.php_cs deleted file mode 100644 index 23ba165..0000000 --- a/.php_cs +++ /dev/null @@ -1,13 +0,0 @@ -setRiskyAllowed(true) + ->setRules([ + '@Symfony' => true, + 'array_syntax' => ['syntax' => 'short'], + 'single_line_throw' => false, + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->in(__DIR__.'/src') + ->name('*.php') + ) +; + +return $config; From a8538848b98ffe07f32a0e315129a482ce99d935 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Mon, 30 Dec 2019 15:03:58 +0100 Subject: [PATCH 3/9] Run php cs fixer --- src/Authentication/Matching.php | 7 +------ src/Authentication/QueryParam.php | 3 --- src/Authentication/RequestConditional.php | 4 ---- src/Builder/ResponseBuilder.php | 20 +++++++++---------- src/Cookie.php | 10 ++++------ src/CookieJar.php | 10 ---------- src/CookieUtil.php | 2 +- src/Decorator/RequestDecorator.php | 2 -- src/Decorator/ResponseDecorator.php | 2 -- src/Encoding/CompressStream.php | 3 +-- src/Encoding/DecompressStream.php | 3 +-- src/Encoding/DeflateStream.php | 3 +-- src/Encoding/FilteredStream.php | 5 ++--- src/Encoding/GzipDecodeStream.php | 3 +-- src/Encoding/GzipEncodeStream.php | 3 +-- src/Encoding/InflateStream.php | 3 +-- src/Formatter.php | 4 ---- src/Formatter/CurlCommandFormatter.php | 2 -- src/Formatter/FullHttpMessageFormatter.php | 3 +-- .../DiactorosMessageFactory.php | 2 +- src/MessageFactory/SlimMessageFactory.php | 4 ++-- src/RequestMatcher/CallbackRequestMatcher.php | 3 --- 22 files changed, 27 insertions(+), 74 deletions(-) diff --git a/src/Authentication/Matching.php b/src/Authentication/Matching.php index 4b89b50..7a5c247 100644 --- a/src/Authentication/Matching.php +++ b/src/Authentication/Matching.php @@ -27,10 +27,6 @@ final class Matching implements Authentication */ private $matcher; - /** - * @param Authentication $authentication - * @param callable|null $matcher - */ public function __construct(Authentication $authentication, callable $matcher = null) { if (is_null($matcher)) { @@ -58,8 +54,7 @@ public function authenticate(RequestInterface $request) /** * Creates a matching authentication for an URL. * - * @param Authentication $authentication - * @param string $url + * @param string $url * * @return self */ diff --git a/src/Authentication/QueryParam.php b/src/Authentication/QueryParam.php index 650cac7..7f95d44 100644 --- a/src/Authentication/QueryParam.php +++ b/src/Authentication/QueryParam.php @@ -20,9 +20,6 @@ final class QueryParam implements Authentication */ private $params = []; - /** - * @param array $params - */ public function __construct(array $params) { $this->params = $params; diff --git a/src/Authentication/RequestConditional.php b/src/Authentication/RequestConditional.php index 5477440..01062cf 100644 --- a/src/Authentication/RequestConditional.php +++ b/src/Authentication/RequestConditional.php @@ -23,10 +23,6 @@ final class RequestConditional implements Authentication */ private $authentication; - /** - * @param RequestMatcher $requestMatcher - * @param Authentication $authentication - */ public function __construct(RequestMatcher $requestMatcher, Authentication $authentication) { $this->requestMatcher = $requestMatcher; diff --git a/src/Builder/ResponseBuilder.php b/src/Builder/ResponseBuilder.php index de2e882..4c3ecfc 100644 --- a/src/Builder/ResponseBuilder.php +++ b/src/Builder/ResponseBuilder.php @@ -18,8 +18,6 @@ class ResponseBuilder /** * Create builder for the given response. - * - * @param ResponseInterface $response */ public function __construct(ResponseInterface $response) { @@ -39,12 +37,12 @@ public function getResponse() /** * Add headers represented by an array of header lines. * - * @param string[] $headers Response headers as array of header lines. + * @param string[] $headers response headers as array of header lines * * @return $this * - * @throws \UnexpectedValueException For invalid header values. - * @throws \InvalidArgumentException For invalid status code arguments. + * @throws \UnexpectedValueException for invalid header values + * @throws \InvalidArgumentException for invalid status code arguments */ public function setHeadersFromArray(array $headers) { @@ -66,12 +64,12 @@ public function setHeadersFromArray(array $headers) /** * Add headers represented by a single string. * - * @param string $headers Response headers as single string. + * @param string $headers response headers as single string * * @return $this * * @throws \InvalidArgumentException if $headers is not a string on object with __toString() - * @throws \UnexpectedValueException For invalid header values. + * @throws \UnexpectedValueException for invalid header values */ public function setHeadersFromString($headers) { @@ -95,11 +93,11 @@ public function setHeadersFromString($headers) /** * Set response status from a status string. * - * @param string $statusLine Response status as a string. + * @param string $statusLine response status as a string * * @return $this * - * @throws \InvalidArgumentException For invalid status line. + * @throws \InvalidArgumentException for invalid status line */ public function setStatus($statusLine) { @@ -121,11 +119,11 @@ public function setStatus($statusLine) /** * Add header represented by a string. * - * @param string $headerLine Response header as a string. + * @param string $headerLine response header as a string * * @return $this * - * @throws \InvalidArgumentException For invalid header names or values. + * @throws \InvalidArgumentException for invalid header names or values */ public function addHeader($headerLine) { diff --git a/src/Cookie.php b/src/Cookie.php index 98ac57c..0cc2d43 100644 --- a/src/Cookie.php +++ b/src/Cookie.php @@ -63,7 +63,7 @@ final class Cookie * @param bool $httpOnly * @param \DateTime|null $expires Expires attribute is HTTP 1.0 only and should be avoided. * - * @throws \InvalidArgumentException If name, value or max age is not valid. + * @throws \InvalidArgumentException if name, value or max age is not valid */ public function __construct( $name, @@ -226,8 +226,6 @@ public function hasExpires() /** * Sets the expires. * - * @param \DateTime|null $expires - * * @return Cookie */ public function withExpires(\DateTime $expires = null) @@ -435,7 +433,7 @@ public function isValid() * * @param string $name * - * @throws \InvalidArgumentException If the name is empty or contains invalid characters. + * @throws \InvalidArgumentException if the name is empty or contains invalid characters */ private function validateName($name) { @@ -456,7 +454,7 @@ private function validateName($name) * * @param string|null $value * - * @throws \InvalidArgumentException If the value contains invalid characters. + * @throws \InvalidArgumentException if the value contains invalid characters */ private function validateValue($value) { @@ -472,7 +470,7 @@ private function validateValue($value) * * @param int|null $maxAge * - * @throws \InvalidArgumentException If the Max-Age is not an empty or integer value. + * @throws \InvalidArgumentException if the Max-Age is not an empty or integer value */ private function validateMaxAge($maxAge) { diff --git a/src/CookieJar.php b/src/CookieJar.php index ab267d3..6d60ec2 100644 --- a/src/CookieJar.php +++ b/src/CookieJar.php @@ -22,8 +22,6 @@ public function __construct() /** * Checks if there is a cookie. * - * @param Cookie $cookie - * * @return bool */ public function hasCookie(Cookie $cookie) @@ -33,8 +31,6 @@ public function hasCookie(Cookie $cookie) /** * Adds a cookie. - * - * @param Cookie $cookie */ public function addCookie(Cookie $cookie) { @@ -57,8 +53,6 @@ public function addCookie(Cookie $cookie) /** * Removes a cookie. - * - * @param Cookie $cookie */ public function removeCookie(Cookie $cookie) { @@ -82,8 +76,6 @@ public function getCookies() /** * Returns all matching cookies. * - * @param Cookie $cookie - * * @return Cookie[] */ public function getMatchingCookies(Cookie $cookie) @@ -98,8 +90,6 @@ public function getMatchingCookies(Cookie $cookie) /** * Finds matching cookies based on a callable. * - * @param callable $match - * * @return Cookie[] */ protected function findMatchingCookies(callable $match) diff --git a/src/CookieUtil.php b/src/CookieUtil.php index 5c670d4..44c5314 100644 --- a/src/CookieUtil.php +++ b/src/CookieUtil.php @@ -30,7 +30,7 @@ final class CookieUtil * * @return \DateTime * - * @throws UnexpectedValueException if we cannot parse the cookie date string. + * @throws UnexpectedValueException if we cannot parse the cookie date string */ public static function parseDate($dateValue) { diff --git a/src/Decorator/RequestDecorator.php b/src/Decorator/RequestDecorator.php index 7c50e58..bd254a8 100644 --- a/src/Decorator/RequestDecorator.php +++ b/src/Decorator/RequestDecorator.php @@ -17,8 +17,6 @@ trait RequestDecorator /** * Exchanges the underlying request with another. * - * @param RequestInterface $request - * * @return self */ public function withRequest(RequestInterface $request) diff --git a/src/Decorator/ResponseDecorator.php b/src/Decorator/ResponseDecorator.php index 82d9ae0..20319ed 100644 --- a/src/Decorator/ResponseDecorator.php +++ b/src/Decorator/ResponseDecorator.php @@ -16,8 +16,6 @@ trait ResponseDecorator /** * Exchanges the underlying response with another. * - * @param ResponseInterface $response - * * @return self */ public function withResponse(ResponseInterface $response) diff --git a/src/Encoding/CompressStream.php b/src/Encoding/CompressStream.php index eeec6e0..bdb740a 100644 --- a/src/Encoding/CompressStream.php +++ b/src/Encoding/CompressStream.php @@ -13,8 +13,7 @@ class CompressStream extends FilteredStream { /** - * @param StreamInterface $stream - * @param int $level + * @param int $level */ public function __construct(StreamInterface $stream, $level = -1) { diff --git a/src/Encoding/DecompressStream.php b/src/Encoding/DecompressStream.php index 9a950ea..ab3a345 100644 --- a/src/Encoding/DecompressStream.php +++ b/src/Encoding/DecompressStream.php @@ -13,8 +13,7 @@ class DecompressStream extends FilteredStream { /** - * @param StreamInterface $stream - * @param int $level + * @param int $level */ public function __construct(StreamInterface $stream, $level = -1) { diff --git a/src/Encoding/DeflateStream.php b/src/Encoding/DeflateStream.php index f7ce8e2..2ab3e00 100644 --- a/src/Encoding/DeflateStream.php +++ b/src/Encoding/DeflateStream.php @@ -13,8 +13,7 @@ class DeflateStream extends FilteredStream { /** - * @param StreamInterface $stream - * @param int $level + * @param int $level */ public function __construct(StreamInterface $stream, $level = -1) { diff --git a/src/Encoding/FilteredStream.php b/src/Encoding/FilteredStream.php index 7e5713e..65f40de 100644 --- a/src/Encoding/FilteredStream.php +++ b/src/Encoding/FilteredStream.php @@ -54,9 +54,8 @@ abstract class FilteredStream implements StreamInterface protected $buffer = ''; /** - * @param StreamInterface $stream - * @param mixed|null $readFilterOptions - * @param mixed|null $writeFilterOptions deprecated since 1.5, will be removed in 2.0 + * @param mixed|null $readFilterOptions + * @param mixed|null $writeFilterOptions deprecated since 1.5, will be removed in 2.0 */ public function __construct(StreamInterface $stream, $readFilterOptions = null, $writeFilterOptions = null) { diff --git a/src/Encoding/GzipDecodeStream.php b/src/Encoding/GzipDecodeStream.php index 19a2b8f..92b5dad 100644 --- a/src/Encoding/GzipDecodeStream.php +++ b/src/Encoding/GzipDecodeStream.php @@ -13,8 +13,7 @@ class GzipDecodeStream extends FilteredStream { /** - * @param StreamInterface $stream - * @param int $level + * @param int $level */ public function __construct(StreamInterface $stream, $level = -1) { diff --git a/src/Encoding/GzipEncodeStream.php b/src/Encoding/GzipEncodeStream.php index 8555d4a..13f097a 100644 --- a/src/Encoding/GzipEncodeStream.php +++ b/src/Encoding/GzipEncodeStream.php @@ -13,8 +13,7 @@ class GzipEncodeStream extends FilteredStream { /** - * @param StreamInterface $stream - * @param int $level + * @param int $level */ public function __construct(StreamInterface $stream, $level = -1) { diff --git a/src/Encoding/InflateStream.php b/src/Encoding/InflateStream.php index 863b73d..06c5187 100644 --- a/src/Encoding/InflateStream.php +++ b/src/Encoding/InflateStream.php @@ -13,8 +13,7 @@ class InflateStream extends FilteredStream { /** - * @param StreamInterface $stream - * @param int $level + * @param int $level */ public function __construct(StreamInterface $stream, $level = -1) { diff --git a/src/Formatter.php b/src/Formatter.php index d04d2c3..d6cd21b 100644 --- a/src/Formatter.php +++ b/src/Formatter.php @@ -15,8 +15,6 @@ interface Formatter /** * Formats a request. * - * @param RequestInterface $request - * * @return string */ public function formatRequest(RequestInterface $request); @@ -24,8 +22,6 @@ public function formatRequest(RequestInterface $request); /** * Formats a response. * - * @param ResponseInterface $response - * * @return string */ public function formatResponse(ResponseInterface $response); diff --git a/src/Formatter/CurlCommandFormatter.php b/src/Formatter/CurlCommandFormatter.php index 2ddb149..6554fc1 100644 --- a/src/Formatter/CurlCommandFormatter.php +++ b/src/Formatter/CurlCommandFormatter.php @@ -68,8 +68,6 @@ public function formatResponse(ResponseInterface $response) } /** - * @param RequestInterface $request - * * @return string */ private function getHeadersAsCommandOptions(RequestInterface $request) diff --git a/src/Formatter/FullHttpMessageFormatter.php b/src/Formatter/FullHttpMessageFormatter.php index d065f0e..0495802 100644 --- a/src/Formatter/FullHttpMessageFormatter.php +++ b/src/Formatter/FullHttpMessageFormatter.php @@ -70,8 +70,7 @@ public function formatResponse(ResponseInterface $response) /** * Add the message body if the stream is seekable. * - * @param MessageInterface $request - * @param string $message + * @param string $message * * @return string */ diff --git a/src/MessageFactory/DiactorosMessageFactory.php b/src/MessageFactory/DiactorosMessageFactory.php index 10a49f2..94b9ad2 100644 --- a/src/MessageFactory/DiactorosMessageFactory.php +++ b/src/MessageFactory/DiactorosMessageFactory.php @@ -2,8 +2,8 @@ namespace Http\Message\MessageFactory; -use Http\Message\StreamFactory\DiactorosStreamFactory; use Http\Message\MessageFactory; +use Http\Message\StreamFactory\DiactorosStreamFactory; use Zend\Diactoros\Request; use Zend\Diactoros\Response; diff --git a/src/MessageFactory/SlimMessageFactory.php b/src/MessageFactory/SlimMessageFactory.php index 869cf77..bee9322 100644 --- a/src/MessageFactory/SlimMessageFactory.php +++ b/src/MessageFactory/SlimMessageFactory.php @@ -2,12 +2,12 @@ namespace Http\Message\MessageFactory; +use Http\Message\MessageFactory; use Http\Message\StreamFactory\SlimStreamFactory; use Http\Message\UriFactory\SlimUriFactory; -use Http\Message\MessageFactory; +use Slim\Http\Headers; use Slim\Http\Request; use Slim\Http\Response; -use Slim\Http\Headers; /** * Creates Slim 3 messages. diff --git a/src/RequestMatcher/CallbackRequestMatcher.php b/src/RequestMatcher/CallbackRequestMatcher.php index 4d45e32..1197dd9 100644 --- a/src/RequestMatcher/CallbackRequestMatcher.php +++ b/src/RequestMatcher/CallbackRequestMatcher.php @@ -17,9 +17,6 @@ final class CallbackRequestMatcher implements RequestMatcher */ private $callback; - /** - * @param callable $callback - */ public function __construct(callable $callback) { $this->callback = $callback; From 03ea4f1b73cd33aade62dd722bfb3ee6505f83af Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Mon, 30 Dec 2019 15:06:27 +0100 Subject: [PATCH 4/9] Add phpstan config --- .gitattributes | 28 ++-- .gitignore | 1 + phpstan-baseline.neon | 337 ++++++++++++++++++++++++++++++++++++++++++ phpstan.neon.dist | 7 + 4 files changed, 360 insertions(+), 13 deletions(-) create mode 100644 phpstan-baseline.neon create mode 100644 phpstan.neon.dist diff --git a/.gitattributes b/.gitattributes index 254f94a..60aab89 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,13 +1,15 @@ -.editorconfig export-ignore -.gitattributes export-ignore -/.github/ export-ignore -.gitignore export-ignore -/.php_cs.dist export-ignore -/.scrutinizer.yml export-ignore -/.styleci.yml export-ignore -/.travis.yml export-ignore -/phpspec.ci.yml export-ignore -/phpspec.yml.dist export-ignore -/phpunit.xml.dist export-ignore -/spec/ export-ignore -/tests/ export-ignore +.editorconfig export-ignore +.gitattributes export-ignore +/.github/ export-ignore +.gitignore export-ignore +/.php_cs.dist export-ignore +/.scrutinizer.yml export-ignore +/.styleci.yml export-ignore +/.travis.yml export-ignore +/phpspec.ci.yml export-ignore +/phpspec.yml.dist export-ignore +/phpstan-baseline.neon export-ignore +/phpstan.neon.dist export-ignore +/phpunit.xml.dist export-ignore +/spec/ export-ignore +/tests/ export-ignore diff --git a/.gitignore b/.gitignore index 1029e28..9771070 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ /build/ /composer.lock /phpspec.yml +/phpstan.neon /phpunit.xml /vendor/ diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..c5e0ce2 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,337 @@ +parameters: + ignoreErrors: + - + message: "#^Property Http\\\\Message\\\\Authentication\\\\Header\\:\\:\\$value type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/Authentication/Header.php + + - + message: "#^Method Http\\\\Message\\\\Authentication\\\\Header\\:\\:__construct\\(\\) has parameter \\$value with no typehint specified\\.$#" + count: 1 + path: src/Authentication/Header.php + + - + message: "#^Property Http\\\\Message\\\\Authentication\\\\QueryParam\\:\\:\\$params type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/Authentication/QueryParam.php + + - + message: "#^Method Http\\\\Message\\\\Authentication\\\\QueryParam\\:\\:__construct\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#" + count: 1 + path: src/Authentication/QueryParam.php + + - + message: "#^Parameter \\#2 \\$prefix of function http_build_query expects string, null given\\.$#" + count: 1 + path: src/Authentication/QueryParam.php + + - + message: "#^Parameter \\#1 \\$statusLine of method Http\\\\Message\\\\Builder\\\\ResponseBuilder\\:\\:setStatus\\(\\) expects string, string\\|null given\\.$#" + count: 1 + path: src/Builder/ResponseBuilder.php + + - + message: "#^Result of \\|\\| is always true\\.$#" + count: 1 + path: src/Builder/ResponseBuilder.php + + - + message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#" + count: 1 + path: src/Builder/ResponseBuilder.php + + - + message: "#^Method Http\\\\Message\\\\Cookie\\:\\:createWithoutValidation\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/Cookie.php + + - + message: "#^Parameter \\#2 \\$str2 of function strcasecmp expects string, string\\|null given\\.$#" + count: 1 + path: src/Cookie.php + + - + message: "#^Parameter \\#1 \\$str of function preg_quote expects string, string\\|null given\\.$#" + count: 1 + path: src/Cookie.php + + - + message: "#^Method Http\\\\Message\\\\Cookie\\:\\:validateName\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/Cookie.php + + - + message: "#^Method Http\\\\Message\\\\Cookie\\:\\:validateValue\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/Cookie.php + + - + message: "#^Method Http\\\\Message\\\\Cookie\\:\\:validateMaxAge\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/Cookie.php + + - + message: "#^Method Http\\\\Message\\\\Cookie\\:\\:normalizeDomain\\(\\) should return string but returns string\\|null\\.$#" + count: 1 + path: src/Cookie.php + + - + message: "#^Parameter \\#1 \\$str of function rtrim expects string, string\\|null given\\.$#" + count: 1 + path: src/Cookie.php + + - + message: "#^Class Http\\\\Message\\\\CookieJar implements generic interface IteratorAggregate but does not specify its types\\: TKey, TValue$#" + count: 1 + path: src/CookieJar.php + + - + message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:addCookie\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/CookieJar.php + + - + message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:removeCookie\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/CookieJar.php + + - + message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:findMatchingCookies\\(\\) should return array\\ but returns array\\\\.$#" + count: 1 + path: src/CookieJar.php + + - + message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:setCookies\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/CookieJar.php + + - + message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:addCookies\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/CookieJar.php + + - + message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:removeCookies\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/CookieJar.php + + - + message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:removeMatchingCookies\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/CookieJar.php + + - + message: "#^Left side of && is always true\\.$#" + count: 1 + path: src/CookieJar.php + + - + message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:clear\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/CookieJar.php + + - + message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:count\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/CookieJar.php + + - + message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:getIterator\\(\\) return type has no value type specified in iterable type Traversable\\\\.$#" + count: 1 + path: src/CookieJar.php + + - + message: "#^Property Http\\\\Message\\\\CookieUtil\\:\\:\\$dateFormats type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/CookieUtil.php + + - + message: "#^Method Http\\\\Message\\\\Encoding\\\\FilteredStream\\:\\:getSize\\(\\) has no return typehint specified\\.$#" + count: 2 + path: src/Encoding/FilteredStream.php + + - + message: "#^Method Http\\\\Message\\\\Encoding\\\\FilteredStream\\:\\:isSeekable\\(\\) has no return typehint specified\\.$#" + count: 2 + path: src/Encoding/FilteredStream.php + + - + message: "#^Method Http\\\\Message\\\\Encoding\\\\FilteredStream\\:\\:seek\\(\\) has no return typehint specified\\.$#" + count: 2 + path: src/Encoding/FilteredStream.php + + - + message: "#^Method Http\\\\Message\\\\Encoding\\\\FilteredStream\\:\\:rewind\\(\\) has no return typehint specified\\.$#" + count: 2 + path: src/Encoding/FilteredStream.php + + - + message: "#^Method Http\\\\Message\\\\Encoding\\\\FilteredStream\\:\\:fill\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/Encoding/FilteredStream.php + + - + message: "#^Method Http\\\\Message\\\\Encoding\\\\ChunkStream\\:\\:fill\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/Encoding/ChunkStream.php + + - + message: "#^Method Http\\\\Message\\\\Encoding\\\\Filter\\\\Chunk\\:\\:filter\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/Encoding/Filter/Chunk.php + + - + message: "#^Method Http\\\\Message\\\\Encoding\\\\Filter\\\\Chunk\\:\\:filter\\(\\) has parameter \\$closing with no typehint specified\\.$#" + count: 1 + path: src/Encoding/Filter/Chunk.php + + - + message: "#^Method Http\\\\Message\\\\Encoding\\\\Filter\\\\Chunk\\:\\:filter\\(\\) has parameter \\$consumed with no typehint specified\\.$#" + count: 1 + path: src/Encoding/Filter/Chunk.php + + - + message: "#^Method Http\\\\Message\\\\Encoding\\\\Filter\\\\Chunk\\:\\:filter\\(\\) has parameter \\$in with no typehint specified\\.$#" + count: 1 + path: src/Encoding/Filter/Chunk.php + + - + message: "#^Method Http\\\\Message\\\\Encoding\\\\Filter\\\\Chunk\\:\\:filter\\(\\) has parameter \\$out with no typehint specified\\.$#" + count: 1 + path: src/Encoding/Filter/Chunk.php + + - + message: "#^Access to an undefined property Http\\\\Message\\\\Encoding\\\\Filter\\\\Chunk\\:\\:\\$stream\\.$#" + count: 2 + path: src/Encoding/Filter/Chunk.php + + - + message: "#^Access to an undefined property object\\:\\:\\$datalen\\.$#" + count: 2 + path: src/Encoding/Filter/Chunk.php + + - + message: "#^Parameter \\#2 \\$bucket of function stream_bucket_append expects object, resource given\\.$#" + count: 2 + path: src/Encoding/Filter/Chunk.php + + - + message: "#^Unreachable statement \\- code above always terminates\\.$#" + count: 1 + path: src/Encoding/Filter/Chunk.php + + - + message: "#^Method Http\\\\Message\\\\MessageFactory\\\\DiactorosMessageFactory\\:\\:createRequest\\(\\) has parameter \\$headers with no value type specified in iterable type array\\.$#" + count: 1 + path: src/MessageFactory/DiactorosMessageFactory.php + + - + message: "#^Method Http\\\\Message\\\\MessageFactory\\\\DiactorosMessageFactory\\:\\:createResponse\\(\\) has parameter \\$headers with no value type specified in iterable type array\\.$#" + count: 1 + path: src/MessageFactory/DiactorosMessageFactory.php + + - + message: "#^Method Http\\\\Message\\\\MessageFactory\\\\GuzzleMessageFactory\\:\\:createRequest\\(\\) has parameter \\$headers with no value type specified in iterable type array\\.$#" + count: 1 + path: src/MessageFactory/GuzzleMessageFactory.php + + - + message: "#^Method Http\\\\Message\\\\MessageFactory\\\\GuzzleMessageFactory\\:\\:createResponse\\(\\) has parameter \\$headers with no value type specified in iterable type array\\.$#" + count: 1 + path: src/MessageFactory/GuzzleMessageFactory.php + + - + message: "#^Method Http\\\\Message\\\\MessageFactory\\\\SlimMessageFactory\\:\\:createRequest\\(\\) has parameter \\$headers with no value type specified in iterable type array\\.$#" + count: 1 + path: src/MessageFactory/SlimMessageFactory.php + + - + message: "#^Method Http\\\\Message\\\\MessageFactory\\\\SlimMessageFactory\\:\\:createResponse\\(\\) has parameter \\$headers with no value type specified in iterable type array\\.$#" + count: 1 + path: src/MessageFactory/SlimMessageFactory.php + + - + message: "#^Property Http\\\\Message\\\\RequestMatcher\\\\RequestMatcher\\:\\:\\$methods type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/RequestMatcher/RequestMatcher.php + + - + message: "#^Property Http\\\\Message\\\\RequestMatcher\\\\RequestMatcher\\:\\:\\$path \\(string\\) does not accept string\\|null\\.$#" + count: 1 + path: src/RequestMatcher/RequestMatcher.php + + - + message: "#^Property Http\\\\Message\\\\RequestMatcher\\\\RequestMatcher\\:\\:\\$host \\(string\\) does not accept string\\|null\\.$#" + count: 1 + path: src/RequestMatcher/RequestMatcher.php + + - + message: "#^Property Http\\\\Message\\\\Stream\\\\BufferedStream\\:\\:\\$size \\(int\\) does not accept int\\|null\\.$#" + count: 1 + path: src/Stream/BufferedStream.php + + - + message: "#^Property Http\\\\Message\\\\Stream\\\\BufferedStream\\:\\:\\$resource \\(resource\\) does not accept resource\\|false\\.$#" + count: 2 + path: src/Stream/BufferedStream.php + + - + message: "#^Dead catch \\- Exception is already caught by Throwable above\\.$#" + count: 1 + path: src/Stream/BufferedStream.php + + - + message: "#^Method Http\\\\Message\\\\Stream\\\\BufferedStream\\:\\:detach\\(\\) should return resource\\|null but empty return statement found\\.$#" + count: 1 + path: src/Stream/BufferedStream.php + + - + message: "#^Property Http\\\\Message\\\\Stream\\\\BufferedStream\\:\\:\\$stream \\(Psr\\\\Http\\\\Message\\\\StreamInterface\\) does not accept null\\.$#" + count: 1 + path: src/Stream/BufferedStream.php + + - + message: "#^Property Http\\\\Message\\\\Stream\\\\BufferedStream\\:\\:\\$resource \\(resource\\) does not accept null\\.$#" + count: 1 + path: src/Stream/BufferedStream.php + + - + message: "#^Method Http\\\\Message\\\\Stream\\\\BufferedStream\\:\\:getSize\\(\\) should return int\\|null but empty return statement found\\.$#" + count: 1 + path: src/Stream/BufferedStream.php + + - + message: "#^Method Http\\\\Message\\\\Stream\\\\BufferedStream\\:\\:tell\\(\\) should return int but returns int\\|false\\.$#" + count: 1 + path: src/Stream/BufferedStream.php + + - + message: "#^Method Http\\\\Message\\\\Stream\\\\BufferedStream\\:\\:seek\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/Stream/BufferedStream.php + + - + message: "#^Method Http\\\\Message\\\\Stream\\\\BufferedStream\\:\\:rewind\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/Stream/BufferedStream.php + + - + message: "#^Parameter \\#1 \\$string of function strlen expects string, string\\|false given\\.$#" + count: 1 + path: src/Stream/BufferedStream.php + + - + message: "#^Method Http\\\\Message\\\\Stream\\\\BufferedStream\\:\\:read\\(\\) should return string but returns string\\|false\\.$#" + count: 1 + path: src/Stream/BufferedStream.php + + - + message: "#^Parameter \\#1 \\$stream of class Slim\\\\Http\\\\Stream constructor expects resource, resource\\|false given\\.$#" + count: 1 + path: src/StreamFactory/SlimStreamFactory.php + + - + message: "#^Unreachable statement \\- code above always terminates\\.$#" + count: 1 + path: src/UriFactory/SlimUriFactory.php + diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..6f8227f --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,7 @@ +includes: + - phpstan-baseline.neon + +parameters: + level: max + paths: + - src From 1fd5c2c78755b340bf8cd87c145b0a230aab1759 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Mon, 30 Dec 2019 15:06:49 +0100 Subject: [PATCH 5/9] Add github actions --- .github/workflows/.editorconfig | 2 ++ .github/workflows/checks.yml | 37 +++++++++++++++++++++ .github/workflows/ci.yml | 59 +++++++++++++++++++++++++++++++++ .github/workflows/static.yml | 34 +++++++++++++++++++ 4 files changed, 132 insertions(+) create mode 100644 .github/workflows/.editorconfig create mode 100644 .github/workflows/checks.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/static.yml diff --git a/.github/workflows/.editorconfig b/.github/workflows/.editorconfig new file mode 100644 index 0000000..7bd3346 --- /dev/null +++ b/.github/workflows/.editorconfig @@ -0,0 +1,2 @@ +[*.yml] +indent_size = 2 diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..48ffa14 --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,37 @@ +name: Checks + +on: + push: + branches: + - master + pull_request: + +jobs: + composer-normalize: + name: Composer Normalize + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v1 + + - name: Install + uses: docker://composer + with: + args: install + + - name: Normalize + uses: docker://composer + with: + args: composer normalize --dry-run + + roave-bc-check: + name: Roave BC Check + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v1 + + - name: Roave BC Check + uses: docker://nyholm/roave-bc-check-ga diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c2070ac --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,59 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + +jobs: + build-lowest-version: + name: Build lowest version + runs-on: ubuntu-latest + + steps: + - name: Set up PHP + uses: shivammathur/setup-php@1.6.2 + with: + php-version: '7.1' + coverage: xdebug + extensions: mbstring + + - name: Setup Problem Matchers for PHPUnit + run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: Checkout code + uses: actions/checkout@v1 + + - name: Download dependencies + run: composer update --prefer-stable --prefer-dist --no-interaction --no-progress --no-suggest --prefer-lowest + + - name: Run tests + run: composer test-ci + + build: + name: Build + runs-on: ubuntu-latest + strategy: + max-parallel: 10 + matrix: + php: ['7.1', '7.2', '7.3', '7.4'] + + steps: + - name: Set up PHP + uses: shivammathur/setup-php@1.6.2 + with: + php-version: ${{ matrix.php }} + extensions: mbstring + + - name: Setup Problem Matchers for PHPUnit + run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: Checkout code + uses: actions/checkout@v1 + + - name: Download dependencies + run: composer update --prefer-stable --prefer-dist --no-interaction --no-progress --no-suggest + + - name: Run tests + run: composer test diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml new file mode 100644 index 0000000..9d15468 --- /dev/null +++ b/.github/workflows/static.yml @@ -0,0 +1,34 @@ +name: Static analysis + +on: + push: + branches: + - master + pull_request: + +jobs: + phpstan: + name: PHPStan + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v1 + + - name: PHPStan + uses: docker://oskarstark/phpstan-ga + with: + args: analyze --no-progress + + php-cs-fixer: + name: PHP-CS-Fixer + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v1 + + - name: PHP-CS-Fixer + uses: docker://oskarstark/php-cs-fixer-ga + with: + args: --dry-run --diff-format udiff From cfa22caae5dbbd4f1cb524aa74140fb4ebc884a1 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Mon, 30 Dec 2019 15:20:47 +0100 Subject: [PATCH 6/9] Remove license badge --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index d55a823..5facafc 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # HTTP Message [![Latest Version](https://img.shields.io/github/release/php-http/message.svg?style=flat-square)](https://github.com/php-http/message/releases) -[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) [![Build Status](https://img.shields.io/travis/php-http/message.svg?style=flat-square)](https://travis-ci.org/php-http/message) [![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/php-http/message.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/message) [![Quality Score](https://img.shields.io/scrutinizer/g/php-http/message.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/message) From cca684f13eaf586200fe15ac241dec3c4ac780f0 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Mon, 30 Dec 2019 15:23:22 +0100 Subject: [PATCH 7/9] Drop travis --- .gitattributes | 1 - .travis.yml | 36 ------------------------------------ README.md | 2 +- 3 files changed, 1 insertion(+), 38 deletions(-) delete mode 100644 .travis.yml diff --git a/.gitattributes b/.gitattributes index 60aab89..4007b2d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,7 +5,6 @@ /.php_cs.dist export-ignore /.scrutinizer.yml export-ignore /.styleci.yml export-ignore -/.travis.yml export-ignore /phpspec.ci.yml export-ignore /phpspec.yml.dist export-ignore /phpstan-baseline.neon export-ignore diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8095e84..0000000 --- a/.travis.yml +++ /dev/null @@ -1,36 +0,0 @@ -language: php - -cache: - directories: - - $HOME/.composer/cache/files - -php: - - 7.1 - - 7.2 - - 7.3 - - 7.4 - -env: - global: - - TEST_COMMAND="composer test" - -matrix: - fast_finish: true - include: - - php: 7.1 - env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" COVERAGE=true TEST_COMMAND="composer test-ci" - -before_install: - - if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi - -install: - - composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction - -script: - - composer validate - - composer normalize --dry-run - - $TEST_COMMAND - -after_success: - - if [[ $COVERAGE = true ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi - - if [[ $COVERAGE = true ]]; then php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml; fi diff --git a/README.md b/README.md index 5facafc..dbdc80c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # HTTP Message [![Latest Version](https://img.shields.io/github/release/php-http/message.svg?style=flat-square)](https://github.com/php-http/message/releases) -[![Build Status](https://img.shields.io/travis/php-http/message.svg?style=flat-square)](https://travis-ci.org/php-http/message) +![GitHub Workflow Status](https://img.shields.io/github/workflow/status/php-http/message/CI?style=flat-square) [![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/php-http/message.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/message) [![Quality Score](https://img.shields.io/scrutinizer/g/php-http/message.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/message) [![Total Downloads](https://img.shields.io/packagist/dt/php-http/message.svg?style=flat-square)](https://packagist.org/packages/php-http/message) From 257e65cd0fcacc21c49f403c5823a20f48b138dd Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Mon, 30 Dec 2019 15:34:09 +0100 Subject: [PATCH 8/9] Drop styleci --- .gitattributes | 1 - .styleci.yml | 14 -------------- 2 files changed, 15 deletions(-) delete mode 100644 .styleci.yml diff --git a/.gitattributes b/.gitattributes index 4007b2d..2efe1cd 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,7 +4,6 @@ .gitignore export-ignore /.php_cs.dist export-ignore /.scrutinizer.yml export-ignore -/.styleci.yml export-ignore /phpspec.ci.yml export-ignore /phpspec.yml.dist export-ignore /phpstan-baseline.neon export-ignore diff --git a/.styleci.yml b/.styleci.yml deleted file mode 100644 index 5328b61..0000000 --- a/.styleci.yml +++ /dev/null @@ -1,14 +0,0 @@ -preset: symfony - -finder: - exclude: - - "spec" - path: - - "src" - - "tests" - -enabled: - - short_array_syntax - -disabled: - - phpdoc_annotation_without_dot # This is still buggy: https://github.com/symfony/symfony/pull/19198 From 209c48611dde8c65ec911b745347b315bfd83a84 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Mon, 30 Dec 2019 15:36:07 +0100 Subject: [PATCH 9/9] Drop scrutinizer --- .gitattributes | 1 - .scrutinizer.yml | 8 -------- README.md | 2 -- 3 files changed, 11 deletions(-) delete mode 100644 .scrutinizer.yml diff --git a/.gitattributes b/.gitattributes index 2efe1cd..0a004a9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,7 +3,6 @@ /.github/ export-ignore .gitignore export-ignore /.php_cs.dist export-ignore -/.scrutinizer.yml export-ignore /phpspec.ci.yml export-ignore /phpspec.yml.dist export-ignore /phpstan-baseline.neon export-ignore diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index 46a7560..0000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,8 +0,0 @@ -filter: - paths: [src/*] -checks: - php: - code_rating: true - duplication: true -tools: - external_code_coverage: true diff --git a/README.md b/README.md index dbdc80c..52abe2b 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,6 @@ [![Latest Version](https://img.shields.io/github/release/php-http/message.svg?style=flat-square)](https://github.com/php-http/message/releases) ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/php-http/message/CI?style=flat-square) -[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/php-http/message.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/message) -[![Quality Score](https://img.shields.io/scrutinizer/g/php-http/message.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/message) [![Total Downloads](https://img.shields.io/packagist/dt/php-http/message.svg?style=flat-square)](https://packagist.org/packages/php-http/message) **HTTP Message related tools.**