-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Config] Add ReflectionClassResource #21079
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
Comments
Doesnt one actually expect things to invalidate, when working on a class? I understand technically we must given a changed signature, but DX-wise effectively we should only when a comment changes or so. Maybe a hash based on stripped code? Or am i missing something? |
that's exactly what I mean, except that I'd not base that on stripped code, but on reflection info only. |
I missed something. The updated code will of course run as usual in runtime. Pheww. I like it 👍 |
The only "problem" i see is classes that are accessed before compilation and actually used in building. Changing those wont invalidate.. but that's a bad feature anyway ;-) |
@weaverryan already added a similar solution some months ago: #18144 / https://github.com/symfony/symfony/blob/master/src/Symfony/Component/DependencyInjection/Config/AutowireServiceResource.php |
Indeed, I missed that! |
Reopening: autowiring has AutowireServiceResource, but with closure proxies, and getter injection, we're going to need a more generic mechanism. |
…s-grekas) This PR was merged into the 3.3-dev branch. Discussion ---------- [DI][Config] Add & use ReflectionClassResource | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #21079 | License | MIT | Doc PR | - With new changes comming to 3.3, we need a more generic reflection tracking logic than the one already managed by the autowiring subsystem. This PR adds a new ReflectionClassResource in the Config component, and a new ContainerBuilder::getReflectionClass() method in the DI one (for fetching+tracking reflection-related info). ReflectionClassResource tracks changes to any public or protected properties/method. PR updated and ready, best viewed [ignoring whitespaces](https://github.com/symfony/symfony/pull/21419/files?w=1). changelog: * added `ReflectionClassResource` class * added second `$exists` constructor argument to `ClassExistenceResource` - with a special mode that prevents fatal errors from happening when some parent class is broken (logic generalized from AutowiringPass) * made `ClassExistenceResource` also work with interfaces and traits * added `ContainerBuilder::getReflectionClass()` for retrieving and tracking reflection class info * deprecated `ContainerBuilder::getClassResource()`, use `ContainerBuilder::getReflectionClass()` or `ContainerBuilder::addObjectResource()` instead Commits ------- 37e4493 [DI][Config] Add & use ReflectionClassResource
When one uses autowiring, the dumped container watches many source files through
FileResource
objects, thus watching the mtime of referenced files.When one is working on a class and this class is autowired, one sufferes from a big DX penalty: the container is rebuild almost everytime the user refreshed its page.
We should enhance this.
The solution seems to be to create a
ReflectionClassResource
that not only tracks mtimes, but also all signature related reflection info of a given class (+parents), and compares a hash of this to returnisFresh
only when a change is detected there also.Would someone like to give this a try?
The text was updated successfully, but these errors were encountered: