Skip to content

Commit 8881221

Browse files
Merge branch '2.7' into 2.8
* 2.7: [2.7] Fix issues reported by static analyse [Serializer] Reduce nesting in YamlFileLoader
2 parents 15106bf + 4597768 commit 8881221

File tree

4 files changed

+28
-27
lines changed

4 files changed

+28
-27
lines changed

src/Symfony/Bridge/Twig/TwigEngine.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function supports($name)
112112
* @param string|TemplateReferenceInterface|\Twig_Template $name A template name or an instance of
113113
* TemplateReferenceInterface or \Twig_Template
114114
*
115-
* @return \Twig_TemplateInterface A \Twig_TemplateInterface instance
115+
* @return \Twig_Template A \Twig_Template instance
116116
*
117117
* @throws \InvalidArgumentException if the template does not exist
118118
*/

src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function getName(Profile $profile, $panel)
6767
*
6868
* @param Profile $profile
6969
*
70-
* @return Twig_Template[]
70+
* @return \Twig_Template[]
7171
*
7272
* @deprecated not used anymore internally
7373
*/

src/Symfony/Component/HttpKernel/EventListener/TestSessionListener.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\HttpKernel\EventListener;
1313

1414
use Symfony\Component\HttpFoundation\Cookie;
15+
use Symfony\Component\HttpFoundation\Session\SessionInterface;
1516
use Symfony\Component\HttpKernel\KernelEvents;
1617
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
1718
use Symfony\Component\HttpKernel\Event\GetResponseEvent;

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

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -60,39 +60,39 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata)
6060
$this->classes = $classes;
6161
}
6262

63-
if (isset($this->classes[$classMetadata->getName()])) {
64-
$yaml = $this->classes[$classMetadata->getName()];
65-
66-
if (isset($yaml['attributes']) && is_array($yaml['attributes'])) {
67-
$attributesMetadata = $classMetadata->getAttributesMetadata();
68-
69-
foreach ($yaml['attributes'] as $attribute => $data) {
70-
if (isset($attributesMetadata[$attribute])) {
71-
$attributeMetadata = $attributesMetadata[$attribute];
72-
} else {
73-
$attributeMetadata = new AttributeMetadata($attribute);
74-
$classMetadata->addAttributeMetadata($attributeMetadata);
75-
}
63+
if (!isset($this->classes[$classMetadata->getName()])) {
64+
return false;
65+
}
7666

77-
if (isset($data['groups'])) {
78-
if (!is_array($data['groups'])) {
79-
throw new MappingException('The "groups" key must be an array of strings in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName());
80-
}
67+
$yaml = $this->classes[$classMetadata->getName()];
8168

82-
foreach ($data['groups'] as $group) {
83-
if (!is_string($group)) {
84-
throw new MappingException('Group names must be strings in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName());
85-
}
69+
if (isset($yaml['attributes']) && is_array($yaml['attributes'])) {
70+
$attributesMetadata = $classMetadata->getAttributesMetadata();
71+
72+
foreach ($yaml['attributes'] as $attribute => $data) {
73+
if (isset($attributesMetadata[$attribute])) {
74+
$attributeMetadata = $attributesMetadata[$attribute];
75+
} else {
76+
$attributeMetadata = new AttributeMetadata($attribute);
77+
$classMetadata->addAttributeMetadata($attributeMetadata);
78+
}
8679

87-
$attributeMetadata->addGroup($group);
80+
if (isset($data['groups'])) {
81+
if (!is_array($data['groups'])) {
82+
throw new MappingException(sprintf('The "groups" key must be an array of strings in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName()));
83+
}
84+
85+
foreach ($data['groups'] as $group) {
86+
if (!is_string($group)) {
87+
throw new MappingException(sprintf('Group names must be strings in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName()));
8888
}
89+
90+
$attributeMetadata->addGroup($group);
8991
}
9092
}
9193
}
92-
93-
return true;
9494
}
9595

96-
return false;
96+
return true;
9797
}
9898
}

0 commit comments

Comments
 (0)