File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 3434use PHPUnit \Framework \Attributes \RequiresPhp ;
3535use PHPUnit \Framework \TestCase ;
3636use ReflectionClass ;
37+ use SomeNamespace \ClassWithConstants ;
3738use WrongClassConstantFile \SecuredRouter ;
3839use function array_map ;
3940use function array_values ;
@@ -191,6 +192,19 @@ public function testDeprecatedConstantFromAnotherFile(): void
191192 $ this ->assertTrue ($ constant ->isDeprecated ()->yes ());
192193 }
193194
195+ public function testFinalConstant (): void
196+ {
197+ $ reflectionProvider = self ::createReflectionProvider ();
198+ $ reflection = $ reflectionProvider ->getClass (ClassWithConstants::class);
199+ $ constant = $ reflection ->getConstant ('FINAL_FROM_DOCBLOCK ' );
200+ $ this ->assertTrue ($ constant ->isFinal ());
201+ $ this ->assertFalse ($ constant ->isFinalByKeyword ());
202+
203+ $ constant = $ reflection ->getConstant ('NATIVE_FINAL ' );
204+ $ this ->assertTrue ($ constant ->isFinal ());
205+ $ this ->assertTrue ($ constant ->isFinalByKeyword ());
206+ }
207+
194208 /**
195209 * @param class-string $className
196210 * @param array<class-string, class-string> $expected
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace SomeNamespace ;
4+
5+ class ClassWithConstants
6+ {
7+ /**
8+ * @final
9+ */
10+ public const FINAL_FROM_DOCBLOCK = 'final from docblock ' ;
11+
12+ public final const NATIVE_FINAL = 'native final ' ;
13+ }
You can’t perform that action at this time.
0 commit comments