-
-
Notifications
You must be signed in to change notification settings - Fork 190
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 test PR #471
__destruct test PR #471
Conversation
This is the correct way to design the test, but it doesn't seem to reproduce the original issue |
$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($configuration); | ||
|
||
$proxy = $factory->createProxy(Destructable::class, function (& $wrapped, $proxy, $method, array $parameters, & $initializer) { | ||
$initializer = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should throw to reproduce the issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will have to ask @mnapoli about how container proxies works, because it only happens with this option enabled. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I'm not familiar with the issue here sorry. But I don't see why an exception should be thrown, especially if the test case reproduces the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@odahcam the issue is not reproduced here:
1) /home/travis/build/Ocramius/ProxyManager/tests/language-feature-scripts/lazy-loading-__destruct-throws.phpt
Failed asserting that string matches format description.
--- Expected
+++ Actual
@@ @@
-%SUncaught Error:%sCall to a member function __destruct() on null in %a
/home/travis/build/Ocramius/ProxyManager/tests/language-feature-scripts/lazy-loading-__destruct-throws.phpt:26
@mnapoli I'm also having trouble in understanding the full scenario for this issue, sorry...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yesterday I started to think this is a issue with PHP-DI, since the problem only occours when I enable the option $container->writeProxiesToFiles(true, 'folder/path')
. If @mnapoli could explain what that method does I would understand it better.
@Ocramius maybe here PHP-DI/PHP-DI#669 you can find more information.
At the end I don't know what exactly is happening either, I'm just facing the problem, where one of the proxies generated by PHP-DI using this library throws inside a __destruct
method because the instance of the class the proxy is for is null inside the proxy class. Yes confusing and strange.
As you can see, things are null here:
And then the error occours:
Maybe you understand better than me whats happening.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the initializer there? It got called, but not reset to null
, which to me smells like it threw an exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't store such information, but I'm pretty sure that the engine will aggressively call __destruct()
anyway.
I'd use a step debugger and put breakpoints on any of the API of the generated code.
Note: this was closed due to |
Maybe we should open an issue pointing to this PR. |
No description provided.