Iterate on subspecs.

@param array $subSpecs      Array of subspecs
@param int   $fieldIndex    The current field index
@param int   $subfieldIndex The current subfield index

@return bool The validation result
961231
private function iterateSubSpec($subSpecs, $fieldIndex, $subfieldIndex = null)
    {
        $valid = true;
        foreach ($subSpecs as $_subSpec) {
            if (is_array($_subSpec)) { // chained subSpecs (OR)
                foreach ($_subSpec as $this->currentSubSpec) {
                    $this->setIndexStartEnd($fieldIndex, $subfieldIndex);
                    if ($valid = $this->checkSubSpec()) {
                        break; // at least one of them is true (OR)
                    }
                }
            } else {
                // repeated SubSpecs (AND)
                $this->currentSubSpec = $_subSpec;
                $this->setIndexStartEnd($fieldIndex, $subfieldIndex);
                if (!$valid = $this->checkSubSpec()) {
                    break; // all of them have to be true (AND)
                }
            }
        }

        return $valid;
    }
244195
private ProjectField selectField(ProjectField[] fields, int index)
   {
      if (index < 1 || index > fields.length)
      {
         throw new IllegalArgumentException(index + " is not a valid field index");
      }
      return (fields[index - 1]);
   }
1253241
public function pluck($field, $indexField=null) {

        $fieldsFormat = $field;
        $usingFormatting = preg_match_all('/{(\w+\.\w+|\w+)}/', $field, $matches);

        //Obtención del campo/s de la consulta
        $fields = [];
        if ($usingFormatting) {
            $fields = $matches[1];
            foreach ($fields as $formatField) {
                if (($pos = strpos($formatField, '.')) !== false) {
                    $replaceFormatField = substr($formatField, $pos + 1);
                    $fieldsFormat = str_replace($formatField, $replaceFormatField, $fieldsFormat);
                }
            }
        }
        else {
            $fields = [$field];
        }

        //Establecer los campos del select
        $selectFields = $fields;
        if ($indexField != null && !in_array($indexField, $selectFields)) {
            $selectFields[] = $indexField;
        }
        $this->selectFields($selectFields);

        //Obtención del campo de indice
        $returnIndexField = $indexField;
        if (!empty($returnIndexField)) {
            if (($pos = strpos($returnIndexField, '.')) !== false) {
                $returnIndexField = substr($returnIndexField, $pos + 1);
            }
        }

        //Obtención de los campos de retorno
        $returnFields = [];
        foreach ($fields as $returnField) {
            if (($pos = strpos($returnField, '.')) !== false) {
                $returnField = substr($returnField, $pos + 1);
            }
            $returnFields[] = $returnField;
        }

        //Creación del array de resultados
        $fieldResults = [];
        $results = $this->find();
        foreach ($results as $result) {
            $value = null;
            if (!$usingFormatting) {
                $value = $result->{$returnFields[0]};
            }
            else {
                $value = $fieldsFormat;
                foreach ($returnFields as $returnField) {
                    $value = str_replace("{" . $returnField . "}", $result->$returnField, $value);
                }
            }

            if ($returnIndexField != null) {
                $fieldResults[$result->$returnIndexField] = $value;
            }
            else {
                $fieldResults[] = $value;
            }
        }
        return $fieldResults;
    }
790900
public function valid($fields = array())
    {
        if (empty($fields)) {
            $fields = array_diff($this->getFields(), array($this->getIndex()));
        }
        foreach ($fields as $field) {
            $value = $this->getFieldValue($field);
            if (!empty($value)) {
                return true;
            }
        }
        return false;
    }
157599
private static boolean checkPureColumnIndex(Index index, int aggCol, List<AbstractExpression> filterExprs) {

        boolean found = false;

        // all left child of filterExprs must be of type TupleValueExpression in equality comparison
        for (AbstractExpression expr : filterExprs) {
            if (expr.getExpressionType() != ExpressionType.COMPARE_EQUAL) {
                return false;
            }
            if (!(expr.getLeft() instanceof TupleValueExpression)) {
                return false;
            }
            if (((TupleValueExpression)expr.getLeft()).getColumnIndex() == aggCol) {
                found = true;
            }
        }

        if (found) {
            return true;
        }
        if (index.getColumns().size() > filterExprs.size()) {
            List<ColumnRef> indexedColRefs = CatalogUtil.getSortedCatalogItems(index.getColumns(), "index");

            if (indexedColRefs.get(filterExprs.size()).getColumn().getIndex() == aggCol) {
                return true;
            }
        }

        return false;
    }
