Skip to content

Commit a9fe295

Browse files
committed
Test for unions of enums
1 parent 0dba054 commit a9fe295

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/PHPStan/Type/TypeCombinatorTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
use InvalidArgumentException;
1515
use Iterator;
1616
use ObjectShapesAcceptance\ClassWithFooIntProperty;
17+
use PHPStan\Fixture\AnotherTestEnum;
1718
use PHPStan\Fixture\FinalClass;
19+
use PHPStan\Fixture\TestEnum;
20+
use PHPStan\Fixture\TestEnumInterface;
1821
use PHPStan\Testing\PHPStanTestCase;
1922
use PHPStan\Type\Accessory\AccessoryLiteralStringType;
2023
use PHPStan\Type\Accessory\AccessoryNonEmptyStringType;
@@ -2494,6 +2497,34 @@ public function dataUnion(): iterable
24942497
UnionType::class,
24952498
'array{a?: true, b: true}|(array{a?: true, c?: true}&non-empty-array)',
24962499
];
2500+
2501+
yield [
2502+
[
2503+
new EnumCaseObjectType(AnotherTestEnum::class, 'ONE'),
2504+
new EnumCaseObjectType(AnotherTestEnum::class, 'TWO'),
2505+
new ObjectType(TestEnumInterface::class),
2506+
],
2507+
UnionType::class,
2508+
'PHPStan\Fixture\AnotherTestEnum::ONE|PHPStan\Fixture\AnotherTestEnum::TWO|PHPStan\Fixture\TestEnumInterface',
2509+
];
2510+
yield [
2511+
[
2512+
new EnumCaseObjectType(TestEnum::class, 'ONE'),
2513+
new EnumCaseObjectType(TestEnum::class, 'TWO'),
2514+
new ObjectType(TestEnumInterface::class),
2515+
],
2516+
ObjectType::class,
2517+
TestEnumInterface::class,
2518+
];
2519+
yield [
2520+
[
2521+
new EnumCaseObjectType(TestEnum::class, 'ONE'),
2522+
new EnumCaseObjectType(TestEnum::class, 'TWO'),
2523+
new ObjectWithoutClassType(),
2524+
],
2525+
ObjectWithoutClassType::class,
2526+
'object',
2527+
];
24972528
}
24982529

24992530
/**

0 commit comments

Comments
 (0)