Skip to content

Commit

Permalink
CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Mar 23, 2014
1 parent 8222de9 commit 392ef35
Show file tree
Hide file tree
Showing 29 changed files with 55 additions and 88 deletions.
6 changes: 3 additions & 3 deletions src/Monolog/Formatter/JsonFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
});

Expand Down
1 change: 1 addition & 0 deletions src/Monolog/Formatter/LogglyFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
8 changes: 5 additions & 3 deletions src/Monolog/Handler/BrowserConsoleHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Monolog\Handler;

use Monolog\Logger;
use Monolog\Formatter\LineFormatter;

/**
Expand Down Expand Up @@ -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)
Expand All @@ -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])) {
Expand Down Expand Up @@ -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;
}

Expand All @@ -172,6 +173,7 @@ private static function call()
{
$args = func_get_args();
$method = array_shift($args);

return self::call_array($method, $args);
}

Expand Down
1 change: 0 additions & 1 deletion src/Monolog/Handler/DynamoDbHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Aws\Common\Aws;
use Aws\DynamoDb\DynamoDbClient;
use Monolog\Formatter\ScalarFormatter;
use Monolog\Handler\AbstractProcessingHandler;
use Monolog\Logger;

/**
Expand Down
10 changes: 5 additions & 5 deletions src/Monolog/Handler/FilterHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Monolog/Handler/FlowdockHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
6 changes: 3 additions & 3 deletions src/Monolog/Handler/GelfHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Monolog/Handler/HipChatHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
10 changes: 6 additions & 4 deletions src/Monolog/Handler/NativeMailerHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
}
1 change: 0 additions & 1 deletion src/Monolog/Handler/RavenHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Monolog\Formatter\LineFormatter;
use Monolog\Formatter\FormatterInterface;
use Monolog\Logger;
use Monolog\Handler\AbstractProcessingHandler;
use Raven_Client;

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Monolog/Handler/RollbarHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
1 change: 0 additions & 1 deletion tests/Monolog/Formatter/ElasticaFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Monolog\Formatter;

use Monolog\Logger;
use Monolog\Formatter\ElasticaFormatter;

class ElasticaFormatterTest extends \PHPUnit_Framework_TestCase
{
Expand Down
1 change: 0 additions & 1 deletion tests/Monolog/Formatter/GelfMessageFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Monolog\Formatter;

use Monolog\Logger;
use Monolog\Formatter\GelfMessageFormatter;

class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Monolog/Formatter/JsonFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
1 change: 0 additions & 1 deletion tests/Monolog/Formatter/LogglyFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Monolog\Formatter;

use Monolog\Logger;
use Monolog\TestCase;

class LogglyFormatterTest extends TestCase
Expand Down
1 change: 0 additions & 1 deletion tests/Monolog/Formatter/LogstashFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Monolog\Formatter;

use Monolog\Logger;
use Monolog\Formatter\LogstashFormatter;

class LogstashFormatterTest extends \PHPUnit_Framework_TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Monolog/Functional/Handler/FirePHPHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/Monolog/Handler/AbstractProcessingHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}))
;
Expand Down
10 changes: 5 additions & 5 deletions tests/Monolog/Handler/BrowserConsoleHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testStyling()
$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;
Expand All @@ -56,7 +56,7 @@ public function testEscaping()
$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;
Expand All @@ -75,7 +75,7 @@ public function testAutolabel()
$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");
Expand All @@ -93,7 +93,7 @@ public function testContext()
$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");
Expand All @@ -118,7 +118,7 @@ public function testConcurrentHandlers()
$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");
Expand Down
14 changes: 7 additions & 7 deletions tests/Monolog/Handler/ElasticSearchHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Monolog\Handler;

use Monolog\Handler\ElasticSearchHandler;
use Monolog\Formatter\ElasticaFormatter;
use Monolog\Formatter\NormalizerFormatter;
use Monolog\TestCase;
Expand Down Expand Up @@ -185,7 +184,7 @@ public function testHandleIntegration()
$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");
}

Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -234,6 +233,7 @@ protected function getDocSourceFromElastic(Client $client, $index, $type, $docum
if (!empty($data['_source'])) {
return $data['_source'];
}

return array();
}
}
4 changes: 2 additions & 2 deletions tests/Monolog/Handler/FingersCrossedHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));
Expand Down
2 changes: 0 additions & 2 deletions tests/Monolog/Handler/GelfHandlerLegacyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

/**
Expand Down
2 changes: 0 additions & 2 deletions tests/Monolog/Handler/GelfHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public function testDebug()

$handler = $this->getHandler($messagePublisher);


$handler->handle($record);

}
Expand All @@ -87,7 +86,6 @@ public function testWarning()

$handler = $this->getHandler($messagePublisher);


$handler->handle($record);
}

Expand Down
Loading

0 comments on commit 392ef35

Please sign in to comment.