mirror of
https://github.com/Seldaek/monolog.git
synced 2025-07-31 18:30:15 +02:00
CS fixes
This commit is contained in:
@@ -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'];
|
||||
|
@@ -186,8 +186,8 @@ class Logger implements LoggerInterface
|
||||
/**
|
||||
* Pops a handler from the stack
|
||||
*
|
||||
* @return HandlerInterface
|
||||
* @throws \LogicException If empty handler stack
|
||||
* @return HandlerInterface
|
||||
*/
|
||||
public function popHandler(): HandlerInterface
|
||||
{
|
||||
@@ -240,8 +240,8 @@ class Logger implements LoggerInterface
|
||||
/**
|
||||
* Removes the processor on top of the stack and returns it.
|
||||
*
|
||||
* @return callable
|
||||
* @throws \LogicException If empty processor stack
|
||||
* @return callable
|
||||
*/
|
||||
public function popProcessor(): callable
|
||||
{
|
||||
@@ -348,8 +348,8 @@ class Logger implements LoggerInterface
|
||||
* Gets the name of the logging level.
|
||||
*
|
||||
* @param int $level
|
||||
* @return string
|
||||
* @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
|
||||
{
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of the Monolog package.
|
||||
*
|
||||
* (c) Jonathan A. Schweder <jonathanschweder@gmail.com>
|
||||
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* 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],
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -132,14 +132,15 @@ class JsonFormatterTest extends TestCase
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
@@ -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()
|
||||
|
@@ -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');
|
||||
|
||||
|
@@ -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');
|
||||
|
||||
|
@@ -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');
|
||||
|
||||
|
@@ -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');
|
||||
|
||||
|
@@ -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');
|
||||
|
||||
|
@@ -170,7 +170,7 @@ class RotatingFileHandlerTest extends TestCase
|
||||
['Y-m-', false],
|
||||
['Y--', false],
|
||||
['m-d', false],
|
||||
['Y-d', false]
|
||||
['Y-d', false],
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -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');
|
||||
|
||||
|
@@ -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();
|
||||
|
@@ -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();
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of the Monolog package.
|
||||
*
|
||||
* (c) Jonathan A. Schweder <jonathanschweder@gmail.com>
|
||||
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user