Skip to content

Commit 4c3f90c

Browse files
committed
[TwigBridge] remove deprecated features
1 parent aa90ce6 commit 4c3f90c

File tree

7 files changed

+5
-234
lines changed

7 files changed

+5
-234
lines changed

src/Symfony/Bridge/Twig/Extension/FormExtension.php

Lines changed: 1 addition & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,8 @@
1212
namespace Symfony\Bridge\Twig\Extension;
1313

1414
use Symfony\Bridge\Twig\TokenParser\FormThemeTokenParser;
15-
use Symfony\Bridge\Twig\Form\TwigRendererInterface;
16-
use Symfony\Component\DependencyInjection\ContainerInterface;
1715
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
18-
use Twig\Environment;
1916
use Twig\Extension\AbstractExtension;
20-
use Twig\Extension\InitRuntimeInterface;
2117
use Twig\TwigFilter;
2218
use Twig\TwigFunction;
2319
use Twig\TwigTest;
@@ -28,37 +24,8 @@
2824
* @author Fabien Potencier <fabien@symfony.com>
2925
* @author Bernhard Schussek <bschussek@gmail.com>
3026
*/
31-
class FormExtension extends AbstractExtension implements InitRuntimeInterface
27+
class FormExtension extends AbstractExtension
3228
{
33-
/**
34-
* @deprecated since version 3.2, to be removed in 4.0 alongside with magic methods below
35-
*/
36-
private $renderer;
37-
38-
public function __construct($renderer = null)
39-
{
40-
if ($renderer instanceof TwigRendererInterface) {
41-
@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);
42-
} elseif (null !== $renderer && !(is_array($renderer) && isset($renderer[0], $renderer[1]) && $renderer[0] instanceof ContainerInterface)) {
43-
throw new \InvalidArgumentException(sprintf('Passing any arguments the constructor of %s is reserved for internal use.', __CLASS__));
44-
}
45-
$this->renderer = $renderer;
46-
}
47-
48-
/**
49-
* {@inheritdoc}
50-
*
51-
* To be removed in 4.0
52-
*/
53-
public function initRuntime(Environment $environment)
54-
{
55-
if ($this->renderer instanceof TwigRendererInterface) {
56-
$this->renderer->setEnvironment($environment);
57-
} elseif (null !== $this->renderer) {
58-
$this->renderer[2] = $environment;
59-
}
60-
}
61-
6229
/**
6330
* {@inheritdoc}
6431
*/
@@ -108,62 +75,6 @@ public function getTests()
10875
);
10976
}
11077

111-
/**
112-
* @internal
113-
*/
114-
public function __get($name)
115-
{
116-
if ('renderer' === $name) {
117-
@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);
118-
119-
if (is_array($this->renderer)) {
120-
$renderer = $this->renderer[0]->get($this->renderer[1]);
121-
if (isset($this->renderer[2])) {
122-
$renderer->setEnvironment($this->renderer[2]);
123-
}
124-
$this->renderer = $renderer;
125-
}
126-
}
127-
128-
return $this->$name;
129-
}
130-
131-
/**
132-
* @internal
133-
*/
134-
public function __set($name, $value)
135-
{
136-
if ('renderer' === $name) {
137-
@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);
138-
}
139-
140-
$this->$name = $value;
141-
}
142-
143-
/**
144-
* @internal
145-
*/
146-
public function __isset($name)
147-
{
148-
if ('renderer' === $name) {
149-
@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);
150-
}
151-
152-
return isset($this->$name);
153-
}
154-
155-
/**
156-
* @internal
157-
*/
158-
public function __unset($name)
159-
{
160-
if ('renderer' === $name) {
161-
@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);
162-
}
163-
164-
unset($this->$name);
165-
}
166-
16778
/**
16879
* {@inheritdoc}
16980
*/

src/Symfony/Bridge/Twig/Extension/YamlExtension.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,7 @@ public function encode($input, $inline = 0, $dumpObjects = 0)
4343
}
4444

4545
if (defined('Symfony\Component\Yaml\Yaml::DUMP_OBJECT')) {
46-
if (is_bool($dumpObjects)) {
47-
@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);
48-
49-
$flags = $dumpObjects ? Yaml::DUMP_OBJECT : 0;
50-
} else {
51-
$flags = $dumpObjects;
52-
}
53-
54-
return $dumper->dump($input, $inline, 0, $flags);
46+
return $dumper->dump($input, $inline, 0, $dumpObjects);
5547
}
5648

5749
return $dumper->dump($input, $inline, 0, false, $dumpObjects);

src/Symfony/Bridge/Twig/Form/TwigRenderer.php

Lines changed: 0 additions & 49 deletions
This file was deleted.

src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/**
2020
* @author Bernhard Schussek <bschussek@gmail.com>
2121
*/
22-
class TwigRendererEngine extends AbstractRendererEngine implements TwigRendererEngineInterface
22+
class TwigRendererEngine extends AbstractRendererEngine
2323
{
2424
/**
2525
* @var Environment
@@ -31,30 +31,12 @@ class TwigRendererEngine extends AbstractRendererEngine implements TwigRendererE
3131
*/
3232
private $template;
3333

34-
public function __construct(array $defaultThemes = array(), Environment $environment = null)
34+
public function __construct(array $defaultThemes = array(), Environment $environment)
3535
{
36-
if (null === $environment) {
37-
@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);
38-
}
39-
4036
parent::__construct($defaultThemes);
4137
$this->environment = $environment;
4238
}
4339

44-
/**
45-
* {@inheritdoc}
46-
*
47-
* @deprecated since version 3.3, to be removed in 4.0
48-
*/
49-
public function setEnvironment(Environment $environment)
50-
{
51-
if ($this->environment) {
52-
@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);
53-
}
54-
55-
$this->environment = $environment;
56-
}
57-
5840
/**
5941
* {@inheritdoc}
6042
*/

src/Symfony/Bridge/Twig/Form/TwigRendererEngineInterface.php

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/Symfony/Bridge/Twig/Form/TwigRendererInterface.php

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/Symfony/Bridge/Twig/Node/FormThemeNode.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111

1212
namespace Symfony\Bridge\Twig\Node;
1313

14-
use Symfony\Bridge\Twig\Form\TwigRenderer;
1514
use Symfony\Component\Form\FormRenderer;
1615
use Twig\Compiler;
17-
use Twig\Error\RuntimeError;
1816
use Twig\Node\Node;
1917

2018
/**
@@ -29,17 +27,10 @@ public function __construct(Node $form, Node $resources, $lineno, $tag = null)
2927

3028
public function compile(Compiler $compiler)
3129
{
32-
try {
33-
$compiler->getEnvironment()->getRuntime(FormRenderer::class);
34-
$renderer = FormRenderer::class;
35-
} catch (RuntimeError $e) {
36-
$renderer = TwigRenderer::class;
37-
}
38-
3930
$compiler
4031
->addDebugInfo($this)
4132
->write('$this->env->getRuntime(')
42-
->string($renderer)
33+
->string(FormRenderer::class)
4334
->raw(')->setTheme(')
4435
->subcompile($this->getNode('form'))
4536
->raw(', ')

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy