Skip to content

Commit

Permalink
CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Jun 18, 2018
1 parent fa9c4eb commit 41b8f5e
Show file tree
Hide file tree
Showing 29 changed files with 71 additions and 56 deletions.
11 changes: 5 additions & 6 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ return PhpCsFixer\Config::create()
'@PSR2' => true,
// some rules disabled as long as 1.x branch is maintained
'binary_operator_spaces' => array(
'align_double_arrow' => null,
'align_equals' => null,
'default' => null,
),
'blank_line_before_return' => true,
'cast_spaces' => true,
'header_comment' => array('header' => $header),
'blank_line_before_statement' => ['statements' => ['continue', 'declare', 'return', 'throw', 'try']],
'cast_spaces' => ['space' => 'single'],
'header_comment' => ['header' => $header],
'include' => true,
'method_separation' => true,
'class_attributes_separation' => ['elements' => ['method']],
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_statement' => true,
Expand Down
2 changes: 1 addition & 1 deletion src/Monolog/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function registerErrorHandler(array $levelMap = [], $callPrevious = true,
}

/**
* @param string|null $level a LogLevel::* constant, null to use the default LogLevel::ALERT or false to disable fatal error handling
* @param string|null $level a LogLevel::* constant, null to use the default LogLevel::ALERT or false to disable fatal error handling
* @param int $reservedMemorySize Amount of KBs to reserve in memory so that it can be freed when handling fatal errors giving Monolog some room in memory to get its job done
*/
public function registerFatalHandler($level = null, int $reservedMemorySize = 20): self
Expand Down
4 changes: 2 additions & 2 deletions src/Monolog/Handler/AbstractSyslogHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ abstract class AbstractSyslogHandler extends AbstractProcessingHandler

