From 17f4984601835c549af73c847794743c960ec51c Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 25 Jul 2024 17:43:11 +0200 Subject: [PATCH] Make use of new PHP 8.4.0 function to replace implicit $http_response_header var (#11995) --- phpstan/baseline.neon | 16 ++++++++++------ src/Composer/Installer.php | 2 +- src/Composer/Util/RemoteFilesystem.php | 7 ++++++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/phpstan/baseline.neon b/phpstan/baseline.neon index 5ae3c0b3b..8f455c83f 100644 --- a/phpstan/baseline.neon +++ b/phpstan/baseline.neon @@ -2045,11 +2045,6 @@ parameters: count: 1 path: ../src/Composer/Installer.php - - - message: "#^Casting to bool something that's already bool\\.$#" - count: 1 - path: ../src/Composer/Installer.php - - message: "#^Only booleans are allowed in &&, array\\\\> given on the right side\\.$#" count: 1 @@ -4353,6 +4348,16 @@ parameters: count: 8 path: ../src/Composer/Util/RemoteFilesystem.php + - + message: "#^Function http_clear_last_response_headers not found\\.$#" + count: 1 + path: ../src/Composer/Util/RemoteFilesystem.php + + - + message: "#^Function http_get_last_response_headers not found\\.$#" + count: 1 + path: ../src/Composer/Util/RemoteFilesystem.php + - message: "#^Method Composer\\\\Util\\\\RemoteFilesystem\\:\\:copy\\(\\) should return bool but returns bool\\|string\\.$#" count: 1 @@ -5095,4 +5100,3 @@ parameters: message: "#^Only booleans are allowed in a ternary operator condition, array\\ given\\.$#" count: 1 path: ../tests/Composer/Test/Util/TlsHelperTest.php - diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 8401072ed..b88906aae 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -1329,7 +1329,7 @@ class Installer */ public function setRunScripts(bool $runScripts = true): self { - $this->runScripts = (bool) $runScripts; + $this->runScripts = $runScripts; return $this; } diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index 560ef35db..7eeebc423 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -533,7 +533,12 @@ class RemoteFilesystem } // https://www.php.net/manual/en/reserved.variables.httpresponseheader.php - $responseHeaders = $http_response_header ?? []; + if (PHP_VERSION_ID >= 80400) { + $responseHeaders = http_get_last_response_headers(); + http_clear_last_response_headers(); + } else { + $responseHeaders = $http_response_header ?? []; + } if (null !== $e) { throw $e;