1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00
This commit is contained in:
Daniil Gentili 2022-07-27 20:24:24 +02:00
parent 68f3f246f5
commit 6ce32a48d5
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 13 additions and 1 deletions

View File

@ -697,8 +697,13 @@ abstract class Type
TIntRange::convertToIntRange($type_1_atomic),
TIntRange::convertToIntRange($type_2_atomic)
);
if ($intersection_atomic) {
if ($intersection_atomic
&& ($intersection_atomic->min_bound !== null || $intersection_atomic->max_bound !== null)
) {
$intersection_performed = true;
if ($intersection_atomic->min_bound === $intersection_atomic->max_bound) {
return new TLiteralInt($intersection_atomic->min_bound);
}
return $intersection_atomic;
}
}

View File

@ -213,6 +213,13 @@ class TypeParseTest extends TestCase
$this->assertSame('array{a: int}', (string) Type::parseString('array{a: int}&array{a?: int}'));
}
public function testIntersectionOfIntranges(): void
{
$this->assertSame('array{a: int<3, 4>}', (string) Type::parseString('array{a: int<2, 4>}&array{a: int<3, 6>}'));
$this->assertSame('array{a: 4}', Type::parseString('array{a: 4}&array{a: int<3, 6>}')->getId(true));
}
public function testIntersectionOfTKeyedArrayWithConflictingProperties(): void
{
$this->expectException(TypeParseTreeException::class);