Skip to content

Commit 8c4cb2f

Browse files
committed
Test about BetterReflection Adapter ReflectionEnum return types
These will likely need fixes on 2.0.x because PHP-Parser now represents `null` and `false` in union types differently and considers them namespaced names on PHP 7.x
1 parent 092aee8 commit 8c4cb2f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace AdapterReflectionEnumReturnTypes;
4+
5+
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnum;
6+
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnumBackedCase;
7+
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnumUnitCase;
8+
use function PHPStan\Testing\assertType;
9+
10+
function (ReflectionEnum $r, string $s): void {
11+
assertType('non-empty-string|false', $r->getFileName());
12+
assertType('int|false', $r->getStartLine());
13+
assertType('int|false', $r->getEndLine());
14+
assertType('string|false', $r->getDocComment());
15+
assertType('PHPStan\BetterReflection\Reflection\Adapter\ReflectionClassConstant|false', $r->getReflectionConstant($s));
16+
assertType('PHPStan\BetterReflection\Reflection\Adapter\ReflectionClass|false', $r->getParentClass());
17+
assertType('non-empty-string|false', $r->getExtensionName());
18+
assertType('PHPStan\BetterReflection\Reflection\Adapter\ReflectionNamedType|null', $r->getBackingType());
19+
};
20+
21+
function (ReflectionEnumBackedCase $r): void {
22+
assertType('string|false', $r->getDocComment());
23+
assertType('PHPStan\BetterReflection\Reflection\Adapter\ReflectionIntersectionType|PHPStan\BetterReflection\Reflection\Adapter\ReflectionNamedType|PHPStan\BetterReflection\Reflection\Adapter\ReflectionUnionType|null', $r->getType());
24+
};
25+
26+
function (ReflectionEnumUnitCase $r): void {
27+
assertType('string|false', $r->getDocComment());
28+
assertType('PHPStan\BetterReflection\Reflection\Adapter\ReflectionIntersectionType|PHPStan\BetterReflection\Reflection\Adapter\ReflectionNamedType|PHPStan\BetterReflection\Reflection\Adapter\ReflectionUnionType|null', $r->getType());
29+
};

0 commit comments

Comments
 (0)