-
-
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
Support for invokable objects in Container::call() #185
Comments
Oh right that's a good idea to add support for that. You could consider it a missing feature :p Let's keep this issue open, hopefully this could be done for the next minor version. If you have time to work on this let me know, else I'll have a look as soon as possible (it shouldn't be a lot of work). |
By the way I love the look of that piece of code: $container->call(
$container->make(SendMailAction::class),
[
'sender' => 'sender@example.com',
'recipient' => 'recipient@example.com',
'subject' => 'Testing',
'content' => 'This is a test message'
]
); Sleek ;) |
Thanks, and I love the features of this package :) I have an idea of where and how to implement it, but I just started working with PHP-DI, and I may miss some internal working. I don't have much time now to test it, that's why I didn't submit a PR together with the issue. |
Sure no problem, I'll mark it for the next version and I'll look into it, like I said it should be fairly quick. |
Callable objects are objects that implement an __invoke() method.
OK I implemented this and put it in a 4.4 branch: #187 |
Well done, I wouldn't have done such extensive re-factoring. |
@andersonamuller Have a look at #192, I've extended the support for callable objects: $container->call('Foo');
// is the same as
$container->call(
$container->get('Foo')
); It will be included in v4.4 too. |
👍 very nice, thanks |
I know this is future compatibility feature (PHP 5.4), but I cannot use a object that implements the method
__invoke
in thecontainer->call
method. Now it throws an exception.Example:
The text was updated successfully, but these errors were encountered: