1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00
This commit is contained in:
Daniil Gentili 2022-12-19 18:31:43 +01:00
parent 4ea5329087
commit ab2692fdd3
7 changed files with 27 additions and 28 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="dev-master@6eb37b9dc2321e4eaade9d3d2dca1aff6f2c0a8f">
<files psalm-version="dev-master@d90a9a28a53176b4eb329d4c062d37516d3227f3">
<file src="examples/TemplateChecker.php">
<PossiblyUndefinedIntArrayOffset occurrences="2">
<code>$comment_block-&gt;tags['variablesfrom'][0]</code>
@ -182,6 +182,9 @@
</PossiblyUndefinedIntArrayOffset>
</file>
<file src="src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php">
<PossiblyUndefinedIntArrayOffset occurrences="1">
<code>$properties[0]</code>
</PossiblyUndefinedIntArrayOffset>
<ReferenceConstraintViolation occurrences="3">
<code>$stmt_type</code>
<code>$stmt_type</code>
@ -231,6 +234,11 @@
<code>$check_type_string</code>
</PossiblyUndefinedIntArrayOffset>
</file>
<file src="src/Psalm/Internal/Cli/LanguageServer.php">
<PossiblyInvalidArgument occurrences="1">
<code>$options['tcp'] ?? null</code>
</PossiblyInvalidArgument>
</file>
<file src="src/Psalm/Internal/Cli/Refactor.php">
<PossiblyUndefinedIntArrayOffset occurrences="1">
<code>$identifier_name</code>
@ -390,9 +398,6 @@
<InvalidArgument occurrences="1">
<code>$class_strings ?: null</code>
</InvalidArgument>
<RedundantCondition occurrences="2">
<code>$is_replace</code>
</RedundantCondition>
</file>
<file src="src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php">
<PossiblyUndefinedIntArrayOffset occurrences="1">
@ -461,17 +466,11 @@
</PossiblyUndefinedIntArrayOffset>
</file>
<file src="src/Psalm/Internal/Type/TypeTokenizer.php">
<InvalidArrayOffset occurrences="1">
<code>$chars[$i - 1]</code>
</InvalidArrayOffset>
<PossiblyInvalidArrayOffset occurrences="7">
<PossiblyInvalidArrayOffset occurrences="4">
<code>$type_tokens[$i - 1]</code>
<code>$type_tokens[$i - 1]</code>
<code>$type_tokens[$i - 1]</code>
<code>$type_tokens[$i - 1]</code>
<code>$type_tokens[$i - 1]</code>
<code>$type_tokens[$i - 1]</code>
<code>$type_tokens[$i - 2]</code>
</PossiblyInvalidArrayOffset>
</file>
<file src="src/Psalm/Storage/ClassConstantStorage.php">

View File

@ -649,12 +649,14 @@ class ArrayAssignmentAnalyzer
]);
} else {
assert($array_atomic_type_list !== null);
$array_atomic_type = array_fill(
$atomic_root_type_array->getMinCount(),
count($atomic_root_type_array->properties)-1,
$array_atomic_type_list,
);
assert(count($array_atomic_type) > 0);
$array_atomic_type = new TKeyedArray(
array_fill(
$atomic_root_type_array->getMinCount(),
count($atomic_root_type_array->properties)-1,
$array_atomic_type_list,
),
$array_atomic_type,
null,
null,
true,

View File

@ -1545,7 +1545,7 @@ class ArrayFetchAnalyzer
);
}
$properties[0] = $properties[0]->setPossiblyUndefined(
$replacement_type->possibly_undefined
$replacement_type->possibly_undefined,
);
$properties[$key_value->value] = $properties[$key_value->value]->
setPossiblyUndefined(true)

View File

@ -676,9 +676,7 @@ class TypeCombiner
if (!$candidate_property_type->possibly_undefined) {
$has_defined_keys = true;
}
if ($combination->fallbackKeyContains($candidate_property_name)) {
} elseif ($combination->fallbackKeyContains($candidate_property_name)) {
$combination->objectlike_entries[$candidate_property_name] = Type::combineUnionTypes(
$combination->objectlike_entries[$candidate_property_name],
$combination->objectlike_value_type,

View File

@ -95,7 +95,9 @@ class TKeyedArray extends Atomic
$this->is_list = false;
break;
}
$had_possibly_undefined = $v->possibly_undefined || $had_possibly_undefined;
if ($v->possibly_undefined) {
$had_possibly_undefined = true;
}
$last_k = $k;
}
}
@ -121,7 +123,9 @@ class TKeyedArray extends Atomic
$cloned->is_list = false;
break;
}
$had_possibly_undefined = $v->possibly_undefined || $had_possibly_undefined;
if ($v->possibly_undefined) {
$had_possibly_undefined = true;
}
$last_k = $k;
}
}

View File

@ -1093,10 +1093,6 @@ class Reconciler
array &$changed_var_ids,
Union $result_type
): void {
if ($result_type->isNever()) {
return;
}
array_pop($key_parts);
$array_key = array_pop($key_parts);
array_pop($key_parts);

View File

@ -219,8 +219,8 @@ class ArrayFunctionCallTest extends TestCase
$result = array_merge($a1, $a2);
',
'assertions' => [
'$result===' => "array{a: 'a2'}"
]
'$result===' => "array{a: 'a2'}",
],
],
'arrayMergeListOfShapes' => [
'code' => '<?php