-
-
Notifications
You must be signed in to change notification settings - Fork 327
Container::call() resolves array callable using class name #173
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
Conversation
This is very clever I love it! Good job on the tests, I'll merge it locally to remove the tabs ;) |
Thanks! Next addition could be to allow "MyClass::myMethod" for $callable, but IMO that brings more drawbacks than advantages, mainly because you lose the benefit of doing MyClass::class to get the FQCN. :) |
Totally agree with you. Bad news though, there's a HHVM bug that makes the tests fail: https://travis-ci.org/mnapoli/PHP-DI/jobs/31234613 And since PHP-DI 4.1, HHVM is supported (i.e. tests must pass), so I'm afraid we'll need to wait for a fix in HHVM :( Here is the bug: facebook/hhvm#3053 (I already reported it few weeks ago) |
OK sorry the bug with HHVM happens on master too, so it has nothing to do with your pull request :/ I have merged you PR manually and reverted your last commit (which wasn't related to this feature). It's in the 4.3 branch: #174 |
I have just released PHP-DI 4.3.0 which includes this feature. Thanks! |
Great, thank you for the awesome library! |
@thispagecannotbefound FYI I've pushed your idea onto callable classes too! In v4.4 (not released yet): $container->call('Foo');
// is the same as
$container->call(
$container->get('Foo')
); Have a look here: #192 |
This change will allow you to call an array callable using a class name, like so:
If the method is not static, 'MyClass' will be resolved using the container.