mirror of
https://github.com/danog/psalm.git
synced 2024-12-12 09:19:40 +01:00
Fixes
This commit is contained in:
parent
d4df856124
commit
c80221344b
@ -1153,8 +1153,9 @@ class AssertionFinder
|
|||||||
|
|
||||||
if (is_numeric($var_id) && null !== $property && !$is_function) {
|
if (is_numeric($var_id) && null !== $property && !$is_function) {
|
||||||
$args = $expr->getArgs();
|
$args = $expr->getArgs();
|
||||||
|
$var_id_int = (int) $var_id;
|
||||||
|
|
||||||
if (!array_key_exists($var_id, $args)) {
|
if (!array_key_exists($var_id_int, $args)) {
|
||||||
IssueBuffer::maybeAdd(
|
IssueBuffer::maybeAdd(
|
||||||
new InvalidDocblock(
|
new InvalidDocblock(
|
||||||
'Variable '.$var_id.' is not an argument so cannot be asserted',
|
'Variable '.$var_id.' is not an argument so cannot be asserted',
|
||||||
@ -1164,7 +1165,7 @@ class AssertionFinder
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/** @var PhpParser\Node\Expr\Variable $arg_value */
|
/** @var PhpParser\Node\Expr\Variable $arg_value */
|
||||||
$arg_value = $args[$var_id]->value;
|
$arg_value = $args[$var_id_int]->value;
|
||||||
|
|
||||||
$arg_var_id = ExpressionIdentifier::getExtendedVarId($arg_value, null, $source);
|
$arg_var_id = ExpressionIdentifier::getExtendedVarId($arg_value, null, $source);
|
||||||
|
|
||||||
|
@ -676,10 +676,9 @@ class StatementsAnalyzer extends SourceAnalyzer
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($checked_types as [$check_type_line, $is_exact]) {
|
foreach ($checked_types as [$check_type_line, $is_exact]) {
|
||||||
/** @var string|null $check_type_string (incorrectly inferred) */
|
|
||||||
[$checked_var, $check_type_string] = array_map('trim', explode('=', $check_type_line));
|
[$checked_var, $check_type_string] = array_map('trim', explode('=', $check_type_line));
|
||||||
|
|
||||||
if ($check_type_string === null) {
|
if ($check_type_string === '') {
|
||||||
IssueBuffer::maybeAdd(
|
IssueBuffer::maybeAdd(
|
||||||
new InvalidDocblock(
|
new InvalidDocblock(
|
||||||
"Invalid format for @psalm-check-type" . ($is_exact ? "-exact" : ""),
|
"Invalid format for @psalm-check-type" . ($is_exact ? "-exact" : ""),
|
||||||
|
@ -184,6 +184,8 @@ class TypeCombiner
|
|||||||
$combined_param_types[] = Type::combineUnionTypes($array_param_type, $traversable_param_types[$i]);
|
$combined_param_types[] = Type::combineUnionTypes($array_param_type, $traversable_param_types[$i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(count($combined_param_types) <= 2);
|
||||||
|
|
||||||
$combination->value_types['iterable'] = new TIterable($combined_param_types);
|
$combination->value_types['iterable'] = new TIterable($combined_param_types);
|
||||||
|
|
||||||
$combination->array_type_params = [];
|
$combination->array_type_params = [];
|
||||||
@ -236,6 +238,7 @@ class TypeCombiner
|
|||||||
|
|
||||||
foreach ($combination->builtin_type_params as $generic_type => $generic_type_params) {
|
foreach ($combination->builtin_type_params as $generic_type => $generic_type_params) {
|
||||||
if ($generic_type === 'iterable') {
|
if ($generic_type === 'iterable') {
|
||||||
|
assert(count($generic_type_params) <= 2);
|
||||||
$new_types[] = new TIterable($generic_type_params);
|
$new_types[] = new TIterable($generic_type_params);
|
||||||
} else {
|
} else {
|
||||||
/** @psalm-suppress ArgumentTypeCoercion Caused by the PropertyTypeCoercion above */
|
/** @psalm-suppress ArgumentTypeCoercion Caused by the PropertyTypeCoercion above */
|
||||||
|
@ -229,6 +229,8 @@ trait GenericTrait
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(count($type_params) === 2);
|
||||||
|
|
||||||
return $type_params === $this->type_params ? null : $type_params;
|
return $type_params === $this->type_params ? null : $type_params;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,6 +255,7 @@ trait GenericTrait
|
|||||||
|
|
||||||
$type_params[$offset] = $type_param;
|
$type_params[$offset] = $type_param;
|
||||||
}
|
}
|
||||||
|
assert(count($type_params) === 2);
|
||||||
|
|
||||||
return $type_params === $this->type_params ? null : $type_params;
|
return $type_params === $this->type_params ? null : $type_params;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user