for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Acelaya\Website\Service;
use Acelaya\Website\Options\MailOptions;
use Swift_Mailer;
use Zend\Expressive\Template\TemplateRendererInterface;
class ContactService implements ContactServiceInterface
{
const TEMPLATE = 'Acelaya::emails/contact';
/**
* @var Swift_Mailer
*/
protected $mailer;
* @var TemplateRendererInterface
protected $renderer;
* @var MailOptions
protected $options;
public function __construct(Swift_Mailer $mailer, TemplateRendererInterface $renderer, MailOptions $options)
$this->mailer = $mailer;
$this->renderer = $renderer;
$this->options = $options;
}
* Sends the email and returns the result
*
* @param array $messageData
* @return bool
public function send(array $messageData): bool
$result = $this->mailer->send($this->createMessage($messageData));
$this->createMessage($messageData)
object<Swift_Mime_MimePart>
object<Swift_Mime_Message>
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 $result === 1;
* @return \Swift_Mime_MimePart
private function createMessage(array $messageData): \Swift_Mime_MimePart
return \Swift_Message::newInstance($this->options->getSubject())
->setTo($this->options->getTo())
->setFrom($this->options->getFrom())
->setReplyTo($messageData['email'])
->setBody($this->composeBody($messageData), 'text/html');
* @return string
private function composeBody(array $messageData): string
return $this->renderer->render(self::TEMPLATE, $messageData);
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: