Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Dec 19, 2022
1 parent 4ea5329 commit d553bbe
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 28 deletions.
21 changes: 10 additions & 11 deletions psalm-baseline.xml
@@ -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>
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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">
<code>$type_tokens[$i - 1]</code>
<code>$type_tokens[$i - 1]</code>
<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 - 2]</code>
</PossiblyInvalidArrayOffset>
</file>
<file src="src/Psalm/Storage/ClassConstantStorage.php">
Expand Down
Expand Up @@ -649,12 +649,14 @@ private static function updateArrayAssignmentChildType(
]);
} 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,
Expand Down
Expand Up @@ -1545,7 +1545,7 @@ private static function handleArrayAccessOnKeyedArray(
);
}
$properties[0] = $properties[0]->setPossiblyUndefined(
$replacement_type->possibly_undefined
$replacement_type->possibly_undefined,
);
$properties[$key_value->value] = $properties[$key_value->value]->
setPossiblyUndefined(true)
Expand Down
2 changes: 2 additions & 0 deletions src/Psalm/Internal/Cli/LanguageServer.php
Expand Up @@ -322,6 +322,8 @@ static function (string $arg) use ($valid_long_options): void {
$project_analyzer->language_server_verbose = true;
}

/** @psalm-trace $options */;
/** @psalm-trace $options['tcp'] */;
$project_analyzer->server($options['tcp'] ?? null, isset($options['tcp-server']));
}
}
4 changes: 1 addition & 3 deletions src/Psalm/Internal/Type/TypeCombiner.php
Expand Up @@ -676,9 +676,7 @@ private static function scrapeTypeProperties(

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,
Expand Down
8 changes: 6 additions & 2 deletions src/Psalm/Type/Atomic/TKeyedArray.php
Expand Up @@ -95,7 +95,9 @@ public function __construct(
$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;
}
}
Expand All @@ -121,7 +123,9 @@ public function setProperties(array $properties): self
$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;
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/Psalm/Type/Reconciler.php
Expand Up @@ -1093,10 +1093,6 @@ private static function adjustTKeyedArrayType(
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);
Expand Down
4 changes: 2 additions & 2 deletions tests/ArrayFunctionCallTest.php
Expand Up @@ -219,8 +219,8 @@ function getInts(): array { return [123]; }
$result = array_merge($a1, $a2);
',
'assertions' => [
'$result===' => "array{a: 'a2'}"
]
'$result===' => "array{a: 'a2'}",
],
],
'arrayMergeListOfShapes' => [
'code' => '<?php
Expand Down

0 comments on commit d553bbe

Please sign in to comment.