/**
* @param mixed $facility
* @param 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 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
*/
public function __construct($facility = LOG_USER, $level = Logger::DEBUG, $bubble = true)
{
Expand Down
3 changes: 2 additions & 1 deletion src/Monolog/Handler/BrowserConsoleHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ private static function generateScript()
if (empty($context) && empty($extra)) {
$script[] = static::call_array('log', static::handleStyles($record['formatted']));
} else {
$script = array_merge($script,
$script = array_merge(
$script,
[static::call_array('groupCollapsed', static::handleStyles($record['formatted']))],
$context,
$extra,
Expand Down
1 change: 0 additions & 1 deletion src/Monolog/Handler/ChromePHPHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
class ChromePHPHandler extends AbstractProcessingHandler
{

use WebRequestRecognizerTrait;

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Monolog/Handler/CubeHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public function __construct($url, $level = Logger::DEBUG, $bubble = true)
if (!in_array($urlInfo['scheme'], $this->acceptedSchemes)) {
throw new \UnexpectedValueException(
'Invalid protocol (' . $urlInfo['scheme'] . ').'
. ' Valid options are ' . implode(', ', $this->acceptedSchemes));
. ' Valid options are ' . implode(', ', $this->acceptedSchemes)
);
}

$this->scheme = $urlInfo['scheme'];
Expand Down
1 change: 1 addition & 0 deletions src/Monolog/Handler/ElasticSearchHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public function setFormatter(FormatterInterface $formatter): HandlerInterface
if ($formatter instanceof ElasticaFormatter) {
return parent::setFormatter($formatter);
}

throw new \InvalidArgumentException('ElasticSearchHandler is only compatible with ElasticaFormatter');
}

Expand Down
6 changes: 4 additions & 2 deletions src/Monolog/Handler/ErrorLogHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function __construct($messageType = self::OPERATING_SYSTEM, $level = Logg

if (false === in_array($messageType, self::getAvailableTypes(), true)) {
$message = sprintf('The given message type "%s" is not supported', print_r($messageType, true));

throw new \InvalidArgumentException($message);
}

Expand Down Expand Up @@ -73,9 +74,10 @@ protected function write(array $record)
{
if (!$this->expandNewlines) {
error_log((string) $record['formatted'], $this->messageType);

return;
}
}

$lines = preg_split('{[\r\n]+}', (string) $record['formatted']);
foreach ($lines as $line) {
error_log($line, $this->messageType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface ActivationStrategyInterface
/**
* Returns whether the given record activates the handler.
*
* @param array $record
* @param array $record
* @return bool
*/
public function isHandlerActivated(array $record);
Expand Down
1 change: 0 additions & 1 deletion src/Monolog/Handler/FirePHPHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/
class FirePHPHandler extends AbstractProcessingHandler
{

use WebRequestRecognizerTrait;

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Monolog/Handler/HandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public function isHandling(array $record): bool;
* Unless the bubbling is interrupted (by returning true), the Logger class will keep on
* calling further handlers in the stack with a given log record.
*
* @param array $record The record to handle
* @return bool true means that this handler handled the record, and that bubbling is not permitted.
* false means the record was either not processed or that this handler allows bubbling.
* @param array $record The record to handle
* @return bool true means that this handler handled the record, and that bubbling is not permitted.
* false means the record was either not processed or that this handler allows bubbling.
*/
public function handle(array $record): bool;

Expand Down
6 changes: 3 additions & 3 deletions src/Monolog/Handler/InsightOpsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
* file that was distributed with this source code.
*/

namespace Monolog\Handler;
namespace Monolog\Handler;

use Monolog\Logger;
use Monolog\Logger;

/**
/**
* Inspired on LogEntriesHandler.
*
* @author Robert Kaufmann III <rok3@rok3.me>
Expand Down
10 changes: 5 additions & 5 deletions src/Monolog/Handler/RollbarHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Sends errors to Rollbar
*
* If the context data contains a `payload` key, that is used as an array
* of payload options to RollbarLogger's log method.
* of payload options to RollbarLogger's log method.
*
* Rollbar's context info will contain the context + extra keys from the log record
* merged, and then on top of that a few keys:
Expand Down Expand Up @@ -59,9 +59,9 @@ class RollbarHandler extends AbstractProcessingHandler
protected $initialized = false;

/**
* @param RollbarLogger $rollbarLogger RollbarLogger object constructed with valid token
* @param 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 RollbarLogger $rollbarLogger RollbarLogger object constructed with valid token
* @param 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
*/
public function __construct(RollbarLogger $rollbarLogger, $level = Logger::ERROR, $bubble = true)
{
Expand Down Expand Up @@ -96,7 +96,7 @@ protected function write(array $record)
} else {
$toLog = $record['message'];
}

$this->rollbarLogger->log($context['level'], $toLog, $context);

$this->hasRecords = true;
Expand Down
2 changes: 1 addition & 1 deletion src/Monolog/Handler/SlackWebhookHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected function write(array $record)
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array('Content-type: application/json'),
CURLOPT_POSTFIELDS => $postString
CURLOPT_POSTFIELDS => $postString,
);
if (defined('CURLOPT_SAFE_UPLOAD')) {
$options[CURLOPT_SAFE_UPLOAD] = true;
Expand Down
1 change: 0 additions & 1 deletion src/Monolog/Handler/SqsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/
class SqsHandler extends AbstractProcessingHandler
{

/** 256 KB in bytes - maximum message size in SQS */
const MAX_MESSAGE_SIZE = 262144;
/** 100 KB in bytes - head message size for new error log */
Expand Down
1 change: 1 addition & 0 deletions src/Monolog/Handler/StreamHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ protected function write(array $record)
restore_error_handler();
if (!is_resource($this->stream)) {
$this->stream = null;

throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened: '.$this->errorMessage, $this->url));
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Monolog/Handler/TestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public function hasRecord($record, $level)
if (isset($record['context']) && $rec['context'] !== $record['context']) {
return false;
}

return true;
}, $level);
}
Expand Down
10 changes: 9 additions & 1 deletion src/Monolog/Handler/WebRequestRecognizerTrait.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
<?php declare(strict_types=1);

/*
* 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;

trait WebRequestRecognizerTrait
{

/**
* Checks if PHP's serving a web request
* @return bool
Expand Down
8 changes: 4 additions & 4 deletions src/Monolog/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ public function useMicrosecondTimestamps(bool $micro)
/**
* Adds a log record.
*
* @param int $level The logging level
* @param string $message The log message
* @param array $context The log context
* @return bool Whether the record has been processed
* @param int $level The logging level
* @param string $message The log message
* @param array $context The log context
* @return bool Whether the record has been processed
*/
public function addRecord(int $level, string $message, array $context = []): bool
{
Expand Down
2 changes: 0 additions & 2 deletions src/Monolog/Processor/HostnameProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

namespace Monolog\Processor;

use Monolog\Logger;

/**
* Injects value of gethostname in all records
*/
Expand Down
2 changes: 2 additions & 0 deletions src/Monolog/Processor/IntrospectionProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ public function __invoke(array $record): array
foreach ($this->skipClassesPartials as $part) {
if (strpos($trace[$i]['class'], $part) !== false) {
$i++;

continue 2;
}
}
} elseif (in_array($trace[$i]['function'], $this->skipFunctions)) {
$i++;

continue;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Monolog/Processor/PsrLogMessageProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class PsrLogMessageProcessor
private $removeUsedContextFields;

/**
* @param string $dateFormat The format of the timestamp: one supported by DateTime::format
* @param bool $removeUsedContextFields If set to true the fields interpolated into message gets unset
* @param string $dateFormat The format of the timestamp: one supported by DateTime::format
* @param bool $removeUsedContextFields If set to true the fields interpolated into message gets unset
*/
public function __construct(string $dateFormat = null, bool $removeUsedContextFields = false)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Monolog/Formatter/GelfMessageFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public function testFormatWithUnlimitedLength()
'context' => array('exception' => str_repeat(' ', 32767 * 2)),
'datetime' => new \DateTime("@0"),
'extra' => array('key' => str_repeat(' ', 32767 * 2)),
'message' => 'log'
'message' => 'log',
);
$message = $formatter->format($record);
$messageArray = $message->toArray();
Expand Down
1 change: 1 addition & 0 deletions tests/Monolog/Handler/ElasticSearchHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public function testHandleIntegration()

$client = new Client();
$handler = new ElasticSearchHandler($client, $this->options);

try {
$handler->handleBatch([$msg]);
} catch (\RuntimeException $e) {
Expand Down
5 changes: 4 additions & 1 deletion tests/Monolog/Handler/FilterHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ public function testHandleWithCallback()
$handler = new FilterHandler(
function ($record, $handler) use ($test) {
return $test;
}, Logger::INFO, Logger::NOTICE, false
},
Logger::INFO,
Logger::NOTICE,
false
);
$handler->handle($this->getRecord(Logger::DEBUG));
$handler->handle($this->getRecord(Logger::INFO));
Expand Down
11 changes: 5 additions & 6 deletions tests/Monolog/Handler/InsightOpsHandlerTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

/*
* This file is part of the Monolog package.
Expand All @@ -9,12 +9,12 @@
* file that was distributed with this source code.
*/

namespace Monolog\Handler;
use Monolog\Test\TestCase;
namespace Monolog\Handler;

use Monolog\Test\TestCase;
use Monolog\Logger;

/**
/**
* @author Robert Kaufmann III <rok3@rok3.me>
* @author Gabriel Machado <gabriel.ms1@hotmail.com>
*/
Expand Down Expand Up @@ -62,7 +62,6 @@ private function createHandler()
->setConstructorArgs($args)
->getMock();


$reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($this->handler, 'localhost:1234');
Expand Down
4 changes: 2 additions & 2 deletions tests/Monolog/Handler/RollbarHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ private function setupRollbarLoggerMock()
{
$config = array(
'access_token' => 'ad865e76e7fb496fab096ac07b1dbabb',
'environment' => 'test'
'environment' => 'test',
);

$this->rollbarLogger = $this->getMockBuilder(RollbarLogger::class)
->setConstructorArgs(array($config))
->setMethods(array('log'))
Expand Down
5 changes: 2 additions & 3 deletions tests/Monolog/Handler/RotatingFileHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ public function rotationTests()
$dayCallback = function ($ago) use ($now) {
return $now + 86400 * $ago;
};
$monthCallback = function($ago) {
$monthCallback = function ($ago) {
return gmmktime(0, 0, 0, (int) (date('n') + $ago), 1, (int) date('Y'));
};
$yearCallback = function($ago) {
$yearCallback = function ($ago) {
return gmmktime(0, 0, 0, 1, 1, (int) (date('Y') + $ago));
};

Expand Down Expand Up @@ -216,7 +216,6 @@ public function testRotationWhenSimilarFileNamesExist($dateFormat)

public function rotationWhenSimilarFilesExistTests()
{

return array(
'Rotation is triggered when the file of the current day is not present but similar exists'
=> array(RotatingFileHandler::FILE_PER_DAY),
Expand Down
Loading

0 comments on commit 41b8f5e

Please sign in to comment.