@param iterable $includesFromParent

@return iterable

@SuppressWarnings(PHPMD.StaticAccess)
@SuppressWarnings(PHPMD.ElseExpression)
423679
private function getValidatedIncludes(iterable $includesFromParent): iterable
    {
        $ruleIndexes = $this->serializerClass::readIncludesRuleIndexes($this->getSerializedRuleSet());

        if ($ruleIndexes === null) {
            // without validation
            foreach ($includesFromParent as $path => $split) {
                yield $path => $split;
            }
        } else {
            // with validation
            $ruleIndex = $this->serializerClass::readRuleMainIndex($ruleIndexes);
            $this->validationStarts(static::PARAM_INCLUDE, $ruleIndexes);
            foreach ($includesFromParent as $path => $split) {
                $this->getCaptures()->clear();
                $this->validateAndAccumulateError($path, $ruleIndex);
                if ($this->getCaptures()->count() > 0) {
                    yield $this->readSingleCapturedValue() => $split;
                }
            }
            $this->validateEnds(static::PARAM_INCLUDE, $ruleIndexes);
        }
    }
726066
private function getValidatedFields(iterable $fieldsFromParent): iterable
    {
        $ruleIndexes = $this->serializerClass::readFieldSetRulesIndexes($this->getSerializedRuleSet());

        if ($ruleIndexes === null) {
            // without validation
            foreach ($fieldsFromParent as $type => $fieldList) {
                yield $type => $fieldList;
            }
        } else {
            // with validation
            $mainIndexes = $this->serializerClass::readRuleMainIndexes($ruleIndexes);
            $this->validationStarts(static::PARAM_FIELDS, $ruleIndexes);
            foreach ($fieldsFromParent as $type => $fieldList) {
                if (array_key_exists($type, $mainIndexes) === true) {
                    yield $type => $this->validateValues($mainIndexes[$type], $fieldList);
                } else {
                    // unknown field set type
                    $this->getValidationErrors()->add(
                        new ValidationError(
                            static::PARAM_FIELDS,
                            $type,
                            ErrorCodes::INVALID_VALUE,
                            Messages::INVALID_VALUE,
                            []
                        )
                    );
                }
            }
            $this->validateEnds(static::PARAM_FIELDS, $ruleIndexes);
        }
    }
73127
private static function doMapRecursive($iterable, callable $callable): array
    {
        $mapped = [];
        foreach ($iterable as $key => $value) {
            $mapped[$key] = is_iterable($value) ?
                static::doMapRecursive($value, $callable) :
                $callable($value, $key);
        }

        return $mapped;
    }
249074
public function getSymbols(): iterable
    {
        return new \CallbackFilterIterator(
            new \RecursiveIteratorIterator(
                new \RecursiveArrayIterator($this->symbols, \RecursiveArrayIterator::CHILD_ARRAYS_ONLY)
            ),
            function ($each): bool {
                return $each !== false;
            }
        );
    }
1250810
public static function count_templates($context, $includes) {
        $params = self::validate_parameters(self::count_templates_parameters(), array(
            'context' => $context,
            'includes' => $includes
        ));
        $context = self::get_context_from_params($params['context']);
        self::validate_context($context);

        return api::count_templates($context, $includes);
    }
1113455
private function parseResource(ResourceInterface $resource): iterable
    {
        $seenBefore = isset($this->resourcesTracker[$resource->getId()][$resource->getType()]);

        // top level resources should be yielded in any case as it could be an array of the resources
        // for deeper levels it's not needed as they go to `included` section and it must have no more
        // than one instance of the same resource.

        if ($seenBefore === false || $resource->getPosition()->getLevel() <= ParserInterface::ROOT_LEVEL) {
            yield $resource;
        }

        // parse relationships only for resources not seen before (prevents infinite loop for circular references)
        if ($seenBefore === false) {
            // remember by id and type
            $this->resourcesTracker[$resource->getId()][$resource->getType()] = true;

            foreach ($resource->getRelationships() as $name => $relationship) {
                \assert(\is_string($name));
                \assert($relationship instanceof RelationshipInterface);

                $isShouldParse = $this->isPathRequested($relationship->getPosition()->getPath());

                if ($isShouldParse === true && $relationship->hasData() === true) {
                    $relData = $relationship->getData();
                    if ($relData->isResource() === true) {
                        yield from $this->parseResource($relData->getResource());

                        continue;
                    } elseif ($relData->isCollection() === true) {
                        foreach ($relData->getResources() as $relResource) {
                            \assert($relResource instanceof ResourceInterface ||
                                $relResource instanceof IdentifierInterface);
                            if ($relResource instanceof ResourceInterface) {
                                yield from $this->parseResource($relResource);
                            }
                        }

                        continue;
                    }

                    \assert($relData->isNull() || $relData->isIdentifier());
                }
            }
        }
    }
1164646
public static function transform($record, $includes = [])
    {
        $model_name = class_basename(get_class($record));
        $transformer = sprintf('\App\Transformers\%sTransformer', $model_name);

        $fractal = new self();

        if ($includes) {
            $fractal->manager->parseIncludes($includes);
        }

        try {
            return $fractal->item($record, new $transformer, $model_name);
        } catch (\Exception $e) {
            //Transformer class doesn't exist
            return [];
        }
    }
