original_string: public function addRequiredFields($fields, ...$otherFields)
      {
          if(!is_array($fields)) {
              $fields = [$fields];
          }
          if(!empty($otherFields)) {
              $fields = array_merge($fields, $otherFields);
          }
          if (ArrayLib::is_associative($fields)) {
              foreach ($fields as $k => $v) {
                  $constraint = Constraint_required::create();
                  if ($v) {
                      $constraint->setMessage($v);
                  }
                  $this->setConstraint($k, $constraint);
              }
          } else {
              foreach ($fields as $field) {
                  $this->setConstraint($field, Constraint_required::create());
              }
          }
  
          return $this;
      }
code: public function addRequiredFields($fields, ...$otherFields)
      {
          if(!is_array($fields)) {
              $fields = [$fields];
          }
          if(!empty($otherFields)) {
              $fields = array_merge($fields, $otherFields);
          }
          if (ArrayLib::is_associative($fields)) {
              foreach ($fields as $k => $v) {
                  $constraint = Constraint_required::create();
                  if ($v) {
                      $constraint->setMessage($v);
                  }
                  $this->setConstraint($k, $constraint);
              }
          } else {
              foreach ($fields as $field) {
                  $this->setConstraint($field, Constraint_required::create());
              }
          }
  
          return $this;
      }
code_tokens: public function addRequiredFields ( $ fields , ... $ otherFields ) { if ( ! is_array ( $ fields ) ) { $ fields = [ $ fields ] ; } if ( ! empty ( $ otherFields ) ) { $ fields = array_merge ( $ fields , $ otherFields ) ; } if ( ArrayLib :: is_associative ( $ fields ) ) { foreach ( $ fields as $ k => $ v ) { $ constraint = Constraint_required :: create ( ) ; if ( $ v ) { $ constraint -> setMessage ( $ v ) ; } $ this -> setConstraint ( $ k , $ constraint ) ; } } else { foreach ( $ fields as $ field ) { $ this -> setConstraint ( $ field , Constraint_required :: create ( ) ) ; } } return $ this ; }
docstring: A quick way of adding required constraints to a number of fields
  
  @param array $fieldNames - can be either indexed array of fieldnames, or associative array of fieldname => message
  @param array $otherFields
  @return this
docstring_tokens: A quick way of adding required constraints to a number of fields