Skip to content

Commit

Permalink
CS fixes & upgrading cs fixer config
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Nov 18, 2015
1 parent 75ca9e5 commit c889fb2
Show file tree
Hide file tree
Showing 64 changed files with 288 additions and 218 deletions.
73 changes: 58 additions & 15 deletions .php_cs
@@ -1,15 +1,58 @@
<?php

$finder = Symfony\CS\Finder\DefaultFinder::create()
->files()
->name('*.php')
->in(__DIR__.'/src')
->in(__DIR__.'/tests')
;

return Symfony\CS\Config\Config::create()
->fixers(array(
'psr0', 'encoding', 'short_tag', 'braces', 'elseif', 'eof_ending', 'function_declaration', 'indentation', 'line_after_namespace', 'linefeed', 'lowercase_constants', 'lowercase_keywords', 'multiple_use', 'php_closing_tag', 'trailing_spaces', 'visibility', 'duplicate_semicolon', 'extra_empty_lines', 'include', 'namespace_no_leading_whitespace', 'object_operator', 'operators_spaces', 'phpdoc_params', 'return', 'single_array_no_trailing_comma', 'spaces_cast', 'standardize_not_equal', 'ternary_spaces', 'unused_use', 'whitespacy_lines',
))
->finder($finder)
;
<?php

$header = <<<EOF
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.
EOF;

$finder = Symfony\CS\Finder\DefaultFinder::create()
->files()
->name('*.php')
->exclude('Fixtures')
->in(__DIR__.'/src')
->in(__DIR__.'/tests')
;

return Symfony\CS\Config\Config::create()
->setUsingCache(true)
->setRiskyAllowed(true)
->setRules(array(
'@PSR2' => true,
'duplicate_semicolon' => true,
'extra_empty_lines' => true,
'header_comment' => array('header' => $header),
'include' => true,
'long_array_syntax' => true,
'method_separation' => true,
'multiline_array_trailing_comma' => true,
'namespace_no_leading_whitespace' => true,
'no_blank_lines_after_class_opening' => true,
'no_empty_lines_after_phpdocs' => true,
'object_operator' => true,
'operators_spaces' => true,
'phpdoc_align' => true,
'phpdoc_indent' => true,
'phpdoc_no_access' => true,
'phpdoc_no_package' => true,
'phpdoc_order' => true,
'phpdoc_scalar' => true,
'phpdoc_trim' => true,
'phpdoc_type_to_var' => true,
'psr0' => true,
'return' => true,
'remove_leading_slash_use' => true,
'remove_lines_between_uses' => true,
'single_array_no_trailing_comma' => true,
'single_blank_line_before_namespace' => true,
'spaces_cast' => true,
'standardize_not_equal' => true,
'ternary_spaces' => true,
'unused_use' => true,
'whitespacy_lines' => true,
))
->finder($finder)
;
6 changes: 3 additions & 3 deletions src/Monolog/Formatter/FluentdFormatter.php
Expand Up @@ -32,7 +32,6 @@
*
* @author Andrius Putna <fordnox@gmail.com>
*/

class FluentdFormatter implements FormatterInterface
{
/**
Expand All @@ -46,7 +45,7 @@ public function __construct($levelTag = false)
throw new \RuntimeException('PHP\'s json extension is required to use Monolog\'s FluentdUnixFormatter');
}

$this->levelTag = (bool)$levelTag;
$this->levelTag = (bool) $levelTag;
}

public function isUsingLevelsInTag()
Expand All @@ -63,7 +62,7 @@ public function format(array $record)

$message = array(
'message' => $record['message'],
'extra' => $record['extra']
'extra' => $record['extra'],
);

if (!$this->levelTag) {
Expand All @@ -86,6 +85,7 @@ public function formatBatch(array $records)
foreach ($records as $record) {
$message .= $this->format($record);
}

return $message;
}
}
5 changes: 3 additions & 2 deletions src/Monolog/Formatter/HtmlFormatter.php
Expand Up @@ -64,8 +64,8 @@ private function addRow($th, $td = ' ', $escapeTd = true)
/**
* Create a HTML h1 tag
*
* @param string $title Text to be in the h1
* @param integer $level Error level
* @param string $title Text to be in the h1
* @param int $level Error level
* @return string
*/
private function addTitle($title, $level)
Expand All @@ -74,6 +74,7 @@ private function addTitle($title, $level)

return '<h1 style="background: '.$this->logLevels[$level].';color: #ffffff;padding: 5px;" class="monolog-output">'.$title.'</h1>';
}

