From 798104eb0a633a8b70c2166ba95359bd99584fa1 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Wed, 10 Dec 2025 17:41:00 +0100 Subject: [PATCH] test with php 8.5 --- .github/workflows/tests.yml | 14 +++++--------- phpstan-baseline.neon | 22 +++++----------------- phpstan.neon.dist | 1 + src/CookieUtil.php | 5 ++++- src/Encoding/Filter/Chunk.php | 2 ++ src/Encoding/FilteredStream.php | 2 ++ 6 files changed, 19 insertions(+), 27 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index be2c811..2ce3f38 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,15 +12,11 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] + php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] steps: - name: Checkout code - uses: actions/checkout@v4 - - - name: Emulate PHP 8.3 - run: composer config platform.php 8.3.999 - if: matrix.php == '8.4' + uses: actions/checkout@v6 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -41,7 +37,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -69,7 +65,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -92,7 +88,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 31bd899..ced0519 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -15,16 +15,6 @@ parameters: 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 type specified\\.$#" count: 1 @@ -101,14 +91,14 @@ parameters: path: src/CookieJar.php - - message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:clear\\(\\) has no return type specified\\.$#" - count: 1 + message: "#^Cannot call method .* on mixed\\.$#" + count: 4 path: src/CookieJar.php - - message: "#^Property Http\\\\Message\\\\CookieUtil\\:\\:\\$dateFormats type has no value type specified in iterable type array\\.$#" + message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:clear\\(\\) has no return type specified\\.$#" count: 1 - path: src/CookieUtil.php + path: src/CookieJar.php - message: "#^Method Http\\\\Message\\\\MessageFactory\\\\DiactorosMessageFactory\\:\\:createRequest\\(\\) has parameter \\$headers with no value type specified in iterable type array\\.$#" @@ -181,6 +171,4 @@ parameters: path: src/UriFactory/SlimUriFactory.php - - message: "#^Call to function array_key_exists\\(\\) with 'chunk' and array will always evaluate to false\\.$#" - count: 1 - path: src/filters.php + message: '#Trait .* is used zero times and is not analysed#' diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 6355eac..5192ac3 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -2,6 +2,7 @@ includes: - phpstan-baseline.neon parameters: + treatPhpDocTypesAsCertain: false level: max paths: - src diff --git a/src/CookieUtil.php b/src/CookieUtil.php index 44c5314..0177a8c 100644 --- a/src/CookieUtil.php +++ b/src/CookieUtil.php @@ -10,7 +10,7 @@ final class CookieUtil * Handles dates as defined by RFC 2616 section 3.3.1, and also some other * non-standard, but common formats. * - * @var array + * @var string[] */ private static $dateFormats = [ 'D, d M y H:i:s T', @@ -34,6 +34,9 @@ final class CookieUtil */ public static function parseDate($dateValue) { + if (!is_string($dateValue)) { + throw new \InvalidArgumentException('Date must be of type string, given '.gettype($dateValue)); + } foreach (self::$dateFormats as $dateFormat) { if (false !== $date = \DateTime::createFromFormat($dateFormat, $dateValue, new \DateTimeZone('GMT'))) { return $date; diff --git a/src/Encoding/Filter/Chunk.php b/src/Encoding/Filter/Chunk.php index 7a9e18f..8002e35 100644 --- a/src/Encoding/Filter/Chunk.php +++ b/src/Encoding/Filter/Chunk.php @@ -12,12 +12,14 @@ class Chunk extends \php_user_filter public function filter($in, $out, &$consumed, $closing): int { while ($bucket = stream_bucket_make_writeable($in)) { + /* @phpstan-ignore argument.type */ $lenbucket = stream_bucket_new($this->stream, dechex($bucket->datalen)."\r\n"); stream_bucket_append($out, $lenbucket); $consumed += $bucket->datalen; stream_bucket_append($out, $bucket); + /* @phpstan-ignore argument.type */ $lenbucket = stream_bucket_new($this->stream, "\r\n"); stream_bucket_append($out, $lenbucket); } diff --git a/src/Encoding/FilteredStream.php b/src/Encoding/FilteredStream.php index 4bc44a6..6a92d41 100644 --- a/src/Encoding/FilteredStream.php +++ b/src/Encoding/FilteredStream.php @@ -113,9 +113,11 @@ public function eof(): bool protected function fill(): void { $readFilterCallback = $this->readFilterCallback; + /* @phpstan-ignore assignOp.invalid */ $this->buffer .= $readFilterCallback($this->stream->read(self::BUFFER_SIZE)); if ($this->stream->eof()) { + /* @phpstan-ignore assignOp.invalid */ $this->buffer .= $readFilterCallback(); } }