10000 Merge branch '2.7' into 2.8 · symfony/symfony@aa7d6a2 · GitHub
[go: up one dir, main page]

Skip to content

Commit aa7d6a2

Browse files
Merge branch '2.7' into 2.8
* 2.7: [WebProfilerBundle] Fix whitespace control in layout.html.twig [Validator] Fix init of YamlFileLoader::$classes for empty files
2 parents 7f633d1 + 56c3eef commit aa7d6a2

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@
7272
<ul id="menu-profiler">
7373
{% for name, template in templates %}
7474
{% set menu -%}
75-
{% if block('menu', template) is defined %}
75+
{%- if block('menu', template) is defined -%}
7676
{% with { collector: profile.getcollector(name), profiler_markup_version: profiler_markup_version } %}
7777
{{- block('menu', template) -}}
7878
{% endwith %}
79-
{% endif %}
79+
{%- endif -%}
8080
{%- endset %}
8181
{% if menu is not empty %}
8282
<li class="{{ name }} {{ name == panel ? 'selected' : '' }}">

src/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,7 @@ public function loadClassMetadata(ClassMetadata $metadata)
4646
$this->yamlParser = new YamlParser();
4747
}
4848

49-
// This method may throw an exception. Do not modify the class'
50-
// state before it completes
51-
if (false === ($classes = $this->parseFile($this->file))) {
52-
return false;
53-
}
54-
55-
$this->classes = $classes;
49+
$this->classes = $this->parseFile($this->file);
5650

5751
if (isset($this->classes['namespaces'])) {
5852
foreach ($this->classes['namespaces'] as $alias => $namespace) {
@@ -111,7 +105,7 @@ protected function parseNodes(array $nodes)
111105
*
112106
* @param string $path The path of the YAML file
113107
*
114-
* @return array|null The class descriptions or null, if the file was empty
108+
* @return array The class descriptions
115109
*
116110
* @throws \InvalidArgumentException If the file could not be loaded or did
117111
* not contain a YAML array
@@ -126,7 +120,7 @@ private function parseFile($path)
126120

127121
// empty file
128122
if (null === $classes) {
129-
return;
123+
return array();
130124
}
131125

132126
// not an array

src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public function testLoadClassMetadataReturnsFalseIfEmpty()
3131
$metadata = new ClassMetadata('Symfony\Component\Validator\Tests\Fixtures\Entity');
3232

3333
$this->assertFalse($loader->loadClassMetadata($metadata));
34+
35+
$r = new \ReflectionProperty($loader, 'classes');
36+
$r->setAccessible(true);
37+
$this->assertSame(array(), $r->getValue($loader));
3438
}
3539

3640
/**

0 commit comments

Comments
 (0)
0