/**
* Formats a log record.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Monolog/Formatter/LogglyFormatter.php
Expand Up @@ -22,7 +22,7 @@ class LogglyFormatter extends JsonFormatter
* Overrides the default batch mode to new lines for compatibility with the
* Loggly bulk API.
*
* @param integer $batchMode
* @param int $batchMode
*/
public function __construct($batchMode = self::BATCH_MODE_NEWLINES, $appendNewline = false)
{
Expand Down
14 changes: 7 additions & 7 deletions src/Monolog/Formatter/LogstashFormatter.php
Expand Up @@ -45,16 +45,16 @@ class LogstashFormatter extends NormalizerFormatter
protected $contextPrefix;

/**
* @var integer logstash format version to use
* @var int logstash format version to use
*/
protected $version;

/**
* @param string $applicationName the application that sends the data, used as the "type" field of logstash
* @param string $systemName the system/machine name, used as the "source" field of logstash, defaults to the hostname of the machine
* @param string $extraPrefix prefix for extra keys inside logstash "fields"
* @param string $contextPrefix prefix for context keys inside logstash "fields", defaults to ctxt_
* @param integer $version the logstash format version to use, defaults to 0
* @param string $applicationName the application that sends the data, used as the "type" field of logstash
* @param string $systemName the system/machine name, used as the "source" field of logstash, defaults to the hostname of the machine
* @param string $extraPrefix prefix for extra keys inside logstash "fields"
* @param string $contextPrefix prefix for context keys inside logstash "fields", defaults to ctxt_
* @param int $version the logstash format version to use, defaults to 0
*/
public function __construct($applicationName, $systemName = null, $extraPrefix = null, $contextPrefix = 'ctxt_', $version = self::V0)
{
Expand Down Expand Up @@ -92,7 +92,7 @@ protected function formatV0(array $record)
$message = array(
'@timestamp' => $record['datetime'],
'@source' => $this->systemName,
'@fields' => array()
'@fields' => array(),
);
if (isset($record['message'])) {
$message['@message'] = $record['message'];
Expand Down
4 changes: 2 additions & 2 deletions src/Monolog/Formatter/NormalizerFormatter.php
Expand Up @@ -165,8 +165,8 @@ protected function toJson($data, $ignoreErrors = false)
/**
* Throws an exception according to a given code with a customized message
*
* @param int $code return code of json_last_error function
* @param mixed $data data that was meant to be encoded
* @param int $code return code of json_last_error function
* @param mixed $data data that was meant to be encoded
* @throws \RuntimeException
*/
private function throwEncodeError($code, $data)
Expand Down
6 changes: 3 additions & 3 deletions src/Monolog/Handler/AbstractHandler.php
Expand Up @@ -32,7 +32,7 @@ abstract class AbstractHandler implements HandlerInterface
protected $processors = array();

/**
* @param integer $level The minimum logging level at which this handler will be triggered
* @param int $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($level = Logger::DEBUG, $bubble = true)
Expand Down Expand Up @@ -118,7 +118,7 @@ public function getFormatter()
/**
* Sets minimum logging level at which this handler will be triggered.
*
* @param integer $level
* @param int $level
* @return self
*/
public function setLevel($level)
Expand All @@ -131,7 +131,7 @@ public function setLevel($level)
/**
* Gets minimum logging level at which this handler will be triggered.
*
* @return integer
* @return int
*/
public function getLevel()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Monolog/Handler/AbstractSyslogHandler.php
Expand Up @@ -54,7 +54,7 @@ abstract class AbstractSyslogHandler extends AbstractProcessingHandler

/**
* @param mixed $facility
* @param integer $level The minimum logging level at which this handler will be triggered
* @param int $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($facility = LOG_USER, $level = Logger::DEBUG, $bubble = true)
Expand Down
4 changes: 2 additions & 2 deletions src/Monolog/Handler/AmqpHandler.php
Expand Up @@ -70,7 +70,7 @@ protected function write(array $record)
0,
array(
'delivery_mode' => 2,
'Content-type' => 'application/json'
'Content-type' => 'application/json',
)
);
} else {
Expand All @@ -79,7 +79,7 @@ protected function write(array $record)
(string) $data,
array(
'delivery_mode' => 2,
'content_type' => 'application/json'
'content_type' => 'application/json',
)
),
$this->exchangeName,
Expand Down
1 change: 0 additions & 1 deletion src/Monolog/Handler/BrowserConsoleHandler.php
Expand Up @@ -31,7 +31,6 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
* Example of formatted string:
*
* You can do [[blue text]]{color: blue} or [[green background]]{background-color: green; color: white}
*
*/
protected function getDefaultFormatter()
{
Expand Down
4 changes: 2 additions & 2 deletions src/Monolog/Handler/BufferHandler.php
Expand Up @@ -32,8 +32,8 @@ class BufferHandler extends AbstractHandler

/**
* @param HandlerInterface $handler Handler.
* @param integer $bufferLimit How many entries should be buffered at most, beyond that the oldest items are removed from the buffer.
* @param integer $level The minimum logging level at which this handler will be triggered
* @param int $bufferLimit How many entries should be buffered at most, beyond that the oldest items are removed from the buffer.
* @param int $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 Boolean $flushOnOverflow If true, the buffer is flushed when the max size has been reached, by default oldest entries are discarded
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Monolog/Handler/ChromePHPHandler.php
Expand Up @@ -51,7 +51,7 @@ class ChromePHPHandler extends AbstractProcessingHandler
protected static $sendHeaders = true;

/**
* @param integer $level The minimum logging level at which this handler will be triggered
* @param int $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($level = Logger::DEBUG, $bubble = true)
Expand Down
2 changes: 1 addition & 1 deletion src/Monolog/Handler/CouchDBHandler.php
Expand Up @@ -54,7 +54,7 @@ protected function write(array $record)
'ignore_errors' => true,
'max_redirects' => 0,
'header' => 'Content-type: application/json',
)
),
));

if (false === @file_get_contents($url, null, $context)) {
Expand Down
12 changes: 6 additions & 6 deletions src/Monolog/Handler/CubeHandler.php
Expand Up @@ -32,8 +32,8 @@ class CubeHandler extends AbstractProcessingHandler
* Create a Cube handler
*
* @throws \UnexpectedValueException when given url is not a valid url.
* A valid url must consist of three parts : protocol://host:port
* Only valid protocols used by Cube are http and udp
* A valid url must consist of three parts : protocol://host:port
* Only valid protocols used by Cube are http and udp
*/
public function __construct($url, $level = Logger::DEBUG, $bubble = true)
{
Expand All @@ -59,7 +59,7 @@ public function __construct($url, $level = Logger::DEBUG, $bubble = true)
/**
* Establish a connection to an UDP socket
*
* @throws \LogicException when unable to connect to the socket
* @throws \LogicException when unable to connect to the socket
* @throws MissingExtensionException when there is no socket extension
*/
protected function connectUdp()
Expand Down Expand Up @@ -142,9 +142,9 @@ private function writeHttp($data)

curl_setopt($this->httpConnection, CURLOPT_POSTFIELDS, '['.$data.']');
curl_setopt($this->httpConnection, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen('['.$data.']'))
);
'Content-Type: application/json',
'Content-Length: ' . strlen('['.$data.']'),
));

Curl\Util::execute($this->httpConnection, 5, false);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Monolog/Handler/Curl/Util.php
Expand Up @@ -26,7 +26,7 @@ class Util
/**
* Executes a CURL request with optional retries and exception on failure
*
* @param resource $ch curl handler
* @param resource $ch curl handler
* @throws \RuntimeException
*/
public static function execute($ch, $retries = 5, $closeAfterDone = true)
Expand Down
6 changes: 3 additions & 3 deletions src/Monolog/Handler/DynamoDbHandler.php
Expand Up @@ -39,8 +39,8 @@ class DynamoDbHandler extends AbstractProcessingHandler
/**
* @param DynamoDbClient $client
* @param string $table
* @param integer $level
* @param boolean $bubble
* @param int $level
* @param bool $bubble
*/
public function __construct(DynamoDbClient $client, $table, $level = Logger::DEBUG, $bubble = true)
{
Expand All @@ -64,7 +64,7 @@ protected function write(array $record)

$this->client->putItem(array(
'TableName' => $this->table,
'Item' => $formatted
'Item' => $formatted,
));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Monolog/Handler/ElasticSearchHandler.php
Expand Up @@ -48,7 +48,7 @@ class ElasticSearchHandler extends AbstractProcessingHandler
/**
* @param Client $client Elastica Client object
* @param array $options Handler configuration
* @param integer $level The minimum logging level at which this handler will be triggered
* @param int $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(Client $client, array $options = array(), $level = Logger::DEBUG, $bubble = true)
Expand Down
4 changes: 2 additions & 2 deletions src/Monolog/Handler/ErrorLogHandler.php
Expand Up @@ -28,8 +28,8 @@ class ErrorLogHandler extends AbstractProcessingHandler
protected $expandNewlines;

/**
* @param integer $messageType Says where the error should go.
* @param integer $level The minimum logging level at which this handler will be triggered
* @param int $messageType Says where the error should go.
* @param int $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 Boolean $expandNewlines If set to true, newlines in the message will be expanded to be take multiple log entries
*/
Expand Down
Expand Up @@ -2,12 +2,12 @@

/*
* 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.
*/
*
* (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\FingersCrossed;

Expand Down
2 changes: 1 addition & 1 deletion src/Monolog/Handler/FleepHookHandler.php
Expand Up @@ -118,7 +118,7 @@ private function buildHeader($content)
private function buildContent($record)
{
$dataArray = array(
'message' => $record['formatted']
'message' => $record['formatted'],
);

return http_build_query($dataArray);
Expand Down
4 changes: 2 additions & 2 deletions src/Monolog/Handler/GelfHandler.php
Expand Up @@ -33,8 +33,8 @@ class GelfHandler extends AbstractProcessingHandler

/**
* @param PublisherInterface|IMessagePublisher|Publisher $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 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($publisher, $level = Logger::DEBUG, $bubble = true)
{
Expand Down

0 comments on commit c889fb2

Please sign in to comment.