Jordi Boggiano 10 лет назад
Родитель
Сommit
ca1376bd61

+ 1 - 0
.gitignore

@@ -3,3 +3,4 @@ composer.phar
 phpunit.xml
 composer.lock
 .DS_Store
+.php_cs.cache

+ 2 - 2
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) {

+ 1 - 1
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(

+ 0 - 1
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);

+ 1 - 2
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%');
     }
 }
-

+ 0 - 1
src/Monolog/Handler/RavenHandler.php

@@ -167,7 +167,6 @@ class RavenHandler extends AbstractProcessingHandler
         if ($previousUserContext !== false) {
             $this->ravenClient->user_context($previousUserContext);
         }
-
     }
 
     /**

+ 3 - 4
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);
             });

+ 1 - 0
src/Monolog/Handler/SlackHandler.php

@@ -219,6 +219,7 @@ class SlackHandler extends SocketHandler
         if ($this->iconEmoji) {
             $dataArray['icon_emoji'] = ":{$this->iconEmoji}:";
         }
+
         return $dataArray;
     }
 

+ 1 - 1
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);
     }

+ 1 - 1
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);
         }
 

+ 8 - 10
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);
             }
         }

+ 2 - 0
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;
     }
 

+ 2 - 2
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,
             )

+ 3 - 3
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';

+ 2 - 2
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()

+ 3 - 3
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',
                     ),

+ 8 - 4
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');
     }

+ 1 - 1
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);
             }));
 

+ 2 - 2
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+/'));

+ 0 - 1
tests/Monolog/RegistryTest.php

@@ -11,7 +11,6 @@
 
 namespace Monolog;
 
-
 class RegistryTest extends \PHPUnit_Framework_TestCase
 {
     protected function setUp()