-
Notifications
You must be signed in to change notification settings - Fork 548
Implement locateIdentifiersByType for OptimizedDirectorySourceLocator #1080
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 locateIdentifiersByType for OptimizedDirectorySourceLocator #1080
Conversation
22b2511 to
449ba41
Compare
|
Yes, looks great :) |
|
I'll try to implement the functions as well for it to have the same functionality as the source locator. |
|
Making the tests pass is a pain! "Works on my machine"™ 🙈 |
ff08115 to
8cd6edc
Compare
8cd6edc to
ba04fac
Compare
|
That's probably the best I can do :) |
|
Thank you, it's nice. Do you plan to also send PRs for all the other source locators? 😊 |
|
Maybe :) |
|
I'll add these methods to ReflectionProvider once all the sensible source locators support that: /**
* @return array<string, ClassReflection>
*/
public function getAllClasses(): array;
/**
* @return array<string, FunctionReflection>
*/
public function getAllFunctions(): array;
/**
* @return array<string, GlobalConstantReflection>
*/
public function getAllConstants(): array;I don't want to do it sooner because it'd lead to incomplete and confusing results. Please note that it doesn't make sense for some source locators like AutoloadSourceLocator to support this, it's fine for some to still return Also I'm torn if the classes and functions should be indexed by lowercase name or not, probably yeah, so that classes like |
|
BTW: My implementation stems from |
|
And I understand how all source locators need to implement this. Otherwise it's ultra confusing :) |
|
I actually had it previously indexed by lowercase names, but the interface specified |
|
Yes, directory source locator doesn't look for constants, that's fine, people should follow this: https://phpstan.org/user-guide/discovering-symbols#global-constants |
As per phpstan/phpstan#6812 (comment)
Am I on the right track?