1373020
protected function searchSelect(SearchableSubquery $subquery, ColumnCollection $columns, array $words)
    {
        $cases = $bindings = [];

        foreach ($columns as $column) {
            list($cases[], $binding) = $this->buildCase($column, $words);

            $bindings = array_merge_recursive($bindings, $binding);
        }

        $select = implode(' + ', $cases);

        $subquery->selectRaw("max({$select}) as relevance");

        $this->addBinding($bindings['select'], 'select');

        return $bindings['where'];
    }
94377
private ResourceField selectField(ResourceField[] fields, int index)
   {
      if (index < 1 || index > fields.length)
      {
         throw new IllegalArgumentException(index + " is not a valid field index");
      }
      return (fields[index - 1]);
   }
1370085
public function getSources(string $fieldType, $sources, string $indexFrom, string $indexTo)
    {
        $mappedSources = $sources;
        if (is_array($sources)) {
            $mappedSources = [];
            $sources = array_filter($sources);
            foreach ($sources as $source) {
                $mappedSources[] = $this->getSource($fieldType, $source, $indexFrom, $indexTo);
            }
        }

        return $mappedSources;
    }
708202
public static function getRulesEndIndexes(array $arrayRulesIndexes): array
    {
        assert(array_key_exists(static::RULES_ARRAY_END_INDEXES, $arrayRulesIndexes));
        $result = $arrayRulesIndexes[static::RULES_ARRAY_END_INDEXES];

        return $result;
    }
982527
protected function joinForSearch($mappings, $subquery)
    {
        $mappings = is_array($mappings) ? $mappings : (array) $mappings;

        $columns = new ColumnCollection;

        $grammar = $this->query->getGrammar();

        $joiner = static::$joinerFactory->make($subquery->getQuery(), $this->model);

        // Here we loop through the search mappings in order to join related tables
        // appropriately and build a searchable column collection, which we will
        // use to build select and where clauses with correct table prefixes.
        foreach ($mappings as $mapping => $weight) {
            if (strpos($mapping, '.') !== false) {
                list($relation, $column) = $this->model->parseMappedColumn($mapping);

                $related = $joiner->leftJoin($relation);

                $columns->add(
                    new Column($grammar, $related->getTable(), $column, $mapping, $weight)
                );
            } else {
                $columns->add(
                    new Column($grammar, $this->model->getTable(), $mapping, $mapping, $weight)
                );
            }
        }

        return $columns;
    }
1286008
private function addInheritedIndexes(ClassMetadata $subClass, ClassMetadata $parentClass)
    {
        if ($subClass->isEmbeddedDocument) {
            return;
        }

        $indexFactory = new IndexFactory($subClass);
        $parentIndex  = $parentClass->getIndex();

        if ($parentIndex !== null) {
            $index = $indexFactory->createInherited($parentIndex);
            $subClass->setIndex($index);
        }

        foreach ($parentClass->getSecondaryIndexes() as $parentIndex) {
            $index = $indexFactory->createInherited($parentIndex);
            $subClass->addSecondaryIndex($index);
        }
    }
318231
public function hasColumnStylesForColumn($columnIndex): bool
    {
        if (!$this->hasColumnStyles()) {
            return false;
        }

        $columnStyles = $this->getColumnStyles();

        return isset($columnStyles[$columnIndex]) ? true : false;
    }
397333
public function offsetSet($index, $item) : void
    {
        if ($item instanceof Fieldset) {
            foreach ($item as $subitem) {
                $this->setValue($subitem);
            }
        } else {
            $this->setValue($item);
        }
        parent::offsetSet($index, $item);
    }
201454
private function addInheritedIndexes(ClassMetadata $subClass, ClassMetadata $parentClass) : void
    {
        foreach ($parentClass->indexes as $index) {
            $subClass->addIndex($index['keys'], $index['options']);
        }
    }
333362
private function validateFilterArguments(int $ruleIndex, iterable $opsAndArgs): iterable
    {
        foreach ($opsAndArgs as $operation => $arguments) {
            yield $operation => $this->validateValues($ruleIndex, $arguments);
        }
    }
232908
public function setField(Field $field, $index = 0)
    {
        $this->field = $field;
        $this->valueIndex = $index;
    }
629100
public function ApplyRules($Fields) {
      foreach ($Fields as $Index => $Row) {
         $Validation = GetValue('Validation', $Row);
         if (!$Validation)
            continue;
         
         $FieldName = GetValue('Name', $Row, $Index);
         if (is_string($Validation)) {
            $this->ApplyRule($FieldName, $Validation);
         } elseif (is_array($Validation)) {
            foreach ($Validation as $Rule) {
               if (is_array($Rule)) {
                  $this->ApplyRule($FieldName, $Rule[0], $Rule[1]);
               } else {
                  $this->ApplyRule($FieldName, $Rule);
               }
            }
         }
      }
   }