mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix reconciliation of ored types
This commit is contained in:
parent
69338abf7c
commit
9f28be415a
@ -105,7 +105,7 @@ class Reconciler
|
||||
foreach ($new_type_part_parts as $new_type_part_part) {
|
||||
$result_type_candidate = self::reconcileTypes(
|
||||
$new_type_part_part,
|
||||
$result_type,
|
||||
$result_type ? clone $result_type : null,
|
||||
$key,
|
||||
$statements_checker,
|
||||
$code_location && isset($referenced_var_ids[$key]) ? $code_location : null,
|
||||
|
@ -364,6 +364,51 @@ class SwitchTypeTest extends TestCase
|
||||
}
|
||||
}',
|
||||
],
|
||||
'switchNullable1' => [
|
||||
'<?php
|
||||
function foo(?string $s) : void {
|
||||
switch ($s) {
|
||||
case "hello":
|
||||
case "goodbye":
|
||||
echo "cool";
|
||||
break;
|
||||
case "hello again":
|
||||
echo "cool";
|
||||
break;
|
||||
}
|
||||
}',
|
||||
],
|
||||
'switchNullable2' => [
|
||||
'<?php
|
||||
function foo(?string $s) : void {
|
||||
switch ($s) {
|
||||
case "hello":
|
||||
echo "cool";
|
||||
case "goodbye":
|
||||
echo "cooler";
|
||||
break;
|
||||
case "hello again":
|
||||
echo "cool";
|
||||
break;
|
||||
}
|
||||
}',
|
||||
],
|
||||
'switchNullable3' => [
|
||||
'<?php
|
||||
function foo(?string $s) : void {
|
||||
switch ($s) {
|
||||
case "hello":
|
||||
echo "cool";
|
||||
break;
|
||||
case "goodbye":
|
||||
echo "cool";
|
||||
break;
|
||||
case "hello again":
|
||||
echo "cool";
|
||||
break;
|
||||
}
|
||||
}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -786,6 +786,17 @@ class TypeReconciliationTest extends TestCase
|
||||
}
|
||||
}'
|
||||
],
|
||||
'reconcileNullableStringWithWeakEquality' => [
|
||||
'<?php
|
||||
function foo(?string $s) : void {
|
||||
if ($s == "hello" || $s == "goodbye") {
|
||||
if ($s == "hello") {
|
||||
echo "cool";
|
||||
}
|
||||
echo "cooler";
|
||||
}
|
||||
}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user