Permalink
Browse files

feature #24398 [DI] Remove AutowireExceptionPass (ogizanagi)

This PR was merged into the 4.0-dev branch.

Discussion
----------

[DI] Remove AutowireExceptionPass

| Q             | A
| ------------- | ---
| Branch?       | master <!-- see comment below -->
| Bug fix?      | no
| New feature?  | yes <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | yes
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->
| Tests pass?   | yes
| Fixed tickets | #24290 <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | N/A

Commits
-------

2ada558 [DI] Remove AutowireExceptionPass
  • Loading branch information...
nicolas-grekas committed Oct 2, 2017
2 parents f2594d2 + 2ada558 commit dea50e0b691bcefa99330cc2c7ac3c3804b763a9
@@ -22,6 +22,7 @@ CHANGELOG
* removed support for setting and accessing private services in `Container`
* removed support for setting pre-defined services in `Container`
* removed support for case insensitivity of parameter names
* removed `AutowireExceptionPass` and `AutowirePass::getAutowiringExceptions()`, use `Definition::addError()` and the `DefinitionErrorExceptionPass` instead
3.4.0
-----

This file was deleted.

Oops, something went wrong.
@@ -31,7 +31,6 @@ class AutowirePass extends AbstractRecursivePass
private $autowired = array();
private $lastFailure;
private $throwOnAutowiringException;
private $autowiringExceptions = array();
/**
* @param bool $throwOnAutowireException Errors can be retrieved via Definition::getErrors()
@@ -41,26 +40,11 @@ public function __construct($throwOnAutowireException = true)
$this->throwOnAutowiringException = $throwOnAutowireException;
}
/**
* @deprecated since version 3.4, to be removed in 4.0.
*
* @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;
}
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
// clear out any possibly stored exceptions from before
$this->autowiringExceptions = array();
try {
parent::process($container);
} finally {
@@ -82,7 +66,6 @@ protected function processValue($value, $isRoot = false)
throw $e;
}
$this->autowiringExceptions[] = $e;
$this->container->getDefinition($this->currentId)->addError($e->getMessage());
return parent::processValue($value, $isRoot);
@@ -23,7 +23,6 @@
class InlineServiceDefinitionsPass extends AbstractRecursivePass implements RepeatablePassInterface
{
private $repeatedPass;
private $inlinedServiceIds = array();
/**
* {@inheritdoc}
@@ -33,22 +32,6 @@ public function setRepeatedPass(RepeatedPass $repeatedPass)
$this->repeatedPass = $repeatedPass;
}
/**
* Returns an array of all services inlined by this pass.
*
* 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;
}
/**
* {@inheritdoc}
*/
@@ -63,7 +46,6 @@ protected function processValue($value, $isRoot = false)
if ($this->isInlineableDefinition($id, $definition, $this->container->getCompiler()->getServiceReferenceGraph())) {
$this->container->log($this, sprintf('Inlined service "%s" to "%s".', $id, $this->currentId));
$this->inlinedServiceIds[$id][] = $this->currentId;
if ($definition->isShared()) {
return $definition;

This file was deleted.

Oops, something went wrong.
@@ -131,24 +131,6 @@ public function testCompleteExistingDefinitionWithNotDefinedArguments()
$this->assertEquals(DInterface::class, (string) $container->getDefinition('h')->getArgument(1));
}
/**
* @group legacy
*/
public function testExceptionsAreStored()
{
$container = new ContainerBuilder();
$container->register('c1', __NAMESPACE__.'\CollisionA');
$container->register('c2', __NAMESPACE__.'\CollisionB');
$container->register('c3', __NAMESPACE__.'\CollisionB');
$aDefinition = $container->register('a', __NAMESPACE__.'\CannotBeAutowired');
$aDefinition->setAutowired(true);
$pass = new AutowirePass(false);
$pass->process($container);
$this->assertCount(1, $pass->getAutowiringExceptions());
}
/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\AutowiringFailedException
* @expectedExceptionMessage Invalid service "private_service": constructor of class "Symfony\Component\DependencyInjection\Tests\Compiler\PrivateConstructor" must be public.
@@ -252,33 +252,6 @@ public function testProcessDoesNotSetLazyArgumentValuesAfterInlining()
$this->assertSame('inline', (string) $values[0]);
}
/**
* @group legacy
*/
public function testGetInlinedServiceIdData()
{
$container = new ContainerBuilder();
$container
->register('inlinable.service')
->setPublic(false)
;
$container
->register('non_inlinable.service')
->setPublic(true)
;
$container
->register('other_service')
->setArguments(array(new Reference('inlinable.service')))
;
$inlinePass = new InlineServiceDefinitionsPass();
$repeatedPass = new RepeatedPass(array(new AnalyzeServiceReferencesPass(), $inlinePass));
$repeatedPass->process($container);
$this->assertEquals(array('inlinable.service' => array('other_service')), $inlinePass->getInlinedServiceIds());
}
protected function process(ContainerBuilder $container)
{
$repeatedPass = new RepeatedPass(array(new AnalyzeServiceReferencesPass(), new InlineServiceDefinitionsPass()));

0 comments on commit dea50e0

Please sign in to comment.