From f882813c58ffb7ec2123585942a36cecd6893b8e Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Fri, 22 Sep 2017 13:54:05 -0400 Subject: [PATCH 1/6] Adding Definition::addError() and a compiler pass to throw errors as exceptions --- .../Compiler/AbstractRecursivePass.php | 3 ++ .../Compiler/AutowireExceptionPass.php | 2 + .../Compiler/AutowirePass.php | 7 ++- .../Compiler/CheckArgumentsValidityPass.php | 32 +++++++++-- .../Compiler/DefinitionErrorExceptionPass.php | 39 ++++++++++++++ .../Compiler/PassConfig.php | 8 +-- .../DependencyInjection/Definition.php | 21 ++++++++ .../Compiler/AutowireExceptionPassTest.php | 3 ++ .../Tests/Compiler/AutowirePassTest.php | 5 +- .../CheckArgumentsValidityPassTest.php | 11 ++++ .../DefinitionErrorExceptionPassTest.php | 53 +++++++++++++++++++ .../Tests/DefinitionTest.php | 9 ++++ 12 files changed, 183 insertions(+), 10 deletions(-) create mode 100644 src/Symfony/Component/DependencyInjection/Compiler/DefinitionErrorExceptionPass.php create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Compiler/DefinitionErrorExceptionPassTest.php diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php index bbe869b935e5c..0851d33e7e9cf 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php @@ -22,6 +22,9 @@ */ abstract class AbstractRecursivePass implements CompilerPassInterface { + /** + * @var ContainerBuilder + */ protected $container; protected $currentId; diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowireExceptionPass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowireExceptionPass.php index 12be3d915fd10..185e0f3d4dabf 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AutowireExceptionPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowireExceptionPass.php @@ -11,6 +11,8 @@ namespace Symfony\Component\DependencyInjection\Compiler; +@trigger_error('The '.__NAMESPACE__.'\AutowireExceptionPass class is deprecated since version 3.4 and will be removed in 4.0. Use the DefinitionErrorExceptionPass class instead.', E_USER_DEPRECATED); + use Symfony\Component\DependencyInjection\ContainerBuilder; /** diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php index 8cb1978ef675d..688099391b5f4 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php @@ -36,7 +36,7 @@ class AutowirePass extends AbstractRecursivePass private $autowiringExceptions = array(); /** - * @param bool $throwOnAutowireException If false, retrieved errors via getAutowiringExceptions + * @param bool $throwOnAutowireException Errors can be retrieved via Definition::getErrors() */ public function __construct($throwOnAutowireException = true) { @@ -44,10 +44,14 @@ public function __construct($throwOnAutowireException = true) } /** + * @deprecated + * * @return AutowiringFailedException[] */ public function getAutowiringExceptions() { + @trigger_error('Calling AutowirePass::getAutowiringExceptions() is deprecated since Symfony 3.4 and will be removed in 4.0. Use Definition::getErrors() instead.', E_USER_DEPRECATED); + return $this->autowiringExceptions; } @@ -106,6 +110,7 @@ protected function processValue($value, $isRoot = false) } $this->autowiringExceptions[] = $e; + $this->container->getDefinition($this->currentId)->addError($e->getMessage()); return parent::processValue($value, $isRoot); } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/CheckArgumentsValidityPass.php b/src/Symfony/Component/DependencyInjection/Compiler/CheckArgumentsValidityPass.php index 6b48a156919da..939c9e8bab896 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/CheckArgumentsValidityPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/CheckArgumentsValidityPass.php @@ -22,6 +22,13 @@ */ class CheckArgumentsValidityPass extends AbstractRecursivePass { + private $throwExceptions; + + public function __construct($throwExceptions = true) + { + $this->throwExceptions = $throwExceptions; + } + /** * {@inheritdoc} */ @@ -35,10 +42,19 @@ protected function processValue($value, $isRoot = false) foreach ($value->getArguments() as $k => $v) { if ($k !== $i++) { if (!is_int($k)) { - throw new RuntimeException(sprintf('Invalid constructor argument for service "%s": integer expected but found string "%s". Check your service definition.', $this->currentId, $k)); + $value->addError(sprintf('Invalid constructor argument for service "%s": integer expected but found string "%s". Check your service definition.', $this->currentId, $k)); + + if ($this->throwExceptions) { + throw new RuntimeException(sprintf('Invalid constructor argument for service "%s": integer expected but found string "%s". Check your service definition.', $this->currentId, $k)); + } + + break; } - throw new RuntimeException(sprintf('Invalid constructor argument %d for service "%s": argument %d must be defined before. Check your service definition.', 1 + $k, $this->currentId, $i)); + $value->addError(sprintf('Invalid constructor argument %d for service "%s": argument %d must be defined before. Check your service definition.', 1 + $k, $this->currentId, $i)); + if ($this->throwExceptions) { + throw new RuntimeException(sprintf('Invalid constructor argument %d for service "%s": argument %d must be defined before. Check your service definition.', 1 + $k, $this->currentId, $i)); + } } } @@ -47,10 +63,18 @@ protected function processValue($value, $isRoot = false) foreach ($methodCall[1] as $k => $v) { if ($k !== $i++) { if (!is_int($k)) { - throw new RuntimeException(sprintf('Invalid argument for method call "%s" of service "%s": integer expected but found string "%s". Check your service definition.', $methodCall[0], $this->currentId, $k)); + $value->addError(sprintf('Invalid argument for method call "%s" of service "%s": integer expected but found string "%s". Check your service definition.', $methodCall[0], $this->currentId, $k)); + if ($this->throwExceptions) { + throw new RuntimeException(sprintf('Invalid argument for method call "%s" of service "%s": integer expected but found string "%s". Check your service definition.', $methodCall[0], $this->currentId, $k)); + } + + break; } - throw new RuntimeException(sprintf('Invalid argument %d for method call "%s" of service "%s": argument %d must be defined before. Check your service definition.', 1 + $k, $methodCall[0], $this->currentId, $i)); + $value->addError(sprintf('Invalid argument %d for method call "%s" of service "%s": argument %d must be defined before. Check your service definition.', 1 + $k, $methodCall[0], $this->currentId, $i)); + if ($this->throwExceptions) { + throw new RuntimeException(sprintf('Invalid argument %d for method call "%s" of service "%s": argument %d must be defined before. Check your service definition.', 1 + $k, $methodCall[0], $this->currentId, $i)); + } } } } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/DefinitionErrorExceptionPass.php b/src/Symfony/Component/DependencyInjection/Compiler/DefinitionErrorExceptionPass.php new file mode 100644 index 0000000000000..69cd899f2a5d4 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Compiler/DefinitionErrorExceptionPass.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\Definition; +use Symfony\Component\DependencyInjection\Exception\RuntimeException; + +/** + * Throws an exception for any Definitions that have errors and still exist. + * + * @author Ryan Weaver + */ +class DefinitionErrorExceptionPass extends AbstractRecursivePass +{ + /** + * {@inheritdoc} + */ + protected function processValue($value, $isRoot = false) + { + if (!$value instanceof Definition || empty($value->getErrors())) { + return parent::processValue($value, $isRoot); + } + + // only show the first error so they user can focus on it + $errors = $value->getErrors(); + $message = reset($errors); + + throw new RuntimeException($message); + } +} diff --git a/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php b/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php index 79792bee4a106..1edc4c21b10f0 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php @@ -59,14 +59,14 @@ public function __construct() new RegisterServiceSubscribersPass(), new ResolveNamedArgumentsPass(), new ResolveBindingsPass(), - $autowirePass = new AutowirePass(false), + new AutowirePass(false), new ResolveServiceSubscribersPass(), new ResolveReferencesToAliasesPass(), new ResolveInvalidReferencesPass(), new AnalyzeServiceReferencesPass(true), new CheckCircularReferencesPass(), new CheckReferenceValidityPass(), - new CheckArgumentsValidityPass(), + new CheckArgumentsValidityPass(false), )); $this->removingPasses = array(array( @@ -75,11 +75,11 @@ public function __construct() new RemoveAbstractDefinitionsPass(), new RepeatedPass(array( new AnalyzeServiceReferencesPass(), - $inlinedServicePass = new InlineServiceDefinitionsPass(), + new InlineServiceDefinitionsPass(), new AnalyzeServiceReferencesPass(), new RemoveUnusedDefinitionsPass(), )), - new AutowireExceptionPass($autowirePass, $inlinedServicePass), + new DefinitionErrorExceptionPass(), new CheckExceptionOnInvalidReferenceBehaviorPass(), )); } diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index 34d6f46cacca4..464932fc0acae 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/src/Symfony/Component/DependencyInjection/Definition.php @@ -44,6 +44,7 @@ class Definition private $autowiringTypes = array(); private $changes = array(); private $bindings = array(); + private $errors = array(); protected $arguments = array(); @@ -959,4 +960,24 @@ public function setBindings(array $bindings) return $this; } + + /** + * Add an error that occurred when building this Definition. + * + * @param string $error + */ + public function addError($error) + { + $this->errors[] = $error; + } + + /** + * Returns any errors that occurred while building this Definition. + * + * @return array + */ + public function getErrors() + { + return $this->errors; + } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowireExceptionPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowireExceptionPassTest.php index 4f0b3d6c2566c..a9c3445cefdd8 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowireExceptionPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowireExceptionPassTest.php @@ -18,6 +18,9 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Exception\AutowiringFailedException; +/** + * @group legacy + */ class AutowireExceptionPassTest extends TestCase { public function testThrowsException() diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php index 94666df608391..da03cf114cd3c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php @@ -157,6 +157,9 @@ public function testCompleteExistingDefinitionWithNotDefinedArguments() $this->assertEquals(DInterface::class, (string) $container->getDefinition('h')->getArgument(1)); } + /** + * @group legacy + */ public function testExceptionsAreStored() { $container = new ContainerBuilder(); @@ -1090,7 +1093,7 @@ public function setFoo(Foo $foo) // should be called } - /** @inheritdoc*/ + /** {@inheritdoc}*/ public function setDependencies(Foo $foo, A $a) { // should be called diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckArgumentsValidityPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckArgumentsValidityPassTest.php index 891acbeee0d89..d121689ff9c6a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckArgumentsValidityPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckArgumentsValidityPassTest.php @@ -64,4 +64,15 @@ public function definitionProvider() array(array(), array(array('baz', array(1 => 1)))), ); } + + public function testNoException() + { + $container = new ContainerBuilder(); + $definition = $container->register('foo'); + $definition->setArguments(array(null, 'a' => 'a')); + + $pass = new CheckArgumentsValidityPass(false); + $pass->process($container); + $this->assertCount(1, $definition->getErrors()); + } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/DefinitionErrorExceptionPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/DefinitionErrorExceptionPassTest.php new file mode 100644 index 0000000000000..e0585e21324b3 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/DefinitionErrorExceptionPassTest.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Tests\Compiler; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\DependencyInjection\Compiler\DefinitionErrorExceptionPass; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Definition; + +class DefinitionErrorExceptionPassTest extends TestCase +{ + /** + * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException + * @expectedExceptionMessage Things went wrong! + */ + public function testThrowsException() + { + $container = new ContainerBuilder(); + $def = new Definition(); + $def->addError('Things went wrong!'); + $def->addError('Now something else!'); + $container->register('foo_service_id') + ->setArguments(array( + $def, + )); + + $pass = new DefinitionErrorExceptionPass(); + $pass->process($container); + } + + public function testNoExceptionThrown() + { + $container = new ContainerBuilder(); + $def = new Definition(); + $container->register('foo_service_id') + ->setArguments(array( + $def, + )); + + $pass = new DefinitionErrorExceptionPass(); + $pass->process($container); + $this->assertSame($def, $container->getDefinition('foo_service_id')->getArgument(0)); + } +} diff --git a/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php b/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php index 2821dc17c0dc2..5fe4236ad9384 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php @@ -387,4 +387,13 @@ public function testShouldAutoconfigure() $def->setAutoconfigured(true); $this->assertTrue($def->isAutoconfigured()); } + + public function testAddError() + { + $def = new Definition('stdClass'); + $this->assertEmpty($def->getErrors()); + $def->addError('First error'); + $def->addError('Second error'); + $this->assertSame(array('First error', 'Second error'), $def->getErrors()); + } } From 33d38f7e62acefdb1f0279f1e66a26343d6b35d0 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Sat, 23 Sep 2017 14:50:40 -0400 Subject: [PATCH 2/6] Tweaks thanks to Nicolas --- .../Compiler/AutowireExceptionPass.php | 2 ++ .../Compiler/AutowirePass.php | 2 +- .../Compiler/CheckArgumentsValidityPass.php | 21 ++++++++++++------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowireExceptionPass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowireExceptionPass.php index 185e0f3d4dabf..3105cfb2323aa 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AutowireExceptionPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowireExceptionPass.php @@ -18,6 +18,8 @@ /** * Throws autowire exceptions from AutowirePass for definitions that still exist. * + * @deprecated AutowireExceptionPass is deprecated since version 3.4 and will be removed in 4.0. + * * @author Ryan Weaver */ class AutowireExceptionPass implements CompilerPassInterface diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php index 688099391b5f4..27e620f2036f9 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php @@ -44,7 +44,7 @@ public function __construct($throwOnAutowireException = true) } /** - * @deprecated + * @deprecated since version 3.3, to be removed in 4.0. * * @return AutowiringFailedException[] */ diff --git a/src/Symfony/Component/DependencyInjection/Compiler/CheckArgumentsValidityPass.php b/src/Symfony/Component/DependencyInjection/Compiler/CheckArgumentsValidityPass.php index 939c9e8bab896..3b9083e28bfb8 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/CheckArgumentsValidityPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/CheckArgumentsValidityPass.php @@ -42,18 +42,20 @@ protected function processValue($value, $isRoot = false) foreach ($value->getArguments() as $k => $v) { if ($k !== $i++) { if (!is_int($k)) { - $value->addError(sprintf('Invalid constructor argument for service "%s": integer expected but found string "%s". Check your service definition.', $this->currentId, $k)); + $msg = sprintf('Invalid constructor argument for service "%s": integer expected but found string "%s". Check your service definition.', $this->currentId, $k); + $value->addError($msg); if ($this->throwExceptions) { - throw new RuntimeException(sprintf('Invalid constructor argument for service "%s": integer expected but found string "%s". Check your service definition.', $this->currentId, $k)); + throw new RuntimeException($msg); } break; } - $value->addError(sprintf('Invalid constructor argument %d for service "%s": argument %d must be defined before. Check your service definition.', 1 + $k, $this->currentId, $i)); + $msg = sprintf('Invalid constructor argument %d for service "%s": argument %d must be defined before. Check your service definition.', 1 + $k, $this->currentId, $i); + $value->addError($msg); if ($this->throwExceptions) { - throw new RuntimeException(sprintf('Invalid constructor argument %d for service "%s": argument %d must be defined before. Check your service definition.', 1 + $k, $this->currentId, $i)); + throw new RuntimeException($msg); } } } @@ -63,17 +65,20 @@ protected function processValue($value, $isRoot = false) foreach ($methodCall[1] as $k => $v) { if ($k !== $i++) { if (!is_int($k)) { - $value->addError(sprintf('Invalid argument for method call "%s" of service "%s": integer expected but found string "%s". Check your service definition.', $methodCall[0], $this->currentId, $k)); + $msg = sprintf('Invalid argument for method call "%s" of service "%s": integer expected but found string "%s". Check your service definition.', $methodCall[0], $this->currentId, $k); + $value->addError($msg); + if ($this->throwExceptions) { - throw new RuntimeException(sprintf('Invalid argument for method call "%s" of service "%s": integer expected but found string "%s". Check your service definition.', $methodCall[0], $this->currentId, $k)); + throw new RuntimeException($msg); } break; } - $value->addError(sprintf('Invalid argument %d for method call "%s" of service "%s": argument %d must be defined before. Check your service definition.', 1 + $k, $methodCall[0], $this->currentId, $i)); + $msg = sprintf('Invalid argument %d for method call "%s" of service "%s": argument %d must be defined before. Check your service definition.', 1 + $k, $methodCall[0], $this->currentId, $i); + $value->addError($msg); if ($this->throwExceptions) { - throw new RuntimeException(sprintf('Invalid argument %d for method call "%s" of service "%s": argument %d must be defined before. Check your service definition.', 1 + $k, $methodCall[0], $this->currentId, $i)); + throw new RuntimeException($msg); } } } From 063727552641424419e9b4b71e9f1248586757e2 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Sun, 24 Sep 2017 11:07:45 -0400 Subject: [PATCH 3/6] Last fixes --- .../DependencyInjection/Compiler/AutowireExceptionPass.php | 2 +- .../DependencyInjection/Tests/Compiler/AutowirePassTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowireExceptionPass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowireExceptionPass.php index 3105cfb2323aa..f01617dd633c6 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AutowireExceptionPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowireExceptionPass.php @@ -18,7 +18,7 @@ /** * Throws autowire exceptions from AutowirePass for definitions that still exist. * - * @deprecated AutowireExceptionPass is deprecated since version 3.4 and will be removed in 4.0. + * @deprecated since version 3.4, will be removed in 4.0. * * @author Ryan Weaver */ diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php index da03cf114cd3c..3a48cfae8d6dc 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php @@ -1093,7 +1093,7 @@ public function setFoo(Foo $foo) // should be called } - /** {@inheritdoc}*/ + /** @inheritdoc*/ public function setDependencies(Foo $foo, A $a) { // should be called From ba22f4daa4e93c65ec8bd3824bacca9084d6c94e Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Sun, 24 Sep 2017 11:10:23 -0400 Subject: [PATCH 4/6] Fixing version number --- .../Component/DependencyInjection/Compiler/AutowirePass.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php index 27e620f2036f9..607b70c85fb61 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php @@ -44,7 +44,7 @@ public function __construct($throwOnAutowireException = true) } /** - * @deprecated since version 3.3, to be removed in 4.0. + * @deprecated since version 3.4, to be removed in 4.0. * * @return AutowiringFailedException[] */ From b97570e9c9d7a7db28c106aca4867870b1352261 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Sun, 24 Sep 2017 11:10:34 -0400 Subject: [PATCH 5/6] deprecating another method --- .../Compiler/InlineServiceDefinitionsPass.php | 4 ++++ .../Tests/Compiler/InlineServiceDefinitionsPassTest.php | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php index 73f75b30a982c..05e7786798d2c 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php @@ -38,10 +38,14 @@ public function setRepeatedPass(RepeatedPass $repeatedPass) * * The key is the inlined service id and its value is the list of services it was inlined into. * + * @deprecated since version 3.4, to be removed in 4.0. + * * @return array */ public function getInlinedServiceIds() { + @trigger_error('Calling InlineServiceDefinitionsPass::getInlinedServiceIds() is deprecated since Symfony 3.4 and will be removed in 4.0.', E_USER_DEPRECATED); + return $this->inlinedServiceIds; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php index 26b24fa713242..6154080c8bc0e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php @@ -252,6 +252,9 @@ public function testProcessDoesNotSetLazyArgumentValuesAfterInlining() $this->assertSame('inline', (string) $values[0]); } + /** + * @group legacy + */ public function testGetInlinedServiceIdData() { $container = new ContainerBuilder(); From dced57cbfe96705c867401b65f5bb2d97bc8c691 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Sun, 24 Sep 2017 11:16:45 -0400 Subject: [PATCH 6/6] consistent CS --- .../DependencyInjection/Compiler/CheckArgumentsValidityPass.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/CheckArgumentsValidityPass.php b/src/Symfony/Component/DependencyInjection/Compiler/CheckArgumentsValidityPass.php index 3b9083e28bfb8..7f032058ab139 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/CheckArgumentsValidityPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/CheckArgumentsValidityPass.php @@ -44,7 +44,6 @@ protected function processValue($value, $isRoot = false) if (!is_int($k)) { $msg = sprintf('Invalid constructor argument for service "%s": integer expected but found string "%s". Check your service definition.', $this->currentId, $k); $value->addError($msg); - if ($this->throwExceptions) { throw new RuntimeException($msg); } @@ -67,7 +66,6 @@ protected function processValue($value, $isRoot = false) if (!is_int($k)) { $msg = sprintf('Invalid argument for method call "%s" of service "%s": integer expected but found string "%s". Check your service definition.', $methodCall[0], $this->currentId, $k); $value->addError($msg); - if ($this->throwExceptions) { throw new RuntimeException($msg); }