Skip to content

Commit 20aacce

Browse files
[Validator] throw when Constraint::_construct() has not been called
1 parent 94007a5 commit 20aacce

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Symfony/Component/Validator/Constraint.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ public function __isset($option)
226226
*/
227227
public function addImplicitGroupName($group)
228228
{
229+
if (null === $this->groups && \array_key_exists('groups', (array) $this)) {
230+
throw new \LogicException(sprintf('"%s::$groups" is set to null. Did you forget to call "%s::__construct()"?', static::class, self::class));
231+
}
232+
229233
if (\in_array(self::DEFAULT_GROUP, $this->groups) && !\in_array($group, $this->groups)) {
230234
$this->groups[] = $group;
231235
}

0 commit comments

Comments
 (0)