1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-21 16:46:11 +02:00

Move to strict mode and fix tests

This commit is contained in:
Jordi Boggiano
2016-05-27 13:44:00 +01:00
parent 788902b320
commit 21dde4dedb
170 changed files with 239 additions and 240 deletions

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the Monolog package.
@@ -13,6 +13,7 @@ namespace Monolog\Handler;
use Monolog\Logger;
use Monolog\Formatter\LineFormatter;
use Swift_Message;
/**
* SwiftMailerHandler uses Swift_Mailer to send the emails
@@ -26,7 +27,7 @@ class SwiftMailerHandler extends MailHandler
/**
* @param \Swift_Mailer $mailer The mailer to use
* @param callable|\Swift_Message $message An example message for real messages, only the body will be replaced
* @param callable|Swift_Message $message An example message for real messages, only the body will be replaced
* @param int $level The minimum logging level at which this handler will be triggered
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
*/
@@ -41,7 +42,7 @@ class SwiftMailerHandler extends MailHandler
/**
* {@inheritdoc}
*/
protected function send($content, array $records)
protected function send(string $content, array $records)
{
$this->mailer->send($this->buildMessage($content, $records));
}
@@ -51,19 +52,19 @@ class SwiftMailerHandler extends MailHandler
*
* @param string $content formatted email body to be sent
* @param array $records Log records that formed the content
* @return \Swift_Message
* @return Swift_Message
*/
protected function buildMessage($content, array $records)
protected function buildMessage(string $content, array $records): Swift_Message
{
$message = null;
if ($this->messageTemplate instanceof \Swift_Message) {
if ($this->messageTemplate instanceof Swift_Message) {
$message = clone $this->messageTemplate;
$message->generateId();
} elseif (is_callable($this->messageTemplate)) {
$message = call_user_func($this->messageTemplate, $content, $records);
}
if (!$message instanceof \Swift_Message) {
if (!$message instanceof Swift_Message) {
throw new \InvalidArgumentException('Could not resolve message as instance of Swift_Message or a callable returning it');
}