mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Make sure weak equality clauses don’t generate ParadoxicalCondition
This commit is contained in:
parent
9f28be415a
commit
d46997b196
@ -155,7 +155,9 @@ class Algebra
|
||||
[$var => [$type]],
|
||||
false,
|
||||
true,
|
||||
$type[0] === '^' || (strlen($type) > 1 && $type[1] === '^')
|
||||
$type[0] === '^'
|
||||
|| $type[0] === '~'
|
||||
|| (strlen($type) > 1 && ($type[1] === '^' || $type[1] === '~'))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -409,6 +409,16 @@ class SwitchTypeTest extends TestCase
|
||||
}
|
||||
}',
|
||||
],
|
||||
'switchNullable4' => [
|
||||
'<?php
|
||||
function foo(?string $s, string $a, string $b) : void {
|
||||
switch ($s) {
|
||||
case $a:
|
||||
case $b:
|
||||
break;
|
||||
}
|
||||
}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -797,6 +797,28 @@ class TypeReconciliationTest extends TestCase
|
||||
}
|
||||
}',
|
||||
],
|
||||
'reconcileNullableStringWithStrictEqualityStrings' => [
|
||||
'<?php
|
||||
function foo(?string $s, string $a, string $b) : void {
|
||||
if ($s === $a || $s === $b) {
|
||||
if ($s === $a) {
|
||||
echo "cool";
|
||||
}
|
||||
echo "cooler";
|
||||
}
|
||||
}',
|
||||
],
|
||||
'reconcileNullableStringWithWeakEqualityStrings' => [
|
||||
'<?php
|
||||
function foo(?string $s, string $a, string $b) : void {
|
||||
if ($s == $a || $s == $b) {
|
||||
if ($s == $a) {
|
||||
echo "cool";
|
||||
}
|
||||
echo "cooler";
|
||||
}
|
||||
}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user