Repository: php/php-src (2025-08-27T22:52:09Z)

Issue:
Deprecation warnings in functions taking $http_response_header as argument
There seems to be an issue here @Girgias if you have a function taking $http_response_header as argument it warns about every usage..

See https://github.com/composer/composer/actions/runs/17278161064/job/49040109053 for the failures:

```
Error: PHP Deprecated:  The predefined locally scoped $http_response_header variable is deprecated, call http_get_last_response_headers() instead in src/Composer/Util/RemoteFilesystem.php on line 659
Error: PHP Deprecated:  The predefined locally scoped $http_response_header variable is deprecated, call http_get_last_response_headers() instead in src/Composer/Util/RemoteFilesystem.php on line 691
Error: PHP Deprecated:  The predefined locally scoped $http_response_header variable is deprecated, call http_get_last_response_headers() instead in src/Composer/Util/RemoteFilesystem.php on line 692
Error: PHP Deprecated:  The predefined locally scoped $http_response_header variable is deprecated, call http_get_last_response_headers() instead in src/Composer/Util/RemoteFilesystem.php on line 693
Error: PHP Deprecated:  The predefined locally scoped $http_response_header variable is deprecated, call http_get_last_response_headers() instead in src/Composer/Util/RemoteFilesystem.php on line 709
```

and https://github.com/composer/composer/pull/12513 seems to fix it. Easy fix but I'd argue if you can make it *not* complain in those cases it would be nicer.

_Originally posted by @Seldaek in https://github.com/php/php-src/pull/19464#issuecomment-3229704712_


Discussion:

Patch:
diff --git a/NEWS b/NEWS
index c5a7aba53d2e1..84f7de878cd58 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,10 @@ PHP                                                                        NEWS
 - Session:
   . Fix RC violation of session SID constant deprecation attribute. (ilutov)
 
+- Standard:
+  . Fix GH-19610 (Deprecation warnings in functions taking as argument).
+    (Girgias)
+
 - URI:
   . Fixed memory management of Uri\WhatWg\Url objects. (timwolla)
   . Fixed memory management of the internal "parse_url" URI parser.
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 0a7ab7da1bd5f..875239515441e 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -7800,6 +7800,8 @@ static void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32
 				ZSTR_VAL(name));
 		} else if (zend_string_equals(name, ZSTR_KNOWN(ZEND_STR_THIS))) {
 			zend_error_noreturn(E_COMPILE_ERROR, "Cannot use $this as parameter");
+		} else if (zend_string_equals_literal(name, "http_response_header")) {
+			CG(context).has_assigned_to_http_response_header = true;
 		}
 
 		if (op_array->fn_flags & ZEND_ACC_VARIADIC) {


Test patch:
diff --git a/ext/standard/tests/http/http_response_header_deprecated_parameter.phpt b/ext/standard/tests/http/http_response_header_deprecated_parameter.phpt
new file mode 100644
index 0000000000000..1dd032a30527e
--- /dev/null
+++ b/ext/standard/tests/http/http_response_header_deprecated_parameter.phpt
@@ -0,0 +1,14 @@
+--TEST--
+$http_reponse_header as a parameter name should not warn
+--FILE--
+<?php
+
+function foo($http_response_header) {
+    var_dump($http_response_header);
+}
+
+foo("OK");
+
+?>
+--EXPECT--
+string(2) "OK"