diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b8564b5b..728a8dbf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,10 @@ jobs: strategy: matrix: include: + - name: PHP 8.5 + PHP_VERSION: 8.5 + - name: PHP 8.4 + PHP_VERSION: 8.4 - name: PHP 8.3 PHP_VERSION: 8.3 - name: PHP 8.2 diff --git a/composer.json b/composer.json index 4c6332dc..7e06af00 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": ">=8.1 <8.4", + "php": ">=8.1 <8.6", "ext-curl": "*", "ext-json": "*" }, diff --git a/src/Parse/HttpClients/ParseCurl.php b/src/Parse/HttpClients/ParseCurl.php index 17cf2fbc..52348552 100644 --- a/src/Parse/HttpClients/ParseCurl.php +++ b/src/Parse/HttpClients/ParseCurl.php @@ -133,10 +133,9 @@ public function close() throw new ParseException('You must call ParseCurl::init first'); } - // close our handle - curl_close($this->curl); - - // unset our curl handle + // PHP 8.5 deprecates curl_close(); it has had no effect since PHP + // 8.0, when CurlHandle became an object released on last reference. + // Unsetting the handle below is what actually closes it. $this->curl = null; } } diff --git a/src/Parse/HttpClients/ParseStream.php b/src/Parse/HttpClients/ParseStream.php index b6845f70..d18a47c0 100644 --- a/src/Parse/HttpClients/ParseStream.php +++ b/src/Parse/HttpClients/ParseStream.php @@ -110,7 +110,22 @@ public function getErrorCode() public function getFileContents($filename, $use_include_path, $context) { $result = file_get_contents($filename, $use_include_path, $context); - $this->responseHeaders = $http_response_header; + + // PHP 8.5 deprecated the locally scoped `$http_response_header` + // variable in favour of `http_get_last_response_headers()`. That + // function does not exist before 8.5, so both paths are kept. + // + // The legacy read uses `??` deliberately: a direct read raises the + // deprecation at compile time on 8.5, even inside `isset()`, while + // a null coalesced read does not. + $hasHeaderFunction = \function_exists( + 'http_get_last_response_headers' + ); + + $this->responseHeaders = $hasHeaderFunction + ? (http_get_last_response_headers() ?? []) + : ($http_response_header ?? []); + return $result; } } diff --git a/src/Parse/ParseException.php b/src/Parse/ParseException.php index 2f46c886..d65b058a 100644 --- a/src/Parse/ParseException.php +++ b/src/Parse/ParseException.php @@ -22,7 +22,7 @@ class ParseException extends Exception * @param int $code Error code. * @param \Exception $previous Previous Exception. */ - public function __construct($message, $code = 0, Exception $previous = null) + public function __construct($message, $code = 0, ?Exception $previous = null) { parent::__construct($message, $code, $previous); }