940406
public function getParents($includeSelf = false)
    {
        $parentsId = $this->getParentsId($includeSelf);
        $orderBy = [];
        foreach ( $parentsId as $id ) {
            $orderBy[] = "`$this->primaryKey` = $id DESC";
        }
        return call_user_func("$this->ownerClassName::find")
            ->where([
                $this->primaryKey => $parentsId,
            ])
            ->orderBy(implode(', ', $orderBy));
    }
1216200
public function findByInterface(string $interface, $include_disabled = false, $sort = false): Collection
    {
        $modules = $this->all($include_disabled)
            ->filter($this->interfaceFilter($interface));

        switch ($interface) {
            case ModuleFooterInterface::class:
                return $modules->sort($this->footerSorter());

            case ModuleMenuInterface::class:
                return $modules->sort($this->menuSorter());

            case ModuleSidebarInterface::class:
                return $modules->sort($this->sidebarSorter());

            case ModuleTabInterface::class:
                return $modules->sort($this->tabSorter());

            default:
                if ($sort) {
                    return $modules->sort($this->moduleSorter());
                }

                return $modules;
        }
    }
1090156
private function createClassmapIterator(
        iterable $classmap,
        iterable $exclude = []
    ): Iterator {
        $files = new AppendIterator();

        foreach ($classmap as $directory) {
            if (!is_dir($directory)) {
                continue;
            }

            $files->append(
                new RecursiveIteratorIterator(
                    new RecursiveDirectoryIterator($directory)
                )
            );
        }

        return new class ($files, $this->preparePattern(...$exclude)) extends FilterIterator {
            /** @var string|null */
            private $excludePattern;

            /**
             * Constructor.
             *
             * @param Iterator    $iterator
             * @param string|null $excludePattern
             */
            public function __construct(
                Iterator $iterator,
                ?string $excludePattern
            ) {
                $this->excludePattern = $excludePattern;

                parent::__construct($iterator);
            }

            /**
             * Check whether the current element of the iterator is acceptable.
             *
             * @return bool
             */
            public function accept(): bool
            {
                /** @var SplFileInfo $file */
                $file = $this->getInnerIterator()->current();

                return (
                    $file->isFile()
                    && (
                        $this->excludePattern === null
                        ?: !preg_match(
                            $this->excludePattern,
                            str_replace('\\', '/', $file->getRealPath())
                        )
                    )
                );
            }
        };
    }
820997
public static function OneOrMore( $iter )
	{
		$iter = $iter->CreateBufferedIterator();
		/**
		 * @var XPath2NodeIterator $probe
		 */
		$probe = $iter->CloneInstance();
		if ( ! $probe->MoveNext() )
		    throw XPath2Exception::withErrorCode( "FORG0004", Resources::FORG0004 );

		return $iter;
	}
168472
public static function getStringOperands($includeSelector = false)
    {
        $values = array(
            self::STRING_STARTS,
            self::STRING_ENDS,
            self::STRING_EQUALS,
            self::STRING_CONTAINS,
        );

        if ($includeSelector) {
            $values[] = self::OPERAND_SELECTOR;
        }

        return $values;
    }
1099781
public function previousUntil(callable $callback, $inclusive = FALSE) {
    $matches = [];
    foreach ($this->nodes as $node) {
      $matches = array_merge($matches, $node->previousUntil($callback, $inclusive)->nodes);
    }
    return new NodeCollection($matches);
  }
607679
public function buildQuery(array $params, $includeCurrent = true)
    {
        if ($includeCurrent == true) {
            $params = array_replace_recursive($this->getQuery(), $params);
        }

        return $this->serialize($params);
    }
462723
public function getMultiOptions($includeSelf = true)
    {
        $this->_tmpResult = [];
        if (!$this->isNewRecord && $includeSelf) {
            $this->_tmpResult[$this->id] = $this;
        }
        return $this->_buildTreeArrayRecursive($this, $this->_filter);
    }
795102
public function include($includes)
	{
		$model = $this;

		(function() use ($includes, $model): void
		{
			$this->including($includes)->loadIncludes([$model]);
		})->bindTo($this->builder(), Query::class)();

		return $this;
	}
298055
public function including($includes)
	{
		if($includes === false)
		{
			$this->model->setIncludes([]);
		}
		else
		{
			$includes = (array) $includes;

			$currentIncludes = $this->model->getIncludes();

			if(!empty($currentIncludes))
			{
				$withCriterion = array_filter(array_keys($includes), 'is_string');

				if(!empty($withCriterion))
				{
					foreach($currentIncludes as $key => $value)
					{
						if(in_array($value, $withCriterion))
						{
							unset($currentIncludes[$key]); // Unset relations that have previously been set without a criterion closure
						}
					}
				}

				$includes = array_merge($currentIncludes, $includes);
			}

			$this->model->setIncludes(array_unique($includes, SORT_REGULAR));
		}

		return $this;
	}