File tree Expand file tree Collapse file tree 6 files changed +43
-2
lines changed Expand file tree Collapse file tree 6 files changed +43
-2
lines changed Original file line number Diff line number Diff line change 2727 $ parameters ->set (Option::PHP_VERSION_FEATURES , $ targetPhpVersionId );
2828 $ parameters ->set (Option::SKIP , [
2929 'tests/*/data/* ' ,
30+ 'tests/*/Fixture/* ' ,
3031 'tests/PHPStan/Analyser/traits/* ' ,
3132 'tests/PHPStan/Generics/functions.php ' ,
3233 'tests/e2e/resultCache_1.php ' ,
Original file line number Diff line number Diff line change 166166 </properties >
167167 </rule >
168168 <exclude-pattern >tests/*/data</exclude-pattern >
169+ <exclude-pattern >tests/*/Fixture</exclude-pattern >
169170 <exclude-pattern >tests/e2e/resultCache_1.php</exclude-pattern >
170171 <exclude-pattern >tests/e2e/resultCache_2.php</exclude-pattern >
171172 <exclude-pattern >tests/e2e/resultCache_3.php</exclude-pattern >
Original file line number Diff line number Diff line change @@ -945,10 +945,13 @@ public function isInternal(): bool
945945
946946 public function isFinal (): bool
947947 {
948+ if ($ this ->isFinalByKeyword ()) {
949+ return true ;
950+ }
951+
948952 if ($ this ->isFinal === null ) {
949953 $ resolvedPhpDoc = $ this ->getResolvedPhpDoc ();
950- $ this ->isFinal = $ this ->reflection ->isFinal ()
951- || ($ resolvedPhpDoc !== null && $ resolvedPhpDoc ->isFinal ());
954+ $ this ->isFinal = $ resolvedPhpDoc !== null && $ resolvedPhpDoc ->isFinal ();
952955 }
953956
954957 return $ this ->isFinal ;
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 ); // lint >= 8.1
2+
3+ namespace PHPStan \Fixture ;
4+
5+ enum TestEnum: int implements TestEnumInterface
6+ {
7+
8+ case ONE = 1 ;
9+ case TWO = 2 ;
10+ const CONST_ONE = 1 ;
11+
12+ }
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 ); // lint >= 8.1
2+
3+ namespace PHPStan \Fixture ;
4+
5+ interface TestEnumInterface
6+ {
7+
8+ }
Original file line number Diff line number Diff line change 2828use NestedTraits \BazTrait ;
2929use NestedTraits \NoTrait ;
3030use PHPStan \Broker \Broker ;
31+ use PHPStan \Fixture \TestEnum ;
3132use PHPStan \Php \PhpVersion ;
3233use PHPStan \PhpDoc \PhpDocInheritanceResolver ;
3334use PHPStan \PhpDoc \StubPhpDocProvider ;
3435use PHPStan \Testing \PHPStanTestCase ;
3536use PHPStan \Type \FileTypeMapper ;
3637use ReflectionClass ;
38+ use ReflectionEnum ;
3739use WrongClassConstantFile \SecuredRouter ;
3840use function array_map ;
3941use function array_values ;
@@ -324,4 +326,18 @@ public function dataNestedRecursiveTraits(): array
324326 ];
325327 }
326328
329+ public function testEnumIsFinal (): void
330+ {
331+ if (PHP_VERSION_ID < 80100 ) {
332+ $ this ->markTestSkipped ('Test requires PHP 8.1. ' );
333+ }
334+
335+ $ reflectionProvider = $ this ->createReflectionProvider ();
336+ $ enum = $ reflectionProvider ->getClass (TestEnum::class);
337+ $ this ->assertTrue ($ enum ->isEnum ());
338+ $ this ->assertInstanceOf (ReflectionEnum::class, $ enum ->getNativeReflection ());
339+ $ this ->assertTrue ($ enum ->isFinal ());
340+ $ this ->assertTrue ($ enum ->isFinalByKeyword ());
341+ }
342+
327343}
You can’t perform that action at this time.
0 commit comments