-
-
Notifications
You must be signed in to change notification settings - Fork 321
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
__destruct
magic method being called before lazy Proxy creates value
#669
Comments
That's interesting, thank you for reporting. It might be worth asking at https://github.com/Ocramius/ProxyManager which is the library that handles that. |
Well, we have some issues there that will need me to take some time to read, I'm linking'em here:
Also, I registered the issue there, because I can't investigate right now: Ocramius/ProxyManager#468 |
I'm afraid we gonna have to handle that case by our own by using the same solution: Ocramius/ProxyManager#373 (comment) |
I'm doing some debugging, the error occurs right after this method... PHP-DI/src/Proxy/ProxyFactory.php Lines 56 to 61 in 65987ec
The class reported in the issue is in a <?php
return [
OTHER_CLASS_Interface::class => DI\autowire(OTHER_CLASS::class),
]; This is the call stack:
The error message:
|
When the class gets destroyed in its life cycle, the
__destruct
method gets called and, if there's one implementation in the original class, the proxy class tries to execute the base class implementation. But looks like the proxy class is getting destroyed before creating a instance for the base class and, as there's no check for null values, we get the following error:The project path and class full qualified names were hidden because it's a private project, where the class is related to database connectivity.
That class just access authorization data and creates a new connection instance. The
__destruct
method implementation exists to ensure the connection will be closed when the class gets destroyed.In this scenario the class was never used and that's why I believe it's getting destructed before creating an instance for the original class.
The text was updated successfully, but these errors were encountered: