-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement ReflectionClass#getInterfaceClassNames()
#1361
Conversation
public function testGetInterfaceNamesWithMissingInterfaceDefinitions(): void | ||
{ | ||
$classInfo = (new DefaultReflector(new SingleFileSourceLocator( | ||
__DIR__ . '/../Fixture/ClassWithMissingInterface.php', | ||
$this->astLocator, | ||
)))->reflectClass(ClassWithMissingInterface::class); | ||
|
||
$this->expectException(IdentifierNotFound::class); | ||
|
||
self::assertNotNull($classInfo->getInterfaceNames()); | ||
} | ||
|
||
public function testGetInterfacesWithMissingInterfaceDefinitions(): void | ||
{ | ||
$classInfo = (new DefaultReflector(new SingleFileSourceLocator( | ||
__DIR__ . '/../Fixture/ClassWithMissingInterface.php', | ||
$this->astLocator, | ||
)))->reflectClass(ClassWithMissingInterface::class); | ||
|
||
$this->expectException(IdentifierNotFound::class); | ||
|
||
self::assertNotNull($classInfo->getInterfaces()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these tests show, that the pre-PR existing API always throws and therefore does not allow to get the interface names, when the class-symbols are not autoloadable.
[ | ||
__DIR__ . '/../Fixture/ClassWithMissingInterface.php', | ||
ClassWithMissingInterface::class, | ||
['Roave\BetterReflectionTest\Fixture\InterfaceThatDoesNotExist'], | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this first test-case shows that we are now able to extract the interface names even if not autoloadable.
the remaining cases add coverage for a few more related cases like autoloadable classes, traits,..
This is a new feature: should go to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM: feel free to send more of these, BTW.
oh sorry. did not relealize 6.12.x is already open |
Yeah, release automation does create a new branch each time :) |
Thanks @staabm! |
ReflectionClass#getInterfaceClassNames()
thank you. I am already working on the "trait-variant" of it |
same motivation as in #1359, but this time for interfaces :-)
refs rectorphp/rector#8093 (comment)
if we agree on this one, I should do another PR for
traits
as a followup