Jordi Boggiano 11 лет назад
Родитель
Сommit
392ef35fd4
29 измененных файлов с 55 добавлено и 88 удалено
  1. 3 3
      src/Monolog/Formatter/JsonFormatter.php
  2. 1 0
      src/Monolog/Formatter/LogglyFormatter.php
  3. 5 3
      src/Monolog/Handler/BrowserConsoleHandler.php
  4. 0 1
      src/Monolog/Handler/DynamoDbHandler.php
  5. 5 5
      src/Monolog/Handler/FilterHandler.php
  6. 3 3
      src/Monolog/Handler/FlowdockHandler.php
  7. 3 3
      src/Monolog/Handler/GelfHandler.php
  8. 1 1
      src/Monolog/Handler/HipChatHandler.php
  9. 6 4
      src/Monolog/Handler/NativeMailerHandler.php
  10. 0 1
      src/Monolog/Handler/RavenHandler.php
  11. 3 3
      src/Monolog/Handler/RollbarHandler.php
  12. 0 1
      tests/Monolog/Formatter/ElasticaFormatterTest.php
  13. 0 1
      tests/Monolog/Formatter/GelfMessageFormatterTest.php
  14. 1 1
      tests/Monolog/Formatter/JsonFormatterTest.php
  15. 0 1
      tests/Monolog/Formatter/LogglyFormatterTest.php
  16. 0 1
      tests/Monolog/Formatter/LogstashFormatterTest.php
  17. 1 1
      tests/Monolog/Functional/Handler/FirePHPHandlerTest.php
  18. 1 1
      tests/Monolog/Handler/AbstractProcessingHandlerTest.php
  19. 5 5
      tests/Monolog/Handler/BrowserConsoleHandlerTest.php
  20. 7 7
      tests/Monolog/Handler/ElasticSearchHandlerTest.php
  21. 2 2
      tests/Monolog/Handler/FingersCrossedHandlerTest.php
  22. 0 2
      tests/Monolog/Handler/GelfHandlerLegacyTest.php
  23. 0 2
      tests/Monolog/Handler/GelfHandlerTest.php
  24. 0 25
      tests/Monolog/Handler/GelfMocks.php
  25. 1 2
      tests/Monolog/Handler/RavenHandlerTest.php
  26. 4 4
      tests/Monolog/Handler/SocketHandlerTest.php
  27. 0 2
      tests/Monolog/Handler/SyslogUdpHandlerTest.php
  28. 2 2
      tests/Monolog/LoggerTest.php
  29. 1 1
      tests/Monolog/TestCase.php

+ 3 - 3
src/Monolog/Formatter/JsonFormatter.php

@@ -76,7 +76,7 @@ class JsonFormatter implements FormatterInterface
     /**
      * Return a JSON-encoded array of records.
      *
-     * @param  array $records
+     * @param  array  $records
      * @return string
      */
     protected function formatBatchJson(array $records)
@@ -88,14 +88,14 @@ class JsonFormatter implements FormatterInterface
      * Use new lines to separate records instead of a
      * JSON-encoded array.
      *
