I know this is future compatibility feature (PHP 5.4), but I cannot use a object that implements the method __invoke in the container->call method. Now it throws an exception.
class SendMailAction
{
private $mailer;
public function __construct(MailerInterface $mailer)
{
$this->mailer = $mailer;
}
public function __invoke($sender, $recipient, $subject, $content)
{
$message = $this->mailer->compose($sender, $recipient, $subject, $content);
return $this->mailer->send($message);
}
}
$container->call(
$container->make(SendMailAction::class),
[
'sender' => 'sender@example.com',
'recipient' => 'recipient@example.com',
'subject' => 'Testing',
'content' => 'This is a test message'
]
);
I know this is future compatibility feature (PHP 5.4), but I cannot use a object that implements the method
__invokein thecontainer->callmethod. Now it throws an exception.Example: