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

Fix parsing classes containing anonymous classes #27

Merged
merged 5 commits into from
Jan 13, 2025

Conversation

stevebauman
Copy link
Contributor

@stevebauman stevebauman commented Jan 6, 2025

This PR patches a bug I discovered when it parses a class containing an anonymous class.

When one is encountered, a FQCN is returned in the result with the basename of ( or {, after the FQCN of the one that contained the anonymous class.

For example, if you remove the isAnonymousClass method included in this PR, the below entry is returned in the class list:

$found = Discover::in(__DIR__ . '/Fakes')->get();

var_dump($found); // [..., "Spatie\StructureDiscoverer\Tests\Fakes\(", ...]

I've added a test case to ensure this is resolved, and have also added a case for ensuring files containing multiple class names can be returned as well.

@freekmurze freekmurze merged commit 42d1612 into spatie:main Jan 13, 2025
15 checks passed
@freekmurze
Copy link
Member

Thank you!

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

Successfully merging this pull request may close these issues.

2 participants