diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 84e2f88b..7a1d94b2 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -141,21 +141,11 @@ public function getConfigTreeBuilder() ->end() ->scalarNode('formatter')->defaultNull()->end() ->scalarNode('captured_body_length') - ->beforeNormalization() - ->always(function ($maxLength) { - if (null === $maxLength) { - return null; - } - - if (!is_int($maxLength)) { - $invalidConfiguration = new InvalidConfigurationException('The child node "captured_body_length" at path "httplug.profiling" must be an integer or null.'); - $invalidConfiguration->setPath('httplug.profiling'); - - throw $invalidConfiguration; - } - - return $maxLength; + ->validate() + ->ifTrue(function ($v) { + return null !== $v && !is_int($v); }) + ->thenInvalid('The child node "captured_body_length" at path "httplug.profiling" must be an integer or null ("%s" given).') ->end() ->defaultValue(0) ->info('Limit long HTTP message bodies to x characters. If set to 0 we do not read the message body. If null the body will not be truncated. Only available with the default formatter (FullHttpMessageFormatter).') diff --git a/tests/Unit/DependencyInjection/ConfigurationTest.php b/tests/Unit/DependencyInjection/ConfigurationTest.php index 570e7482..31b33c96 100644 --- a/tests/Unit/DependencyInjection/ConfigurationTest.php +++ b/tests/Unit/DependencyInjection/ConfigurationTest.php @@ -406,7 +406,7 @@ public function testLimitlessCapturedBodyLength() /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException - * @expectedExceptionMessage The child node "captured_body_length" at path "httplug.profiling" must be an integer or null. + * @expectedExceptionMessage The child node "captured_body_length" at path "httplug.profiling" must be an integer or null */ public function testInvalidCapturedBodyLengthString() {