bug #30506 [TwigBridge] remove deprecation triggered when using Twig 2.7 (nicolas-grekas)

This PR was merged into the 3.4 branch.

Discussion
----------

[TwigBridge] remove deprecation triggered when using Twig 2.7

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

Needs https://github.com/twigphp/Twig/pull/2874
Should make the CI green on 3.4.

Commits
-------

c17a5b25b5 [TwigBridge] remove deprecation triggered when using Twig 2.7
This commit is contained in:
Nicolas Grekas 2019-03-10 18:08:49 +01:00
commit 4b5c6926cf
3 changed files with 25 additions and 3 deletions

View File

@ -18,7 +18,6 @@ use Symfony\Component\Form\ChoiceList\View\ChoiceView;
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 @@ class FormExtension extends AbstractExtension implements InitRuntimeInterface
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;
}

View File

@ -0,0 +1,23 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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
{
}

View File

@ -258,7 +258,7 @@ class DebugClassLoader
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');