8000 [TwigBridge] remove deprecated features by xabbuh · Pull Request #22783 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[TwigBridge] remove deprecated features #22783

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
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
91 changes: 1 addition & 90 deletions src/Symfony/Bridge/Twig/Extension/FormExtension.php
8000
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@
namespace Symfony\Bridge\Twig\Extension;

use Symfony\Bridge\Twig\TokenParser\FormThemeTokenParser;
use Symfony\Bridge\Twig\Form\TwigRendererInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
use Twig\Environment;
use Twig\Extension\AbstractExtension;
use Twig\Extension\InitRuntimeInterface;
use Twig\TwigFilter;
use Twig\TwigFunction;
use Twig\TwigTest;
Expand All @@ -28,37 +24,8 @@
* @author Fabien Potencier <fabien@symfony.com>
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class FormExtension extends AbstractExtension implements InitRuntimeInterface
class FormExtension extends AbstractExtension
{
/**
* @deprecated since version 3.2, to be removed in 4.0 alongside with magic methods below
*/
private $renderer;

public function __construct($renderer = null)
{
if ($renderer instanceof TwigRendererInterface) {
@trigger_error(sprintf('Passing a Twig Form Renderer to the "%s" constructor is deprecated since version 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__));
}
$this->renderer = $renderer;
}

/**
* {@inheritdoc}
*
* To be removed in 4.0
*/
public function initRuntime(Environment $environment)
{
if ($this->renderer instanceof TwigRendererInterface) {
$this->renderer->setEnvironment($environment);
} elseif (null !== $this->renderer) {
$this->renderer[2] = $environment;
}
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -108,62 +75,6 @@ public function getTests()
);
}

/**
* @internal
*/
public function __get($name)
{
if ('renderer' === $name) {
@trigger_error(sprintf('Using the "%s::$renderer" property is deprecated since version 3.2 as it will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED);

if (is_array($this->renderer)) {
$renderer = $this->renderer[0]->get($this->renderer[1]);
if (isset($this->renderer[2])) {
$renderer->setEnvironment($this->renderer[2]);
}
$this->renderer = $renderer;
}
}

return $this->$name;
}

/**
* @internal
*/
public function __set($name, $value)
{
if ('renderer' === $name) {
@trigger_error(sprintf('Using the "%s::$renderer" property is deprecated since version 3.2 as it will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED);
}

$this->$name = $value;
}

/**
* @internal
*/
public function __isset($name)
{
if ('renderer' === $name) {
@trigger_error(sprintf('Using the "%s::$renderer" property is deprecated since version 3.2 as it will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED);
}

return isset($this->$name);
}

/**
* @internal
*/
public function __unset($name)
{
if ('renderer' === $name) {
@trigger_error(sprintf('Using the "%s::$renderer" property is deprecated since version 3.2 as it will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED);
}

unset($this->$name);
}

/**
* {@inheritdoc}
*/
Expand Down
10 changes: 1 addition & 9 deletions src/Symfony/Bridge/Twig/Extension/YamlExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,7 @@ public function encode($input, $inline = 0, $dumpObjects = 0)
}

if (defined('Symfony\Component\Yaml\Yaml::DUMP_OBJECT')) {
if (is_bool($dumpObjects)) {
@trigger_error('Passing a boolean flag to toggle object support is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::DUMP_OBJECT flag instead.', E_USER_DEPRECATED);

$flags = $dumpObjects ? Yaml::DUMP_OBJECT : 0;
} else {
$flags = $dumpObjects;
}

return $dumper->dump($input, $inline, 0, $flags);
return $dumper->dump($input, $inline, 0, $dumpObjects);
}

return $dumper->dump($input, $inline, 0, false, $dumpObjects);
Expand Down
49 changes: 0 additions & 49 deletions src/Symfony/Bridge/Twig/Form/TwigRenderer.php

This file was deleted.

22 changes: 2 additions & 20 deletions src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/**
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class TwigRendererEngine extends AbstractRendererEngine implements TwigRendererEngineInterface
class TwigRendererEngine extends AbstractRendererEngine
{
/**
* @var Environment
Expand All @@ -31,30 +31,12 @@ class TwigRendererEngine extends AbstractRendererEngine implements TwigRendererE
*/
private $template;

public function __construct(array $defaultThemes = array(), Environment $environment = null)
public function __construct(array $defaultThemes, Environment $environment)
{
if (null === $environment) {
@trigger_error(sprintf('Not passing a Twig Environment as the second argument for "%s" constructor is deprecated since version 3.2 and won\'t be possible in 4.0.', static::class), E_USER_DEPRECATED);
}

parent::__construct($defaultThemes);
$this->environment = $environment;
}

/**
* {@inheritdoc}
*
* @deprecated since version 3.3, to be removed in 4.0
*/
public function setEnvironment(Environment $environment)
{
if ($this->environment) {
@trigger_error(sprintf('The "%s()" method is deprecated since version 3.3 and will be removed in 4.0. Pass the Twig Environment as second argument of the constructor instead.', __METHOD__), E_USER_DEPRECATED);
}

$this->environment = $environment;
}

/**
* {@inheritdoc}
*/
Expand Down
28 changes: 0 additions & 28 deletions src/Symfony/Bridge/Twig/Form/TwigRendererEngineInterface.php

This file was deleted.

28 changes: 0 additions & 28 deletions src/Symfony/Bridge/Twig/Form/TwigRendererInterface.php

This file was deleted.

11 changes: 1 addition & 10 deletions src/Symfony/Bridge/Twig/Node/FormThemeNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@

namespace Symfony\Bridge\Twig\Node;

use Symfony\Bridge\Twig\Form\TwigRenderer;
use Symfony\Component\Form\FormRenderer;
use Twig\Compiler;
use Twig\Error\RuntimeError;
use Twig\Node\Node;

/**
6D6C Expand All @@ -29,17 +27,10 @@ public function __construct(Node $form, Node $resources, $lineno, $tag = null)

public function compile(Compiler $compiler)
{
try {
$compiler->getEnvironment()->getRuntime(FormRenderer::class);
$renderer = FormRenderer::class;
} catch (RuntimeError $e) {
$renderer = TwigRenderer::class;
}

$compiler
->addDebugInfo($this)
->write('$this->env->getRuntime(')
->string($renderer)
->string(FormRenderer::class)
->raw(')->setTheme(')
->subcompile($this->getNode('form'))
->raw(', ')
Expand Down
0