diff --git a/src/Monolog/Handler/RollbarHandler.php b/src/Monolog/Handler/RollbarHandler.php index c9102e40..fcb1b1a5 100644 --- a/src/Monolog/Handler/RollbarHandler.php +++ b/src/Monolog/Handler/RollbarHandler.php @@ -40,7 +40,7 @@ class RollbarHandler extends AbstractProcessingHandler */ protected $rollbarNotifier; - protected $levelMap = array( + protected $levelMap = [ Logger::DEBUG => 'debug', Logger::INFO => 'info', Logger::NOTICE => 'info', @@ -49,7 +49,7 @@ class RollbarHandler extends AbstractProcessingHandler Logger::CRITICAL => 'critical', Logger::ALERT => 'critical', Logger::EMERGENCY => 'critical', - ); + ]; /** * Records whether any log records have been added since the last flush of the rollbar notifier @@ -76,17 +76,17 @@ class RollbarHandler extends AbstractProcessingHandler protected function write(array $record) { $context = $record['context']; - $payload = array(); + $payload = []; if (isset($context['payload'])) { $payload = $context['payload']; unset($context['payload']); } - $context = array_merge($context, $record['extra'], array( + $context = array_merge($context, $record['extra'], [ 'level' => $this->levelMap[$record['level']], 'monolog_level' => $record['level_name'], 'channel' => $record['channel'], 'datetime' => $record['datetime']->format('U'), - )); + ]); if (isset($context['exception']) && $context['exception'] instanceof Exception) { $exception = $context['exception']; diff --git a/src/Monolog/Logger.php b/src/Monolog/Logger.php index 06614510..57c76993 100644 --- a/src/Monolog/Logger.php +++ b/src/Monolog/Logger.php @@ -186,8 +186,8 @@ class Logger implements LoggerInterface /** * Pops a handler from the stack * + * @throws \LogicException If empty handler stack * @return HandlerInterface - * @throws \LogicException If empty handler stack */ public function popHandler(): HandlerInterface { @@ -240,8 +240,8 @@ class Logger implements LoggerInterface /** * Removes the processor on top of the stack and returns it. * + * @throws \LogicException If empty processor stack * @return callable - * @throws \LogicException If empty processor stack */ public function popProcessor(): callable { @@ -347,9 +347,9 @@ class Logger implements LoggerInterface /** * Gets the name of the logging level. * - * @param int $level - * @return string + * @param int $level * @throws \Psr\Log\InvalidArgumentException If level is not defined + * @return string */ public static function getLevelName(int $level): string { @@ -364,8 +364,8 @@ class Logger implements LoggerInterface * Converts PSR-3 levels to Monolog ones if necessary * * @param string|int Level number (monolog) or name (PSR-3) - * @return int * @throws \Psr\Log\InvalidArgumentException If level is not defined + * @return int */ public static function toMonologLevel($level): int { diff --git a/src/Monolog/Processor/MercurialProcessor.php b/src/Monolog/Processor/MercurialProcessor.php index 1be3f292..ce3b8eae 100644 --- a/src/Monolog/Processor/MercurialProcessor.php +++ b/src/Monolog/Processor/MercurialProcessor.php @@ -3,7 +3,7 @@ /* * This file is part of the Monolog package. * - * (c) Jonathan A. Schweder + * (c) Jordi Boggiano * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -51,9 +51,10 @@ class MercurialProcessor } $result = explode(' ', trim(`hg id -nb`)); - return self::$cache = array( + + return self::$cache = [ 'branch' => $result[1], 'revision' => $result[2], - ); + ]; } } diff --git a/tests/Monolog/Formatter/JsonFormatterTest.php b/tests/Monolog/Formatter/JsonFormatterTest.php index 1068fb9d..6dfdbb7a 100644 --- a/tests/Monolog/Formatter/JsonFormatterTest.php +++ b/tests/Monolog/Formatter/JsonFormatterTest.php @@ -125,21 +125,22 @@ class JsonFormatterTest extends TestCase } /** - * @param JsonFormatter $formatter + * @param JsonFormatter $formatter * @param \Exception|\Throwable $exception * * @return string */ private function formatRecordWithExceptionInContext(JsonFormatter $formatter, $exception) { - $message = $formatter->format(array( + $message = $formatter->format([ 'level_name' => 'CRITICAL', 'channel' => 'core', - 'context' => array('exception' => $exception), + 'context' => ['exception' => $exception], 'datetime' => null, - 'extra' => array(), + 'extra' => [], 'message' => 'foobar', - )); + ]); + return $message; } diff --git a/tests/Monolog/Formatter/NormalizerFormatterTest.php b/tests/Monolog/Formatter/NormalizerFormatterTest.php index 6cb53efe..0043afd6 100644 --- a/tests/Monolog/Formatter/NormalizerFormatterTest.php +++ b/tests/Monolog/Formatter/NormalizerFormatterTest.php @@ -93,14 +93,14 @@ class NormalizerFormatterTest extends \PHPUnit_Framework_TestCase $formatter = new NormalizerFormatter('Y-m-d'); $e = new \SoapFault('foo', 'bar', 'hello', 'world'); - $formatted = $formatter->format(array( + $formatted = $formatter->format([ 'exception' => $e, - )); + ]); unset($formatted['exception']['trace']); - $this->assertEquals(array( - 'exception' => array( + $this->assertEquals([ + 'exception' => [ 'class' => 'SoapFault', 'message' => 'bar', 'code' => 0, @@ -108,8 +108,8 @@ class NormalizerFormatterTest extends \PHPUnit_Framework_TestCase 'faultcode' => 'foo', 'faultactor' => 'hello', 'detail' => 'world', - ), - ), $formatted); + ], + ], $formatted); } public function testFormatToStringExceptionHandle() diff --git a/tests/Monolog/Handler/FlowdockHandlerTest.php b/tests/Monolog/Handler/FlowdockHandlerTest.php index d8e1b991..23f8b06c 100644 --- a/tests/Monolog/Handler/FlowdockHandlerTest.php +++ b/tests/Monolog/Handler/FlowdockHandlerTest.php @@ -68,7 +68,7 @@ class FlowdockHandlerTest extends TestCase ->setMethods(['fsockopen', 'streamSetTimeout', 'closeSocket']) ->getMock(); - $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString'); + $reflectionProperty = new \ReflectionProperty('Monolog\Handler\SocketHandler', 'connectionString'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($this->handler, 'localhost:1234'); diff --git a/tests/Monolog/Handler/HipChatHandlerTest.php b/tests/Monolog/Handler/HipChatHandlerTest.php index 6eefd27d..4df4de47 100644 --- a/tests/Monolog/Handler/HipChatHandlerTest.php +++ b/tests/Monolog/Handler/HipChatHandlerTest.php @@ -209,7 +209,7 @@ class HipChatHandlerTest extends TestCase ->setMethods(['fsockopen', 'streamSetTimeout', 'closeSocket']) ->getMock(); - $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString'); + $reflectionProperty = new \ReflectionProperty('Monolog\Handler\SocketHandler', 'connectionString'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($this->handler, 'localhost:1234'); diff --git a/tests/Monolog/Handler/LogEntriesHandlerTest.php b/tests/Monolog/Handler/LogEntriesHandlerTest.php index d4f920ea..92a206d6 100644 --- a/tests/Monolog/Handler/LogEntriesHandlerTest.php +++ b/tests/Monolog/Handler/LogEntriesHandlerTest.php @@ -66,7 +66,7 @@ class LogEntriesHandlerTest extends TestCase ->setMethods(['fsockopen', 'streamSetTimeout', 'closeSocket']) ->getMock(); - $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString'); + $reflectionProperty = new \ReflectionProperty('Monolog\Handler\SocketHandler', 'connectionString'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($this->handler, 'localhost:1234'); diff --git a/tests/Monolog/Handler/LogmaticHandlerTest.php b/tests/Monolog/Handler/LogmaticHandlerTest.php index 71b87d03..e55f6121 100644 --- a/tests/Monolog/Handler/LogmaticHandlerTest.php +++ b/tests/Monolog/Handler/LogmaticHandlerTest.php @@ -66,7 +66,7 @@ class LogmaticHandlerTest extends TestCase ->setMethods(['fsockopen', 'streamSetTimeout', 'closeSocket']) ->getMock(); - $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString'); + $reflectionProperty = new \ReflectionProperty('Monolog\Handler\SocketHandler', 'connectionString'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($this->handler, 'localhost:1234'); diff --git a/tests/Monolog/Handler/PushoverHandlerTest.php b/tests/Monolog/Handler/PushoverHandlerTest.php index 6c11a01f..6a295c92 100644 --- a/tests/Monolog/Handler/PushoverHandlerTest.php +++ b/tests/Monolog/Handler/PushoverHandlerTest.php @@ -121,7 +121,7 @@ class PushoverHandlerTest extends TestCase ->setMethods(['fsockopen', 'streamSetTimeout', 'closeSocket']) ->getMock(); - $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString'); + $reflectionProperty = new \ReflectionProperty('Monolog\Handler\SocketHandler', 'connectionString'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($this->handler, 'localhost:1234'); diff --git a/tests/Monolog/Handler/RotatingFileHandlerTest.php b/tests/Monolog/Handler/RotatingFileHandlerTest.php index 58188e26..9075aa2e 100644 --- a/tests/Monolog/Handler/RotatingFileHandlerTest.php +++ b/tests/Monolog/Handler/RotatingFileHandlerTest.php @@ -170,7 +170,7 @@ class RotatingFileHandlerTest extends TestCase ['Y-m-', false], ['Y--', false], ['m-d', false], - ['Y-d', false] + ['Y-d', false], ]; } diff --git a/tests/Monolog/Handler/SlackHandlerTest.php b/tests/Monolog/Handler/SlackHandlerTest.php index 8bec3379..c08284a5 100644 --- a/tests/Monolog/Handler/SlackHandlerTest.php +++ b/tests/Monolog/Handler/SlackHandlerTest.php @@ -131,7 +131,7 @@ class SlackHandlerTest extends TestCase ->setMethods(['fsockopen', 'streamSetTimeout', 'closeSocket']) ->getMock(); - $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString'); + $reflectionProperty = new \ReflectionProperty('Monolog\Handler\SocketHandler', 'connectionString'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($this->handler, 'localhost:1234'); diff --git a/tests/Monolog/Handler/SyslogUdpHandlerTest.php b/tests/Monolog/Handler/SyslogUdpHandlerTest.php index 9ce807bc..1a764ff0 100644 --- a/tests/Monolog/Handler/SyslogUdpHandlerTest.php +++ b/tests/Monolog/Handler/SyslogUdpHandlerTest.php @@ -31,7 +31,7 @@ class SyslogUdpHandlerTest extends TestCase $handler = new SyslogUdpHandler("127.0.0.1", 514, "authpriv"); $handler->setFormatter(new \Monolog\Formatter\ChromePHPFormatter()); - $socket = $this->getMockBuilder('\Monolog\Handler\SyslogUdp\UdpSocket') + $socket = $this->getMockBuilder('Monolog\Handler\SyslogUdp\UdpSocket') ->setMethods(['write']) ->setConstructorArgs(['lol', 'lol']) ->getMock(); @@ -52,7 +52,7 @@ class SyslogUdpHandlerTest extends TestCase $handler = new SyslogUdpHandler("127.0.0.1", 514, "authpriv"); $handler->setFormatter($this->getIdentityFormatter()); - $socket = $this->getMockBuilder('\Monolog\Handler\SyslogUdp\UdpSocket') + $socket = $this->getMockBuilder('Monolog\Handler\SyslogUdp\UdpSocket') ->setMethods(['write']) ->setConstructorArgs(['lol', 'lol']) ->getMock(); diff --git a/tests/Monolog/Handler/UdpSocketTest.php b/tests/Monolog/Handler/UdpSocketTest.php index c13d0cb3..5f33269f 100644 --- a/tests/Monolog/Handler/UdpSocketTest.php +++ b/tests/Monolog/Handler/UdpSocketTest.php @@ -21,7 +21,7 @@ class UdpSocketTest extends TestCase { public function testWeDoNotTruncateShortMessages() { - $socket = $this->getMockBuilder('\Monolog\Handler\SyslogUdp\UdpSocket') + $socket = $this->getMockBuilder('Monolog\Handler\SyslogUdp\UdpSocket') ->setMethods(['send']) ->setConstructorArgs(['lol', 'lol']) ->getMock(); @@ -35,7 +35,7 @@ class UdpSocketTest extends TestCase public function testLongMessagesAreTruncated() { - $socket = $this->getMockBuilder('\Monolog\Handler\SyslogUdp\UdpSocket') + $socket = $this->getMockBuilder('Monolog\Handler\SyslogUdp\UdpSocket') ->setMethods(['send']) ->setConstructorArgs(['lol', 'lol']) ->getMock(); diff --git a/tests/Monolog/Processor/MercurialProcessorTest.php b/tests/Monolog/Processor/MercurialProcessorTest.php index 0581859b..73901b5f 100644 --- a/tests/Monolog/Processor/MercurialProcessorTest.php +++ b/tests/Monolog/Processor/MercurialProcessorTest.php @@ -3,7 +3,7 @@ /* * This file is part of the Monolog package. * - * (c) Jonathan A. Schweder + * (c) Jordi Boggiano * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -27,6 +27,7 @@ class MercurialProcessorTest extends TestCase } if ($result != 0) { $this->markTestSkipped('hg is missing'); + return; }