diff --git a/composer.json b/composer.json index 58fdd75..f723587 100644 --- a/composer.json +++ b/composer.json @@ -45,7 +45,7 @@ "laminas/laminas-diactoros": "^3.1.0", "nyholm/psr7": "^1.8.1", "php-http/psr7-integration-tests": "^1.3.0", - "phpstan/phpstan": "^1.10", + "phpstan/phpstan": "^2.0", "phpunit/phpunit": "^9.6", "doctrine/instantiator": "^1.3.1", "squizlabs/php_codesniffer": "^3.9" diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 134d4e6..6dcdc68 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,5 +1,7 @@ parameters: - checkMissingIterableValueType: false level: max paths: - src + ignoreErrors: + - + identifier: missingType.iterableValue diff --git a/src/Response.php b/src/Response.php index 6a8435e..ab8cc21 100644 --- a/src/Response.php +++ b/src/Response.php @@ -270,7 +270,7 @@ public function withFileDownload($file, ?string $name = null, $contentType = tru ? $file->getMetadata() : stream_get_meta_data($file); - if (is_array($metaData) && isset($metaData['uri'])) { + if (is_array($metaData) && isset($metaData['uri']) && is_string($metaData['uri'])) { $uri = $metaData['uri']; if ('php://' !== substr($uri, 0, 6)) { $fileName = basename($uri); diff --git a/src/ServerRequest.php b/src/ServerRequest.php index 1ce0f2e..6baca40 100644 --- a/src/ServerRequest.php +++ b/src/ServerRequest.php @@ -40,6 +40,7 @@ class ServerRequest implements ServerRequestInterface { protected ServerRequestInterface $serverRequest; + /** @var array */ protected array $bodyParsers; /** @@ -49,7 +50,7 @@ final public function __construct(ServerRequestInterface $serverRequest) { $this->serverRequest = $serverRequest; - $this->registerMediaTypeParser('application/json', function ($input) { + $this->registerMediaTypeParser('application/json', function (string $input) { $result = json_decode($input, true); if (!is_array($result)) { @@ -59,7 +60,7 @@ final public function __construct(ServerRequestInterface $serverRequest) return $result; }); - $xmlParserCallable = function ($input) { + $xmlParserCallable = function (string $input) { $backup = self::disableXmlEntityLoader(true); $backup_errors = libxml_use_internal_errors(true); $result = simplexml_load_string($input); @@ -78,7 +79,7 @@ final public function __construct(ServerRequestInterface $serverRequest) $this->registerMediaTypeParser('application/xml', $xmlParserCallable); $this->registerMediaTypeParser('text/xml', $xmlParserCallable); - $this->registerMediaTypeParser('application/x-www-form-urlencoded', function ($input) { + $this->registerMediaTypeParser('application/x-www-form-urlencoded', function (string $input) { parse_str($input, $data); return $data; }); @@ -214,7 +215,7 @@ public function getQueryParams(): array { $queryParams = $this->serverRequest->getQueryParams(); - if (is_array($queryParams) && !empty($queryParams)) { + if (!empty($queryParams)) { return $queryParams; }