Skip to content

Commit

Permalink
minor #31951 [DI] remove deprecated code paths (nicolas-grekas)
Browse files Browse the repository at this point in the history
This PR was merged into the 5.0-dev branch.

Discussion
----------

[DI] remove deprecated code paths

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | yes
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

@ro0NL there is still one legacy test in ValidateEnvPlaceholdersPassTest, I'll let you remove it if you don't mind, please :)

Commits
-------

3ff69f0 [DI] remove deprecated code paths
  • Loading branch information
nicolas-grekas committed Jun 8, 2019
2 parents a2f2769 + 3ff69f0 commit ceb40c1
Show file tree
Hide file tree
Showing 22 changed files with 15 additions and 348 deletions.
Expand Up @@ -12,10 +12,10 @@
namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;

use Psr\Container\ContainerInterface;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\CompatibilityServiceSubscriberInterface as ServiceSubscriberInterface;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Contracts\Service\ServiceSubscriberInterface;

/**
* Generates the router matcher and generator classes.
Expand Down
Expand Up @@ -12,9 +12,9 @@
namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;

use Psr\Container\ContainerInterface;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\CompatibilityServiceSubscriberInterface as ServiceSubscriberInterface;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface;
use Symfony\Contracts\Service\ServiceSubscriberInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

/**
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion src/Symfony/Bundle/FrameworkBundle/Routing/Router.php
Expand Up @@ -13,7 +13,6 @@

use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\CompatibilityServiceSubscriberInterface as ServiceSubscriberInterface;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\Config\ContainerParametersResource;
use Symfony\Component\DependencyInjection\ContainerInterface as SymfonyContainerInterface;
Expand All @@ -23,6 +22,7 @@
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Router as BaseRouter;
use Symfony\Contracts\Service\ServiceSubscriberInterface;

/**
* This Router creates the Loader only when the cache is empty.
Expand Down
Expand Up @@ -12,8 +12,8 @@
namespace Symfony\Bundle\TwigBundle\CacheWarmer;

use Psr\Container\ContainerInterface;
use Symfony\Bundle\TwigBundle\DependencyInjection\CompatibilityServiceSubscriberInterface as ServiceSubscriberInterface;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
use Symfony\Contracts\Service\ServiceSubscriberInterface;
use Twig\Environment;
use Twig\Error\Error;

Expand Down

This file was deleted.

Expand Up @@ -15,7 +15,6 @@
use Symfony\Component\Cache\DependencyInjection\CachePoolClearerPass;
use Symfony\Component\Cache\DependencyInjection\CachePoolPass;
use Symfony\Component\DependencyInjection\Compiler\RemoveUnusedDefinitionsPass;
use Symfony\Component\DependencyInjection\Compiler\RepeatedPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
Expand Down Expand Up @@ -53,12 +52,6 @@ public function testPoolRefsAreWeak()
$container->setAlias('clearer_alias', 'clearer');

$pass = new RemoveUnusedDefinitionsPass();
foreach ($container->getCompiler()->getPassConfig()->getRemovingPasses() as $removingPass) {
if ($removingPass instanceof RepeatedPass) {
$pass->setRepeatedPass(new RepeatedPass([$pass]));
break;
}
}
foreach ([new CachePoolPass(), $pass, new CachePoolClearerPass()] as $pass) {
$pass->process($container);
}
Expand Down
Expand Up @@ -11,7 +11,6 @@

namespace Symfony\Component\Config\Resource;

use Symfony\Component\DependencyInjection\ServiceSubscriberInterface as LegacyServiceSubscriberInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Messenger\Handler\MessageSubscriberInterface;
use Symfony\Contracts\Service\ServiceSubscriberInterface;
Expand Down Expand Up @@ -166,10 +165,7 @@ private function generateSignature(\ReflectionClass $class)
}
}

if (interface_exists(LegacyServiceSubscriberInterface::class, false) && $class->isSubclassOf(LegacyServiceSubscriberInterface::class)) {
yield LegacyServiceSubscriberInterface::class;
yield print_r([$class->name, 'getSubscribedServices'](), true);
} elseif (interface_exists(ServiceSubscriberInterface::class, false) && $class->isSubclassOf(ServiceSubscriberInterface::class)) {
if (interface_exists(ServiceSubscriberInterface::class, false) && $class->isSubclassOf(ServiceSubscriberInterface::class)) {
yield ServiceSubscriberInterface::class;
yield print_r($class->name::getSubscribedServices(), true);
}
Expand Down
Expand Up @@ -27,7 +27,7 @@
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
* @author Nicolas Grekas <p@tchwork.com>
*/
class AnalyzeServiceReferencesPass extends AbstractRecursivePass implements RepeatablePassInterface
class AnalyzeServiceReferencesPass extends AbstractRecursivePass
{
private $graph;
private $currentDefinition;
Expand All @@ -49,14 +49,6 @@ public function __construct(bool $onlyConstructorArguments = false, bool $hasPro
$this->enableExpressionProcessing();
}

/**
* {@inheritdoc}
*/
public function setRepeatedPass(RepeatedPass $repeatedPass)
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
}

