1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

update define types to be correct

This commit is contained in:
kkmuffme 2023-11-29 08:41:54 +01:00
parent 982f95c87e
commit 4f25ccee40
4 changed files with 38 additions and 3 deletions

View File

@ -1552,7 +1552,7 @@ return [
'decbin' => ['string', 'num'=>'int'],
'dechex' => ['string', 'num'=>'int'],
'decoct' => ['string', 'num'=>'int'],
'define' => ['bool', 'constant_name'=>'string', 'value'=>'mixed', 'case_insensitive='=>'bool'],
'define' => ['bool', 'constant_name'=>'string', 'value'=>'array|scalar|null', 'case_insensitive='=>'false'],
'define_syslog_variables' => ['void'],
'defined' => ['bool', 'constant_name'=>'string'],
'deflate_add' => ['string|false', 'context'=>'DeflateContext', 'data'=>'string', 'flush_mode='=>'int'],

View File

@ -64,6 +64,10 @@ return [
'old' => ['int', 'scale'=>'int'],
'new' => ['int', 'scale='=>'int'],
],
'define' => [
'old' => ['bool', 'constant_name'=>'string', 'value'=>'array|scalar|null', 'case_insensitive='=>'bool'],
'new' => ['bool', 'constant_name'=>'string', 'value'=>'array|scalar|null', 'case_insensitive='=>'false'],
],
'ldap_compare' => [
'old' => ['bool|int', 'ldap'=>'resource', 'dn'=>'string', 'attribute'=>'string', 'value'=>'string'],
'new' => ['bool|int', 'ldap'=>'resource', 'dn'=>'string', 'attribute'=>'string', 'value'=>'string', 'controls='=>'array'],

View File

@ -9937,7 +9937,7 @@ return [
'decbin' => ['string', 'num'=>'int'],
'dechex' => ['string', 'num'=>'int'],
'decoct' => ['string', 'num'=>'int'],
'define' => ['bool', 'constant_name'=>'string', 'value'=>'mixed', 'case_insensitive='=>'bool'],
'define' => ['bool', 'constant_name'=>'string', 'value'=>'array|scalar|null', 'case_insensitive='=>'bool'],
'define_syslog_variables' => ['void'],
'defined' => ['bool', 'constant_name'=>'string'],
'deflate_add' => ['string|false', 'context'=>'resource', 'data'=>'string', 'flush_mode='=>'int'],

View File

@ -225,7 +225,38 @@ final class NamedFunctionCallHandler
}
if ($function_id === 'defined') {
if ($first_arg && !$context->inside_negation) {
$fq_const_name = ConstFetchAnalyzer::getConstName(
$first_arg->value,
$statements_analyzer->node_data,
$codebase,
$statements_analyzer->getAliases(),
);
if ($fq_const_name !== null) {
$const_type = ConstFetchAnalyzer::getConstType(
$statements_analyzer,
$fq_const_name,
true,
$context,
);
if (!$const_type) {
ConstFetchAnalyzer::setConstType(
$statements_analyzer,
$fq_const_name,
Type::getMixed(),
$context,
);
$context->check_consts = false;
}
} else {
$context->check_consts = false;
}
} else {
$context->check_consts = false;
}
return;
}