Skip to content

Commit

Permalink
Convert to short arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
fprochazka committed Apr 19, 2016
1 parent 21657e1 commit 5ec8fca
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 174 deletions.
90 changes: 45 additions & 45 deletions src/Kdyby/Monolog/CustomChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CustomChannel extends Monolog\Logger

public function __construct($name, Logger $parentLogger)
{
parent::__construct($name, array(), array());
parent::__construct($name, [], []);
$this->parentLogger = $parentLogger;
}

Expand Down Expand Up @@ -106,9 +106,9 @@ public function getProcessors()
* {@inheritdoc}
* @return Boolean Whether the record has been processed
*/
public function addRecord($level, $message, array $context = array())
public function addRecord($level, $message, array $context = [])
{
return $this->parentLogger->addRecord($level, $message, array('channel' => $this->name) + $context);
return $this->parentLogger->addRecord($level, $message, ['channel' => $this->name] + $context);
}


Expand All @@ -117,9 +117,9 @@ public function addRecord($level, $message, array $context = array())
* {@inheritdoc}
* @return Boolean Whether the record has been processed
*/
public function addDebug($message, array $context = array())
public function addDebug($message, array $context = [])
{
return $this->parentLogger->addDebug($message, array('channel' => $this->name) + $context);
return $this->parentLogger->addDebug($message, ['channel' => $this->name] + $context);
}


Expand All @@ -128,9 +128,9 @@ public function addDebug($message, array $context = array())
* {@inheritdoc}
* @return Boolean Whether the record has been processed
*/
public function addInfo($message, array $context = array())
public function addInfo($message, array $context = [])
{
return $this->parentLogger->addInfo($message, array('channel' => $this->name) + $context);
return $this->parentLogger->addInfo($message, ['channel' => $this->name] + $context);
}


Expand All @@ -139,9 +139,9 @@ public function addInfo($message, array $context = array())
* {@inheritdoc}
* @return Boolean Whether the record has been processed
*/
public function addNotice($message, array $context = array())
public function addNotice($message, array $context = [])
{
return $this->parentLogger->addNotice($message, array('channel' => $this->name) + $context);
return $this->parentLogger->addNotice($message, ['channel' => $this->name] + $context);
}


Expand All @@ -150,9 +150,9 @@ public function addNotice($message, array $context = array())
* {@inheritdoc}
* @return Boolean Whether the record has been processed
*/
public function addWarning($message, array $context = array())
public function addWarning($message, array $context = [])
{
return $this->parentLogger->addWarning($message, array('channel' => $this->name) + $context);
return $this->parentLogger->addWarning($message, ['channel' => $this->name] + $context);
}


Expand All @@ -161,9 +161,9 @@ public function addWarning($message, array $context = array())
* {@inheritdoc}
* @return Boolean Whether the record has been processed
*/
public function addError($message, array $context = array())
public function addError($message, array $context = [])
{
return $this->parentLogger->addError($message, array('channel' => $this->name) + $context);
return $this->parentLogger->addError($message, ['channel' => $this->name] + $context);
}


Expand All @@ -172,9 +172,9 @@ public function addError($message, array $context = array())
* {@inheritdoc}
* @return Boolean Whether the record has been processed
*/
public function addCritical($message, array $context = array())
public function addCritical($message, array $context = [])
{
return $this->parentLogger->addCritical($message, array('channel' => $this->name) + $context);
return $this->parentLogger->addCritical($message, ['channel' => $this->name] + $context);
}


Expand All @@ -183,9 +183,9 @@ public function addCritical($message, array $context = array())
* {@inheritdoc}
* @return Boolean Whether the record has been processed
*/
public function addAlert($message, array $context = array())
public function addAlert($message, array $context = [])
{
return $this->parentLogger->addAlert($message, array('channel' => $this->name) + $context);
return $this->parentLogger->addAlert($message, ['channel' => $this->name] + $context);
}


Expand All @@ -194,9 +194,9 @@ public function addAlert($message, array $context = array())
* {@inheritdoc}
* @return Boolean Whether the record has been processed
*/
public function addEmergency($message, array $context = array())
public function addEmergency($message, array $context = [])
{
return $this->parentLogger->addEmergency($message, array('channel' => $this->name) + $context);
return $this->parentLogger->addEmergency($message, ['channel' => $this->name] + $context);
}


Expand All @@ -216,9 +216,9 @@ public function isHandling($level)
* {@inheritdoc}
* @return Boolean Whether the record has been processed
*/
public function log($level, $message, array $context = array())
public function log($level, $message, array $context = [])
{
return $this->parentLogger->log($level, $message, array('channel' => $this->name) + $context);
return $this->parentLogger->log($level, $message, ['channel' => $this->name] + $context);
}


