From c17a5b25b5f476763f8076ec07f6fbb64c7f5852 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 10 Mar 2019 11:43:50 +0100 Subject: [PATCH] [TwigBridge] remove deprecation triggered when using Twig 2.7 --- .../Bridge/Twig/Extension/FormExtension.php | 3 +-- .../Twig/Extension/InitRuntimeInterface.php | 23 +++++++++++++++++++ .../Component/Debug/DebugClassLoader.php | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 src/Symfony/Bridge/Twig/Extension/InitRuntimeInterface.php diff --git a/src/Symfony/Bridge/Twig/Extension/FormExtension.php b/src/Symfony/Bridge/Twig/Extension/FormExtension.php index 7ba3d17cd882..1314e6544200 100644 --- a/src/Symfony/Bridge/Twig/Extension/FormExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/FormExtension.php @@ -18,7 +18,6 @@ use Symfony\Component\Form\FormView; use Twig\Environment; use Twig\Extension\AbstractExtension; -use Twig\Extension\InitRuntimeInterface; use Twig\TwigFilter; use Twig\TwigFunction; use Twig\TwigTest; @@ -41,7 +40,7 @@ public function __construct($renderer = null) if ($renderer instanceof TwigRendererInterface) { @trigger_error(sprintf('Passing a Twig Form Renderer to the "%s" constructor is deprecated since Symfony 3.2 and won\'t be possible in 4.0. Pass the Twig\Environment to the TwigRendererEngine constructor instead.', static::class), E_USER_DEPRECATED); } elseif (null !== $renderer && !(\is_array($renderer) && isset($renderer[0], $renderer[1]) && $renderer[0] instanceof ContainerInterface)) { - throw new \InvalidArgumentException(sprintf('Passing any arguments the constructor of %s is reserved for internal use.', __CLASS__)); + throw new \InvalidArgumentException(sprintf('Passing any arguments to the constructor of %s is reserved for internal use.', __CLASS__)); } $this->renderer = $renderer; } diff --git a/src/Symfony/Bridge/Twig/Extension/InitRuntimeInterface.php b/src/Symfony/Bridge/Twig/Extension/InitRuntimeInterface.php new file mode 100644 index 000000000000..5ba5e5570259 --- /dev/null +++ b/src/Symfony/Bridge/Twig/Extension/InitRuntimeInterface.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\Twig\Extension; + +use Twig\Extension\InitRuntimeInterface as TwigInitRuntimeInterface; + +/** + * @deprecated to be removed in 4.x + * + * @internal to be removed in 4.x + */ +interface InitRuntimeInterface extends TwigInitRuntimeInterface +{ +} diff --git a/src/Symfony/Component/Debug/DebugClassLoader.php b/src/Symfony/Component/Debug/DebugClassLoader.php index 87071530c614..b728b9b90fee 100644 --- a/src/Symfony/Component/Debug/DebugClassLoader.php +++ b/src/Symfony/Component/Debug/DebugClassLoader.php @@ -258,7 +258,7 @@ public function checkAnnotations(\ReflectionClass $refl, $class) if (!isset(self::$checkedClasses[$use])) { $this->checkClass($use); } - if (isset(self::$deprecated[$use]) && \strncmp($ns, \str_replace('_', '\\', $use), $len)) { + if (isset(self::$deprecated[$use]) && \strncmp($ns, \str_replace('_', '\\', $use), $len) && !isset(self::$deprecated[$class])) { $type = class_exists($class, false) ? 'class' : (interface_exists($class, false) ? 'interface' : 'trait'); $verb = class_exists($use, false) || interface_exists($class, false) ? 'extends' : (interface_exists($use, false) ? 'implements' : 'uses');