vendor/symfony/validator/Constraints/Traverse.php line 27

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. use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
  13. /**
  14.  * @Annotation
  15.  *
  16.  * @author Bernhard Schussek <bschussek@gmail.com>
  17.  */
  18. #[\Attribute(\Attribute::TARGET_CLASS)]
  19. class Traverse extends Constraint
  20. {
  21.     public $traverse true;
  22.     public function __construct(bool|array $traverse null)
  23.     {
  24.         if (\is_array($traverse) && \array_key_exists('groups'$traverse)) {
  25.             throw new ConstraintDefinitionException(sprintf('The option "groups" is not supported by the constraint "%s".'__CLASS__));
  26.         }
  27.         parent::__construct($traverse);
  28.     }
  29.     /**
  30.      * {@inheritdoc}
  31.      */
  32.     public function getDefaultOption(): ?string
  33.     {
  34.         return 'traverse';
  35.     }
  36.     /**
  37.      * {@inheritdoc}
  38.      */
  39.     public function getTargets(): string|array
  40.     {
  41.         return self::CLASS_CONSTRAINT;
  42.     }
  43. }