diff --git a/src/Monolog/Formatter/JsonFormatter.php b/src/Monolog/Formatter/JsonFormatter.php index 62c700267..206ec2499 100644 --- a/src/Monolog/Formatter/JsonFormatter.php +++ b/src/Monolog/Formatter/JsonFormatter.php @@ -76,7 +76,7 @@ public function formatBatch(array $records) /** * Return a JSON-encoded array of records. * - * @param array $records + * @param array $records * @return string */ protected function formatBatchJson(array $records) @@ -88,14 +88,14 @@ protected function formatBatchJson(array $records) * 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); }); diff --git a/src/Monolog/Formatter/LogglyFormatter.php b/src/Monolog/Formatter/LogglyFormatter.php index db9e7c3f4..5f2709850 100644 --- a/src/Monolog/Formatter/LogglyFormatter.php +++ b/src/Monolog/Formatter/LogglyFormatter.php @@ -42,6 +42,7 @@ public function format(array $record) $record["timestamp"] = $record["datetime"]->format("c"); // @todo unset the 'datetime' parameter, retained for BC } + return parent::format($record); } diff --git a/src/Monolog/Handler/BrowserConsoleHandler.php b/src/Monolog/Handler/BrowserConsoleHandler.php index 95f74f105..43190b92f 100644 --- a/src/Monolog/Handler/BrowserConsoleHandler.php +++ b/src/Monolog/Handler/BrowserConsoleHandler.php @@ -11,7 +11,6 @@ namespace Monolog\Handler; -use Monolog\Logger; use Monolog\Formatter\LineFormatter; /** @@ -103,7 +102,8 @@ private static function generateScript() ); } } - 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 @@ private static function handleCustomStyles($style, $string) 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 @@ private static function dump($title, array $dict) } $script[] = self::call('log', self::quote('%s: %o'), self::quote($key), $value); } + return $script; } @@ -172,6 +173,7 @@ private static function call() { $args = func_get_args(); $method = array_shift($args); + return self::call_array($method, $args); } diff --git a/src/Monolog/Handler/DynamoDbHandler.php b/src/Monolog/Handler/DynamoDbHandler.php index 5702c5fb7..e7f843c8a 100644 --- a/src/Monolog/Handler/DynamoDbHandler.php +++ b/src/Monolog/Handler/DynamoDbHandler.php @@ -14,7 +14,6 @@ use Aws\Common\Aws; use Aws\DynamoDb\DynamoDbClient; use Monolog\Formatter\ScalarFormatter; -use Monolog\Handler\AbstractProcessingHandler; use Monolog\Logger; /** diff --git a/src/Monolog/Handler/FilterHandler.php b/src/Monolog/Handler/FilterHandler.php index 51a46fb4d..16276fb02 100644 --- a/src/Monolog/Handler/FilterHandler.php +++ b/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 @@ public function getAcceptedLevels() } /** - * @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) { diff --git a/src/Monolog/Handler/FlowdockHandler.php b/src/Monolog/Handler/FlowdockHandler.php index a5428dc8a..0916343c0 100644 --- a/src/Monolog/Handler/FlowdockHandler.php +++ b/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 */ diff --git a/src/Monolog/Handler/GelfHandler.php b/src/Monolog/Handler/GelfHandler.php index c38aef807..790f6364d 100644 --- a/src/Monolog/Handler/GelfHandler.php +++ b/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) { diff --git a/src/Monolog/Handler/HipChatHandler.php b/src/Monolog/Handler/HipChatHandler.php index 3e4009960..38ce931ce 100644 --- a/src/Monolog/Handler/HipChatHandler.php +++ b/src/Monolog/Handler/HipChatHandler.php @@ -285,7 +285,7 @@ private function combineRecords($records) * system where `mb_strlen()` is unavailable. * * @param string $str - * @param int $length + * @param int $length * * @return bool */ diff --git a/src/Monolog/Handler/NativeMailerHandler.php b/src/Monolog/Handler/NativeMailerHandler.php index e371c224d..f97df482a 100644 --- a/src/Monolog/Handler/NativeMailerHandler.php +++ b/src/Monolog/Handler/NativeMailerHandler.php @@ -77,7 +77,7 @@ public function __construct($to, $subject, $from, $level = Logger::ERROR, $bubbl /** * 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 @@ public function getEncoding() } /** - * @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; } } diff --git a/src/Monolog/Handler/RavenHandler.php b/src/Monolog/Handler/RavenHandler.php index 653e61c1c..98e91691a 100644 --- a/src/Monolog/Handler/RavenHandler.php +++ b/src/Monolog/Handler/RavenHandler.php @@ -14,7 +14,6 @@ use Monolog\Formatter\LineFormatter; use Monolog\Formatter\FormatterInterface; use Monolog\Logger; -use Monolog\Handler\AbstractProcessingHandler; use Raven_Client; /** diff --git a/src/Monolog/Handler/RollbarHandler.php b/src/Monolog/Handler/RollbarHandler.php index 18f2036ab..fb02ad60e 100644 --- a/src/Monolog/Handler/RollbarHandler.php +++ b/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) { diff --git a/tests/Monolog/Formatter/ElasticaFormatterTest.php b/tests/Monolog/Formatter/ElasticaFormatterTest.php index 59f159f06..546e5c260 100644 --- a/tests/Monolog/Formatter/ElasticaFormatterTest.php +++ b/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 { diff --git a/tests/Monolog/Formatter/GelfMessageFormatterTest.php b/tests/Monolog/Formatter/GelfMessageFormatterTest.php index c031d68ad..d47ba91cc 100644 --- a/tests/Monolog/Formatter/GelfMessageFormatterTest.php +++ b/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 { diff --git a/tests/Monolog/Formatter/JsonFormatterTest.php b/tests/Monolog/Formatter/JsonFormatterTest.php index bad19f731..39cb1c5fa 100644 --- a/tests/Monolog/Formatter/JsonFormatterTest.php +++ b/tests/Monolog/Formatter/JsonFormatterTest.php @@ -64,7 +64,7 @@ public function testFormatBatchNewlines() $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)); diff --git a/tests/Monolog/Formatter/LogglyFormatterTest.php b/tests/Monolog/Formatter/LogglyFormatterTest.php index 4ef0cb8a9..6d59b3f3d 100644 --- a/tests/Monolog/Formatter/LogglyFormatterTest.php +++ b/tests/Monolog/Formatter/LogglyFormatterTest.php @@ -11,7 +11,6 @@ namespace Monolog\Formatter; -use Monolog\Logger; use Monolog\TestCase; class LogglyFormatterTest extends TestCase diff --git a/tests/Monolog/Formatter/LogstashFormatterTest.php b/tests/Monolog/Formatter/LogstashFormatterTest.php index b02a09880..5776ab721 100644 --- a/tests/Monolog/Formatter/LogstashFormatterTest.php +++ b/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 { diff --git a/tests/Monolog/Functional/Handler/FirePHPHandlerTest.php b/tests/Monolog/Functional/Handler/FirePHPHandlerTest.php index 65b530970..7e4e7eb56 100644 --- a/tests/Monolog/Functional/Handler/FirePHPHandlerTest.php +++ b/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; diff --git a/tests/Monolog/Handler/AbstractProcessingHandlerTest.php b/tests/Monolog/Handler/AbstractProcessingHandlerTest.php index 96871d3ee..24d4f63ce 100644 --- a/tests/Monolog/Handler/AbstractProcessingHandlerTest.php +++ b/tests/Monolog/Handler/AbstractProcessingHandlerTest.php @@ -70,7 +70,7 @@ public function testProcessRecord() $handledRecord = null; $handler->expects($this->once()) ->method('write') - ->will($this->returnCallback(function($record) use (&$handledRecord) { + ->will($this->returnCallback(function ($record) use (&$handledRecord) { $handledRecord = $record; })) ; diff --git a/tests/Monolog/Handler/BrowserConsoleHandlerTest.php b/tests/Monolog/Handler/BrowserConsoleHandlerTest.php index ff244f12c..f3d8038c7 100644 --- a/tests/Monolog/Handler/BrowserConsoleHandlerTest.php +++ b/tests/Monolog/Handler/BrowserConsoleHandlerTest.php @@ -40,7 +40,7 @@ public function testStyling() $handler->handle($this->getRecord(Logger::DEBUG, 'foo[[bar]]{color: red}')); $expected = <<handle($this->getRecord(Logger::DEBUG, "[foo] [[\"bar\n[baz]\"]]{color: red}")); $expected = <<handle($this->getRecord(Logger::DEBUG, '[[foo]]{macro: autolabel}')); $expected = <<handle($this->getRecord(Logger::DEBUG, 'test', array('foo' => 'bar'))); $expected = <<handle($this->getRecord(Logger::DEBUG, 'test4')); $expected = <<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 @@ public function testHandleIntegration() /** * 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 @@ protected function getCreatedDocId(Response $response) /** * 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 @@ protected function getDocSourceFromElastic(Client $client, $index, $type, $docum if (!empty($data['_source'])) { return $data['_source']; } + return array(); } } diff --git a/tests/Monolog/Handler/FingersCrossedHandlerTest.php b/tests/Monolog/Handler/FingersCrossedHandlerTest.php index 7713e6a93..12c5ea11d 100644 --- a/tests/Monolog/Handler/FingersCrossedHandlerTest.php +++ b/tests/Monolog/Handler/FingersCrossedHandlerTest.php @@ -102,7 +102,7 @@ public function testHandleBufferLimit() 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 @@ public function testHandleWithCallback() */ public function testHandleWithBadCallbackThrowsException() { - $handler = new FingersCrossedHandler(function($record, $handler) { + $handler = new FingersCrossedHandler(function ($record, $handler) { return 'foo'; }); $handler->handle($this->getRecord(Logger::WARNING)); diff --git a/tests/Monolog/Handler/GelfHandlerLegacyTest.php b/tests/Monolog/Handler/GelfHandlerLegacyTest.php index 50cb7cfec..d60a6db37 100644 --- a/tests/Monolog/Handler/GelfHandlerLegacyTest.php +++ b/tests/Monolog/Handler/GelfHandlerLegacyTest.php @@ -23,8 +23,6 @@ public function setUp() if (!class_exists('Gelf\MessagePublisher') || !class_exists('Gelf\Message')) { $this->markTestSkipped("mlehner/gelf-php not installed"); } - - require_once __DIR__ . '/GelfMocks.php'; } /** diff --git a/tests/Monolog/Handler/GelfHandlerTest.php b/tests/Monolog/Handler/GelfHandlerTest.php index 131e6526e..83136875c 100644 --- a/tests/Monolog/Handler/GelfHandlerTest.php +++ b/tests/Monolog/Handler/GelfHandlerTest.php @@ -64,7 +64,6 @@ public function testDebug() $handler = $this->getHandler($messagePublisher); - $handler->handle($record); } @@ -87,7 +86,6 @@ public function testWarning() $handler = $this->getHandler($messagePublisher); - $handler->handle($record); } diff --git a/tests/Monolog/Handler/GelfMocks.php b/tests/Monolog/Handler/GelfMocks.php deleted file mode 100644 index dda871140..000000000 --- a/tests/Monolog/Handler/GelfMocks.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * 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; -} diff --git a/tests/Monolog/Handler/RavenHandlerTest.php b/tests/Monolog/Handler/RavenHandlerTest.php index 8d3ea81f2..bde55b171 100644 --- a/tests/Monolog/Handler/RavenHandlerTest.php +++ b/tests/Monolog/Handler/RavenHandlerTest.php @@ -14,7 +14,6 @@ use Monolog\TestCase; use Monolog\Logger; use Monolog\Formatter\LineFormatter; -use Monolog\Handler\RavenHandler; class RavenHandlerTest extends TestCase { @@ -99,7 +98,7 @@ public function testHandleBatch() $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; })); diff --git a/tests/Monolog/Handler/SocketHandlerTest.php b/tests/Monolog/Handler/SocketHandlerTest.php index c642bea8b..3a925eb59 100644 --- a/tests/Monolog/Handler/SocketHandlerTest.php +++ b/tests/Monolog/Handler/SocketHandlerTest.php @@ -120,7 +120,7 @@ public function testWriteFailsOnIfFwriteReturnsFalse() { $this->setMockHandler(array('fwrite')); - $callback = function($arg) { + $callback = function ($arg) { $map = array( 'Hello world' => 6, 'world' => false, @@ -143,7 +143,7 @@ public function testWriteFailsIfStreamTimesOut() { $this->setMockHandler(array('fwrite', 'streamGetMetadata')); - $callback = function($arg) { + $callback = function ($arg) { $map = array( 'Hello world' => 6, 'world' => 5, @@ -170,7 +170,7 @@ public function testWriteFailsOnIncompleteWrite() $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 @@ public function testWriteWithMock() { $this->setMockHandler(array('fwrite')); - $callback = function($arg) { + $callback = function ($arg) { $map = array( 'Hello world' => 6, 'world' => 5, diff --git a/tests/Monolog/Handler/SyslogUdpHandlerTest.php b/tests/Monolog/Handler/SyslogUdpHandlerTest.php index 1cc2148a1..269a296ea 100644 --- a/tests/Monolog/Handler/SyslogUdpHandlerTest.php +++ b/tests/Monolog/Handler/SyslogUdpHandlerTest.php @@ -2,8 +2,6 @@ namespace Monolog\Handler; -use Monolog\TestCase; - class SyslogUdpHandlerTest extends \PHPUnit_Framework_TestCase { /** diff --git a/tests/Monolog/LoggerTest.php b/tests/Monolog/LoggerTest.php index 8bcbbf90a..7a19c0b4e 100644 --- a/tests/Monolog/LoggerTest.php +++ b/tests/Monolog/LoggerTest.php @@ -162,7 +162,7 @@ public function testProcessorsAreExecuted() $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 @@ public function testProcessorsNotCalledWhenNotHandled() ; $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'); diff --git a/tests/Monolog/TestCase.php b/tests/Monolog/TestCase.php index 1067b9197..cae793400 100644 --- a/tests/Monolog/TestCase.php +++ b/tests/Monolog/TestCase.php @@ -51,7 +51,7 @@ protected function getIdentityFormatter() $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; }