/**
* Processes a ContainerBuilder object to populate the service reference graph.
*/
Expand Down
Expand Up @@ -22,10 +22,9 @@
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
class InlineServiceDefinitionsPass extends AbstractRecursivePass implements RepeatablePassInterface
class InlineServiceDefinitionsPass extends AbstractRecursivePass
{
private $analyzingPass;
private $repeatedPass;
private $cloningIds = [];
private $connectedIds = [];
private $notInlinedIds = [];
Expand All @@ -37,15 +36,6 @@ public function __construct(AnalyzeServiceReferencesPass $analyzingPass = null)
$this->analyzingPass = $analyzingPass;
}

/**
* {@inheritdoc}
*/
public function setRepeatedPass(RepeatedPass $repeatedPass)
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
$this->repeatedPass = $repeatedPass;
}

public function process(ContainerBuilder $container)
{
$this->container = $container;
Expand Down Expand Up @@ -94,10 +84,6 @@ public function process(ContainerBuilder $container)
}
} while ($this->inlinedIds && $this->analyzingPass);

if ($this->inlinedIds && $this->repeatedPass) {
$this->repeatedPass->setRepeat();
}

foreach ($remainingInlinedIds as $id) {
$definition = $container->getDefinition($id);

Expand Down
Expand Up @@ -20,18 +20,10 @@
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
* @author Nicolas Grekas <p@tchwork.com>
*/
class RemoveUnusedDefinitionsPass extends AbstractRecursivePass implements RepeatablePassInterface
class RemoveUnusedDefinitionsPass extends AbstractRecursivePass
{
private $connectedIds = [];

/**
* {@inheritdoc}
*/
public function setRepeatedPass(RepeatedPass $repeatedPass)
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
}

/**
* Processes the ContainerBuilder to remove unused definitions.
*/
Expand Down

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion src/Symfony/Component/DependencyInjection/Container.php
Expand Up @@ -39,7 +39,7 @@
* @author Fabien Potencier <fabien@symfony.com>
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
class Container implements ResettableContainerInterface
class Container implements ContainerInterface, ResetInterface
{
protected $parameterBag;
protected $services = [];
Expand Down
Expand Up @@ -592,14 +592,6 @@ private function parseCallable($callable, string $parameter, string $id, string
throw new InvalidArgumentException(sprintf('The value of the "%s" option for the "%s" service must be the id of the service without the "@" prefix (replace "%s" with "%s" in "%s").', $parameter, $id, $callable, substr($callable, 1), $file));
}

if (false !== strpos($callable, ':') && false === strpos($callable, '::')) {
$parts = explode(':', $callable);

@trigger_error(sprintf('Using short %s syntax for service "%s" is deprecated since Symfony 4.4, use "[\'@%s\', \'%s\']" instead.', $parameter, $id, ...$parts), E_USER_DEPRECATED);

return [$this->resolveServices('@'.$parts[0], $file), $parts[1]];
}

return $callable;
}

Expand Down

0 comments on commit ceb40c1

Please sign in to comment.