Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Dec 12, 2022
1 parent 412732a commit 47e970e
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 11 deletions.
Expand Up @@ -177,7 +177,7 @@ public static function isContainedBy(
&& $atomic_comparison_result->replacement_atomic_type instanceof TGenericObject
&& $atomic_comparison_result_type_params
) {
/** @psalm-suppress InvalidArgument Psalm bug */
/** @psalm-suppress ArgumentTypeCoercion Psalm bug */
$atomic_comparison_result->replacement_atomic_type =
$atomic_comparison_result->replacement_atomic_type
->setTypeParams($atomic_comparison_result_type_params);
Expand Down
8 changes: 4 additions & 4 deletions src/Psalm/Internal/Type/TypeCombiner.php
Expand Up @@ -476,7 +476,7 @@ private static function scrapeTypeProperties(
} else {
foreach ($combination->array_type_params as $i => $array_type_param) {
$iterable_type_param = $combination->builtin_type_params['iterable'][$i];
/** @psalm-suppress InvalidPropertyAssignmentValue */
/** @psalm-suppress PropertyTypeCoercion */
$combination->builtin_type_params['iterable'][$i] = Type::combineUnionTypes(
$iterable_type_param,
$array_type_param
Expand All @@ -497,7 +497,7 @@ private static function scrapeTypeProperties(
} elseif (isset($combination->builtin_type_params['Traversable'])) {
foreach ($combination->builtin_type_params['Traversable'] as $i => $array_type_param) {
$iterable_type_param = $combination->builtin_type_params['iterable'][$i];
/** @psalm-suppress InvalidPropertyAssignmentValue */
/** @psalm-suppress PropertyTypeCoercion */
$combination->builtin_type_params['iterable'][$i] = Type::combineUnionTypes(
$iterable_type_param,
$array_type_param
Expand Down Expand Up @@ -615,7 +615,7 @@ private static function scrapeTypeProperties(
|| ($type instanceof TArray && $type_key === 'iterable')
) {
foreach ($type->type_params as $i => $type_param) {
/** @psalm-suppress InvalidPropertyAssignmentValue */
/** @psalm-suppress PropertyTypeCoercion */
$combination->builtin_type_params[$type_key][$i] = Type::combineUnionTypes(
$combination->builtin_type_params[$type_key][$i] ?? null,
$type_param,
Expand All @@ -629,7 +629,7 @@ private static function scrapeTypeProperties(

if ($type instanceof TGenericObject) {
foreach ($type->type_params as $i => $type_param) {
/** @psalm-suppress InvalidPropertyAssignmentValue */
/** @psalm-suppress PropertyTypeCoercion */
$combination->object_type_params[$type_key][$i] = Type::combineUnionTypes(
$combination->object_type_params[$type_key][$i] ?? null,
$type_param,
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/IssueBuffer.php
Expand Up @@ -647,7 +647,7 @@ public static function finish(
// do nothing
}

/** @psalm-suppress InvalidArgument due to Psalm bug */
/** @psalm-suppress ArgumentTypeCoercion due to Psalm bug */
$event = new AfterAnalysisEvent(
$codebase,
$issues_data,
Expand Down
2 changes: 2 additions & 0 deletions src/Psalm/Type/Atomic/TKeyedArray.php
Expand Up @@ -519,6 +519,7 @@ public function replaceTemplateTypesWithStandins(
}
$cloned = clone $this;
$cloned->properties = $properties;
/** @psalm-suppress PropertyTypeCoercion */
$cloned->fallback_params = $fallback_params;
return $cloned;
}
Expand Down Expand Up @@ -549,6 +550,7 @@ public function replaceTemplateTypesWithArgTypes(
if ($properties !== $this->properties || $fallback_params !== $this->fallback_params) {
$cloned = clone $this;
$cloned->properties = $properties;
/** @psalm-suppress PropertyTypeCoercion */
$cloned->fallback_params = $fallback_params;
return $cloned;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ArgTest.php
Expand Up @@ -630,7 +630,7 @@ function foo(int ...$values): array
return $values;
}
',
'error_message' => 'InvalidReturnStatement',
'error_message' => 'LessSpecificReturnStatement',
],
'preventUnpackingPossiblyIterable' => [
'code' => '<?php
Expand Down
2 changes: 1 addition & 1 deletion tests/ArrayAccessTest.php
Expand Up @@ -1355,7 +1355,7 @@ function takesList(array $arr) : array {
return $arr;
}',
'error_message' => 'InvalidReturnStatement',
'error_message' => 'LessSpecificReturnStatement',
],
'simpleXmlArrayFetchResultCannotEqualString' => [
'code' => '<?php
Expand Down
2 changes: 1 addition & 1 deletion tests/ArrayAssignmentTest.php
Expand Up @@ -2350,7 +2350,7 @@ function getList(array $list): array {
return $list;
}',
'error_message' => 'InvalidReturnStatement',
'error_message' => 'LessSpecificReturnStatement',
],
// Skipped because the ref-type of array_pop was fixed (list->list)
'SKIPPED-assignToListWithAlteredForeachKeyVar' => [
Expand Down
2 changes: 1 addition & 1 deletion tests/ArrayFunctionCallTest.php
Expand Up @@ -2528,7 +2528,7 @@ function foo($data): void {
function ints(array $ints) : void {}
$brr = array_filter([2,3,0,4,5]);
ints($brr);',
'error_message' => 'InvalidArgument',
'error_message' => 'ArgumentTypeCoercion',
],
'usortOneParamInvalid' => [
'code' => '<?php
Expand Down
2 changes: 1 addition & 1 deletion tests/ListTest.php
Expand Up @@ -191,7 +191,7 @@ function getKey() {
$a = [getKey() => 1];
takesList($a);',
'error_message' => 'InvalidArgument',
'error_message' => 'ArgumentTypeCoercion',
],
];
}
Expand Down

0 comments on commit 47e970e

Please sign in to comment.