-
Notifications
You must be signed in to change notification settings - Fork 310
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 "autoload warmers" so tab completion and PsySH commands work with all classes. #650
Comments
What about just using composer's optimised autoloading mechanism. That already produces class mappings for us. |
Moreover, it means we don't need to care about the (auto)loading mech ism for classes. They need not be PSR-0/4, even (which means requiring the files could have side effects other than defining a class/interface/trait). |
I mean, I use |
Composer's That runs on PsySH's source in ~0.02s, which is fast enough to do once on every shell session and just store it in memory. |
Adding a dependency on |
The problem with doing that is we could require files that are not meant to be required. That is just doing the "classmap" strategy, right? |
The best strategy, I think, is just do an optimised autoload dump, possibly to some temp location, to give us an accurate list of all the classes, defined by the autoloading strategies from people's composer.json files, and that of the dependencies? |
playing with a hacked up version of this, i'm not convinced we want to pre-warm so maybe we make it opt-in? prefix based? namespace based? there's a sweet spot somewhere in here, but i'm not sure it's "every class known to composer". |
i imagine it would be an interface, and maybe a couple of implementations. one based on composer, that reads either configs or generated autoloaders, uses them to enumerate all possible classes. another could be symfony finder based, and walk the filesystem according to the finder rules.
in all cases, we probably just want them to emit a list of files which possibly / probably contain classes, then use php parser to parse the file and make sure (1) it's valid PHP and won't error, (2) it contains only class and function definitions at the top level, not things that probably have side effects.
Originally posted by @bobthecow in #539 (comment)
👆See that issue for more discussion.
The text was updated successfully, but these errors were encountered: