Skip to content

Commit 0537dec

Browse files
authored
Add missing superglobals (#207)
* Add more superglobals to test fixture This adds the missing `$HTTP_RAW_POST_DATA`, `$http_response_header`, and `$php_errormsg`. * Add missing superglobals to VariableAnalysisSniff
1 parent 22f4228 commit 0537dec

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Tests/VariableAnalysisSniff/fixtures/FunctionWithGlobalVarFixture.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,17 @@ function globalWithUnusedFunctionArg($user_type, $text, $testvar) { // should wa
5757
}
5858

5959
echo $sunday;
60+
61+
function function_with_reserved_variables() {
62+
$opts = [];
63+
$url = 'https://example.com/';
64+
$context = stream_context_create($opts);
65+
$response = @file_get_contents($url, false, $context);
66+
$response_headers = handle_response_headers($http_response_header);
67+
return [
68+
$response,
69+
$response_headers,
70+
$php_errormsg,
71+
$HTTP_RAW_POST_DATA,
72+
];
73+
}

VariableAnalysis/Sniffs/CodeAnalysis/VariableAnalysisSniff.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,9 @@ protected function processVariableAsSuperGlobal($varName) {
799799
'_ENV',
800800
'argv',
801801
'argc',
802+
'php_errormsg',
803+
'http_response_header',
804+
'HTTP_RAW_POST_DATA',
802805
])) {
803806
return true;
804807
}

0 commit comments

Comments
 (0)