diff --git a/.gitignore b/.gitignore index 0a3fb552..22486e9c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ composer.phar phpunit.xml composer.lock .DS_Store +.php_cs.cache diff --git a/src/Monolog/Handler/BrowserConsoleHandler.php b/src/Monolog/Handler/BrowserConsoleHandler.php index 66832ee9..a4099524 100644 --- a/src/Monolog/Handler/BrowserConsoleHandler.php +++ b/src/Monolog/Handler/BrowserConsoleHandler.php @@ -63,8 +63,8 @@ class BrowserConsoleHandler extends AbstractProcessingHandler // Check content type foreach (headers_list() as $header) { if (stripos($header, 'content-type:') === 0) { - // This handler only works with HTML and javascript outputs - // text/javascript is obsolete in favour of application/javascript, but still used + // This handler only works with HTML and javascript outputs + // text/javascript is obsolete in favour of application/javascript, but still used if (stripos($header, 'application/javascript') !== false || stripos($header, 'text/javascript') !== false) { $htmlTags = false; } elseif (stripos($header, 'text/html') === false) { diff --git a/src/Monolog/Handler/ChromePHPHandler.php b/src/Monolog/Handler/ChromePHPHandler.php index bc659349..b3f2963b 100644 --- a/src/Monolog/Handler/ChromePHPHandler.php +++ b/src/Monolog/Handler/ChromePHPHandler.php @@ -129,7 +129,7 @@ class ChromePHPHandler extends AbstractProcessingHandler $json = @json_encode(self::$json); $data = base64_encode(utf8_encode($json)); - if (strlen($data) > 240*1024) { + if (strlen($data) > 240 * 1024) { self::$overflowed = true; $record = array( diff --git a/src/Monolog/Handler/Curl/Util.php b/src/Monolog/Handler/Curl/Util.php index 8125d06b..8b56a3ef 100644 --- a/src/Monolog/Handler/Curl/Util.php +++ b/src/Monolog/Handler/Curl/Util.php @@ -33,7 +33,6 @@ class Util { while ($retries--) { if (curl_exec($ch) === false) { - if (false === in_array(curl_errno($ch), self::$retriableErrorCodes, true) || !$retries) { if ($closeAfterDone) { curl_close($ch); diff --git a/src/Monolog/Handler/PHPConsoleHandler.php b/src/Monolog/Handler/PHPConsoleHandler.php index 169bea0e..2b7e3531 100644 --- a/src/Monolog/Handler/PHPConsoleHandler.php +++ b/src/Monolog/Handler/PHPConsoleHandler.php @@ -215,7 +215,7 @@ class PHPConsoleHandler extends AbstractProcessingHandler { $tags = null; if (!empty($record['context'])) { - $context =& $record['context']; + $context = & $record['context']; foreach ($this->options['debugTagsKeysInContext'] as $key) { if (!empty($context[$key])) { $tags = $context[$key]; @@ -240,4 +240,3 @@ class PHPConsoleHandler extends AbstractProcessingHandler return new LineFormatter('%message%'); } } - diff --git a/src/Monolog/Handler/RavenHandler.php b/src/Monolog/Handler/RavenHandler.php index 7fedc16f..c37dbf31 100644 --- a/src/Monolog/Handler/RavenHandler.php +++ b/src/Monolog/Handler/RavenHandler.php @@ -167,7 +167,6 @@ class RavenHandler extends AbstractProcessingHandler if ($previousUserContext !== false) { $this->ravenClient->user_context($previousUserContext); } - } /** diff --git a/src/Monolog/Handler/RedisHandler.php b/src/Monolog/Handler/RedisHandler.php index dd0e747e..157e2f99 100644 --- a/src/Monolog/Handler/RedisHandler.php +++ b/src/Monolog/Handler/RedisHandler.php @@ -56,8 +56,7 @@ class RedisHandler extends AbstractProcessingHandler */ protected function write(array $record) { - if ($this->capSize) - { + if ($this->capSize) { $this->writeCapped($record); } else { $this->redisClient->rpush($this->redisKey, $record["formatted"]); @@ -73,7 +72,7 @@ class RedisHandler extends AbstractProcessingHandler */ protected function writeCapped(array $record) { - if($this->redisClient instanceof \Redis) { + if ($this->redisClient instanceof \Redis) { $this->redisClient->multi() ->rpush($this->redisKey, $record["formatted"]) ->ltrim($this->redisKey, -$this->capSize, -1) @@ -81,7 +80,7 @@ class RedisHandler extends AbstractProcessingHandler } else { $redisKey = $this->redisKey; $capSize = $this->capSize; - $this->redisClient->transaction(function($tx) use($record, $redisKey, $capSize) { + $this->redisClient->transaction(function ($tx) use ($record, $redisKey, $capSize) { $tx->rpush($redisKey, $record["formatted"]); $tx->ltrim($redisKey, -$capSize, -1); }); diff --git a/src/Monolog/Handler/SlackHandler.php b/src/Monolog/Handler/SlackHandler.php index c7a1c7e9..643b003b 100644 --- a/src/Monolog/Handler/SlackHandler.php +++ b/src/Monolog/Handler/SlackHandler.php @@ -219,6 +219,7 @@ class SlackHandler extends SocketHandler if ($this->iconEmoji) { $dataArray['icon_emoji'] = ":{$this->iconEmoji}:"; } + return $dataArray; } diff --git a/src/Monolog/Handler/SocketHandler.php b/src/Monolog/Handler/SocketHandler.php index ee486f69..561e2fbd 100644 --- a/src/Monolog/Handler/SocketHandler.php +++ b/src/Monolog/Handler/SocketHandler.php @@ -190,7 +190,7 @@ class SocketHandler extends AbstractProcessingHandler protected function streamSetTimeout() { $seconds = floor($this->timeout); - $microseconds = round(($this->timeout - $seconds)*1e6); + $microseconds = round(($this->timeout - $seconds) * 1e6); return stream_set_timeout($this->resource, $seconds, $microseconds); } diff --git a/src/Monolog/Handler/SwiftMailerHandler.php b/src/Monolog/Handler/SwiftMailerHandler.php index 003a1a2a..c724bb21 100644 --- a/src/Monolog/Handler/SwiftMailerHandler.php +++ b/src/Monolog/Handler/SwiftMailerHandler.php @@ -57,7 +57,7 @@ class SwiftMailerHandler extends MailHandler $message = null; if ($this->messageTemplate instanceof \Swift_Message) { $message = clone $this->messageTemplate; - } else if (is_callable($this->messageTemplate)) { + } elseif (is_callable($this->messageTemplate)) { $message = call_user_func($this->messageTemplate, $content, $records); } diff --git a/src/Monolog/Handler/TestHandler.php b/src/Monolog/Handler/TestHandler.php index 24c025a0..e24fa9e9 100644 --- a/src/Monolog/Handler/TestHandler.php +++ b/src/Monolog/Handler/TestHandler.php @@ -11,8 +11,6 @@ namespace Monolog\Handler; -use Monolog\Logger; - /** * Used for testing purposes. * @@ -28,7 +26,7 @@ use Monolog\Logger; * @method boolean hasNotice($record) * @method boolean hasInfo($record) * @method boolean hasDebug($record) - * + * * @method boolean hasEmergencyRecords() * @method boolean hasAlertRecords() * @method boolean hasCriticalRecords() @@ -37,7 +35,7 @@ use Monolog\Logger; * @method boolean hasNoticeRecords() * @method boolean hasInfoRecords() * @method boolean hasDebugRecords() - * + * * @method boolean hasEmergencyThatContains($message) * @method boolean hasAlertThatContains($message) * @method boolean hasCriticalThatContains($message) @@ -46,7 +44,7 @@ use Monolog\Logger; * @method boolean hasNoticeThatContains($message) * @method boolean hasInfoThatContains($message) * @method boolean hasDebugThatContains($message) - * + * * @method boolean hasEmergencyThatMatches($message) * @method boolean hasAlertThatMatches($message) * @method boolean hasCriticalThatMatches($message) @@ -55,7 +53,7 @@ use Monolog\Logger; * @method boolean hasNoticeThatMatches($message) * @method boolean hasInfoThatMatches($message) * @method boolean hasDebugThatMatches($message) - * + * * @method boolean hasEmergencyThatPasses($message) * @method boolean hasAlertThatPasses($message) * @method boolean hasCriticalThatPasses($message) @@ -86,21 +84,21 @@ class TestHandler extends AbstractProcessingHandler $record = $record['message']; } - return $this->hasRecordThatPasses(function($rec) use ($record) { + return $this->hasRecordThatPasses(function ($rec) use ($record) { return $rec['message'] === $record; }, $level); } public function hasRecordThatContains($message, $level) { - return $this->hasRecordThatPasses(function($rec) use ($message) { + return $this->hasRecordThatPasses(function ($rec) use ($message) { return strpos($rec['message'], $message) !== false; }, $level); } public function hasRecordThatMatches($regex, $level) { - return $this->hasRecordThatPasses(function($rec) use ($regex) { + return $this->hasRecordThatPasses(function ($rec) use ($regex) { return preg_match($regex, $rec['message']) > 0; }, $level); } @@ -133,7 +131,6 @@ class TestHandler extends AbstractProcessingHandler $this->records[] = $record; } - public function __call($method, $args) { if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) { @@ -141,6 +138,7 @@ class TestHandler extends AbstractProcessingHandler $level = constant('Monolog\Logger::' . strtoupper($matches[2])); if (method_exists($this, $genericMethod)) { $args[] = $level; + return call_user_func_array(array($this, $genericMethod), $args); } } diff --git a/src/Monolog/Logger.php b/src/Monolog/Logger.php index 32e3dd92..b042fa74 100644 --- a/src/Monolog/Logger.php +++ b/src/Monolog/Logger.php @@ -157,6 +157,7 @@ class Logger implements LoggerInterface public function pushHandler(HandlerInterface $handler) { array_unshift($this->handlers, $handler); + return $this; } @@ -194,6 +195,7 @@ class Logger implements LoggerInterface throw new \InvalidArgumentException('Processors must be valid callables (callback or object with an __invoke method), '.var_export($callback, true).' given'); } array_unshift($this->processors, $callback); + return $this; } diff --git a/src/Monolog/Processor/IntrospectionProcessor.php b/src/Monolog/Processor/IntrospectionProcessor.php index 294a295c..85da0298 100644 --- a/src/Monolog/Processor/IntrospectionProcessor.php +++ b/src/Monolog/Processor/IntrospectionProcessor.php @@ -70,8 +70,8 @@ class IntrospectionProcessor $record['extra'] = array_merge( $record['extra'], array( - 'file' => isset($trace[$i-1]['file']) ? $trace[$i-1]['file'] : null, - 'line' => isset($trace[$i-1]['line']) ? $trace[$i-1]['line'] : null, + 'file' => isset($trace[$i - 1]['file']) ? $trace[$i - 1]['file'] : null, + 'line' => isset($trace[$i - 1]['line']) ? $trace[$i - 1]['line'] : null, 'class' => isset($trace[$i]['class']) ? $trace[$i]['class'] : null, 'function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : null, ) diff --git a/src/Monolog/Processor/MemoryProcessor.php b/src/Monolog/Processor/MemoryProcessor.php index 0820def4..eb802c0e 100644 --- a/src/Monolog/Processor/MemoryProcessor.php +++ b/src/Monolog/Processor/MemoryProcessor.php @@ -52,10 +52,10 @@ abstract class MemoryProcessor return $bytes; } - if ($bytes > 1024*1024) { - return round($bytes/1024/1024, 2).' MB'; + if ($bytes > 1024 * 1024) { + return round($bytes / 1024 / 1024, 2).' MB'; } elseif ($bytes > 1024) { - return round($bytes/1024, 2).' KB'; + return round($bytes / 1024, 2).' KB'; } return $bytes . ' B'; diff --git a/tests/Monolog/Formatter/LineFormatterTest.php b/tests/Monolog/Formatter/LineFormatterTest.php index c1b2e0ee..aef4e560 100644 --- a/tests/Monolog/Formatter/LineFormatterTest.php +++ b/tests/Monolog/Formatter/LineFormatterTest.php @@ -120,7 +120,7 @@ class LineFormatterTest extends \PHPUnit_Framework_TestCase $path = str_replace('\\/', '/', json_encode(__FILE__)); - $this->assertEquals('['.date('Y-m-d').'] core.CRITICAL: foobar {"exception":"[object] (RuntimeException(code: 0): Foo at '.substr($path, 1, -1).':'.(__LINE__-8).')"} []'."\n", $message); + $this->assertEquals('['.date('Y-m-d').'] core.CRITICAL: foobar {"exception":"[object] (RuntimeException(code: 0): Foo at '.substr($path, 1, -1).':'.(__LINE__ - 8).')"} []'."\n", $message); } public function testDefFormatWithPreviousException() @@ -138,7 +138,7 @@ class LineFormatterTest extends \PHPUnit_Framework_TestCase $path = str_replace('\\/', '/', json_encode(__FILE__)); - $this->assertEquals('['.date('Y-m-d').'] core.CRITICAL: foobar {"exception":"[object] (RuntimeException(code: 0): Foo at '.substr($path, 1, -1).':'.(__LINE__-8).', LogicException(code: 0): Wut? at '.substr($path, 1, -1).':'.(__LINE__-12).')"} []'."\n", $message); + $this->assertEquals('['.date('Y-m-d').'] core.CRITICAL: foobar {"exception":"[object] (RuntimeException(code: 0): Foo at '.substr($path, 1, -1).':'.(__LINE__ - 8).', LogicException(code: 0): Wut? at '.substr($path, 1, -1).':'.(__LINE__ - 12).')"} []'."\n", $message); } public function testBatchFormat() diff --git a/tests/Monolog/Handler/ChromePHPHandlerTest.php b/tests/Monolog/Handler/ChromePHPHandlerTest.php index 2f55faf8..4d64025f 100644 --- a/tests/Monolog/Handler/ChromePHPHandlerTest.php +++ b/tests/Monolog/Handler/ChromePHPHandlerTest.php @@ -51,10 +51,10 @@ class ChromePHPHandlerTest extends TestCase { $handler = new TestChromePHPHandler(); $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->handle($this->getRecord(Logger::WARNING, str_repeat('a', 150*1024))); + $handler->handle($this->getRecord(Logger::WARNING, str_repeat('a', 150 * 1024))); // overflow chrome headers limit - $handler->handle($this->getRecord(Logger::WARNING, str_repeat('a', 100*1024))); + $handler->handle($this->getRecord(Logger::WARNING, str_repeat('a', 100 * 1024))); $expected = array( 'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode(array( @@ -69,7 +69,7 @@ class ChromePHPHandlerTest extends TestCase ), array( 'test', - str_repeat('a', 150*1024), + str_repeat('a', 150 * 1024), 'unknown', 'warn', ), diff --git a/tests/Monolog/Handler/HipChatHandlerTest.php b/tests/Monolog/Handler/HipChatHandlerTest.php index ff773c98..0ea738cd 100644 --- a/tests/Monolog/Handler/HipChatHandlerTest.php +++ b/tests/Monolog/Handler/HipChatHandlerTest.php @@ -47,7 +47,8 @@ class HipChatHandlerTest extends TestCase return $content; } - public function testWriteV2() { + public function testWriteV2() + { $this->createHandler('myToken', 'room1', 'Monolog', false, 'hipchat.foo.bar', 'v2'); $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); fseek($this->res, 0); @@ -58,7 +59,8 @@ class HipChatHandlerTest extends TestCase return $content; } - public function testWriteV2Notify() { + public function testWriteV2Notify() + { $this->createHandler('myToken', 'room1', 'Monolog', true, 'hipchat.foo.bar', 'v2'); $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); fseek($this->res, 0); @@ -69,7 +71,8 @@ class HipChatHandlerTest extends TestCase return $content; } - public function testRoomSpaces() { + public function testRoomSpaces() + { $this->createHandler('myToken', 'room name', 'Monolog', false, 'hipchat.foo.bar', 'v2'); $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); fseek($this->res, 0); @@ -233,7 +236,8 @@ class HipChatHandlerTest extends TestCase $hipChatHandler = new \Monolog\Handler\HipChatHandler('token', 'room', 'SixteenCharsHere'); } - public function testCreateWithTooLongNameV2() { + public function testCreateWithTooLongNameV2() + { // creating a handler with too long of a name but using the v2 api doesn't matter. $hipChatHandler = new \Monolog\Handler\HipChatHandler('token', 'room', 'SixteenCharsHere', false, Logger::CRITICAL, true, true, 'test', 'api.hipchat.com', 'v2'); } diff --git a/tests/Monolog/Handler/RedisHandlerTest.php b/tests/Monolog/Handler/RedisHandlerTest.php index c415c722..97e0d948 100644 --- a/tests/Monolog/Handler/RedisHandlerTest.php +++ b/tests/Monolog/Handler/RedisHandlerTest.php @@ -114,7 +114,7 @@ class RedisHandlerTest extends TestCase // Redis uses multi $redis->expects($this->once()) ->method('transaction') - ->will($this->returnCallback(function($cb) use ($redisTransaction){ + ->will($this->returnCallback(function ($cb) use ($redisTransaction) { $cb($redisTransaction); })); diff --git a/tests/Monolog/Handler/TestHandlerTest.php b/tests/Monolog/Handler/TestHandlerTest.php index de3ae4b6..75cc4a8d 100644 --- a/tests/Monolog/Handler/TestHandlerTest.php +++ b/tests/Monolog/Handler/TestHandlerTest.php @@ -28,7 +28,7 @@ class TestHandlerTest extends TestCase $record = $this->getRecord($level, 'test'.$method); $this->assertFalse($handler->{'has'.$method}($record), 'has'.$method); $this->assertFalse($handler->{'has'.$method.'ThatContains'}('test'), 'has'.$method.'ThatContains'); - $this->assertFalse($handler->{'has'.$method.'ThatPasses'}(function($rec){ + $this->assertFalse($handler->{'has'.$method.'ThatPasses'}(function ($rec) { return true; }), 'has'.$method.'ThatPasses'); $this->assertFalse($handler->{'has'.$method.'ThatMatches'}('/test\w+/')); @@ -39,7 +39,7 @@ class TestHandlerTest extends TestCase $this->assertTrue($handler->{'has'.$method}($record), 'has'.$method); $this->assertTrue($handler->{'has'.$method}('test'.$method), 'has'.$method); $this->assertTrue($handler->{'has'.$method.'ThatContains'}('test'), 'has'.$method.'ThatContains'); - $this->assertTrue($handler->{'has'.$method.'ThatPasses'}(function($rec){ + $this->assertTrue($handler->{'has'.$method.'ThatPasses'}(function ($rec) { return true; }), 'has'.$method.'ThatPasses'); $this->assertTrue($handler->{'has'.$method.'ThatMatches'}('/test\w+/')); diff --git a/tests/Monolog/RegistryTest.php b/tests/Monolog/RegistryTest.php index 29925f8a..9dca6f2f 100644 --- a/tests/Monolog/RegistryTest.php +++ b/tests/Monolog/RegistryTest.php @@ -11,7 +11,6 @@ namespace Monolog; - class RegistryTest extends \PHPUnit_Framework_TestCase { protected function setUp()