Skip to content

Commit 3a7a5c2

Browse files
authored
Merge branch 'master' into autowiring_monolog_channels
2 parents 4120c49 + 3239d22 commit 3a7a5c2

16 files changed

+616
-608
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## 3.5.0 (xxxx-xx-xx)
22

3+
* Added support for Monolog 2.0
34
* Added `sentry` type to use sentry 2.0 client
45
* Added `insightops` handler
56
* Added possibility for auto-wire monolog channel according to the type-hinted aliases, introduced in the Symfony 4.2

DependencyInjection/Compiler/AddProcessorsPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ public function process(ContainerBuilder $container)
4747
}
4848

4949
if (!empty($tag['method'])) {
50-
$processor = array(new Reference($id), $tag['method']);
50+
$processor = [new Reference($id), $tag['method']];
5151
} else {
5252
// If no method is defined, fallback to use __invoke
5353
$processor = new Reference($id);
5454
}
55-
$definition->addMethodCall('pushProcessor', array($processor));
55+
$definition->addMethodCall('pushProcessor', [$processor]);
5656
}
5757
}
5858
}

DependencyInjection/Compiler/AddSwiftMailerTransportPass.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ public function process(ContainerBuilder $container)
3535
$mailerId = (string) $definition->getArgument(0);
3636

3737
// Try to fetch the transport for a non-default mailer first, then go with the default swiftmailer
38-
$possibleServices = array(
38+
$possibleServices = [
3939
$mailerId.'.transport.real',
4040
$mailerId.'.transport',
4141
'swiftmailer.transport.real',
4242
'swiftmailer.transport',
43-
);
43+
];
4444

4545
foreach ($possibleServices as $serviceId) {
4646
if ($container->hasAlias($serviceId) || $container->hasDefinition($serviceId)) {
4747
$definition->addMethodCall(
4848
'setTransport',
49-
array(new Reference($serviceId))
49+
[new Reference($serviceId)]
5050
);
5151

5252
break;

DependencyInjection/Compiler/DebugHandlerPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ public function process(ContainerBuilder $container)
4646
return;
4747
}
4848

49-
$debugHandler = new Definition('Symfony\Bridge\Monolog\Handler\DebugHandler', array(Logger::DEBUG, true));
49+
$debugHandler = new Definition('Symfony\Bridge\Monolog\Handler\DebugHandler', [Logger::DEBUG, true]);
5050
$container->setDefinition('monolog.handler.debug', $debugHandler);
5151

5252
foreach ($this->channelPass->getChannels() as $channel) {
5353
$container
5454
->getDefinition($channel === 'app' ? 'monolog.logger' : 'monolog.logger.'.$channel)
55-
->addMethodCall('pushHandler', array(new Reference('monolog.handler.debug')));
55+
->addMethodCall('pushHandler', [new Reference('monolog.handler.debug')]);
5656
}
5757
}
5858
}

DependencyInjection/Compiler/FixEmptyLoggerPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function process(ContainerBuilder $container)
4949
}
5050
}
5151

52-
$def->addMethodCall('pushHandler', array(new Reference('monolog.handler.null_internal')));
52+
$def->addMethodCall('pushHandler', [new Reference('monolog.handler.null_internal')]);
5353
}
5454
}
5555
}

DependencyInjection/Compiler/LoggerChannelPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727
class LoggerChannelPass implements CompilerPassInterface
2828
{
29-
protected $channels = array('app');
29+
protected $channels = ['app'];
3030

3131
/**
3232
* {@inheritDoc}
@@ -103,7 +103,7 @@ public function process(ContainerBuilder $container)
103103
$msg = 'Monolog configuration error: The logging channel "'.$channel.'" assigned to the "'.substr($handler, 16).'" handler does not exist.';
104104
throw new \InvalidArgumentException($msg, 0, $e);
105105
}
106-
$logger->addMethodCall('pushHandler', array(new Reference($handler)));
106+
$logger->addMethodCall('pushHandler', [new Reference($handler)]);
107107
}
108108
}
109109
}

DependencyInjection/Configuration.php

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -421,10 +421,10 @@ public function getConfigTreeBuilder()
421421
*/
422422

423423
if (is_array($value)) {
424-
return isset($value['code']) ? $value : array('code' => key($value), 'urls' => current($value));
424+
return isset($value['code']) ? $value : ['code' => key($value), 'urls' => current($value)];
425425
}
426426

427-
return array('code' => $value, 'urls' => array());
427+
return ['code' => $value, 'urls' => []];
428428
}, $values);
429429
})
430430
->end()
@@ -481,7 +481,7 @@ public function getConfigTreeBuilder()
481481
->canBeUnset()
482482
->beforeNormalization()
483483
->ifString()
484-
->then(function ($v) { return array('id' => $v); })
484+
->then(function ($v) { return ['id' => $v]; })
485485
->end()
486486
->children()
487487
->scalarNode('id')->end()
@@ -500,7 +500,7 @@ public function getConfigTreeBuilder()
500500
->canBeUnset()
501501
->beforeNormalization()
502502
->ifString()
503-
->then(function ($v) { return array('id' => $v); })
503+
->then(function ($v) { return ['id' => $v]; })
504504
->end()
505505
->children()
506506
->scalarNode('id')->end()
@@ -528,7 +528,7 @@ public function getConfigTreeBuilder()
528528
->canBeUnset()
529529
->beforeNormalization()
530530
->ifString()
531-
->then(function ($v) { return array('id' => $v); })
531+
->then(function ($v) { return ['id' => $v]; })
532532
->end()
533533
->children()
534534
->scalarNode('id')->end()
@@ -552,7 +552,7 @@ public function getConfigTreeBuilder()
552552
->canBeUnset()
553553
->beforeNormalization()
554554
->ifString()
555-
->then(function ($v) { return array('id' => $v); })
555+
->then(function ($v) { return ['id' => $v]; })
556556
->end()
557557
->children()
558558
->scalarNode('id')->end()
@@ -573,7 +573,7 @@ public function getConfigTreeBuilder()
573573
->canBeUnset()
574574
->beforeNormalization()
575575
->ifString()
576-
->then(function ($v) { return array('id' => $v); })
576+
->then(function ($v) { return ['id' => $v]; })
577577
->end()
578578
->children()
579579
->scalarNode('id')->end()
@@ -600,7 +600,7 @@ public function getConfigTreeBuilder()
600600
->prototype('scalar')->end()
601601
->beforeNormalization()
602602
->ifString()
603-
->then(function ($v) { return array($v); })
603+
->then(function ($v) { return [$v]; })
604604
->end()
605605
->end()
606606
->scalarNode('subject')->end() // swift_mailer and native_mailer
@@ -614,7 +614,7 @@ public function getConfigTreeBuilder()
614614
->canBeUnset()
615615
->beforeNormalization()
616616
->ifString()
617-
->then(function ($v) { return array('id' => $v); })
617+
->then(function ($v) { return ['id' => $v]; })
618618
->end()
619619
->children()
620620
->scalarNode('id')->isRequired()->end()
@@ -660,8 +660,8 @@ public function getConfigTreeBuilder()
660660
->beforeNormalization()
661661
->ifArray()
662662
->then(function ($v) {
663-
$map = array();
664-
$verbosities = array('VERBOSITY_QUIET', 'VERBOSITY_NORMAL', 'VERBOSITY_VERBOSE', 'VERBOSITY_VERY_VERBOSE', 'VERBOSITY_DEBUG');
663+
$map = [];
664+
$verbosities = ['VERBOSITY_QUIET', 'VERBOSITY_NORMAL', 'VERBOSITY_VERBOSE', 'VERBOSITY_VERY_VERBOSE', 'VERBOSITY_DEBUG'];
665665
// allow numeric indexed array with ascendning verbosity and lowercase names of the constants
666666
foreach ($v as $verbosity => $level) {
667667
if (is_int($verbosity) && isset($verbosities[$verbosity])) {
@@ -683,7 +683,7 @@ public function getConfigTreeBuilder()
683683
->end()
684684
->validate()
685685
->always(function ($v) {
686-
$map = array();
686+
$map = [];
687687
foreach ($v as $verbosity => $level) {
688688
$verbosityConstant = 'Symfony\Component\Console\Output\OutputInterface::'.$verbosity;
689689

@@ -718,11 +718,11 @@ public function getConfigTreeBuilder()
718718
->canBeUnset()
719719
->beforeNormalization()
720720
->ifString()
721-
->then(function ($v) { return array('elements' => array($v)); })
721+
->then(function ($v) { return ['elements' => [$v]]; })
722722
->end()
723723
->beforeNormalization()
724724
->ifTrue(function ($v) { return is_array($v) && is_numeric(key($v)); })
725-
->then(function ($v) { return array('elements' => $v); })
725+
->then(function ($v) { return ['elements' => $v]; })
726726
->end()
727727
->validate()
728728
->ifTrue(function ($v) { return empty($v); })
@@ -735,7 +735,7 @@ public function getConfigTreeBuilder()
735735
$isExclusive = 'exclusive' === $v['type'];
736736
}
737737

738-
$elements = array();
738+
$elements = [];
739739
foreach ($v['elements'] as $element) {
740740
if (0 === strpos($element, '!')) {
741741
if (false === $isExclusive) {
@@ -756,13 +756,13 @@ public function getConfigTreeBuilder()
756756
return null;
757757
}
758758

759-
return array('type' => $isExclusive ? 'exclusive' : 'inclusive', 'elements' => $elements);
759+
return ['type' => $isExclusive ? 'exclusive' : 'inclusive', 'elements' => $elements];
760760
})
761761
->end()
762762
->children()
763763
->scalarNode('type')
764764
->validate()
765-
->ifNotInArray(array('inclusive', 'exclusive'))
765+
->ifNotInArray(['inclusive', 'exclusive'])
766766
->thenInvalid('The type of channels has to be inclusive or exclusive')
767767
->end()
768768
->end()
@@ -855,11 +855,11 @@ public function getConfigTreeBuilder()
855855
->thenInvalid('The token and room have to be specified to use a HipChatHandler')
856856
->end()
857857
->validate()
858-
->ifTrue(function ($v) { return 'hipchat' === $v['type'] && !in_array($v['message_format'], array('text', 'html')); })
858+
->ifTrue(function ($v) { return 'hipchat' === $v['type'] && !in_array($v['message_format'], ['text', 'html']); })
859859
->thenInvalid('The message_format has to be "text" or "html" in a HipChatHandler')
860860
->end()
861861
->validate()
862-
->ifTrue(function ($v) { return 'hipchat' === $v['type'] && null !== $v['api_version'] && !in_array($v['api_version'], array('v1', 'v2'), true); })
862+
->ifTrue(function ($v) { return 'hipchat' === $v['type'] && null !== $v['api_version'] && !in_array($v['api_version'], ['v1', 'v2'], true); })
863863
->thenInvalid('The api_version has to be "v1" or "v2" in a HipChatHandler')
864864
->end()
865865
->validate()
@@ -938,25 +938,25 @@ public function getConfigTreeBuilder()
938938
->ifTrue(function ($v) { return isset($v['debug']); })
939939
->thenInvalid('The "debug" name cannot be used as it is reserved for the handler of the profiler')
940940
->end()
941-
->example(array(
942-
'syslog' => array(
941+
->example([
942+
'syslog' => [
943943
'type' => 'stream',
944944
'path' => '/var/log/symfony.log',
945945
'level' => 'ERROR',
946946
'bubble' => 'false',
947947
'formatter' => 'my_formatter',
948-
),
949-
'main' => array(
948+
],
949+
'main' => [
950950
'type' => 'fingers_crossed',
951951
'action_level' => 'WARNING',
952952
'buffer_size' => 30,
953953
'handler' => 'custom',
954-
),
955-
'custom' => array(
954+
],
955+
'custom' => [
956956
'type' => 'service',
957957
'id' => 'my_handler',
958-
)
959-
))
958+
]
959+
])
960960
->end()
961961
->end()
962962
;

0 commit comments

Comments
 (0)