Skip to content

Commit ab2692f

Browse files
committed
Update
1 parent 4ea5329 commit ab2692f

File tree

7 files changed

+27
-28
lines changed

7 files changed

+27
-28
lines changed

psalm-baseline.xml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="dev-master@6eb37b9dc2321e4eaade9d3d2dca1aff6f2c0a8f">
2+
<files psalm-version="dev-master@d90a9a28a53176b4eb329d4c062d37516d3227f3">
33
<file src="examples/TemplateChecker.php">
44
<PossiblyUndefinedIntArrayOffset occurrences="2">
55
<code>$comment_block-&gt;tags['variablesfrom'][0]</code>
@@ -182,6 +182,9 @@
182182
</PossiblyUndefinedIntArrayOffset>
183183
</file>
184184
<file src="src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php">
185+
<PossiblyUndefinedIntArrayOffset occurrences="1">
186+
<code>$properties[0]</code>
187+
</PossiblyUndefinedIntArrayOffset>
185188
<ReferenceConstraintViolation occurrences="3">
186189
<code>$stmt_type</code>
187190
<code>$stmt_type</code>
@@ -231,6 +234,11 @@
231234
<code>$check_type_string</code>
232235
</PossiblyUndefinedIntArrayOffset>
233236
</file>
237+
<file src="src/Psalm/Internal/Cli/LanguageServer.php">
238+
<PossiblyInvalidArgument occurrences="1">
239+
<code>$options['tcp'] ?? null</code>
240+
</PossiblyInvalidArgument>
241+
</file>
234242
<file src="src/Psalm/Internal/Cli/Refactor.php">
235243
<PossiblyUndefinedIntArrayOffset occurrences="1">
236244
<code>$identifier_name</code>
@@ -390,9 +398,6 @@
390398
<InvalidArgument occurrences="1">
391399
<code>$class_strings ?: null</code>
392400
</InvalidArgument>
393-
<RedundantCondition occurrences="2">
394-
<code>$is_replace</code>
395-
</RedundantCondition>
396401
</file>
397402
<file src="src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php">
398403
<PossiblyUndefinedIntArrayOffset occurrences="1">
@@ -461,17 +466,11 @@
461466
</PossiblyUndefinedIntArrayOffset>
462467
</file>
463468
<file src="src/Psalm/Internal/Type/TypeTokenizer.php">
464-
<InvalidArrayOffset occurrences="1">
465-
<code>$chars[$i - 1]</code>
466-
</InvalidArrayOffset>
467-
<PossiblyInvalidArrayOffset occurrences="7">
468-
<code>$type_tokens[$i - 1]</code>
469-
<code>$type_tokens[$i - 1]</code>
469+
<PossiblyInvalidArrayOffset occurrences="4">
470470
<code>$type_tokens[$i - 1]</code>
471471
<code>$type_tokens[$i - 1]</code>
472472
<code>$type_tokens[$i - 1]</code>
473473
<code>$type_tokens[$i - 1]</code>
474-
<code>$type_tokens[$i - 2]</code>
475474
</PossiblyInvalidArrayOffset>
476475
</file>
477476
<file src="src/Psalm/Storage/ClassConstantStorage.php">

src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -649,12 +649,14 @@ private static function updateArrayAssignmentChildType(
649649
]);
650650
} else {
651651
assert($array_atomic_type_list !== null);
652+
$array_atomic_type = array_fill(
653+
$atomic_root_type_array->getMinCount(),
654+
count($atomic_root_type_array->properties)-1,
655+
$array_atomic_type_list,
656+
);
657+
assert(count($array_atomic_type) > 0);
652658
$array_atomic_type = new TKeyedArray(
653-
array_fill(
654-
$atomic_root_type_array->getMinCount(),
655-
count($atomic_root_type_array->properties)-1,
656-
$array_atomic_type_list,
657-
),
659+
$array_atomic_type,
658660
null,
659661
null,
660662
true,

src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,7 @@ private static function handleArrayAccessOnKeyedArray(
15451545
);
15461546
}
15471547
$properties[0] = $properties[0]->setPossiblyUndefined(
1548-
$replacement_type->possibly_undefined
1548+
$replacement_type->possibly_undefined,
15491549
);
15501550
$properties[$key_value->value] = $properties[$key_value->value]->
15511551
setPossiblyUndefined(true)

src/Psalm/Internal/Type/TypeCombiner.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -676,9 +676,7 @@ private static function scrapeTypeProperties(
676676

677677
if (!$candidate_property_type->possibly_undefined) {
678678
$has_defined_keys = true;
679-
}
680-
681-
if ($combination->fallbackKeyContains($candidate_property_name)) {
679+
} elseif ($combination->fallbackKeyContains($candidate_property_name)) {
682680
$combination->objectlike_entries[$candidate_property_name] = Type::combineUnionTypes(
683681
$combination->objectlike_entries[$candidate_property_name],
684682
$combination->objectlike_value_type,

src/Psalm/Type/Atomic/TKeyedArray.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ public function __construct(
9595
$this->is_list = false;
9696
break;
9797
}
98-
$had_possibly_undefined = $v->possibly_undefined || $had_possibly_undefined;
98+
if ($v->possibly_undefined) {
99+
$had_possibly_undefined = true;
100+
}
99101
$last_k = $k;
100102
}
101103
}
@@ -121,7 +123,9 @@ public function setProperties(array $properties): self
121123
$cloned->is_list = false;
122124
break;
123125
}
124-
$had_possibly_undefined = $v->possibly_undefined || $had_possibly_undefined;
126+
if ($v->possibly_undefined) {
127+
$had_possibly_undefined = true;
128+
}
125129
$last_k = $k;
126130
}
127131
}

src/Psalm/Type/Reconciler.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,10 +1093,6 @@ private static function adjustTKeyedArrayType(
10931093
array &$changed_var_ids,
10941094
Union $result_type
10951095
): void {
1096-
if ($result_type->isNever()) {
1097-
return;
1098-
}
1099-
11001096
array_pop($key_parts);
11011097
$array_key = array_pop($key_parts);
11021098
array_pop($key_parts);

tests/ArrayFunctionCallTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ function getInts(): array { return [123]; }
219219
$result = array_merge($a1, $a2);
220220
',
221221
'assertions' => [
222-
'$result===' => "array{a: 'a2'}"
223-
]
222+
'$result===' => "array{a: 'a2'}",
223+
],
224224
],
225225
'arrayMergeListOfShapes' => [
226226
'code' => '<?php

0 commit comments

Comments
 (0)