Skip to content

Commit

Permalink
bug #44854 [Validator] throw when Constraint::_construct() has not be…
Browse files Browse the repository at this point in the history
…en 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 #44846
| License       | MIT
| Doc PR        | -

Instead of #44847

Commits
-------

20aacce [Validator] throw when Constraint::_construct() has not been called
  • Loading branch information
ogizanagi committed Dec 31, 2021
2 parents 94007a5 + 20aacce commit d1b22ce
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Symfony/Component/Validator/Constraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ public function __isset($option)
*/
public function addImplicitGroupName($group)
{
if (null === $this->groups && \array_key_exists('groups', (array) $this)) {
throw new \LogicException(sprintf('"%s::$groups" is set to null. Did you forget to call "%s::__construct()"?', static::class, self::class));
}

if (\in_array(self::DEFAULT_GROUP, $this->groups) && !\in_array($group, $this->groups)) {
$this->groups[] = $group;
}
Expand Down

0 comments on commit d1b22ce

Please sign in to comment.