Skip to content

Commit

Permalink
Trait method rename with wrong case should still work
Browse files Browse the repository at this point in the history
  • Loading branch information
kukulich committed Sep 17, 2021
1 parent c568af2 commit 0ba851c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Reflection/ReflectionClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ private function methodHash(string $className, string $methodName): string
return sprintf(
'%s::%s',
$className,
$methodName,
strtolower($methodName),
);
}

Expand Down
29 changes: 29 additions & 0 deletions test/unit/Reflection/ReflectionClassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1882,4 +1882,33 @@ class Foo
self::assertCount(2, $constants);
self::assertSame($expectedConstants, $constants);
}

public function testTraitRenamingMethodWithWrongCaseShouldStillWork(): void
{
$php = <<<'PHP'
<?php
trait MyTrait
{
protected function myMethod() : void{
}
}
class HelloWorld
{
use MyTrait {
MyMethod as myRenamedMethod;
}
public function sayHello(int $date): void
{
$this->myRenamedMethod();
}
}
PHP;

$reflection = (new ClassReflector(new StringSourceLocator($php, $this->astLocator)))->reflect('HelloWorld');
self::assertTrue($reflection->hasMethod('myRenamedMethod'));
}
}

0 comments on commit 0ba851c

Please sign in to comment.