Expand All @@ -227,9 +227,9 @@ public function log($level, $message, array $context = array())
* {@inheritdoc}
* @return Boolean Whether the record has been processed
*/
public function debug($message, array $context = array())
public function debug($message, array $context = [])
{
return $this->parentLogger->debug($message, array('channel' => $this->name) + $context);
return $this->parentLogger->debug($message, ['channel' => $this->name] + $context);
}


Expand All @@ -238,9 +238,9 @@ public function debug($message, array $context = array())
* {@inheritdoc}
* @return Boolean Whether the record has been processed
*/
public function info($message, array $context = array())
public function info($message, array $context = [])
{
return $this->parentLogger->info($message, array('channel' => $this->name) + $context);
return $this->parentLogger->info($message, ['channel' => $this->name] + $context);
}


Expand All @@ -249,9 +249,9 @@ public function info($message, array $context = array())
* {@inheritdoc}
* @return Boolean Whether the record has been processed
*/
public function notice($message, array $context = array())
public function notice($message, array $context = [])
{
return $this->parentLogger->notice($message, array('channel' => $this->name) + $context);
return $this->parentLogger->notice($message, ['channel' => $this->name] + $context);
}


Expand All @@ -260,9 +260,9 @@ public function notice($message, array $context = array())
* {@inheritdoc}
* @return Boolean Whether the record has been processed
*/
public function warn($message, array $context = array())
public function warn($message, array $context = [])
{
return $this->parentLogger->warn($message, array('channel' => $this->name) + $context);
return $this->parentLogger->warn($message, ['channel' => $this->name] + $context);
}


Expand All @@ -271,9 +271,9 @@ public function warn($message, array $context = array())
* {@inheritdoc}
* @return Boolean Whether the record has been processed
*/
public function warning($message, array $context = array())
public function warning($message, array $context = [])
{
return $this->parentLogger->warning($message, array('channel' => $this->name) + $context);
return $this->parentLogger->warning($message, ['channel' => $this->name] + $context);
}


Expand All @@ -282,9 +282,9 @@ public function warning($message, array $context = array())
* {@inheritdoc}
* @return Boolean Whether the record has been processed
*/
public function err($message, array $context = array())
public function err($message, array $context = [])
{
return $this->parentLogger->err($message, array('channel' => $this->name) + $context);
return $this->parentLogger->err($message, ['channel' => $this->name] + $context);
}


Expand All @@ -293,9 +293,9 @@ public function err($message, array $context = array())
* {@inheritdoc}
* @return Boolean Whether the record has been processed
*/
public function error($message, array $context = array())
public function error($message, array $context = [])
{
return $this->parentLogger->error($message, array('channel' => $this->name) + $context);
return $this->parentLogger->error($message, ['channel' => $this->name] + $context);
}


Expand All @@ -304,9 +304,9 @@ public function error($message, array $context = array())
* {@inheritdoc}
* @return Boolean Whether the record has been processed
*/
public function crit($message, array $context = array())
public function crit($message, array $context = [])
{
return $this->parentLogger->crit($message, array('channel' => $this->name) + $context);
return $this->parentLogger->crit($message, ['channel' => $this->name] + $context);
}


Expand All @@ -315,9 +315,9 @@ public function crit($message, array $context = array())
* {@inheritdoc}
* @return Boolean Whether the record has been processed
*/
public function critical($message, array $context = array())
public function critical($message, array $context = [])
{
return $this->parentLogger->critical($message, array('channel' => $this->name) + $context);
return $this->parentLogger->critical($message, ['channel' => $this->name] + $context);
}


Expand All @@ -326,9 +326,9 @@ public function critical($message, array $context = array())
* {@inheritdoc}
* @return Boolean Whether the record has been processed
*/
public function alert($message, array $context = array())
public function alert($message, array $context = [])
{
return $this->parentLogger->alert($message, array('channel' => $this->name) + $context);
return $this->parentLogger->alert($message, ['channel' => $this->name] + $context);
}


Expand All @@ -337,9 +337,9 @@ public function alert($message, array $context = array())
* {@inheritdoc}
* @return Boolean Whether the record has been processed
*/
public function emerg($message, array $context = array())
public function emerg($message, array $context = [])
{
return $this->parentLogger->emerg($message, array('channel' => $this->name) + $context);
return $this->parentLogger->emerg($message, ['channel' => $this->name] + $context);
}


