Skip to content

Commit b9c91cd

Browse files
committed
Deprecate passing a concrete service in optional cache warmers
1 parent 068f8d1 commit b9c91cd

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* Generates the router matcher and generator classes.
2020
*
2121
* @author Fabien Potencier <[email protected]>
22+
*
23+
* @final since version 3.4, to be given a container instead in 4.0
2224
*/
2325
class RouterCacheWarmer implements CacheWarmerInterface
2426
{

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TranslationsCacheWarmer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class TranslationsCacheWarmer implements CacheWarmerInterface
2929
/**
3030
* TranslationsCacheWarmer constructor.
3131
*
32-
* @param ContainerInterface|TranslatorInterface $container
32+
* @param ContainerInterface $container
3333
*/
3434
public function __construct($container)
3535
{
@@ -38,8 +38,9 @@ public function __construct($container)
3838
$this->container = $container;
3939
} elseif ($container instanceof TranslatorInterface) {
4040
$this->translator = $container;
41+
@trigger_error(sprintf('Using a "%s" as first argument of %s is deprecated since version 3.4 and will be unsupported in version 4.0. Use a %s instead.', TranslatorInterface::class, __CLASS__, ContainerInterface::class), E_USER_DEPRECATED);
4142
} else {
42-
throw new \InvalidArgumentException(sprintf('%s only accepts instance of Symfony\Component\DependencyInjection\ContainerInterface or Symfony\Component\Translation\TranslatorInterface as first argument.', __CLASS__));
43+
throw new \InvalidArgumentException(sprintf('%s only accepts instance of Symfony\Component\DependencyInjection\ContainerInterface as first argument.', __CLASS__));
4344
}
4445
}
4546

src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheWarmer.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class TemplateCacheWarmer implements CacheWarmerInterface
3030
/**
3131
* TemplateCacheWarmer constructor.
3232
*
33-
* @param ContainerInterface|Environment $container
34-
* @param \Traversable $iterator
33+
* @param ContainerInterface $container
34+
* @param \Traversable $iterator
3535
*/
3636
public function __construct($container, \Traversable $iterator)
3737
{
@@ -40,8 +40,9 @@ public function __construct($container, \Traversable $iterator)
4040
$this->container = $container;
4141
} elseif ($container instanceof Environment) {
4242
$this->twig = $container;
43+
@trigger_error(sprintf('Using a "%s" as first argument of %s is deprecated since version 3.4 and will be unsupported in version 4.0. Use a %s instead.', Environment::class, __CLASS__, Container::class), E_USER_DEPRECATED);
4344
} else {
44-
throw new \InvalidArgumentException(sprintf('%s only accepts instance of Symfony\Component\DependencyInjection\ContainerInterface or Environment as first argument.', __CLASS__));
45+
throw new \InvalidArgumentException(sprintf('%s only accepts instance of Symfony\Component\DependencyInjection\ContainerInterface as first argument.', __CLASS__));
4546
}
4647

4748
$this->iterator = $iterator;

0 commit comments

Comments
 (0)