From f4a785bfb33a375e232bdb0fb6971661f03dffc7 Mon Sep 17 00:00:00 2001 From: Christian Raue Date: Wed, 12 Aug 2015 19:27:52 +0200 Subject: [PATCH 1/3] fixed a namespace in the upgrade file --- UPGRADE-2.7.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UPGRADE-2.7.md b/UPGRADE-2.7.md index 8fd61b41fd..0abc3ae85f 100644 --- a/UPGRADE-2.7.md +++ b/UPGRADE-2.7.md @@ -168,7 +168,7 @@ Form } ``` - * `Symfony\Component\Form\Extension\Core\ChoiceList\View\ChoiceView` was + * `Symfony\Component\Form\Extension\Core\View\ChoiceView` was deprecated and will be removed in Symfony 3.0. You should use `Symfony\Component\Form\ChoiceList\View\ChoiceView` instead. The constructor arguments of the new class are in the same order than in the From 99a1fcc3e2d51a9be176ad5d8ed1fcda4a4492d7 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 23 Aug 2015 09:25:58 +0200 Subject: [PATCH 2/3] replaced deprecated Twig sameas test by same as --- .../bootstrap_3_horizontal_layout.html.twig | 2 +- .../views/Form/bootstrap_3_layout.html.twig | 4 ++-- .../views/Form/form_div_layout.html.twig | 22 +++++++++---------- .../Resources/views/Collector/form.html.twig | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_horizontal_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_horizontal_layout.html.twig index f6b8671513..767e2798f3 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_horizontal_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_horizontal_layout.html.twig @@ -9,7 +9,7 @@ {% block form_label -%} {% spaceless %} - {% if label is sameas(false) %} + {% if label is same as(false) %}
{% else %} {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ block('form_label_class'))|trim}) %} diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig index 7405612a9b..a788a3df89 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig @@ -166,12 +166,12 @@ {% if parent_label_class is defined %} {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ parent_label_class)|trim}) %} {% endif %} - {% if label is not sameas(false) and label is empty %} + {% if label is not same as(false) and label is empty %} {% set label = name|humanize %} {% endif %} {{- widget|raw -}} - {{- label is not sameas(false) ? (translation_domain is sameas(false) ? label : label|trans({}, translation_domain)) -}} + {{- label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}} {% endif %} {% endblock checkbox_radio_label %} diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig index 1c428fdbc7..77275db49e 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig @@ -74,13 +74,13 @@ {%- block choice_widget_options -%} {% for group_label, choice in options %} {%- if choice is iterable -%} - + {% set options = choice %} {{- block('choice_widget_options') -}} {%- else -%} {% set attr = choice.attr %} - + {%- endif -%} {% endfor %} {%- endblock choice_widget_options -%} @@ -220,7 +220,7 @@ {% set label = name|humanize %} {%- endif -%} {%- endif -%} - {{ translation_domain is sameas(false) ? label : label|trans({}, translation_domain) }} + {{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }} {%- endif -%} {%- endblock form_label -%} @@ -321,9 +321,9 @@ {{- " " -}} {%- if attrname in ['placeholder', 'title'] -%} {{- attrname }}="{{ attrvalue|trans({}, translation_domain) }}" - {%- elseif attrvalue is sameas(true) -%} + {%- elseif attrvalue is same as(true) -%} {{- attrname }}="{{ attrname }}" - {%- elseif attrvalue is not sameas(false) -%} + {%- elseif attrvalue is not same as(false) -%} {{- attrname }}="{{ attrvalue }}" {%- endif -%} {%- endfor -%} @@ -335,9 +335,9 @@ {{- " " -}} {%- if attrname in ['placeholder', 'title'] -%} {{- attrname }}="{{ attrvalue|trans({}, translation_domain) }}" - {%- elseif attrvalue is sameas(true) -%} + {%- elseif attrvalue is same as(true) -%} {{- attrname }}="{{ attrname }}" - {%- elseif attrvalue is not sameas(false) -%} + {%- elseif attrvalue is not same as(false) -%} {{- attrname }}="{{ attrvalue }}" {%- endif -%} {%- endfor -%} @@ -349,9 +349,9 @@ {{- " " -}} {%- if attrname in ['placeholder', 'title'] -%} {{- attrname }}="{{ attrvalue|trans({}, translation_domain) }}" - {%- elseif attrvalue is sameas(true) -%} + {%- elseif attrvalue is same as(true) -%} {{- attrname }}="{{ attrname }}" - {%- elseif attrvalue is not sameas(false) -%} + {%- elseif attrvalue is not same as(false) -%} {{- attrname }}="{{ attrvalue }}" {%- endif -%} {%- endfor -%} @@ -362,9 +362,9 @@ {{- " " -}} {%- if attrname in ['placeholder', 'title'] -%} {{- attrname }}="{{ attrvalue|trans({}, translation_domain) }}" - {%- elseif attrvalue is sameas(true) -%} + {%- elseif attrvalue is same as(true) -%} {{- attrname }}="{{ attrname }}" - {%- elseif attrvalue is not sameas(false) -%} + {%- elseif attrvalue is not same as(false) -%} {{- attrname }}="{{ attrvalue }}" {%- endif -%} {%- endfor -%} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/form.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/form.html.twig index 037ad28c84..33cbf8f242 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/form.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/form.html.twig @@ -610,7 +610,7 @@ {{ option }}
{{ value }}
- {% if data.resolved_options[option] is sameas(value) %} + {% if data.resolved_options[option] is same as(value) %} same as passed value {% else %}
{{ data.resolved_options[option] }}
From 7b643540582f0e96b840b770cdec6e08a3d9afef Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 23 Aug 2015 09:30:32 +0200 Subject: [PATCH 3/3] fixed Twig deprecations --- src/Symfony/Bridge/Twig/Node/DumpNode.php | 2 +- src/Symfony/Bridge/Twig/Node/StopwatchNode.php | 2 +- .../Bridge/Twig/Tests/Extension/DumpExtensionTest.php | 6 +++--- .../Twig/Tests/Extension/ExpressionExtensionTest.php | 4 ++-- .../Tests/Extension/Fixtures/StubFilesystemLoader.php | 2 +- .../Twig/Tests/Extension/StopwatchExtensionTest.php | 4 ++-- src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php | 8 ++++---- .../Bundle/TwigBundle/Controller/ExceptionController.php | 6 ++++-- src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php | 2 +- .../Bundle/TwigBundle/TokenParser/RenderTokenParser.php | 2 +- .../Tests/Controller/ProfilerControllerTest.php | 2 +- 11 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Node/DumpNode.php b/src/Symfony/Bridge/Twig/Node/DumpNode.php index bdcb68caa6..522497ba65 100644 --- a/src/Symfony/Bridge/Twig/Node/DumpNode.php +++ b/src/Symfony/Bridge/Twig/Node/DumpNode.php @@ -18,7 +18,7 @@ class DumpNode extends \Twig_Node { private $varPrefix; - public function __construct($varPrefix, \Twig_NodeInterface $values = null, $lineno, $tag = null) + public function __construct($varPrefix, \Twig_Node $values = null, $lineno, $tag = null) { parent::__construct(array('values' => $values), array(), $lineno, $tag); $this->varPrefix = $varPrefix; diff --git a/src/Symfony/Bridge/Twig/Node/StopwatchNode.php b/src/Symfony/Bridge/Twig/Node/StopwatchNode.php index cc12abd05d..06eeb49272 100644 --- a/src/Symfony/Bridge/Twig/Node/StopwatchNode.php +++ b/src/Symfony/Bridge/Twig/Node/StopwatchNode.php @@ -18,7 +18,7 @@ namespace Symfony\Bridge\Twig\Node; */ class StopwatchNode extends \Twig_Node { - public function __construct(\Twig_NodeInterface $name, $body, \Twig_Node_Expression_AssignName $var, $lineno = 0, $tag = null) + public function __construct(\Twig_Node $name, $body, \Twig_Node_Expression_AssignName $var, $lineno = 0, $tag = null) { parent::__construct(array('body' => $body, 'name' => $name, 'var' => $var), array(), $lineno, $tag); } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php index 36a50190d1..af93114e5a 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php @@ -23,7 +23,7 @@ class DumpExtensionTest extends \PHPUnit_Framework_TestCase public function testDumpTag($template, $debug, $expectedOutput, $expectedDumped) { $extension = new DumpExtension(new VarCloner()); - $twig = new \Twig_Environment(new \Twig_Loader_String(), array( + $twig = new \Twig_Environment(new \Twig_Loader_Array(array('template' => $template)), array( 'debug' => $debug, 'cache' => false, 'optimizations' => 0, @@ -35,7 +35,7 @@ class DumpExtensionTest extends \PHPUnit_Framework_TestCase $prevDumper = VarDumper::setHandler(function ($var) use (&$dumped) {$dumped = $var;}); try { - $this->assertEquals($expectedOutput, $twig->render($template)); + $this->assertEquals($expectedOutput, $twig->render('template')); } catch (\Exception $exception) { } @@ -63,7 +63,7 @@ class DumpExtensionTest extends \PHPUnit_Framework_TestCase public function testDump($context, $args, $expectedOutput, $debug = true) { $extension = new DumpExtension(new VarCloner()); - $twig = new \Twig_Environment(new \Twig_Loader_String(), array( + $twig = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array( 'debug' => $debug, 'cache' => false, 'optimizations' => 0, diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/ExpressionExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/ExpressionExtensionTest.php index 749133c65c..0c7cc1bd41 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/ExpressionExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/ExpressionExtensionTest.php @@ -21,10 +21,10 @@ class ExpressionExtensionTest extends \PHPUnit_Framework_TestCase public function testExpressionCreation() { $template = "{{ expression('1 == 1') }}"; - $twig = new \Twig_Environment(new \Twig_Loader_String(), array('debug' => true, 'cache' => false, 'autoescape' => true, 'optimizations' => 0)); + $twig = new \Twig_Environment(new \Twig_Loader_Array(array('template' => $template)), array('debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0)); $twig->addExtension(new ExpressionExtension()); - $output = $twig->render($template); + $output = $twig->render('template'); $this->assertEquals('1 == 1', $output); } } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubFilesystemLoader.php b/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubFilesystemLoader.php index 5a63537a2f..5f306013d9 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubFilesystemLoader.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubFilesystemLoader.php @@ -13,7 +13,7 @@ namespace Symfony\Bridge\Twig\Tests\Extension\Fixtures; class StubFilesystemLoader extends \Twig_Loader_Filesystem { - protected function findTemplate($name) + protected function findTemplate($name, $throw = true) { // strip away bundle name $parts = explode(':', $name); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php index bac855390f..8c0cdfe69b 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php @@ -28,11 +28,11 @@ class StopwatchExtensionTest extends \PHPUnit_Framework_TestCase */ public function testTiming($template, $events) { - $twig = new \Twig_Environment(new \Twig_Loader_String(), array('debug' => true, 'cache' => false, 'autoescape' => true, 'optimizations' => 0)); + $twig = new \Twig_Environment(new \Twig_Loader_Array(array('template' => $template)), array('debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0)); $twig->addExtension(new StopwatchExtension($this->getStopwatch($events))); try { - $nodes = $twig->render($template); + $nodes = $twig->render('template'); } catch (\Twig_Error_Runtime $e) { throw $e->getPrevious(); } diff --git a/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php index 5fdd54f49e..2553b9ea2a 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php @@ -19,7 +19,7 @@ class DumpNodeTest extends \PHPUnit_Framework_TestCase { $node = new DumpNode('bar', null, 7); - $env = new \Twig_Environment(); + $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface')); $compiler = new \Twig_Compiler($env); $expected = <<<'EOTXT' @@ -43,7 +43,7 @@ EOTXT; { $node = new DumpNode('bar', null, 7); - $env = new \Twig_Environment(); + $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface')); $compiler = new \Twig_Compiler($env); $expected = <<<'EOTXT' @@ -70,7 +70,7 @@ EOTXT; )); $node = new DumpNode('bar', $vars, 7); - $env = new \Twig_Environment(); + $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface')); $compiler = new \Twig_Compiler($env); $expected = <<<'EOTXT' @@ -93,7 +93,7 @@ EOTXT; )); $node = new DumpNode('bar', $vars, 7); - $env = new \Twig_Environment(); + $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface')); $compiler = new \Twig_Compiler($env); $expected = <<<'EOTXT' diff --git a/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php b/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php index 3bab43b523..b0c172c1e9 100644 --- a/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php +++ b/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php @@ -63,7 +63,7 @@ class ExceptionController $code = $exception->getStatusCode(); return new Response($this->twig->render( - $this->findTemplate($request, $request->getRequestFormat(), $code, $showException), + (string) $this->findTemplate($request, $request->getRequestFormat(), $code, $showException), array( 'status_code' => $code, 'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '', @@ -125,9 +125,11 @@ class ExceptionController return new TemplateReference('TwigBundle', 'Exception', $showException ? 'exception_full' : $name, 'html', 'twig'); } - // to be removed when the minimum required version of Twig is >= 2.0 + // to be removed when the minimum required version of Twig is >= 3.0 protected function templateExists($template) { + $template = (string) $template; + $loader = $this->twig->getLoader(); if ($loader instanceof \Twig_ExistsLoaderInterface) { return $loader->exists($template); diff --git a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php index 3c7f925d03..769976b304 100644 --- a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php +++ b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php @@ -63,7 +63,7 @@ class FilesystemLoader extends \Twig_Loader_Filesystem * * @throws \Twig_Error_Loader if the template could not be found */ - protected function findTemplate($template) + protected function findTemplate($template, $throw = true) { $logicalName = (string) $template; diff --git a/src/Symfony/Bundle/TwigBundle/TokenParser/RenderTokenParser.php b/src/Symfony/Bundle/TwigBundle/TokenParser/RenderTokenParser.php index 0d3ae2b86d..b386c9b57f 100644 --- a/src/Symfony/Bundle/TwigBundle/TokenParser/RenderTokenParser.php +++ b/src/Symfony/Bundle/TwigBundle/TokenParser/RenderTokenParser.php @@ -27,7 +27,7 @@ class RenderTokenParser extends \Twig_TokenParser * * @param \Twig_Token $token A \Twig_Token instance * - * @return \Twig_NodeInterface A \Twig_NodeInterface instance + * @return \Twig_Node A \Twig_Node instance */ public function parse(\Twig_Token $token) { diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php index 25b5c82f6c..4a290ad514 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php @@ -77,7 +77,7 @@ class ProfilerControllerTest extends \PHPUnit_Framework_TestCase public function testSearchResult() { $urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface'); - $twig = $this->getMock('Twig_Environment'); + $twig = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock(); $profiler = $this ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') ->disableOriginalConstructor()