Skip to content

Commit 2d1b1a7

Browse files
committed
bug #17430 [Serializer] Ensure that groups are strings (dunglas)
This PR was squashed before being merged into the 2.7 branch (closes #17430). Discussion ---------- [Serializer] Ensure that groups are strings | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Commits ------- 0a3b877 [Serializer] Ensure that groups are strings
2 parents 4c9a5b8 + d6e38f2 commit 2d1b1a7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Mapping/Loader/YamlFileLoader.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,15 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata)
7474
}
7575

7676
if (isset($data['groups'])) {
77+
if (!is_array($data['groups'])) {
78+
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());
79+
}
80+
7781
foreach ($data['groups'] as $group) {
82+
if (!is_string($group)) {
83+
throw new MappingException('Group names must be strings in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName());
84+
}
85+
7886
$attributeMetadata->addGroup($group);
7987
}
8088
}

0 commit comments

Comments
 (0)