8000 Merge branch '2.8' · symfony/symfony@5183c88 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5183c88

Browse files
Merge branch '2.8'
* 2.8: Always enable clock-mock for HttpFoundation [ClassLoader] Fix parsing namespace when token_get_all() is missing Bug #16343 [Router] Too many Routes ? Fixes the stack traces of the deprecation logs fix unused variable warning [Translation][Form] Do not translate form labels and placeholders when 'translation_domain' is false add composer exclude-from-classmap for new 2.8 components [Yaml] sync changelog and upgrade files [Debug] Ensure class declarations are loaded only once Minor design tweaks for the Logs and Doctrine profiler panels Conflicts: UPGRADE-2.8.md
2 parents cd0ffc9 + da43309 commit 5183c88

22 files changed

+285
-23
lines changed

UPGRADE-3.0.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,6 +1333,11 @@ UPGRADE FROM 2.x to 3.0
13331333

13341334
### Yaml
13351335

1336+
* Using a colon in an unquoted mapping value leads to a `ParseException`.
1337+
* Starting an unquoted string with `@`, `` ` ``, `|`, or `>` leads to a `ParseException`.
1338+
* Deprecated non-escaped \ in double-quoted strings when parsing Yaml
1339+
("Foo\Var" is not valid whereas "Foo\\Var" is)
1340+
13361341
* The ability to pass file names to `Yaml::parse()` has been removed.
13371342

13381343
Before:

phpunit.xml.dist

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,14 @@
4747
</exclude>
4848
</whitelist>
4949
</filter>
50+
51+
<listeners>
52+
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener">
53+
<arguments>
54+
<array>
55+
<element><string>Symfony\Component\HttpFoundation</string></element>
56+
</array>
57+
</arguments>
58+
</listener>
59+
</listeners>
5060
</phpunit>

src/Symfony/Bridge/PhpUnit/ClockMock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static function microtime($asFloat = false)
6666
return self::$now;
6767
}
6868

69-
return sprintf("%0.6f %d\n", $now - (int) $now, (int) self::$now);
69+
return sprintf("%0.6f %d\n", self::$now - (int) self::$now, (int) self::$now);
7070
}
7171

7272
public static function register($class)

src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
{%- endif -%}
5858
<select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}>
5959
{%- if placeholder is not none -%}
60-
<option value=""{% if required and value is empty %} selected="selected"{% endif %}>{{ placeholder != '' ? placeholder|trans({}, translation_domain) }}</option>
60+
<option value=""{% if required and value is empty %} selected="selected"{% endif %}>{{ placeholder != '' ? (translation_domain is same as(false) ? placeholder : placeholder|trans({}, translation_domain)) }}</option>
6161
{%- endif -%}
6262
{%- if preferred_choices|length > 0 -%}
6363
{% set options = preferred_choices %}
@@ -192,7 +192,7 @@
192192
{% set label = name|humanize %}
193193
{%- endif -%}
194194
{%- endif -%}
195-
<button type="{{ type|default('button') }}" {{ block('button_attributes') }}>{{ label|trans({}, translation_domain) }}</button>
195+
<button type="{{ type|default('button') }}" {{ block('button_attributes') }}>{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}</button>
196196
{%- endblock button_widget -%}
197197

198198
{%- block submit_widget -%}
@@ -320,7 +320,7 @@
320320
{%- for attrname, attrvalue in attr -%}
321321
{{- " " -}}
322322
{%- if attrname in ['placeholder', 'title'] -%}
323-
{{- attrname }}="{{ attrvalue|trans({}, translation_domain) }}"
323+
{{- attrname }}="{{ translation_domain is same as(false) ? attrvalue : attrvalue|trans({}, translation_domain) }}"
324324
{%- elseif attrvalue is same as(true) -%}
325325
{{- attrname }}="{{ attrname }}"
326326
{%- elseif attrvalue is not same as(false) -%}
@@ -334,7 +334,7 @@
334334
{%- for attrname, attrvalue in attr -%}
335335
{{- " " -}}
336336
{%- if attrname in ['placeholder', 'title'] -%}
337-
{{- attrname }}="{{ attrvalue|trans({}, translation_domain) }}"
337+
{{- attrname }}="{{ translation_domain is same as(false) ? attrvalue : attrvalue|trans({}, translation_domain) }}"
338338
{%- elseif attrvalue is same as(true) -%}
339339
{{- attrname }}="{{ attrname }}"
340340
{%- elseif attrvalue is not same as(false) -%}
@@ -348,7 +348,7 @@
348348
{%- for attrname, attrvalue in attr -%}
349349
{{- " " -}}
350350
{%- if attrname in ['placeholder', 'title'] -%}
351-
{{- attrname }}="{{ attrvalue|trans({}, translation_domain) }}"
351+
{{- attrname }}="{{ translation_domain is same as(false) ? attrvalue : attrvalue|trans({}, translation_domain) }}"
352352
{%- elseif attrvalue is same as(true) -%}
353353
{{- attrname }}="{{ attrname }}"
354354
{%- elseif attrvalue is not same as(false) -%}
@@ -361,7 +361,7 @@
361361
{%- for attrname, attrvalue in attr -%}
362362
{{- " " -}}
363363
{%- if attrname in ['placeholder', 'title'] -%}
364-
{{- attrname }}="{{ attrvalue|trans({}, translation_domain) }}"
364+
{{- attrname }}="{{ translation_domain is same as(false) ? attrvalue : attrvalue|trans({}, translation_domain) }}"
365365
{%- elseif attrvalue is same as(true) -%}
366366
{{- attrname }}="{{ attrname }}"
367367
{%- elseif attrvalue is not same as(false) -%}

src/Symfony/Bridge/Twig/Resources/views/Form/foundation_5_layout.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
{%- endif -%}
151151
<select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple" data-customforms="disabled"{% endif %}>
152152
{% if placeholder is not none -%}
153-
<option value=""{% if required and value is empty %} selected="selected"{% endif %}>{{ placeholder|trans({}, translation_domain) }}</option>
153+
<option value=""{% if required and value is empty %} selected="selected"{% endif %}>{{ translation_domain is same as(false) ? placeholder : placeholder|trans({}, translation_domain) }}</option>
154154
{%- endif %}
155155
{%- if preferred_choices|length > 0 -%}
156156
{% set options = preferred_choices %}
@@ -253,7 +253,7 @@
253253
{% endif %}
254254
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
255255
{{ widget|raw }}
256-
{{ label|trans({}, translation_domain) }}
256+
{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}
257257
</label>
258258
{%- endblock checkbox_radio_label %}
259259

src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/button_attributes.html.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
id="<?php echo $view->escape($id) ?>" name="<?php echo $view->escape($full_name) ?>" <?php if ($disabled): ?>disabled="disabled" <?php endif ?>
22
<?php foreach ($attr as $k => $v): ?>
33
<?php if (in_array($v, array('placeholder', 'title'), true)): ?>
4-
<?php printf('%s="%s" ', $view->escape($k), $view->escape($view['translator']->trans($v, array(), $translation_domain))) ?>
4+
<?php printf('%s="%s" ', $view->escape($k), $view->escape(false !== $translation_domain ? $view['translator']->trans($v, array(), $translation_domain) : $v)) ?>
55
<?php elseif ($v === true): ?>
66
<?php printf('%s="%s" ', $view->escape($k), $view->escape($k)) ?>
77
<?php elseif ($v !== false): ?>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?php if (!$label) { $label = isset($label_format)
22
? strtr($label_format, array('%name%' => $name, '%id%' => $id))
33
: $view['form']->humanize($name); } ?>
4-
<button type="<?php echo isset($type) ? $view->escape($type) : 'button' ?>" <?php echo $view['form']->block($form, 'button_attributes') ?>><?php echo $view->escape($view['translator']->trans($label, array(), $translation_domain)) ?></button>
4+
<button type="<?php echo isset($type) ? $view->escape($type) : 'button' ?>" <?php echo $view['form']->block($form, 'button_attributes') ?>><?php echo $view->escape(false !== $translation_domain ? $view['translator']->trans($label, array(), $translation_domain) : $label) ?></button>

src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_collapsed.html.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
)) ?>
88
<?php if ($multiple): ?> multiple="multiple"<?php endif ?>
99
>
10-
<?php if (null !== $placeholder): ?><option value=""<?php if ($required and empty($value) && '0' !== $value): ?> selected="selected"<?php endif?>><?php echo '' != $placeholder ? $view->escape($view['translator']->trans($placeholder, array(), $translation_domain)) : '' ?></option><?php endif; ?>
10+
<?php if (null !== $placeholder): ?><option value=""<?php if ($required and empty($value) && '0' !== $value): ?> selected="selected"<?php endif?>><?php echo '' != $placeholder ? $view->escape(false !== $translation_domain ? $view['translator']->trans($placeholder, array(), $translation_domain) : $placeholder) : '' ?></option><?php endif; ?>
1111
<?php if (count($preferred_choices) > 0): ?>
1212
<?php echo $view['form']->block($form, 'choice_widget_options', array('choices' => $preferred_choices)) ?>
1313
<?php if (count($choices) > 0 && null !== $separator): ?>

src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/widget_attributes.html.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<?php if ($required): ?> required="required"<?php endif ?>
33
<?php foreach ($attr as $k => $v): ?>
44
<?php if (in_array($k, array('placeholder', 'title'), true)): ?>
5-
<?php printf(' %s="%s"', $view->escape($k), $view->escape($view['translator']->trans($v, array(), $translation_domain))) ?>
5+
<?php printf(' %s="%s"', $view->escape($k), $view->escape(false !== $translation_domain ? $view['translator']->trans($v, array(), $translation_domain) : $v)) ?>
66
<?php elseif ($v === true): ?>
77
<?php printf(' %s="%s"', $view->escape($k), $view->escape($k)) ?>
88
<?php elseif ($v !== false): ?>

src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/widget_container_attributes.html.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php if (!empty($id)): ?>id="<?php echo $view->escape($id) ?>" <?php endif ?>
22
<?php foreach ($attr as $k => $v): ?>
33
<?php if (in_array($v, array('placeholder', 'title'), true)): ?>
4-
<?php printf('%s="%s" ', $view->escape($k), $view->escape($view['translator']->trans($v, array(), $translation_domain))) ?>
4+
<?php printf('%s="%s" ', $view->escape($k), $view->escape(false !== $translation_domain ? $view['translator']->trans($v, array(), $translation_domain) : $v)) ?>
55
<?php elseif ($v === true): ?>
66
<?php printf('%s="%s" ', $view->escape($k), $view->escape($k)) ?>
77
<?php elseif ($v !== false): ?>

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@
169169
{% if index == 2 %}
170170
<ul class="sf-call-stack" id="{{ id }}" class="hidden">
171171
{% endif %}
172+
172173
{% if call.class is defined %}
173174
{% set from = call.class|abbr_class ~ '::' ~ call.function|abbr_method() %}
174175
{% elseif call.function is defined %}
@@ -179,7 +180,14 @@
179180
{% set from = '-' %}
180181
{% endif %}
181182

182-
<li><span class="text-small">Called from</span> {{ call.file is defined and call.line is defined ? call.file|format_file(call.line, from) : from|raw }}</li>
183+
{% set file_name = (call.file is defined and call.line is defined) ? call.file|replace({'\\': '/'})|split('/')|last %}
184+
185+
<li>
186+
{{ from|raw }}
187+
{% if file_name %}
188+
<span class="text-small">(called from {{ call.file|format_file(call.line, file_name)|raw }})</span>
189+
{% endif %}
190+
</li>
183191

184192
{% if index == stack|length - 1 %}
185193
</ul>

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,13 +808,28 @@ table.logs .metadata strong {
808808
color: #222;
809809
}
810810

811+
table.logs .sf-call-stack {
812+
margin: 1em 0 1em 1.5em;
813+
}
814+
table.logs .sf-call-stack li {
815+
margin-bottom: 5px;
816+
}
817+
table.logs .sf-call-stack abbr {
818+
border: none;
819+
}
820+
811821
{# Doctrine panel
812822
========================================================================= #}
813823
.sql-runnable {
814824
background: #F5F5F5;
815825
margin: .5em 0;
816826
padding: 1em;
817827
}
828+
.queries-table pre {
829+
{{ mixins.break_long_words|raw }}
830+
margin: 0;
831+
white-space: pre-wrap;
832+
}
818833

819834
{# Dump panel
820835
========================================================================= #}

src/Symfony/Component/ClassLoader/ClassCollectionLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive =
134134
public static function fixNamespaceDeclarations($source)
135135
{
136136
if (!function_exists('token_get_all') || !self::$useTokenizer) {
137-
if (preg_match('/namespace(.*?)\s*;/', $source)) {
138-
$source = preg_replace('/namespace(.*?)\s*;/', "namespace$1\n{", $source)."}\n";
137+
if (preg_match('/(^|\s)namespace(.*?)\s*;/', $source)) {
138+
$source = preg_replace('/(^|\s)namespace(.*?)\s*;/', "$1namespace$2\n{", $source)."}\n";
139139
}
140140

141141
return $source;

src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public function getFixNamespaceDeclarationsDataWithoutTokenizer()
198198
array("namespace Bar ;\nclass Foo {}\n", "namespace Bar\n{\nclass Foo {}\n}\n"),
199199
array("namespace Foo\Bar;\nclass Foo {}\n", "namespace Foo\Bar\n{\nclass Foo {}\n}\n"),
200200
array("namespace Foo\Bar\Bar\n{\nclass Foo {}\n}\n", "namespace Foo\Bar\Bar\n{\nclass Foo {}\n}\n"),
201-
array("namespace\n{\nclass Foo {}\n}\n", "namespace\n{\nclass Foo {}\n}\n"),
201+
array("\nnamespace\n{\nclass Foo {}\n\$namespace=123;}\n", "\nnamespace\n{\nclass Foo {}\n\$namespace=123;}\n"),
202202
);
203203
}
204204

src/Symfony/Component/Debug/DebugClassLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function loadClass($class)
120120
try {
121121
if ($this->isFinder) {
122122
if ($file = $this->classLoader[0]->findFile($class)) {
123-
require $file;
123+
require_once $file;
124124
}
125125
} else {
126126
call_user_func($this->classLoader, $class);

src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,32 @@ public function testSingleChoiceWithoutTranslation()
254254
);
255255
}
256256

257+
public function testSingleChoiceWithPlaceholderWithoutTranslation()
258+
{
259+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
260+
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
261+
'multiple' => false,
262+
'expanded' => false,
263+
'required' => false,
264+
'translation_domain' => false,
265+
'placeholder' => 'Placeholder&Not&Translated',
266+
));
267+
268+
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
269+
'/select
270+
[@name="name"]
271+
[@class="my&class form-control"]
272+
[not(@required)]
273+
[
274+
./option[@value=""][not(@selected)][not(@disabled)][.="Placeholder&Not&Translated"]
275+
/following-sibling::option[@value="&a"][@selected="selected"][.="Choice&A"]
276+
/following-sibling::option[@value="&b"][not(@selected)][.="Choice&B"]
277+
]
278+
[count(./option)=3]
279+
'
280+
);
281+
}
282+
257283
public function testSingleChoiceAttributes()
258284
{
259285
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
@@ -765,6 +791,52 @@ public function testSingleChoiceExpandedWithPlaceholder()
765791
);
766792
}
767793

794+
public function testSingleChoiceExpandedWithPlaceholderWithoutTranslation()
795+
{
796+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array(
797+
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
798+
'multiple' => false,
799+
'expanded' => true,
800+
'translation_domain' => false,
801+
'placeholder' => 'Placeholder&Not&Translated',
802+
));
803+
804+
$this->assertWidgetMatchesXpath($form->createView(), array(),
805+
'/div
806+
[
807+
./div
808+
[@class="radio"]
809+
[
810+
./label
811+
[.=" Placeholder&Not&Translated"]
812+
[
813+
./input[@type="radio"][@name="name"][@id="name_placeholder"][not(@checked)]
814+
]
815+
]
816+
/following-sibling::div
817+
[@class="radio"]
818+
[
819+
./label
820+
[.=" Choice&A"]
821+
[
822+
./input[@type="radio"][@name="name"][@id="name_0"][@checked]
823+
]
824+
]
825+
/following-sibling::div
826+
[@class="radio"]
827+
[
828+
./label
829+
[.=" Choice&B"]
830+
[
831+
./input[@type="radio"][@name="name"][@id="name_1"][not(@checked)]
832+
]
833+
]
834+
/following-sibling::input[@type="hidden"][@id="name__token"][@class="form-control"]
835+
]
836+
'
837+
);
838+
}
839+
768840
public function testSingleChoiceExpandedWithBooleanValue()
769841
{
770842
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', true, array(
@@ -1996,6 +2068,17 @@ public function testButton()
19962068
);
19972069
}
19982070

2071+
public function testButtonlabelWithoutTranslation()
2072+
{
2073+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', null, array(
2074+
'translation_domain' => false,
2075+
));
2076+
2077+
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
2078+
'/button[@type="button"][@name="name"][.="Name"][@class="my&class btn"]'
2079+
);
2080+
}
2081+
19992082
public function testSubmit()
20002083
{
20012084
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\SubmitType');

0 commit comments

Comments
 (0)
0