original_string: public function addConstraint(Constraint $constraint)
      {
          if ($constraint instanceof Traverse) {
              throw new ConstraintDefinitionException(sprintf('The constraint "%s" can only be put on classes. Please use "Symfony\Component\Validator\Constraints\Valid" instead.', \get_class($constraint)));
          }
  
          if ($constraint instanceof Valid && null === $constraint->groups) {
              $this->cascadingStrategy = CascadingStrategy::CASCADE;
  
              if ($constraint->traverse) {
                  $this->traversalStrategy = TraversalStrategy::IMPLICIT;
              } else {
                  $this->traversalStrategy = TraversalStrategy::NONE;
              }
  
              return $this;
          }
  
          $this->constraints[] = $constraint;
  
          foreach ($constraint->groups as $group) {
              $this->constraintsByGroup[$group][] = $constraint;
          }
  
          return $this;
      }
code: public function addConstraint(Constraint $constraint)
      {
          if ($constraint instanceof Traverse) {
              throw new ConstraintDefinitionException(sprintf('The constraint "%s" can only be put on classes. Please use "Symfony\Component\Validator\Constraints\Valid" instead.', \get_class($constraint)));
          }
  
          if ($constraint instanceof Valid && null === $constraint->groups) {
              $this->cascadingStrategy = CascadingStrategy::CASCADE;
  
              if ($constraint->traverse) {
                  $this->traversalStrategy = TraversalStrategy::IMPLICIT;
              } else {
                  $this->traversalStrategy = TraversalStrategy::NONE;
              }
  
              return $this;
          }
  
          $this->constraints[] = $constraint;
  
          foreach ($constraint->groups as $group) {
              $this->constraintsByGroup[$group][] = $constraint;
          }
  
          return $this;
      }
code_tokens: public function addConstraint ( Constraint $ constraint ) { if ( $ constraint instanceof Traverse ) { throw new ConstraintDefinitionException ( sprintf ( 'The constraint "%s" can only be put on classes. Please use "Symfony\Component\Validator\Constraints\Valid" instead.' , \ get_class ( $ constraint ) ) ) ; } if ( $ constraint instanceof Valid && null === $ constraint -> groups ) { $ this -> cascadingStrategy = CascadingStrategy :: CASCADE ; if ( $ constraint -> traverse ) { $ this -> traversalStrategy = TraversalStrategy :: IMPLICIT ; } else { $ this -> traversalStrategy = TraversalStrategy :: NONE ; } return $ this ; } $ this -> constraints [ ] = $ constraint ; foreach ( $ constraint -> groups as $ group ) { $ this -> constraintsByGroup [ $ group ] [ ] = $ constraint ; } return $ this ; }
docstring: Adds a constraint.
  
  If the constraint {@link Valid} is added, the cascading strategy will be
  changed to {@link CascadingStrategy::CASCADE}. Depending on the
  $traverse property of that constraint, the traversal strategy
  will be set to one of the following:
  
  - {@link TraversalStrategy::IMPLICIT} if $traverse is enabled
  - {@link TraversalStrategy::NONE} if $traverse is disabled
  
  @return $this
  
  @throws ConstraintDefinitionException When trying to add the
  {@link Traverse} constraint
docstring_tokens: Adds a constraint .