mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
parent
1e454fa3d5
commit
81423dc12b
@ -650,11 +650,9 @@ class VariableFetchAnalyzer
|
|||||||
$bool_string_helper = new Union([new TBool(), new TString()]);
|
$bool_string_helper = new Union([new TBool(), new TString()]);
|
||||||
$bool_string_helper->possibly_undefined = true;
|
$bool_string_helper->possibly_undefined = true;
|
||||||
|
|
||||||
$detailed_type = new TKeyedArray([
|
$detailed_type_members = [
|
||||||
// https://www.php.net/manual/en/reserved.variables.server.php
|
// https://www.php.net/manual/en/reserved.variables.server.php
|
||||||
'PHP_SELF' => $non_empty_string_helper,
|
'PHP_SELF' => $non_empty_string_helper,
|
||||||
'argv' => $argv_helper,
|
|
||||||
'argc' => $argc_helper,
|
|
||||||
'GATEWAY_INTERFACE' => $non_empty_string_helper,
|
'GATEWAY_INTERFACE' => $non_empty_string_helper,
|
||||||
'SERVER_ADDR' => $non_empty_string_helper,
|
'SERVER_ADDR' => $non_empty_string_helper,
|
||||||
'SERVER_NAME' => $non_empty_string_helper,
|
'SERVER_NAME' => $non_empty_string_helper,
|
||||||
@ -727,7 +725,15 @@ class VariableFetchAnalyzer
|
|||||||
// phpunit
|
// phpunit
|
||||||
'APP_DEBUG' => $bool_string_helper,
|
'APP_DEBUG' => $bool_string_helper,
|
||||||
'APP_ENV' => $string_helper,
|
'APP_ENV' => $string_helper,
|
||||||
]);
|
];
|
||||||
|
|
||||||
|
if ($var_id === '$_SERVER') {
|
||||||
|
// those elements are not usually present in $_ENV
|
||||||
|
$detailed_type_members['argc'] = $argc_helper;
|
||||||
|
$detailed_type_members['argv'] = $argv_helper;
|
||||||
|
}
|
||||||
|
|
||||||
|
$detailed_type = new TKeyedArray($detailed_type_members);
|
||||||
|
|
||||||
// generic case for all other elements
|
// generic case for all other elements
|
||||||
$detailed_type->previous_key_type = Type::getNonEmptyString();
|
$detailed_type->previous_key_type = Type::getNonEmptyString();
|
||||||
|
@ -22,5 +22,14 @@ class SuperGlobalsTest extends TestCase
|
|||||||
',
|
',
|
||||||
'assertions' => []
|
'assertions' => []
|
||||||
];
|
];
|
||||||
|
|
||||||
|
yield 'ENV has scalar entries only' => [
|
||||||
|
'<?php
|
||||||
|
/** @return array<array-key, scalar> */
|
||||||
|
function f(): array {
|
||||||
|
return $_ENV;
|
||||||
|
}
|
||||||
|
'
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user