Skip to content

Commit d1b22ce

Browse files
committed
bug symfony#44854 [Validator] throw when Constraint::_construct() has not been called (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- [Validator] throw when Constraint::_construct() has not been called | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix symfony#44846 | License | MIT | Doc PR | - Instead of symfony#44847 Commits ------- 20aacce [Validator] throw when Constraint::_construct() has not been called
2 parents 94007a5 + 20aacce commit d1b22ce

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)