Valid.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 __get(string $option)
  23. {
  24. if ('groups' === $option) {
  25. // when this is reached, no groups have been configured
  26. return null;
  27. }
  28. return parent::__get($option);
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function addImplicitGroupName($group)
  34. {
  35. if (null !== $this->groups) {
  36. parent::addImplicitGroupName($group);
  37. }
  38. }
  39. }