-     * @param  array $records
+     * @param  array  $records
      * @return string
      */
     protected function formatBatchNewlines(array $records)
     {
         $instance = $this;
 
-        array_walk($records, function(&$value, $key) use ($instance) {
+        array_walk($records, function (&$value, $key) use ($instance) {
             $value = $instance->format($value);
         });
 

+ 1 - 0
src/Monolog/Formatter/LogglyFormatter.php

@@ -42,6 +42,7 @@ class LogglyFormatter extends JsonFormatter
             $record["timestamp"] = $record["datetime"]->format("c");
             // @todo unset the 'datetime' parameter, retained for BC
         }
+
         return parent::format($record);
     }
 

+ 5 - 3
src/Monolog/Handler/BrowserConsoleHandler.php

@@ -11,7 +11,6 @@
 
 namespace Monolog\Handler;
 
-use Monolog\Logger;
 use Monolog\Formatter\LineFormatter;
 
 /**
@@ -103,7 +102,8 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
                 );
             }
         }
-        return "(function(c){if (c && c.groupCollapsed) {\n" . implode("\n", $script) . "\n}})(console);";
+
+        return "(function (c) {if (c && c.groupCollapsed) {\n" . implode("\n", $script) . "\n}})(console);";
     }
 
     private static function handleStyles($formatted)
@@ -130,7 +130,7 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
         static $colors = array('blue', 'green', 'red', 'magenta', 'orange', 'black', 'grey');
         static $labels = array();
 
-        return preg_replace_callback('/macro\s*:(.*?)(?:;|$)/', function($m) use($string, &$colors, &$labels) {
+        return preg_replace_callback('/macro\s*:(.*?)(?:;|$)/', function ($m) use ($string, &$colors, &$labels) {
             if (trim($m[1]) === 'autolabel') {
                 // Format the string as a label with consistent auto assigned background color
                 if (!isset($labels[$string])) {
@@ -160,6 +160,7 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
             }
             $script[] = self::call('log', self::quote('%s: %o'), self::quote($key), $value);
         }
+
         return $script;
     }
 
@@ -172,6 +173,7 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
     {
         $args = func_get_args();
         $method = array_shift($args);
+
         return self::call_array($method, $args);
     }
 

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

@@ -14,7 +14,6 @@ namespace Monolog\Handler;
 use Aws\Common\Aws;
 use Aws\DynamoDb\DynamoDbClient;
 use Monolog\Formatter\ScalarFormatter;
-use Monolog\Handler\AbstractProcessingHandler;
 use Monolog\Logger;
 
 /**

+ 5 - 5
src/Monolog/Handler/FilterHandler.php

@@ -36,10 +36,10 @@ class FilterHandler extends AbstractHandler
     protected $bubble;
 
     /**
-     * @param callable|HandlerInterface $handler Handler or factory callable($record, $this).
+     * @param callable|HandlerInterface $handler        Handler or factory callable($record, $this).
      * @param int|array                 $minLevelOrList A list of levels to accept or a minimum level if maxLevel is provided
-     * @param int                       $maxLevel Maximum level to accept, only used if $minLevelOrList is an array
-     * @param Boolean                   $bubble Whether the messages that are handled can bubble up the stack or not
+     * @param int                       $maxLevel       Maximum level to accept, only used if $minLevelOrList is an array
+     * @param Boolean                   $bubble         Whether the messages that are handled can bubble up the stack or not
      */
     public function __construct($handler, $minLevelOrList = Logger::DEBUG, $maxLevel = Logger::EMERGENCY, $bubble = true)
     {
@@ -57,8 +57,8 @@ class FilterHandler extends AbstractHandler
     }
 
     /**
-     * @param int|array                 $minLevelOrList A list of levels to accept or a minimum level if maxLevel is provided
-     * @param int                       $maxLevel Maximum level to accept, only used if $minLevelOrList is an array
+     * @param int|array $minLevelOrList A list of levels to accept or a minimum level if maxLevel is provided
+     * @param int       $maxLevel       Maximum level to accept, only used if $minLevelOrList is an array
      */
     public function setAcceptedLevels($minLevelOrList = Logger::DEBUG, $maxLevel = Logger::EMERGENCY)
     {

+ 3 - 3
src/Monolog/Handler/FlowdockHandler.php

@@ -32,9 +32,9 @@ class FlowdockHandler extends SocketHandler
     protected $apiToken;
 
     /**
-     * @param string $apiToken
-     * @param bool|int $level The minimum logging level at which this handler will be triggered
-     * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
+     * @param string   $apiToken
+     * @param bool|int $level    The minimum logging level at which this handler will be triggered
+     * @param bool     $bubble   Whether the messages that are handled can bubble up the stack or not
      *
      * @throws MissingExtensionException if OpenSSL is missing
      */

+ 3 - 3
src/Monolog/Handler/GelfHandler.php

@@ -31,9 +31,9 @@ class GelfHandler extends AbstractProcessingHandler
     protected $publisher;
 
     /**
-     * @param PublisherInterface|IMessagePublisher  $publisher a publisher object
-     * @param integer    $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
+     * @param PublisherInterface|IMessagePublisher $publisher a publisher object
+     * @param integer                              $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
      */
     public function __construct($publisher, $level = Logger::DEBUG, $bubble = true)
     {

+ 1 - 1
src/Monolog/Handler/HipChatHandler.php

@@ -285,7 +285,7 @@ class HipChatHandler extends SocketHandler
      * system where `mb_strlen()` is unavailable.
      *
      * @param string $str
-     * @param int $length
+     * @param int    $length
      *
      * @return bool
      */

+ 6 - 4
src/Monolog/Handler/NativeMailerHandler.php

@@ -77,7 +77,7 @@ class NativeMailerHandler extends MailHandler
     /**
      * Add headers to the message
      *
-     * @param string|array $headers Custom added headers
+     * @param  string|array $headers Custom added headers
      * @return null
      */
     public function addHeader($headers)
@@ -123,23 +123,25 @@ class NativeMailerHandler extends MailHandler
     }
 
     /**
-     * @param string $contentType The content type of the email - Defaults to text/plain. Use text/html for HTML
-     * messages.
+     * @param  string $contentType The content type of the email - Defaults to text/plain. Use text/html for HTML
+     *                             messages.
      * @return self
      */
     public function setContentType($contentType)
     {
         $this->contentType = $contentType;
+
         return $this;
     }
 
     /**
-     * @param string $encoding
+     * @param  string $encoding
      * @return self
      */
     public function setEncoding($encoding)
     {
         $this->encoding = $encoding;
+
         return $this;
     }
 }

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

@@ -14,7 +14,6 @@ namespace Monolog\Handler;
 use Monolog\Formatter\LineFormatter;
 use Monolog\Formatter\FormatterInterface;
 use Monolog\Logger;
-use Monolog\Handler\AbstractProcessingHandler;
 use Raven_Client;
 
 /**

+ 3 - 3
src/Monolog/Handler/RollbarHandler.php

@@ -21,9 +21,9 @@ class RollbarHandler extends AbstractProcessingHandler
     protected $rollbarNotifier;
 
     /**
-     * @param RollbarNotifier  $rollbarNotifier RollbarNotifier object constructed with valid token
-     * @param integer          $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
+     * @param RollbarNotifier $rollbarNotifier RollbarNotifier object constructed with valid token
+     * @param integer         $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
      */
     public function __construct(RollbarNotifier $rollbarNotifier, $level = Logger::ERROR, $bubble = true)
     {

+ 0 - 1
tests/Monolog/Formatter/ElasticaFormatterTest.php

@@ -12,7 +12,6 @@
 namespace Monolog\Formatter;
 
 use Monolog\Logger;
-use Monolog\Formatter\ElasticaFormatter;
 
 class ElasticaFormatterTest extends \PHPUnit_Framework_TestCase
 {

+ 0 - 1
tests/Monolog/Formatter/GelfMessageFormatterTest.php

@@ -12,7 +12,6 @@
 namespace Monolog\Formatter;
 
 use Monolog\Logger;
-use Monolog\Formatter\GelfMessageFormatter;
 
 class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
 {

+ 1 - 1
tests/Monolog/Formatter/JsonFormatterTest.php

@@ -64,7 +64,7 @@ class JsonFormatterTest extends TestCase
             $this->getRecord(Logger::WARNING),
             $this->getRecord(Logger::DEBUG),
         );
-        array_walk($expected, function(&$value, $key) {
+        array_walk($expected, function (&$value, $key) {
             $value = json_encode($value);
         });
         $this->assertEquals(implode("\n", $expected), $formatter->formatBatch($records));

+ 0 - 1
tests/Monolog/Formatter/LogglyFormatterTest.php

@@ -11,7 +11,6 @@
 
 namespace Monolog\Formatter;
 
-use Monolog\Logger;
 use Monolog\TestCase;
 
 class LogglyFormatterTest extends TestCase

+ 0 - 1
tests/Monolog/Formatter/LogstashFormatterTest.php

@@ -12,7 +12,6 @@
 namespace Monolog\Formatter;
 
 use Monolog\Logger;
-use Monolog\Formatter\LogstashFormatter;
 
 class LogstashFormatterTest extends \PHPUnit_Framework_TestCase
 {

+ 1 - 1
tests/Monolog/Functional/Handler/FirePHPHandlerTest.php

@@ -9,7 +9,7 @@
  * file that was distributed with this source code.
  */
 
-spl_autoload_register(function($class) {
+spl_autoload_register(function ($class) {
     $file = __DIR__.'/../../../../src/'.strtr($class, '\\', '/').'.php';
     if (file_exists($file)) {
         require $file;

+ 1 - 1
tests/Monolog/Handler/AbstractProcessingHandlerTest.php

@@ -70,7 +70,7 @@ class AbstractProcessingHandlerTest extends TestCase
         $handledRecord = null;
         $handler->expects($this->once())
             ->method('write')
-            ->will($this->returnCallback(function($record) use (&$handledRecord) {
+            ->will($this->returnCallback(function ($record) use (&$handledRecord) {
                 $handledRecord = $record;
             }))
         ;

+ 5 - 5
tests/Monolog/Handler/BrowserConsoleHandlerTest.php

@@ -40,7 +40,7 @@ class BrowserConsoleHandlerTest extends TestCase
         $handler->handle($this->getRecord(Logger::DEBUG, 'foo[[bar]]{color: red}'));
 
         $expected = <<<EOF
-(function(c){if (c && c.groupCollapsed) {
+(function (c) {if (c && c.groupCollapsed) {
 c.log("%cfoo%cbar%c", "font-weight: normal", "color: red", "font-weight: normal");
 }})(console);
 EOF;
@@ -56,7 +56,7 @@ EOF;
         $handler->handle($this->getRecord(Logger::DEBUG, "[foo] [[\"bar\n[baz]\"]]{color: red}"));
 
         $expected = <<<EOF
-(function(c){if (c && c.groupCollapsed) {
+(function (c) {if (c && c.groupCollapsed) {
 c.log("%c[foo] %c\"bar\\n[baz]\"%c", "font-weight: normal", "color: red", "font-weight: normal");
 }})(console);
 EOF;
@@ -75,7 +75,7 @@ EOF;
         $handler->handle($this->getRecord(Logger::DEBUG, '[[foo]]{macro: autolabel}'));
 
         $expected = <<<EOF
-(function(c){if (c && c.groupCollapsed) {
+(function (c) {if (c && c.groupCollapsed) {
 c.log("%c%cfoo%c", "font-weight: normal", "background-color: blue; color: white; border-radius: 3px; padding: 0 2px 0 2px", "font-weight: normal");
 c.log("%c%cbar%c", "font-weight: normal", "background-color: green; color: white; border-radius: 3px; padding: 0 2px 0 2px", "font-weight: normal");
 c.log("%c%cfoo%c", "font-weight: normal", "background-color: blue; color: white; border-radius: 3px; padding: 0 2px 0 2px", "font-weight: normal");
@@ -93,7 +93,7 @@ EOF;
         $handler->handle($this->getRecord(Logger::DEBUG, 'test', array('foo' => 'bar')));
 
         $expected = <<<EOF
-(function(c){if (c && c.groupCollapsed) {
+(function (c) {if (c && c.groupCollapsed) {
 c.groupCollapsed("%ctest", "font-weight: normal");
 c.log("%c%s", "font-weight: bold", "Context");
 c.log("%s: %o", "foo", "bar");
@@ -118,7 +118,7 @@ EOF;
         $handler2->handle($this->getRecord(Logger::DEBUG, 'test4'));
 
         $expected = <<<EOF
-(function(c){if (c && c.groupCollapsed) {
+(function (c) {if (c && c.groupCollapsed) {
 c.log("%ctest1", "font-weight: normal");
 c.log("%ctest2", "font-weight: normal");
 c.log("%ctest3", "font-weight: normal");

+ 7 - 7
tests/Monolog/Handler/ElasticSearchHandlerTest.php

@@ -11,7 +11,6 @@
 
 namespace Monolog\Handler;
 
-use Monolog\Handler\ElasticSearchHandler;
 use Monolog\Formatter\ElasticaFormatter;
 use Monolog\Formatter\NormalizerFormatter;
 use Monolog\TestCase;
@@ -185,7 +184,7 @@ class ElasticSearchHandlerTest extends TestCase
         $handler = new ElasticSearchHandler($client, $this->options);
         try {
             $handler->handleBatch(array($msg));
-        } catch(\RuntimeException $e) {
+        } catch (\RuntimeException $e) {
             $this->markTestSkipped("Cannot connect to Elastic Search server on localhost");
         }
 
@@ -208,7 +207,7 @@ class ElasticSearchHandlerTest extends TestCase
 
     /**
      * Return last created document id from ES response
-     * @param Response $response Elastica Response object
+     * @param  Response    $response Elastica Response object
      * @return string|null
      */
     protected function getCreatedDocId(Response $response)
@@ -221,10 +220,10 @@ class ElasticSearchHandlerTest extends TestCase
 
     /**
      * Retrieve document by id from Elasticsearch
-     * @param Client $client Elastica client
-     * @param string $index
-     * @param string $type
-     * @param string $documentId
+     * @param  Client $client     Elastica client
+     * @param  string $index
+     * @param  string $type
+     * @param  string $documentId
      * @return array
      */
     protected function getDocSourceFromElastic(Client $client, $index, $type, $documentId)
@@ -234,6 +233,7 @@ class ElasticSearchHandlerTest extends TestCase
         if (!empty($data['_source'])) {
             return $data['_source'];
         }
+
         return array();
     }
 }

+ 2 - 2
tests/Monolog/Handler/FingersCrossedHandlerTest.php

@@ -102,7 +102,7 @@ class FingersCrossedHandlerTest extends TestCase
     public function testHandleWithCallback()
     {
         $test = new TestHandler();
-        $handler = new FingersCrossedHandler(function($record, $handler) use ($test) {
+        $handler = new FingersCrossedHandler(function ($record, $handler) use ($test) {
                     return $test;
                 });
         $handler->handle($this->getRecord(Logger::DEBUG));
@@ -120,7 +120,7 @@ class FingersCrossedHandlerTest extends TestCase
      */
     public function testHandleWithBadCallbackThrowsException()
     {
-        $handler = new FingersCrossedHandler(function($record, $handler) {
+        $handler = new FingersCrossedHandler(function ($record, $handler) {
                     return 'foo';
                 });
         $handler->handle($this->getRecord(Logger::WARNING));

+ 0 - 2
tests/Monolog/Handler/GelfHandlerLegacyTest.php

@@ -23,8 +23,6 @@ class GelfHandlerLegacyTest extends TestCase
         if (!class_exists('Gelf\MessagePublisher') || !class_exists('Gelf\Message')) {
             $this->markTestSkipped("mlehner/gelf-php not installed");
         }
-
-        require_once __DIR__ . '/GelfMocks.php';
     }
 
     /**

+ 0 - 2
tests/Monolog/Handler/GelfHandlerTest.php

@@ -64,7 +64,6 @@ class GelfHandlerTest extends TestCase
 
         $handler = $this->getHandler($messagePublisher);
 
-
         $handler->handle($record);
 
     }
@@ -87,7 +86,6 @@ class GelfHandlerTest extends TestCase
 
         $handler = $this->getHandler($messagePublisher);
 
-
         $handler->handle($record);
     }
 

+ 0 - 25
tests/Monolog/Handler/GelfMocks.php

@@ -1,25 +0,0 @@
-<?php
-
-/*
- * This file is part of the Monolog package.
- *
- * (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.
- */
-
-namespace Monolog\Handler;
-
-use Gelf\MessagePublisher;
-use Gelf\Message;
-
-class MockMessagePublisher extends MessagePublisher
-{
-    public function publish(Message $message)
-    {
-        $this->lastMessage = $message;
-    }
-
-    public $lastMessage = null;
-}

+ 1 - 2
tests/Monolog/Handler/RavenHandlerTest.php

@@ -14,7 +14,6 @@ namespace Monolog\Handler;
 use Monolog\TestCase;
 use Monolog\Logger;
 use Monolog\Formatter\LineFormatter;
-use Monolog\Handler\RavenHandler;
 
 class RavenHandlerTest extends TestCase
 {
@@ -99,7 +98,7 @@ class RavenHandlerTest extends TestCase
         $logFormatter->expects($this->once())->method('formatBatch');
 
         $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
-        $formatter->expects($this->once())->method('format')->with($this->callback(function($record) {
+        $formatter->expects($this->once())->method('format')->with($this->callback(function ($record) {
             return $record['level'] == 400;
         }));
 

+ 4 - 4
tests/Monolog/Handler/SocketHandlerTest.php

@@ -120,7 +120,7 @@ class SocketHandlerTest extends TestCase
     {
         $this->setMockHandler(array('fwrite'));
 
-        $callback = function($arg) {
+        $callback = function ($arg) {
             $map = array(
                 'Hello world' => 6,
                 'world' => false,
@@ -143,7 +143,7 @@ class SocketHandlerTest extends TestCase
     {
         $this->setMockHandler(array('fwrite', 'streamGetMetadata'));
 
-        $callback = function($arg) {
+        $callback = function ($arg) {
             $map = array(
                 'Hello world' => 6,
                 'world' => 5,
@@ -170,7 +170,7 @@ class SocketHandlerTest extends TestCase
         $this->setMockHandler(array('fwrite', 'streamGetMetadata'));
 
         $res = $this->res;
-        $callback = function($string) use ($res) {
+        $callback = function ($string) use ($res) {
             fclose($res);
 
             return strlen('Hello');
@@ -200,7 +200,7 @@ class SocketHandlerTest extends TestCase
     {
         $this->setMockHandler(array('fwrite'));
 
-        $callback = function($arg) {
+        $callback = function ($arg) {
             $map = array(
                 'Hello world' => 6,
                 'world' => 5,

+ 0 - 2
tests/Monolog/Handler/SyslogUdpHandlerTest.php

@@ -2,8 +2,6 @@
 
 namespace Monolog\Handler;
 
-use Monolog\TestCase;
-
 class SyslogUdpHandlerTest extends \PHPUnit_Framework_TestCase
 {
     /**

+ 2 - 2
tests/Monolog/LoggerTest.php

@@ -162,7 +162,7 @@ class LoggerTest extends \PHPUnit_Framework_TestCase
         $logger = new Logger(__METHOD__);
         $handler = new TestHandler;
         $logger->pushHandler($handler);
-        $logger->pushProcessor(function($record) {
+        $logger->pushProcessor(function ($record) {
             $record['extra']['win'] = true;
 
             return $record;
@@ -216,7 +216,7 @@ class LoggerTest extends \PHPUnit_Framework_TestCase
         ;
         $logger->pushHandler($handler);
         $that = $this;
-        $logger->pushProcessor(function($record) use ($that) {
+        $logger->pushProcessor(function ($record) use ($that) {
             $that->fail('The processor should not be called');
         });
         $logger->addAlert('test');

+ 1 - 1
tests/Monolog/TestCase.php

@@ -51,7 +51,7 @@ class TestCase extends \PHPUnit_Framework_TestCase
         $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
         $formatter->expects($this->any())
             ->method('format')
-            ->will($this->returnCallback(function($record) { return $record['message']; }));
+            ->will($this->returnCallback(function ($record) { return $record['message']; }));
 
         return $formatter;
     }