Merge branch '2.7' into 2.8
* 2.7: fixed Twig deprecations replaced deprecated Twig sameas test by same as fixed a namespace in the upgrade file
This commit is contained in:
commit
472b374790
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
{% block form_label -%}
|
||||
{% spaceless %}
|
||||
{% if label is sameas(false) %}
|
||||
{% if label is same as(false) %}
|
||||
<div class="{{ block('form_label_class') }}"></div>
|
||||
{% else %}
|
||||
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ block('form_label_class'))|trim}) %}
|
||||
|
@ -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 %}
|
||||
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
|
||||
{{- 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)) -}}
|
||||
</label>
|
||||
{% endif %}
|
||||
{% endblock checkbox_radio_label %}
|
||||
|
@ -74,13 +74,13 @@
|
||||
{%- block choice_widget_options -%}
|
||||
{% for group_label, choice in options %}
|
||||
{%- if choice is iterable -%}
|
||||
<optgroup label="{{ choice_translation_domain is sameas(false) ? group_label : group_label|trans({}, choice_translation_domain) }}">
|
||||
<optgroup label="{{ choice_translation_domain is same as(false) ? group_label : group_label|trans({}, choice_translation_domain) }}">
|
||||
{% set options = choice %}
|
||||
{{- block('choice_widget_options') -}}
|
||||
</optgroup>
|
||||
{%- else -%}
|
||||
{% set attr = choice.attr %}
|
||||
<option value="{{ choice.value }}" {{ block('attributes') }}{% if choice is selectedchoice(value) %} selected="selected"{% endif %}>{{ choice_translation_domain is sameas(false) ? choice.label : choice.label|trans({}, choice_translation_domain) }}</option>
|
||||
<option value="{{ choice.value }}" {{ block('attributes') }}{% if choice is selectedchoice(value) %} selected="selected"{% endif %}>{{ choice_translation_domain is same as(false) ? choice.label : choice.label|trans({}, choice_translation_domain) }}</option>
|
||||
{%- endif -%}
|
||||
{% endfor %}
|
||||
{%- endblock choice_widget_options -%}
|
||||
@ -225,7 +225,7 @@
|
||||
{% set label = name|humanize %}
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>{{ translation_domain is sameas(false) ? label : label|trans({}, translation_domain) }}</label>
|
||||
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}</label>
|
||||
{%- endif -%}
|
||||
{%- endblock form_label -%}
|
||||
|
||||
@ -325,9 +325,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 -%}
|
||||
@ -339,9 +339,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 -%}
|
||||
@ -353,9 +353,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 -%}
|
||||
@ -366,9 +366,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 -%}
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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'
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -628,7 +628,7 @@
|
||||
<th>{{ option }}</th>
|
||||
<td><pre>{{ value }}</pre></td>
|
||||
<td>
|
||||
{% if data.resolved_options[option] is sameas(value) %}
|
||||
{% if data.resolved_options[option] is same as(value) %}
|
||||
<em>same as passed value</em>
|
||||
{% else %}
|
||||
<pre>{{ data.resolved_options[option] }}</pre>
|
||||
|
@ -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()
|
||||
|
Reference in New Issue
Block a user