diff --git a/composer.json b/composer.json index 9b64f2fb..f15cd1ea 100644 --- a/composer.json +++ b/composer.json @@ -46,9 +46,9 @@ "http-interop/http-factory-tests": "^0.9.0", "laminas/laminas-coding-standard": "~2.5.0", "php-http/psr7-integration-tests": "^1.3", - "phpunit/phpunit": "^9.5.28", + "phpunit/phpunit": "^9.6.16", "psalm/plugin-phpunit": "^0.18.4", - "vimeo/psalm": "^5.17" + "vimeo/psalm": "^5.22.1" }, "provide": { "psr/http-factory-implementation": "^1.1 || ^2.0", diff --git a/composer.lock b/composer.lock index 37019178..e5b01d90 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": "341ed9ff6c12facfe31c4f83371be987", + "content-hash": "0e37388efcaed862295d6a84c299f121", "packages": [ { "name": "psr/http-factory", @@ -858,16 +858,16 @@ }, { "name": "fidry/cpu-core-counter", - "version": "1.0.0", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/theofidry/cpu-core-counter.git", - "reference": "85193c0b0cb5c47894b5eaec906e946f054e7077" + "reference": "f92996c4d5c1a696a6a970e20f7c4216200fcc42" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/85193c0b0cb5c47894b5eaec906e946f054e7077", - "reference": "85193c0b0cb5c47894b5eaec906e946f054e7077", + "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/f92996c4d5c1a696a6a970e20f7c4216200fcc42", + "reference": "f92996c4d5c1a696a6a970e20f7c4216200fcc42", "shasum": "" }, "require": { @@ -907,7 +907,7 @@ ], "support": { "issues": "https://github.com/theofidry/cpu-core-counter/issues", - "source": "https://github.com/theofidry/cpu-core-counter/tree/1.0.0" + "source": "https://github.com/theofidry/cpu-core-counter/tree/1.1.0" }, "funding": [ { @@ -915,7 +915,7 @@ "type": "github" } ], - "time": "2023-09-17T21:38:23+00:00" + "time": "2024-02-07T09:43:46+00:00" }, { "name": "http-interop/http-factory-tests", @@ -1083,16 +1083,16 @@ }, { "name": "netresearch/jsonmapper", - "version": "v4.2.0", + "version": "v4.4.1", "source": { "type": "git", "url": "https://github.com/cweiske/jsonmapper.git", - "reference": "f60565f8c0566a31acf06884cdaa591867ecc956" + "reference": "132c75c7dd83e45353ebb9c6c9f591952995bbf0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/f60565f8c0566a31acf06884cdaa591867ecc956", - "reference": "f60565f8c0566a31acf06884cdaa591867ecc956", + "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/132c75c7dd83e45353ebb9c6c9f591952995bbf0", + "reference": "132c75c7dd83e45353ebb9c6c9f591952995bbf0", "shasum": "" }, "require": { @@ -1103,7 +1103,7 @@ "php": ">=7.1" }, "require-dev": { - "phpunit/phpunit": "~7.5 || ~8.0 || ~9.0", + "phpunit/phpunit": "~7.5 || ~8.0 || ~9.0 || ~10.0", "squizlabs/php_codesniffer": "~3.5" }, "type": "library", @@ -1128,9 +1128,9 @@ "support": { "email": "cweiske@cweiske.de", "issues": "https://github.com/cweiske/jsonmapper/issues", - "source": "https://github.com/cweiske/jsonmapper/tree/v4.2.0" + "source": "https://github.com/cweiske/jsonmapper/tree/v4.4.1" }, - "time": "2023-04-09T17:37:40+00:00" + "time": "2024-01-31T06:18:54+00:00" }, { "name": "nikic/php-parser", @@ -1883,16 +1883,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.15", + "version": "9.6.16", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "05017b80304e0eb3f31d90194a563fd53a6021f1" + "reference": "3767b2c56ce02d01e3491046f33466a1ae60a37f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/05017b80304e0eb3f31d90194a563fd53a6021f1", - "reference": "05017b80304e0eb3f31d90194a563fd53a6021f1", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3767b2c56ce02d01e3491046f33466a1ae60a37f", + "reference": "3767b2c56ce02d01e3491046f33466a1ae60a37f", "shasum": "" }, "require": { @@ -1966,7 +1966,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.15" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.16" }, "funding": [ { @@ -1982,7 +1982,7 @@ "type": "tidelift" } ], - "time": "2023-12-01T16:55:19+00:00" + "time": "2024-01-19T07:03:14+00:00" }, { "name": "psalm/plugin-phpunit", @@ -3174,16 +3174,16 @@ }, { "name": "spatie/array-to-xml", - "version": "3.2.2", + "version": "3.2.3", "source": { "type": "git", "url": "https://github.com/spatie/array-to-xml.git", - "reference": "96be97e664c87613121d073ea39af4c74e57a7f8" + "reference": "c95fd4db94ec199f798d4b5b4a81757bd20d88ab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/array-to-xml/zipball/96be97e664c87613121d073ea39af4c74e57a7f8", - "reference": "96be97e664c87613121d073ea39af4c74e57a7f8", + "url": "https://api.github.com/repos/spatie/array-to-xml/zipball/c95fd4db94ec199f798d4b5b4a81757bd20d88ab", + "reference": "c95fd4db94ec199f798d4b5b4a81757bd20d88ab", "shasum": "" }, "require": { @@ -3221,7 +3221,7 @@ "xml" ], "support": { - "source": "https://github.com/spatie/array-to-xml/tree/3.2.2" + "source": "https://github.com/spatie/array-to-xml/tree/3.2.3" }, "funding": [ { @@ -3233,7 +3233,7 @@ "type": "github" } ], - "time": "2023-11-14T14:08:51+00:00" + "time": "2024-02-07T10:39:02+00:00" }, { "name": "squizlabs/php_codesniffer", @@ -3317,16 +3317,16 @@ }, { "name": "symfony/console", - "version": "v6.4.2", + "version": "v6.4.3", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "0254811a143e6bc6c8deea08b589a7e68a37f625" + "reference": "2aaf83b4de5b9d43b93e4aec6f2f8b676f7c567e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/0254811a143e6bc6c8deea08b589a7e68a37f625", - "reference": "0254811a143e6bc6c8deea08b589a7e68a37f625", + "url": "https://api.github.com/repos/symfony/console/zipball/2aaf83b4de5b9d43b93e4aec6f2f8b676f7c567e", + "reference": "2aaf83b4de5b9d43b93e4aec6f2f8b676f7c567e", "shasum": "" }, "require": { @@ -3391,7 +3391,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.4.2" + "source": "https://github.com/symfony/console/tree/v6.4.3" }, "funding": [ { @@ -3407,7 +3407,7 @@ "type": "tidelift" } ], - "time": "2023-12-10T16:15:48+00:00" + "time": "2024-01-23T14:51:35+00:00" }, { "name": "symfony/deprecation-contracts", @@ -3478,16 +3478,16 @@ }, { "name": "symfony/filesystem", - "version": "v6.4.0", + "version": "v6.4.3", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "952a8cb588c3bc6ce76f6023000fb932f16a6e59" + "reference": "7f3b1755eb49297a0827a7575d5d2b2fd11cc9fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/952a8cb588c3bc6ce76f6023000fb932f16a6e59", - "reference": "952a8cb588c3bc6ce76f6023000fb932f16a6e59", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/7f3b1755eb49297a0827a7575d5d2b2fd11cc9fb", + "reference": "7f3b1755eb49297a0827a7575d5d2b2fd11cc9fb", "shasum": "" }, "require": { @@ -3521,7 +3521,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v6.4.0" + "source": "https://github.com/symfony/filesystem/tree/v6.4.3" }, "funding": [ { @@ -3537,20 +3537,20 @@ "type": "tidelift" } ], - "time": "2023-07-26T17:27:13+00:00" + "time": "2024-01-23T14:51:35+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb" + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", - "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4", + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4", "shasum": "" }, "require": { @@ -3564,9 +3564,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -3603,7 +3600,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0" }, "funding": [ { @@ -3619,20 +3616,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "875e90aeea2777b6f135677f618529449334a612" + "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/875e90aeea2777b6f135677f618529449334a612", - "reference": "875e90aeea2777b6f135677f618529449334a612", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/32a9da87d7b3245e09ac426c83d334ae9f06f80f", + "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f", "shasum": "" }, "require": { @@ -3643,9 +3640,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -3684,7 +3678,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.29.0" }, "funding": [ { @@ -3700,20 +3694,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92" + "reference": "bc45c394692b948b4d383a08d7753968bed9a83d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", - "reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/bc45c394692b948b4d383a08d7753968bed9a83d", + "reference": "bc45c394692b948b4d383a08d7753968bed9a83d", "shasum": "" }, "require": { @@ -3724,9 +3718,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -3768,7 +3759,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.29.0" }, "funding": [ { @@ -3784,20 +3775,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "42292d99c55abe617799667f454222c54c60e229" + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229", - "reference": "42292d99c55abe617799667f454222c54c60e229", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", "shasum": "" }, "require": { @@ -3811,9 +3802,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -3851,7 +3839,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" }, "funding": [ { @@ -3867,7 +3855,7 @@ "type": "tidelift" } ], - "time": "2023-07-28T09:04:16+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/service-contracts", @@ -3953,16 +3941,16 @@ }, { "name": "symfony/string", - "version": "v6.4.2", + "version": "v6.4.3", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "7cb80bc10bfcdf6b5492741c0b9357dac66940bc" + "reference": "7a14736fb179876575464e4658fce0c304e8c15b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/7cb80bc10bfcdf6b5492741c0b9357dac66940bc", - "reference": "7cb80bc10bfcdf6b5492741c0b9357dac66940bc", + "url": "https://api.github.com/repos/symfony/string/zipball/7a14736fb179876575464e4658fce0c304e8c15b", + "reference": "7a14736fb179876575464e4658fce0c304e8c15b", "shasum": "" }, "require": { @@ -4019,7 +4007,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.4.2" + "source": "https://github.com/symfony/string/tree/v6.4.3" }, "funding": [ { @@ -4035,7 +4023,7 @@ "type": "tidelift" } ], - "time": "2023-12-10T16:15:48+00:00" + "time": "2024-01-25T09:26:29+00:00" }, { "name": "theseer/tokenizer", @@ -4089,16 +4077,16 @@ }, { "name": "vimeo/psalm", - "version": "5.19.0", + "version": "5.22.1", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "06b71be009a6bd6d81b9811855d6629b9fe90e1b" + "reference": "e9dad66e11274315dac27e08349c628c7d6a1a43" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/06b71be009a6bd6d81b9811855d6629b9fe90e1b", - "reference": "06b71be009a6bd6d81b9811855d6629b9fe90e1b", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/e9dad66e11274315dac27e08349c628c7d6a1a43", + "reference": "e9dad66e11274315dac27e08349c628c7d6a1a43", "shasum": "" }, "require": { @@ -4121,7 +4109,7 @@ "netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0", "nikic/php-parser": "^4.16", "php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0", - "sebastian/diff": "^4.0 || ^5.0", + "sebastian/diff": "^4.0 || ^5.0 || ^6.0", "spatie/array-to-xml": "^2.17.0 || ^3.0", "symfony/console": "^4.1.6 || ^5.0 || ^6.0 || ^7.0", "symfony/filesystem": "^5.4 || ^6.0 || ^7.0" @@ -4195,7 +4183,7 @@ "issues": "https://github.com/vimeo/psalm/issues", "source": "https://github.com/vimeo/psalm" }, - "time": "2024-01-09T21:02:43+00:00" + "time": "2024-02-15T22:52:31+00:00" }, { "name": "webimpress/coding-standard", diff --git a/src/AbstractSerializer.php b/src/AbstractSerializer.php index 3b290f05..5dc49c1c 100644 --- a/src/AbstractSerializer.php +++ b/src/AbstractSerializer.php @@ -99,7 +99,7 @@ protected static function splitStream(StreamInterface $stream): array continue; } - if (! $currentHeader) { + if ($currentHeader === false) { throw Exception\DeserializationException::forInvalidHeader(); } diff --git a/src/CallbackStream.php b/src/CallbackStream.php index 11e10df1..4e32fc0f 100644 --- a/src/CallbackStream.php +++ b/src/CallbackStream.php @@ -84,7 +84,7 @@ public function tell(): int */ public function eof(): bool { - return empty($this->callback); + return $this->callback === null; } /** @@ -149,7 +149,7 @@ public function read(int $length): string public function getContents(): string { $callback = $this->detach(); - $contents = $callback ? $callback() : ''; + $contents = $callback !== null ? $callback() : ''; return (string) $contents; } diff --git a/src/RequestTrait.php b/src/RequestTrait.php index 4ce4478b..e8519a36 100644 --- a/src/RequestTrait.php +++ b/src/RequestTrait.php @@ -252,7 +252,7 @@ public function withUri(UriInterface $uri, bool $preserveHost = false): RequestI } $host = $uri->getHost(); - if ($uri->getPort()) { + if ($uri->getPort() !== null) { $host .= ':' . $uri->getPort(); } @@ -294,7 +294,7 @@ private function setMethod(string $method): void private function getHostFromUri(): string { $host = $this->uri->getHost(); - $host .= $this->uri->getPort() ? ':' . $this->uri->getPort() : ''; + $host .= $this->uri->getPort() !== null ? ':' . $this->uri->getPort() : ''; return $host; } } diff --git a/src/Stream.php b/src/Stream.php index 2af1bb8b..2c0955de 100644 --- a/src/Stream.php +++ b/src/Stream.php @@ -210,11 +210,11 @@ public function isWritable(): bool $meta = stream_get_meta_data($this->resource); $mode = $meta['mode']; - return strstr($mode, 'x') - || strstr($mode, 'w') - || strstr($mode, 'c') - || strstr($mode, 'a') - || strstr($mode, '+'); + return strstr($mode, 'x') !== false + || strstr($mode, 'w') !== false + || strstr($mode, 'c') !== false + || strstr($mode, 'a') !== false + || strstr($mode, '+') !== false; } /** @@ -251,7 +251,7 @@ public function isReadable(): bool $meta = stream_get_meta_data($this->resource); $mode = $meta['mode']; - return strstr($mode, 'r') || strstr($mode, '+'); + return strstr($mode, 'r') !== false || strstr($mode, '+') !== false; } /** diff --git a/src/UploadedFile.php b/src/UploadedFile.php index 354b0428..ba32a1c6 100644 --- a/src/UploadedFile.php +++ b/src/UploadedFile.php @@ -50,8 +50,7 @@ class UploadedFile implements UploadedFileInterface private bool $moved = false; - /** @var null|StreamInterface */ - private $stream; + private ?StreamInterface $stream = null; /** * @param string|resource|StreamInterface $streamOrFile @@ -72,7 +71,7 @@ public function __construct( $this->stream = new Stream($streamOrFile); } - if (! $this->file && ! $this->stream) { + if ($this->file === null && $this->stream === null) { if (! $streamOrFile instanceof StreamInterface) { throw new Exception\InvalidArgumentException('Invalid stream or file provided for UploadedFile'); } @@ -150,7 +149,10 @@ public function moveTo(string $targetPath): void $sapi = PHP_SAPI; switch (true) { - case empty($sapi) || str_starts_with($sapi, 'cli') || str_starts_with($sapi, 'phpdbg') || ! $this->file: + case empty($sapi) + || str_starts_with($sapi, 'cli') + || str_starts_with($sapi, 'phpdbg') + || $this->file === null: // Non-SAPI environment, or no filename present $this->writeFile($targetPath); diff --git a/src/UriFactory.php b/src/UriFactory.php index 31f5a1de..1c8c3a50 100644 --- a/src/UriFactory.php +++ b/src/UriFactory.php @@ -60,7 +60,7 @@ public static function createFromSapi(array $server, array $headers): Uri [$host, $port] = self::marshalHostAndPort($server, $headers); if (! empty($host)) { $uri = $uri->withHost($host); - if (! empty($port)) { + if ($port !== null) { $uri = $uri->withPort($port); } } @@ -115,7 +115,7 @@ private static function getHeaderFromArray(string $name, array $headers, $defaul * Marshal the host and port from the PHP environment. * * @param array> $headers - * @return array{string, int|null} Array of two items, host and port, + * @return array{0:string, 1:int|null} Array of two items, host and port, * in that order (can be passed to a list() operation). */ private static function marshalHostAndPort(array $server, array $headers): array @@ -162,7 +162,7 @@ private static function marshalHostAndPort(array $server, array $headers): array private static function marshalIpv6HostAndPort(array $server, ?int $port): array { $host = '[' . (string) $server['SERVER_ADDR'] . ']'; - $port = $port ?: 80; + $port = $port ?? 80; $portSeparatorPos = strrpos($host, ':'); if (false === $portSeparatorPos) { diff --git a/test/ResponseTest.php b/test/ResponseTest.php index c450deeb..63b697a7 100644 --- a/test/ResponseTest.php +++ b/test/ResponseTest.php @@ -73,7 +73,7 @@ private function fetchIanaStatusCodes(): DOMDocument } } if ($ianaHttpStatusCodes) { - if (! getenv('ALWAYS_REFRESH_IANA_HTTP_STATUS_CODES')) { + if (getenv('ALWAYS_REFRESH_IANA_HTTP_STATUS_CODES') === 'false') { // use cached codes return $ianaHttpStatusCodes; } @@ -82,7 +82,7 @@ private function fetchIanaStatusCodes(): DOMDocument $updatedQueryResult = $xpath->query('//ns:updated'); if ($updatedQueryResult !== false && $updatedQueryResult->length > 0) { - $updated = $updatedQueryResult->item(0)?->nodeValue ?: ''; + $updated = $updatedQueryResult->item(0)?->nodeValue ?? ''; $updated = strtotime($updated); } } @@ -91,7 +91,7 @@ private function fetchIanaStatusCodes(): DOMDocument curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_USERAGENT, 'PHP Curl'); - if ($updated) { + if ($updated !== null) { $ifModifiedSince = sprintf( 'If-Modified-Since: %s', gmdate('D, d M Y H:i:s \G\M\T', $updated) @@ -142,8 +142,8 @@ public function ianaCodesReasonPhrasesProvider(): array continue; } - $value = $valueQueryResult->item(0)?->nodeValue ?: ''; - $description = $descriptionQueryResult->item(0)?->nodeValue ?: ''; + $value = $valueQueryResult->item(0)?->nodeValue ?? ''; + $description = $descriptionQueryResult->item(0)?->nodeValue ?? ''; if (in_array($description, ['Unassigned', '(Unused)'], true)) { continue; diff --git a/test/StreamTest.php b/test/StreamTest.php index 10824637..b01918dc 100644 --- a/test/StreamTest.php +++ b/test/StreamTest.php @@ -27,6 +27,7 @@ use function fwrite; use function imagecreate; use function is_resource; +use function is_string; use function shmop_open; use function stream_get_meta_data; use function sys_get_temp_dir; @@ -51,7 +52,7 @@ protected function setUp(): void protected function tearDown(): void { - if ($this->tmpnam && file_exists($this->tmpnam)) { + if (is_string($this->tmpnam) && file_exists($this->tmpnam)) { unlink($this->tmpnam); } }