Skip to content

[DI] Remove AutowireExceptionPass #24398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Symfony/Component/DependencyInjection/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

@stof stof Oct 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not having anything in the 3.4 changelog about the deprecation looks weird to me. The changelog should be updated (in a separate branch)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #24399 :)


3.4.0
-----
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the property should be removed also (same in the other pass)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Done.

}

/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
// clear out any possibly stored exceptions from before
$this->autowiringExceptions = array();

try {
parent::process($container);
} finally {
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
class InlineServiceDefinitionsPass extends AbstractRecursivePass implements RepeatablePassInterface
{
private $repeatedPass;
private $inlinedServiceIds = array();

/**
* {@inheritdoc}
Expand All @@ -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}
*/
Expand All @@ -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;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down