Expand All @@ -348,9 +348,9 @@ public function emerg($message, array $context = array())
* {@inheritdoc}
* @return Boolean Whether the record has been processed
*/
public function emergency($message, array $context = array())
public function emergency($message, array $context = [])
{
return $this->parentLogger->emergency($message, array('channel' => $this->name) + $context);
return $this->parentLogger->emergency($message, ['channel' => $this->name] + $context);
}

}
40 changes: 20 additions & 20 deletions src/Kdyby/Monolog/DI/MonologExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ class MonologExtension extends CompilerExtension
const TAG_PROCESSOR = 'monolog.processor';
const TAG_PRIORITY = 'monolog.priority';

private $defaults = array(
'handlers' => array(),
'processors' => array(),
private $defaults = [
'handlers' => [],
'processors' => [],
'name' => 'app',
'hookToTracy' => TRUE,
'tracyBaseUrl' => NULL,
'usePriorityProcessor' => TRUE,
// 'registerFallback' => TRUE,
);
];



Expand All @@ -55,7 +55,7 @@ public function loadConfiguration()
}

$builder->addDefinition($this->prefix('logger'))
->setClass('Kdyby\Monolog\Logger', array($config['name']));
->setClass('Kdyby\Monolog\Logger', [$config['name']]);

if (!isset($builder->parameters['logDir'])) {
if (Debugger::$logDirectory) {
Expand All @@ -75,7 +75,7 @@ public function loadConfiguration()

// Tracy adapter
$builder->addDefinition($this->prefix('adapter'))
->setClass('Kdyby\Monolog\Diagnostics\MonologAdapter', array($this->prefix('@logger')))
->setClass('Kdyby\Monolog\Diagnostics\MonologAdapter', [$this->prefix('@logger')])
->addTag('logger');

if ($builder->hasDefinition('tracy.logger')) { // since Nette 2.3
Expand All @@ -101,9 +101,9 @@ protected function loadHandlers(array $config)
$builder = $this->getContainerBuilder();

foreach ($config['handlers'] as $handlerName => $implementation) {
$this->compiler->parseServices($builder, array(
'services' => array($serviceName = $this->prefix('handler.' . $handlerName) => $implementation),
));
$this->compiler->parseServices($builder, [
'services' => [$serviceName = $this->prefix('handler.' . $handlerName) => $implementation],
]);

$builder->getDefinition($serviceName)
->addTag(self::TAG_HANDLER)
Expand Down Expand Up @@ -141,9 +141,9 @@ protected function loadProcessors(array $config)
}

foreach ($config['processors'] as $processorName => $implementation) {
$this->compiler->parseServices($builder, array(
'services' => array($serviceName = $this->prefix('processor.' . $processorName) => $implementation),
));
$this->compiler->parseServices($builder, [
'services' => [$serviceName = $this->prefix('processor.' . $processorName) => $implementation],
]);

$builder->getDefinition($serviceName)
->addTag(self::TAG_PROCESSOR)
Expand All @@ -159,19 +159,19 @@ public function beforeCompile()
$logger = $builder->getDefinition($this->prefix('logger'));

foreach ($handlers = $this->findByTagSorted(self::TAG_HANDLER) as $serviceName => $meta) {
$logger->addSetup('pushHandler', array('@' . $serviceName));
$logger->addSetup('pushHandler', ['@' . $serviceName]);
}

foreach ($this->findByTagSorted(self::TAG_PROCESSOR) as $serviceName => $meta) {
$logger->addSetup('pushProcessor', array('@' . $serviceName));
$logger->addSetup('pushProcessor', ['@' . $serviceName]);
}

$config = $this->getConfig(array('registerFallback' => empty($handlers)) + $this->getConfig($this->defaults));
$config = $this->getConfig(['registerFallback' => empty($handlers)] + $this->getConfig($this->defaults));

if ($config['registerFallback']) {
$logger->addSetup('pushHandler', array(
new Statement('Kdyby\Monolog\Handler\FallbackNetteHandler', array($config['name'], $builder->expand('%logDir%')))
));
$logger->addSetup('pushHandler', [
new Statement('Kdyby\Monolog\Handler\FallbackNetteHandler', [$config['name'], $builder->expand('%logDir%')])
]);
}
}

Expand Down Expand Up @@ -211,11 +211,11 @@ public function afterCompile(Code\ClassType $class)
$code = '\Nette\Diagnostics\Debugger::$logger = $this->getService(?);';
}

$initialize->addBody($code, array($this->prefix('adapter')));
$initialize->addBody($code, [$this->prefix('adapter')]);
}

if (empty(Debugger::$logDirectory)) {
$initialize->addBody('Tracy\Debugger::$logDirectory = ?;', array($builder->expand('%logDir%')));
$initialize->addBody('Tracy\Debugger::$logDirectory = ?;', [$builder->expand('%logDir%')]);
}
}

Expand Down
Loading

0 comments on commit 5ec8fca

Please sign in to comment.