Skip to content

Commit

Permalink
Tests that final modifier when using a method from a trait is allowed
Browse files Browse the repository at this point in the history
  • Loading branch information
kukulich committed Dec 2, 2023
1 parent e0f312c commit ce959aa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/unit/Fixture/TraitFixture.php
Expand Up @@ -133,3 +133,10 @@ class TraitFixtureF
}

}

class TraitFixtureWithFinal
{
use TraitFixtureTraitA {
foo as final;
}
}
15 changes: 15 additions & 0 deletions test/unit/Reflection/ReflectionClassTest.php
Expand Up @@ -15,6 +15,7 @@
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\RequiresPhp;
use PHPUnit\Framework\TestCase;
use Qux;
use ReflectionClass as CoreReflectionClass;
Expand Down Expand Up @@ -1617,6 +1618,20 @@ public function testMethodsFromTraits(): void
self::assertSame('TraitFixtureTraitC2', $classInfo->getMethod('d_renamed')->getDeclaringClass()->getName());
}

#[RequiresPhp('8.3')]
public function testMethodsFromTraitsWithFinal(): void
{
$reflector = new DefaultReflector(new SingleFileSourceLocator(
__DIR__ . '/../Fixture/TraitFixture.php',
$this->astLocator,
));

$classInfo = $reflector->reflectClass('TraitFixtureWithFinal');

self::assertTrue($classInfo->hasMethod('foo'));
self::assertTrue($classInfo->getMethod('foo')->isFinal());
}

public function testMethodsFromTraitsWithConflicts(): void
{
$reflector = new DefaultReflector(new SingleFileSourceLocator(
Expand Down

0 comments on commit ce959aa

Please sign in to comment.