for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Shippinno\Notification\Infrastructure\Domain\Model;
use InvalidArgumentException;
use Shippinno\Email\EmailNotSentException;
use Shippinno\Email\SendEmail;
use Shippinno\Notification\Domain\Model\EmailDestination;
use Shippinno\Notification\Domain\Model\Gateway;
use Shippinno\Notification\Domain\Model\Notification;
use Shippinno\Notification\Domain\Model\NotificationNotSentException;
use Tanigami\ValueObjects\Web\Email;
use Tanigami\ValueObjects\Web\EmailAddress;
class EmailGateway extends Gateway
{
/**
* @var SendEmail
*/
private $sendEmail;
* @var EmailAddress
private $from;
* @param SendEmail $sendEmail
* @param EmailAddress $from
public function __construct(SendEmail $sendEmail, EmailAddress $from)
$this->sendEmail = $sendEmail;
$this->from = $from;
}
* {@inheritdoc}
protected function doSend(Notification $notification): void
/** @var EmailDestination $destination */
$destination = $notification->destination();
$email = new Email(
$notification->subject()->subject(),
$notification->body()->body(),
$this->from,
$destination->to(),
$destination->cc(),
$destination->bcc()
);
try {
$this->sendEmail->execute($email);
} catch (EmailNotSentException $e) {
throw new NotificationNotSentException($notification, $e);
$e
object<Shippinno\Email\EmailNotSentException>
null|object<Throwable>
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
* @return string
public function destinationType(): string
return EmailDestination::class;
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: