diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
index c4b5786744..26519c7cc2 100644
--- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
+++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
@@ -1,6 +1,11 @@
CHANGELOG
=========
+5.3.0
+-----
+
+ * Added support for configuring PHP error level to log levels
+
5.2.0
-----
diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
index 3460470622..e0a073c88f 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
@@ -1070,14 +1070,31 @@ class Configuration implements ConfigurationInterface
->info('PHP errors handling configuration')
->addDefaultsIfNotSet()
->children()
- ->scalarNode('log')
+ ->variableNode('log')
->info('Use the application logger instead of the PHP logger for logging PHP errors.')
- ->example('"true" to use the default configuration: log all errors. "false" to disable. An integer bit field of E_* constants.')
+ ->example('"true" to use the default configuration: log all errors. "false" to disable. An integer bit field of E_* constants, or an array mapping E_* constants to log levels.')
->defaultValue($this->debug)
->treatNullLike($this->debug)
+ ->beforeNormalization()
+ ->ifArray()
+ ->then(function (array $v): array {
+ if (!($v[0]['type'] ?? false)) {
+ return $v;
+ }
+
+ // Fix XML normalization
+
+ $ret = [];
+ foreach ($v as ['type' => $type, 'logLevel' => $logLevel]) {
+ $ret[$type] = $logLevel;
+ }
+
+ return $ret;
+ })
+ ->end()
->validate()
- ->ifTrue(function ($v) { return !(\is_int($v) || \is_bool($v)); })
- ->thenInvalid('The "php_errors.log" parameter should be either an integer or a boolean.')
+ ->ifTrue(function ($v) { return !(\is_int($v) || \is_bool($v) || \is_array($v)); })
+ ->thenInvalid('The "php_errors.log" parameter should be either an integer, a boolean, or an array')
->end()
->end()
->booleanNode('throw')
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
index 61410d874c..c92fd3cd3b 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
@@ -313,10 +313,18 @@
+
+
+
+
+
+
+
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_log_levels.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_log_levels.php
new file mode 100644
index 0000000000..e4560ac45f
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_log_levels.php
@@ -0,0 +1,10 @@
+loadFromExtension('framework', [
+ 'php_errors' => [
+ 'log' => [
+ \E_NOTICE => \Psr\Log\LogLevel::ERROR,
+ \E_WARNING => \Psr\Log\LogLevel::ERROR,
+ ]
+ ],
+]);
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/php_errors_log_levels.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/php_errors_log_levels.xml
new file mode 100644
index 0000000000..1b6642a575
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/php_errors_log_levels.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/php_errors_log_levels.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/php_errors_log_levels.yml
new file mode 100644
index 0000000000..ad9fd30667
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/php_errors_log_levels.yml
@@ -0,0 +1,5 @@
+framework:
+ php_errors:
+ log:
+ !php/const \E_NOTICE: !php/const Psr\Log\LogLevel::ERROR
+ !php/const \E_WARNING: !php/const Psr\Log\LogLevel::ERROR
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
index 0fc7b47d56..9efb52f327 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
@@ -498,6 +498,18 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertSame(8, $definition->getArgument(2));
}
+ public function testPhpErrorsWithLogLevels()
+ {
+ $container = $this->createContainerFromFile('php_errors_log_levels');
+
+ $definition = $container->getDefinition('debug.debug_handlers_listener');
+ $this->assertEquals(new Reference('monolog.logger.php', ContainerInterface::NULL_ON_INVALID_REFERENCE), $definition->getArgument(1));
+ $this->assertSame([
+ \E_NOTICE => \Psr\Log\LogLevel::ERROR,
+ \E_WARNING => \Psr\Log\LogLevel::ERROR,
+ ], $definition->getArgument(2));
+ }
+
public function testRouter()
{
$container = $this->createContainerFromFile('full');