-
-
Notifications
You must be signed in to change notification settings - Fork 192
Fixed #364 #404
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
Fixed #364 #404
Conversation
|
Requires a test case |
|
|
||
| $strategy = $this->configuration->getGeneratorStrategy(); | ||
|
|
||
| if ($strategy instanceof FileWriterGeneratorStrategy) { |
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.
This couples the factory implementation to an implementation of the GeneratorStrategy - please don't do this. The only assumption is that you get a generator strategy, but you can't upcast and check it.
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.
@Ocramius. Please check, it is updated.
|
@Ocramius. There is problem with loaders like as ZF1 they doesn't check is the file exists and try to include him. So when you use class_exists() second parameter autoload=true by default it's tried to load proxy file than is not generated yet. And error on including this not found file will happen. Unfortunately I don't not how to register the autoload function that will make error in test. Adding autoload function must be not in tests - another not will not work, if you know how it can be simulated i'll be grateful. |
|
@MadLexx check https://github.com/Ocramius/ProxyManager/tree/master/tests/language-feature-scripts for the absolute simplest way to implement such a test. You can register an autoloader in a |
|
@Ocramius These tests seem to work. Thanks. Please check. |
|
@Ocramius Please check is this realization is good for you? Thanks. |
|
|
||
| spl_autoload_register(function ($name) use ($fqcn) { | ||
| if ($name === $fqcn) { | ||
| throw new \Exception(sprintf("Cannot load class %s", $name)); |
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.
Oh, now I understand what the bug is about. I don't think this needs fixing, tbh - this is a broken autoloader, not a broken ProxyManager detail.
The simplest solution for this is to have the proxy autoloader on top of the autoload stack, but overall the sanest solution is to trash the broken autoloader. Autoloaders should have a :bool signature and only crash on fatals...
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.
@Ocramius. Thanks for comment. I understand this, but many old projects has "bad" autoloader, and this fix can make them work. In another side if proxies does not generated before script run we will have error even if the proxy autoloader are registered at top. ZF1 one of "wrong" loader examples. Unfortunately not all projects has composer autoloader or has custom autoloader that followed by best practices.
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.
With this patch they will generate proxy if they don't generated for "file write" strategy without the work break.
|
Was this supposed to be closed? |
Fixed issue #364. File does not written because autoload executing much earlier than boolean returned.