-
-
Notifications
You must be signed in to change notification settings - Fork 324
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
Document limitations when using lazy loaded dependencies that involve variadic functions #359
Comments
Well thank you for going so far in the debugging :) Ping @Ocramius. It seems Ocramius/ProxyManager#177 is about supporting PHP 5.6's variadics (the |
@mnapoli I still need to pack variadics, scalar type hints and return type hints into ProxyManager. |
Just to be sure, when you say variadics you also mean "PHP < 5.6 kind of variadics" which consists of passing more parameters than defined right? In that case indeed we could document in PHP-DI that this is not supported right now to avoid confusion. |
No, I mean 5.6 variadics ( Pre-PHP-5.6 "variadic arguments" are totally ignored. Going to open an issue for that now. |
Note: this is also broken in doctrine2, now that I notice it (known, but undocumented limitation). Actually, the lazy loading ghost objects in ProxyManager 2.x work with that one, but I still need to implement them. Opened Ocramius/ProxyManager#265 to track that, thanks! |
Thanks! |
I provided documentation for this sort of problem in ProxyManager and fixed the support of variadic arguments in the 2.x branch. There is also a possible resolution path for this particular issue at Ocramius/ProxyManager#269, but it is complex and for a super-edge case. I'll get a 2.0 release out soon, but be aware that:
|
👍 I was just reading this ;) Thanks |
just checking on the status on this to see whether this issue can be closed... ProxyManager 2.0 have been released for a while now and Ocramius/ProxyManager#265 is closed. But I am not sure whether the named 'Ghost objects' which should support the pre-PHP-5.6 variadic functions is already implemented. |
But it seems that v2 requires PHP 7 right? |
aah, yeah seems to be the case: https://github.com/Ocramius/ProxyManager/blob/6c89b7bd6039d8047b1473e2074cb56baa4bc15d/composer.json#L22 Can we then conclude this will not be resolved for the time being and this limitation needs to be documented? |
Yep! |
Note: you can require As for the rest: you simply need to document that lazy services with variadic signatures require PHP 7 and the latest ProxyManager. |
👍 good idea! Thanks for the links |
Aah, nice approach 😉 |
@mnapoli are you considering adopting the suggestion of @Ocramius ? Guess it would be similar to: https://github.com/doctrine/migrations/blob/5f9429e5e6dd31d0f36c8951daa184112a39e195/composer.json#L18 |
Oh yes I'm definitely up for it, I just didn't have time to implement it yet. I guess what's to do:
If you are up for it I'll be 👍 to merge it! |
Fixed in #414 (PHP-DI can now be installed with ProxyManager ~1.0 or ~2.0). |
@mnapoli awesome! I really hope to push those 2.0 installations up (too many 1.x users ;-) ) |
When using lazy loaded dependencies, I encountered some curious behaviour when handing over more parameters to a function than defined in its signature (variadic functions).
Now let's try to use this Service when fetched from the dependency injection container
I use this approach to inject extra variables when translating messages like: "User X has logged in on Y", where X and Y would be 'additional' parameters.
This probably has to do with the intermediate proxy classes that are generated. For example from a generated proxy class:
When looking at Ocramius/ProxyManager#177, I think this behaviour is expected. Therefore I think it should be mentioned in the documentation as a warning...
The text was updated successfully, but these errors were encountered: