mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Fix logic bugs caught by better elseif checks
This commit is contained in:
parent
54cd529642
commit
234787bcd6
@ -459,7 +459,6 @@
|
|||||||
<code><![CDATA[$combination->array_type_params[1]]]></code>
|
<code><![CDATA[$combination->array_type_params[1]]]></code>
|
||||||
<code><![CDATA[$combination->array_type_params[1]]]></code>
|
<code><![CDATA[$combination->array_type_params[1]]]></code>
|
||||||
<code><![CDATA[$combination->array_type_params[1]]]></code>
|
<code><![CDATA[$combination->array_type_params[1]]]></code>
|
||||||
<code><![CDATA[$combination->array_type_params[1]]]></code>
|
|
||||||
</PossiblyUndefinedIntArrayOffset>
|
</PossiblyUndefinedIntArrayOffset>
|
||||||
</file>
|
</file>
|
||||||
<file src="src/Psalm/Internal/Type/TypeExpander.php">
|
<file src="src/Psalm/Internal/Type/TypeExpander.php">
|
||||||
|
@ -2434,7 +2434,7 @@ class ClassAnalyzer extends ClassLikeAnalyzer
|
|||||||
$storage->name,
|
$storage->name,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} elseif ($case_storage->value !== null && $storage->enum_type !== null) {
|
} elseif ($case_storage->value !== null) {
|
||||||
if ((is_int($case_storage->value) && $storage->enum_type === 'string')
|
if ((is_int($case_storage->value) && $storage->enum_type === 'string')
|
||||||
|| (is_string($case_storage->value) && $storage->enum_type === 'int')
|
|| (is_string($case_storage->value) && $storage->enum_type === 'int')
|
||||||
) {
|
) {
|
||||||
|
@ -144,11 +144,10 @@ class ClassTemplateParamCollector
|
|||||||
$template_result,
|
$template_result,
|
||||||
);
|
);
|
||||||
|
|
||||||
$class_template_params[$type_name][$class_storage->name]
|
$class_template_params[$type_name] = [
|
||||||
= $output_type_extends ?? Type::getMixed();
|
$class_storage->name => $output_type_extends ?? Type::getMixed(),
|
||||||
}
|
];
|
||||||
|
} else {
|
||||||
if (!isset($class_template_params[$type_name][$class_storage->name])) {
|
|
||||||
$class_template_params[$type_name] = [$class_storage->name => Type::getMixed()];
|
$class_template_params[$type_name] = [$class_storage->name => Type::getMixed()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -362,9 +362,11 @@ class TypeCombiner
|
|||||||
$new_types[] = $type->setFromDocblock($from_docblock);
|
$new_types[] = $type->setFromDocblock($from_docblock);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$new_types && !$has_never) {
|
if (!$new_types) {
|
||||||
throw new UnexpectedValueException('There should be types here');
|
if (!$has_never) {
|
||||||
} elseif (!$new_types && $has_never) {
|
throw new UnexpectedValueException('There should be types here');
|
||||||
|
}
|
||||||
|
|
||||||
$union_type = Type::getNever($from_docblock);
|
$union_type = Type::getNever($from_docblock);
|
||||||
} else {
|
} else {
|
||||||
$union_type = new Union($new_types);
|
$union_type = new Union($new_types);
|
||||||
@ -1351,9 +1353,7 @@ class TypeCombiner
|
|||||||
|
|
||||||
if (!$combination->array_type_params || $combination->array_type_params[1]->isNever()) {
|
if (!$combination->array_type_params || $combination->array_type_params[1]->isNever()) {
|
||||||
if (!$overwrite_empty_array
|
if (!$overwrite_empty_array
|
||||||
&& ($combination->array_type_params
|
&& $combination->array_type_params
|
||||||
&& ($combination->array_type_params[1]->isNever()
|
|
||||||
|| $combination->array_type_params[1]->isMixed()))
|
|
||||||
) {
|
) {
|
||||||
foreach ($combination->objectlike_entries as &$objectlike_entry) {
|
foreach ($combination->objectlike_entries as &$objectlike_entry) {
|
||||||
$objectlike_entry = $objectlike_entry->setPossiblyUndefined(true);
|
$objectlike_entry = $objectlike_entry->setPossiblyUndefined(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user