diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index bc71b62f..00000000 --- a/.coveralls.yml +++ /dev/null @@ -1,2 +0,0 @@ -coverage_clover: clover.xml -json_path: coveralls-upload.json diff --git a/.laminas-ci.json b/.laminas-ci.json index e50b00a1..eee20cbb 100644 --- a/.laminas-ci.json +++ b/.laminas-ci.json @@ -3,6 +3,6 @@ "gd" ], "ignore_php_platform_requirements": { - "8.1": true + "8.2": true } } diff --git a/composer.json b/composer.json index 9d816c9e..67be2475 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ }, "sort-packages": true, "platform": { - "php": "7.4.99" + "php": "8.0.99" } }, "extra": { @@ -34,7 +34,7 @@ } }, "require": { - "php": "^7.4 || ~8.0.0 || ~8.1.0", + "php": "~8.0.0 || ~8.1.0 || ~8.2.0", "psr/http-factory": "^1.0", "psr/http-message": "^1.0" }, @@ -46,9 +46,9 @@ "http-interop/http-factory-tests": "^0.9.0", "laminas/laminas-coding-standard": "^2.4.0", "php-http/psr7-integration-tests": "^1.1.1", - "phpunit/phpunit": "^9.5.23", + "phpunit/phpunit": "^9.5.25", "psalm/plugin-phpunit": "^0.17.0", - "vimeo/psalm": "^4.24.0" + "vimeo/psalm": "^4.28" }, "provide": { "psr/http-factory-implementation": "1.0", diff --git a/composer.lock b/composer.lock index 93f7c085..c5dca247 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "045a64c18e2a12cc4d77ad3273984e8b", + "content-hash": "5c5528de41e8d4bdbec331be4f4d6355", "packages": [ { "name": "psr/http-factory", @@ -2036,22 +2036,27 @@ }, { "name": "psr/container", - "version": "1.1.2", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", "shasum": "" }, "require": { "php": ">=7.4.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, "autoload": { "psr-4": { "Psr\\Container\\": "src/" @@ -2078,36 +2083,36 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/1.1.2" + "source": "https://github.com/php-fig/container/tree/2.0.2" }, - "time": "2021-11-05T16:50:12+00:00" + "time": "2021-11-05T16:47:00+00:00" }, { "name": "psr/log", - "version": "1.1.4", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "3.x-dev" } }, "autoload": { "psr-4": { - "Psr\\Log\\": "Psr/Log/" + "Psr\\Log\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -2128,9 +2133,9 @@ "psr-3" ], "support": { - "source": "https://github.com/php-fig/log/tree/1.1.4" + "source": "https://github.com/php-fig/log/tree/3.0.0" }, - "time": "2021-05-03T11:20:27+00:00" + "time": "2021-07-14T16:46:02+00:00" }, { "name": "sebastian/cli-parser", @@ -3215,46 +3220,42 @@ }, { "name": "symfony/console", - "version": "v5.4.13", + "version": "v6.0.13", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "3f97f6c7b7e26848a90c0c0cfb91eeb2bb8618be" + "reference": "8f14753b865651c2aad107ef97475740a9b0730f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/3f97f6c7b7e26848a90c0c0cfb91eeb2bb8618be", - "reference": "3f97f6c7b7e26848a90c0c0cfb91eeb2bb8618be", + "url": "https://api.github.com/repos/symfony/console/zipball/8f14753b865651c2aad107ef97475740a9b0730f", + "reference": "8f14753b865651c2aad107ef97475740a9b0730f", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", + "php": ">=8.0.2", "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php73": "^1.9", - "symfony/polyfill-php80": "^1.16", "symfony/service-contracts": "^1.1|^2|^3", - "symfony/string": "^5.1|^6.0" + "symfony/string": "^5.4|^6.0" }, "conflict": { - "psr/log": ">=3", - "symfony/dependency-injection": "<4.4", - "symfony/dotenv": "<5.1", - "symfony/event-dispatcher": "<4.4", - "symfony/lock": "<4.4", - "symfony/process": "<4.4" + "symfony/dependency-injection": "<5.4", + "symfony/dotenv": "<5.4", + "symfony/event-dispatcher": "<5.4", + "symfony/lock": "<5.4", + "symfony/process": "<5.4" }, "provide": { - "psr/log-implementation": "1.0|2.0" + "psr/log-implementation": "1.0|2.0|3.0" }, "require-dev": { - "psr/log": "^1|^2", - "symfony/config": "^4.4|^5.0|^6.0", - "symfony/dependency-injection": "^4.4|^5.0|^6.0", - "symfony/event-dispatcher": "^4.4|^5.0|^6.0", - "symfony/lock": "^4.4|^5.0|^6.0", - "symfony/process": "^4.4|^5.0|^6.0", - "symfony/var-dumper": "^4.4|^5.0|^6.0" + "psr/log": "^1|^2|^3", + "symfony/config": "^5.4|^6.0", + "symfony/dependency-injection": "^5.4|^6.0", + "symfony/event-dispatcher": "^5.4|^6.0", + "symfony/lock": "^5.4|^6.0", + "symfony/process": "^5.4|^6.0", + "symfony/var-dumper": "^5.4|^6.0" }, "suggest": { "psr/log": "For using the console logger", @@ -3294,7 +3295,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.13" + "source": "https://github.com/symfony/console/tree/v6.0.13" }, "funding": [ { @@ -3310,74 +3311,7 @@ "type": "tidelift" } ], - "time": "2022-08-26T13:50:20+00:00" - }, - { - "name": "symfony/deprecation-contracts", - "version": "v2.5.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "files": [ - "function.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "A generic function and convention to trigger deprecation notices", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.2" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-01-02T09:53:40+00:00" + "time": "2022-09-03T14:23:25+00:00" }, { "name": "symfony/polyfill-ctype", @@ -3709,85 +3643,6 @@ ], "time": "2022-05-24T11:49:31+00:00" }, - { - "name": "symfony/polyfill-php73", - "version": "v1.26.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/e440d35fa0286f77fb45b79a03fedbeda9307e85", - "reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.26-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.26.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-05-24T11:49:31+00:00" - }, { "name": "symfony/polyfill-php80", "version": "v1.26.0", @@ -3873,22 +3728,21 @@ }, { "name": "symfony/service-contracts", - "version": "v2.5.2", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "4b426aac47d6427cc1a1d0f7e2ac724627f5966c" + "reference": "d78d39c1599bd1188b8e26bb341da52c3c6d8a66" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/4b426aac47d6427cc1a1d0f7e2ac724627f5966c", - "reference": "4b426aac47d6427cc1a1d0f7e2ac724627f5966c", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/d78d39c1599bd1188b8e26bb341da52c3c6d8a66", + "reference": "d78d39c1599bd1188b8e26bb341da52c3c6d8a66", "shasum": "" }, "require": { - "php": ">=7.2.5", - "psr/container": "^1.1", - "symfony/deprecation-contracts": "^2.1|^3" + "php": ">=8.0.2", + "psr/container": "^2.0" }, "conflict": { "ext-psr": "<1.1|>=2" @@ -3899,7 +3753,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "2.5-dev" + "dev-main": "3.0-dev" }, "thanks": { "name": "symfony/contracts", @@ -3936,7 +3790,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v2.5.2" + "source": "https://github.com/symfony/service-contracts/tree/v3.0.2" }, "funding": [ { @@ -3952,38 +3806,37 @@ "type": "tidelift" } ], - "time": "2022-05-30T19:17:29+00:00" + "time": "2022-05-30T19:17:58+00:00" }, { "name": "symfony/string", - "version": "v5.4.13", + "version": "v6.0.13", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "2900c668a32138a34118740de3e4d5a701801f53" + "reference": "65e99fb179e7241606377e4042cd2161f3dd1c05" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/2900c668a32138a34118740de3e4d5a701801f53", - "reference": "2900c668a32138a34118740de3e4d5a701801f53", + "url": "https://api.github.com/repos/symfony/string/zipball/65e99fb179e7241606377e4042cd2161f3dd1c05", + "reference": "65e99fb179e7241606377e4042cd2161f3dd1c05", "shasum": "" }, "require": { - "php": ">=7.2.5", + "php": ">=8.0.2", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-intl-grapheme": "~1.0", "symfony/polyfill-intl-normalizer": "~1.0", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php80": "~1.15" + "symfony/polyfill-mbstring": "~1.0" }, "conflict": { - "symfony/translation-contracts": ">=3.0" + "symfony/translation-contracts": "<2.0" }, "require-dev": { - "symfony/error-handler": "^4.4|^5.0|^6.0", - "symfony/http-client": "^4.4|^5.0|^6.0", - "symfony/translation-contracts": "^1.1|^2", - "symfony/var-exporter": "^4.4|^5.0|^6.0" + "symfony/error-handler": "^5.4|^6.0", + "symfony/http-client": "^5.4|^6.0", + "symfony/translation-contracts": "^2.0|^3.0", + "symfony/var-exporter": "^5.4|^6.0" }, "type": "library", "autoload": { @@ -4022,7 +3875,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.4.13" + "source": "https://github.com/symfony/string/tree/v6.0.13" }, "funding": [ { @@ -4038,7 +3891,7 @@ "type": "tidelift" } ], - "time": "2022-09-01T01:52:16+00:00" + "time": "2022-09-02T08:05:03+00:00" }, { "name": "theseer/tokenizer", @@ -4369,7 +4222,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^7.4 || ~8.0.0 || ~8.1.0" + "php": "~8.0.0 || ~8.1.0 || ~8.2.0" }, "platform-dev": { "ext-curl": "*", @@ -4378,7 +4231,7 @@ "ext-libxml": "*" }, "platform-overrides": { - "php": "7.4.99" + "php": "8.0.99" }, "plugin-api-version": "2.3.0" } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 949d2955..6fb6c6f4 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + null|callable @@ -314,9 +314,6 @@ gettype($port) - - SensitiveParameter - @@ -542,7 +539,7 @@ setMethods - [' THIS WILL NOT WORK '] + $resource $test diff --git a/src/Exception/InvalidForwardedHeaderNameException.php b/src/Exception/InvalidForwardedHeaderNameException.php index 219bc3ef..c010a429 100644 --- a/src/Exception/InvalidForwardedHeaderNameException.php +++ b/src/Exception/InvalidForwardedHeaderNameException.php @@ -6,7 +6,6 @@ use Laminas\Diactoros\ServerRequestFilter\FilterUsingXForwardedHeaders; -use function get_class; use function gettype; use function is_object; use function is_string; @@ -18,7 +17,7 @@ class InvalidForwardedHeaderNameException extends RuntimeException implements Ex public static function forHeader($name): self { if (! is_string($name)) { - $name = sprintf('(value of type %s)', is_object($name) ? get_class($name) : gettype($name)); + $name = sprintf('(value of type %s)', is_object($name) ? $name::class : gettype($name)); } return new self(sprintf( diff --git a/src/Exception/InvalidProxyAddressException.php b/src/Exception/InvalidProxyAddressException.php index 56cbdeb6..43fd224e 100644 --- a/src/Exception/InvalidProxyAddressException.php +++ b/src/Exception/InvalidProxyAddressException.php @@ -4,7 +4,6 @@ namespace Laminas\Diactoros\Exception; -use function get_class; use function gettype; use function is_object; use function sprintf; @@ -14,7 +13,7 @@ class InvalidProxyAddressException extends RuntimeException implements Exception /** @param mixed $proxy */ public static function forInvalidProxyArgument($proxy): self { - $type = is_object($proxy) ? get_class($proxy) : gettype($proxy); + $type = is_object($proxy) ? $proxy::class : gettype($proxy); return new self(sprintf( 'Invalid proxy of type "%s" provided;' . ' must be a valid IPv4 or IPv6 address, optionally with a subnet mask provided' diff --git a/src/HeaderSecurity.php b/src/HeaderSecurity.php index 69a25254..99ea5185 100644 --- a/src/HeaderSecurity.php +++ b/src/HeaderSecurity.php @@ -4,7 +4,6 @@ namespace Laminas\Diactoros; -use function get_class; use function gettype; use function in_array; use function is_numeric; @@ -129,7 +128,7 @@ public static function assertValid($value): void if (! is_string($value) && ! is_numeric($value)) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid header value type; must be a string or numeric; received %s', - is_object($value) ? get_class($value) : gettype($value) + is_object($value) ? $value::class : gettype($value) )); } if (! self::isValid($value)) { @@ -153,7 +152,7 @@ public static function assertValidName($name): void if (! is_string($name)) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid header name type; expected string; received %s', - is_object($name) ? get_class($name) : gettype($name) + is_object($name) ? $name::class : gettype($name) )); } if (! preg_match('/^[a-zA-Z0-9\'`#$%&*+.^_|~!-]+$/', $name)) { diff --git a/src/MessageTrait.php b/src/MessageTrait.php index 14feb58b..3945b69d 100644 --- a/src/MessageTrait.php +++ b/src/MessageTrait.php @@ -10,7 +10,6 @@ use function array_map; use function array_merge; use function array_values; -use function get_class; use function gettype; use function implode; use function is_array; @@ -361,7 +360,7 @@ private function validateProtocolVersion($version): void if (! is_string($version)) { throw new Exception\InvalidArgumentException(sprintf( 'Unsupported HTTP protocol version; must be a string, received %s', - is_object($version) ? get_class($version) : gettype($version) + is_object($version) ? $version::class : gettype($version) )); } diff --git a/src/RequestTrait.php b/src/RequestTrait.php index d23ad1ab..3194682e 100644 --- a/src/RequestTrait.php +++ b/src/RequestTrait.php @@ -9,7 +9,6 @@ use Psr\Http\Message\UriInterface; use function array_keys; -use function get_class; use function gettype; use function is_object; use function is_string; @@ -291,7 +290,7 @@ private function setMethod($method): void if (! is_string($method)) { throw new Exception\InvalidArgumentException(sprintf( 'Unsupported HTTP method; must be a string, received %s', - is_object($method) ? get_class($method) : gettype($method) + is_object($method) ? $method::class : gettype($method) )); } diff --git a/src/Response.php b/src/Response.php index 18eae1e7..0fc353d7 100644 --- a/src/Response.php +++ b/src/Response.php @@ -7,7 +7,6 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\StreamInterface; -use function get_class; use function gettype; use function is_float; use function is_numeric; @@ -178,7 +177,7 @@ private function setStatusCode($code, $reasonPhrase = ''): void if (! is_string($reasonPhrase)) { throw new Exception\InvalidArgumentException(sprintf( 'Unsupported response reason phrase; must be a string, received %s', - is_object($reasonPhrase) ? get_class($reasonPhrase) : gettype($reasonPhrase) + is_object($reasonPhrase) ? $reasonPhrase::class : gettype($reasonPhrase) )); } diff --git a/src/Response/HtmlResponse.php b/src/Response/HtmlResponse.php index 298b87c3..746f3df3 100644 --- a/src/Response/HtmlResponse.php +++ b/src/Response/HtmlResponse.php @@ -9,7 +9,6 @@ use Laminas\Diactoros\Stream; use Psr\Http\Message\StreamInterface; -use function get_class; use function gettype; use function is_object; use function is_string; @@ -61,7 +60,7 @@ private function createBody($html): StreamInterface if (! is_string($html)) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid content (%s) provided to %s', - is_object($html) ? get_class($html) : gettype($html), + is_object($html) ? $html::class : gettype($html), self::class )); } diff --git a/src/Response/RedirectResponse.php b/src/Response/RedirectResponse.php index e2ec04e2..0f42ebc9 100644 --- a/src/Response/RedirectResponse.php +++ b/src/Response/RedirectResponse.php @@ -8,7 +8,6 @@ use Laminas\Diactoros\Response; use Psr\Http\Message\UriInterface; -use function get_class; use function gettype; use function is_object; use function is_string; @@ -37,7 +36,7 @@ public function __construct($uri, int $status = 302, array $headers = []) throw new Exception\InvalidArgumentException(sprintf( 'Uri provided to %s MUST be a string or Psr\Http\Message\UriInterface instance; received "%s"', self::class, - is_object($uri) ? get_class($uri) : gettype($uri) + is_object($uri) ? $uri::class : gettype($uri) )); } diff --git a/src/Response/TextResponse.php b/src/Response/TextResponse.php index 65ee3e08..60298491 100644 --- a/src/Response/TextResponse.php +++ b/src/Response/TextResponse.php @@ -9,7 +9,6 @@ use Laminas\Diactoros\Stream; use Psr\Http\Message\StreamInterface; -use function get_class; use function gettype; use function is_object; use function is_string; @@ -61,7 +60,7 @@ private function createBody($text): StreamInterface if (! is_string($text)) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid content (%s) provided to %s', - is_object($text) ? get_class($text) : gettype($text), + is_object($text) ? $text::class : gettype($text), self::class )); } diff --git a/src/Response/XmlResponse.php b/src/Response/XmlResponse.php index f0cb0bac..8a4d4237 100644 --- a/src/Response/XmlResponse.php +++ b/src/Response/XmlResponse.php @@ -9,7 +9,6 @@ use Laminas\Diactoros\Stream; use Psr\Http\Message\StreamInterface; -use function get_class; use function gettype; use function is_object; use function is_string; @@ -63,7 +62,7 @@ private function createBody($xml): StreamInterface if (! is_string($xml)) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid content (%s) provided to %s', - is_object($xml) ? get_class($xml) : gettype($xml), + is_object($xml) ? $xml::class : gettype($xml), self::class )); } diff --git a/src/Uri.php b/src/Uri.php index 5c7cdfc8..728b06d3 100644 --- a/src/Uri.php +++ b/src/Uri.php @@ -9,7 +9,6 @@ use function array_keys; use function explode; -use function get_class; use function gettype; use function implode; use function is_float; @@ -212,7 +211,7 @@ public function withScheme($scheme): UriInterface throw new Exception\InvalidArgumentException(sprintf( '%s expects a string argument; received %s', __METHOD__, - is_object($scheme) ? get_class($scheme) : gettype($scheme) + is_object($scheme) ? $scheme::class : gettype($scheme) )); } @@ -249,14 +248,14 @@ public function withUserInfo( throw new Exception\InvalidArgumentException(sprintf( '%s expects a string user argument; received %s', __METHOD__, - is_object($user) ? get_class($user) : gettype($user) + is_object($user) ? $user::class : gettype($user) )); } if (null !== $password && ! is_string($password)) { throw new Exception\InvalidArgumentException(sprintf( '%s expects a string or null password argument; received %s', __METHOD__, - is_object($password) ? get_class($password) : gettype($password) + is_object($password) ? $password::class : gettype($password) )); } @@ -287,7 +286,7 @@ public function withHost($host): UriInterface throw new Exception\InvalidArgumentException(sprintf( '%s expects a string argument; received %s', __METHOD__, - is_object($host) ? get_class($host) : gettype($host) + is_object($host) ? $host::class : gettype($host) )); } @@ -311,7 +310,7 @@ public function withPort($port): UriInterface if (! is_numeric($port) || is_float($port)) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid port "%s" specified; must be an integer, an integer string, or null', - is_object($port) ? get_class($port) : gettype($port) + is_object($port) ? $port::class : gettype($port) )); } @@ -411,7 +410,7 @@ public function withFragment($fragment): UriInterface throw new Exception\InvalidArgumentException(sprintf( '%s expects a string argument; received %s', __METHOD__, - is_object($fragment) ? get_class($fragment) : gettype($fragment) + is_object($fragment) ? $fragment::class : gettype($fragment) )); } diff --git a/test/StreamTest.php b/test/StreamTest.php index b008b48f..2cf7bb5d 100644 --- a/test/StreamTest.php +++ b/test/StreamTest.php @@ -4,6 +4,8 @@ namespace LaminasTest\Diactoros; +use CurlHandle; +use GdImage; use InvalidArgumentException; use Laminas\Diactoros\Stream; use PHPUnit\Framework\TestCase; @@ -57,7 +59,7 @@ public function testCanInstantiateWithStreamIdentifier(): void $this->assertInstanceOf(Stream::class, $this->stream); } - public function testCanInstantiteWithStreamResource(): void + public function testCanInstantiateWithStreamResource(): void { $resource = fopen('php://memory', 'wb+'); $stream = new Stream($resource); @@ -67,7 +69,8 @@ public function testCanInstantiteWithStreamResource(): void public function testCanInstantiateWithGDResource(): void { $resource = imagecreate(1, 1); - $stream = new Stream($resource); + self::assertInstanceOf(GdImage::class, $resource); + $stream = new Stream($resource); $this->assertInstanceOf(Stream::class, $stream); } @@ -102,6 +105,7 @@ public function testPassingInvalidStreamResourceToConstructorRaisesException(): { $this->expectException(InvalidArgumentException::class); + /** @psalm-suppress InvalidArgument */ new Stream([' THIS WILL NOT WORK ']); } @@ -610,7 +614,7 @@ public function testRaisesExceptionOnConstructionForNonStreamResources(): void $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('stream'); - /** @psalm-suppress ImplicitToStringCast */ + /** @psalm-suppress ImplicitToStringCast, PossiblyInvalidArgument */ new Stream($resource); } @@ -629,11 +633,11 @@ public function testRaisesExceptionOnAttachForNonStreamResources(): void $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('stream'); - /** @psalm-suppress ImplicitToStringCast */ + /** @psalm-suppress ImplicitToStringCast, PossiblyInvalidArgument */ $stream->attach($resource); } - /** @return resource|false */ + /** @return CurlHandle|GdImage|false|resource */ public function getResourceFor67() { if (function_exists('curl_init')) {