Skip to content

Commit 72952cb

Browse files
phpstan-botclaude
andcommitted
Add unit tests for NeverType and NonAcceptingNeverType isSuperTypeOf TemplateType
Tests both NeverType and NonAcceptingNeverType return Maybe when checking isSuperTypeOf against a TemplateType, since a template type can be instantiated to never. Tests with both unbound and bounded template types. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4e894ee commit 72952cb

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

tests/PHPStan/Type/TemplateTypeTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,30 @@ public static function dataIsSuperTypeOf(): array
281281
TrinaryLogic::createMaybe(),
282282
TrinaryLogic::createYes(),
283283
],
284+
23 => [
285+
$templateType('T', null),
286+
new NeverType(),
287+
TrinaryLogic::createYes(), // T isSuperTypeTo *NEVER* - never is bottom type
288+
TrinaryLogic::createMaybe(), // *NEVER* isSuperTypeTo T - T could be never
289+
],
290+
24 => [
291+
$templateType('T', null),
292+
new NonAcceptingNeverType(),
293+
TrinaryLogic::createYes(), // T isSuperTypeTo never - never is bottom type
294+
TrinaryLogic::createMaybe(), // never isSuperTypeTo T - T could be never
295+
],
296+
25 => [
297+
$templateType('T', new ObjectType('DateTime')),
298+
new NeverType(),
299+
TrinaryLogic::createYes(), // (T of DateTime) isSuperTypeTo *NEVER* - never is bottom type
300+
TrinaryLogic::createMaybe(), // *NEVER* isSuperTypeTo (T of DateTime) - T could be never
301+
],
302+
26 => [
303+
$templateType('T', new ObjectType('DateTime')),
304+
new NonAcceptingNeverType(),
305+
TrinaryLogic::createYes(), // (T of DateTime) isSuperTypeTo never - never is bottom type
306+
TrinaryLogic::createMaybe(), // never isSuperTypeTo (T of DateTime) - T could be never
307+
],
284308
];
285309
}
286310

0 commit comments

Comments
 (0)