original_string: protected function normalizeValidationRuleSourceData($rules)
      {
          if (false === $rules || empty($rules)) {
              return [];
          }
  
          if (is_string($rules)) {
              $rules = (array) $rules;
          }
  
          if ( ! is_array($rules)) {
              throw new UnexpectedValueException("Form field base validation rules not array or arrayable");
          }
  
          // Loop through and cast anything not already a data object
          $rules = array_map([$this, 'normalizeRulesProperty'], $rules, array_keys($rules));
  
          // Make sure there is only one entry per rule key
          $rules = $this->getRuleMerger()->collapseRulesForDuplicateKeys($rules);
  
          // Key the array by the rule key
          return array_combine(
              array_map(function (ValidationRuleDataInterface $rule) {
                  return $rule->key() ?: '';
              }, $rules),
              $rules
          );
      }
code: protected function normalizeValidationRuleSourceData($rules)
      {
          if (false === $rules || empty($rules)) {
              return [];
          }
  
          if (is_string($rules)) {
              $rules = (array) $rules;
          }
  
          if ( ! is_array($rules)) {
              throw new UnexpectedValueException("Form field base validation rules not array or arrayable");
          }
  
          // Loop through and cast anything not already a data object
          $rules = array_map([$this, 'normalizeRulesProperty'], $rules, array_keys($rules));
  
          // Make sure there is only one entry per rule key
          $rules = $this->getRuleMerger()->collapseRulesForDuplicateKeys($rules);
  
          // Key the array by the rule key
          return array_combine(
              array_map(function (ValidationRuleDataInterface $rule) {
                  return $rule->key() ?: '';
              }, $rules),
              $rules
          );
      }
code_tokens: protected function normalizeValidationRuleSourceData ( $ rules ) { if ( false === $ rules || empty ( $ rules ) ) { return [ ] ; } if ( is_string ( $ rules ) ) { $ rules = ( array ) $ rules ; } if ( ! is_array ( $ rules ) ) { throw new UnexpectedValueException ( "Form field base validation rules not array or arrayable" ) ; } // Loop through and cast anything not already a data object $ rules = array_map ( [ $ this , 'normalizeRulesProperty' ] , $ rules , array_keys ( $ rules ) ) ; // Make sure there is only one entry per rule key $ rules = $ this -> getRuleMerger ( ) -> collapseRulesForDuplicateKeys ( $ rules ) ; // Key the array by the rule key return array_combine ( array_map ( function ( ValidationRuleDataInterface $ rule ) { return $ rule -> key ( ) ? : '' ; } , $ rules ) , $ rules ) ; }
docstring: Normalizes generated validation rule data to an array of data object instances.
  
  The entries will be collapsed to one per key, and the array will be keyed by the key.
  
  @param mixed $rules
  @return ValidationRuleDataInterface[]
docstring_tokens: Normalizes generated validation rule data to an array of data object instances .