From ffc84e4cefede77a631810c4cf740c04478820a7 Mon Sep 17 00:00:00 2001 From: Markus Reinhold Date: Sun, 14 Dec 2025 00:09:53 +0100 Subject: [PATCH 1/2] Add php 8.5 to test pipeline Use http_get_last_response_headers instead of $http_response_header if possible. --- .github/workflows/main.yml | 2 +- src/HttpAdapter/HttpStreamWrapperClient.php | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 36657a0..871d4bf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,7 @@ jobs: strategy: matrix: operating-system: [ubuntu-latest] - php-version: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] + php-version: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] name: ${{ matrix.php-version }} runs-on: ${{ matrix.operating-system }} steps: diff --git a/src/HttpAdapter/HttpStreamWrapperClient.php b/src/HttpAdapter/HttpStreamWrapperClient.php index 97cf2b8..c3362c7 100644 --- a/src/HttpAdapter/HttpStreamWrapperClient.php +++ b/src/HttpAdapter/HttpStreamWrapperClient.php @@ -80,7 +80,11 @@ private function request(string $method, Request $request): Response ); } - return HttpStreamWrapperResponse::fromResponse($http_response_header, $responseBody); + $responseHeaders = (function_exists('http_get_last_response_headers') + ? http_get_last_response_headers() + : $http_response_header) ?? []; + + return HttpStreamWrapperResponse::fromResponse($responseHeaders, $responseBody); } /** From 6af4d43ce66fd4cd5509177214b6fa4b1b8a80fe Mon Sep 17 00:00:00 2001 From: Markus Reinhold Date: Wed, 17 Dec 2025 18:47:48 +0100 Subject: [PATCH 2/2] Check php version This avoids calling manual defined functions in older PHP versions. --- phpstan.neon.dist | 3 +++ src/HttpAdapter/HttpStreamWrapperClient.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 85f3ab2..1fc3399 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -2,3 +2,6 @@ parameters: paths: - src level: max + reportUnmatchedIgnoredErrors: false + ignoreErrors: + - '#^Function http_get_last_response_headers not found.$#' diff --git a/src/HttpAdapter/HttpStreamWrapperClient.php b/src/HttpAdapter/HttpStreamWrapperClient.php index c3362c7..f74acf2 100644 --- a/src/HttpAdapter/HttpStreamWrapperClient.php +++ b/src/HttpAdapter/HttpStreamWrapperClient.php @@ -80,7 +80,7 @@ private function request(string $method, Request $request): Response ); } - $responseHeaders = (function_exists('http_get_last_response_headers') + $responseHeaders = (PHP_VERSION_ID >= 80500 ? http_get_last_response_headers() : $http_response_header) ?? [];