vendor/symfony/validator/Constraints/Valid.php line 23

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Validator\Constraints;
  11. use Symfony\Component\Validator\Constraint;
  12. /**
  13. * @Annotation
  14. * @Target({"PROPERTY", "METHOD", "ANNOTATION"})
  15. *
  16. * @author Bernhard Schussek <bschussek@gmail.com>
  17. */
  18. #[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
  19. class Valid extends Constraint
  20. {
  21. public $traverse = true;
  22. public function __construct(?array $options = null, ?array $groups = null, $payload = null, ?bool $traverse = null)
  23. {
  24. parent::__construct($options ?? [], $groups, $payload);
  25. $this->traverse = $traverse ?? $this->traverse;
  26. }
  27. public function __get(string $option)
  28. {
  29. if ('groups' === $option) {
  30. // when this is reached, no groups have been configured
  31. return null;
  32. }
  33. return parent::__get($option);
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function addImplicitGroupName(string $group)
  39. {
  40. if (null !== $this->groups) {
  41. parent::addImplicitGroupName($group);
  42. }
  43. }
  44. }