Skip to content
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

Merged
merged 1 commit into from
Aug 7, 2023

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Aug 7, 2023

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

Comment on lines +429 to +451
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());
}
Copy link
Contributor Author

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.

@Ocramius Ocramius added this to the 6.12.0 milestone Aug 7, 2023
Comment on lines +472 to +476
[
__DIR__ . '/../Fixture/ClassWithMissingInterface.php',
ClassWithMissingInterface::class,
['Roave\BetterReflectionTest\Fixture\InterfaceThatDoesNotExist'],
],
Copy link
Contributor Author

@staabm staabm Aug 7, 2023

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,..

@Ocramius
Copy link
Member

Ocramius commented Aug 7, 2023

This is a new feature: should go to 6.12.x :-)

@Ocramius Ocramius changed the base branch from 6.11.x to 6.12.x August 7, 2023 12:34
Copy link
Member

@Ocramius Ocramius left a 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.

@staabm
Copy link
Contributor Author

staabm commented Aug 7, 2023

oh sorry. did not relealize 6.12.x is already open

@Ocramius
Copy link
Member

Ocramius commented Aug 7, 2023

Yeah, release automation does create a new branch each time :)

@Ocramius Ocramius self-assigned this Aug 7, 2023
@Ocramius Ocramius merged commit 350fb40 into Roave:6.12.x Aug 7, 2023
23 checks passed
@Ocramius
Copy link
Member

Ocramius commented Aug 7, 2023

Thanks @staabm!

@Ocramius Ocramius changed the title Implement ReflectionClass->getInterfaceClassNames() Implement `ReflectionClass->getInterfaceClassNames() Aug 7, 2023
@staabm staabm deleted the interfaces branch August 7, 2023 13:03
@Ocramius Ocramius changed the title Implement `ReflectionClass->getInterfaceClassNames() Implement ReflectionClass#getInterfaceClassNames() Aug 7, 2023
@staabm
Copy link
Contributor Author

staabm commented Aug 7, 2023

thank you. I am already working on the "trait-variant" of it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants