@param Functions\ElementProjection $projectionFunction

@return Ordering
773343
public function update(Functions\ElementProjection $projectionFunction)
    {
        if ($this->projectionFunction === $projectionFunction) {
            return $this;
        }

        return new self($projectionFunction, $this->isAscendingId);
    }
1098755
final public function orderBy(string $memberExpression, string $direction)
    {
        $this->orderings[] = new MemberOrdering(
            $this->memberExpressionParser->parse($this->class, $memberExpression),
            $direction
        );

        return $this;
    }
155637
public function addElement(OrderElement $elements)
    {
        $this->elements[] = $elements;
        $elements->setOrder($this);

        return $this;
    }
76186
public function sortByCallable(callable $sortFunc)
    {
        $this->prepare();

        if (!is_array($this->_map)) {
            return $this;
        }

        usort($this->_map, $sortFunc);

        return $this;
    }
131699
public function prepareSortOrProjection(array $fields)
    {
        $preparedFields = array();

        foreach ($fields as $key => $value) {
            $preparedFields[$this->prepareFieldName($key)] = $value;
        }

        return $preparedFields;
    }
667886
function project($projections)
    {
        if (func_get_args() === 1) {
            $projections = (array) $projections;
        }

        if (!is_array($projections)) {
            $projections = func_get_args();
        }

        foreach ($projections as $projection) {
            $this->nodes->projections[] = $projection;
        }
        return $this;
    }
456469
public function orderBy($fields, string $direction = 'ASC'): IQueryBuilderHandler
    {
        if (\is_array($fields) === false) {
            $fields = [$fields];
        }

        foreach ((array)$fields as $key => $value) {
            $field = $key;
            $type = $value;

            if (\is_int($key) === true) {
                $field = $value;
                $type = $direction;
            }

            if (($field instanceof Raw) === false) {
                $field = $this->addTablePrefix($field);
            }

            $this->statements['orderBys'][] = compact('field', 'type');
        }

        return $this;
    }
6346
protected function orderFixturesByDependencies($usedPrioritySorting)
    {
        $sequenceForClasses = $orderedFixtures = [];

        // If fixtures were already ordered by number then we need
        // to remove classes which are not instances of OrderedFixtureInterface
        // in case fixtures implementing DependentFixtureInterface exist.
        // This is because, in that case, the method orderFixturesByDependencies
        // will handle all fixtures which are not instances of
        // OrderedFixtureInterface
        if ($usedPrioritySorting) {
            $this->orderedFixtures = array_filter(
                $this->orderedFixtures,
                function ($fixture) {
                    return $fixture instanceof OrderedFixtureInterface;
                }
            );
        }

        // First we determine which classes has dependencies and which don't
        foreach ($this->fixtures as $fixture) {
            $fixtureClass = get_class($fixture);

            if ($fixture instanceof OrderedFixtureInterface) {
                continue;
            } elseif ($fixture instanceof DependentFixtureInterface) {
                $dependenciesClasses = $fixture->getDependencies();

                $this->validateDependencies($fixtureClass, $dependenciesClasses);

                // We mark this class as unsequenced
                $sequenceForClasses[$fixtureClass] = -1;
            } else {
                // This class has no dependencies, so we assign 0
                $sequenceForClasses[$fixtureClass] = 0;
            }
        }

        // Now we order fixtures by sequence
        $sequence  = 1;
        $lastCount = -1;

        while (($count = count($unsequencedClasses = $this->getUnsequencedClasses($sequenceForClasses))) > 0
            && $count !== $lastCount) {
            foreach ($unsequencedClasses as $key => $class) {
                $fixture                 = $this->fixtures[$class];
                $dependencies            = $fixture->getDependencies();
                $unsequencedDependencies = $this->getUnsequencedClasses($sequenceForClasses, $dependencies);

                if (count($unsequencedDependencies) === 0) {
                    $sequenceForClasses[$class] = $sequence++;
                }
            }

            $lastCount = $count;
        }

        // If there're fixtures unsequenced left and they couldn't be sequenced,
        // it means we have a circular reference
        if ($count > 0) {
            $msg = 'Classes "%s" have produced a CircularReferenceException. ';
            $msg .= 'An example of this problem would be the following: Class C has class B as its dependency. ';
            $msg .= 'Then, class B has class A has its dependency. Finally, class A has class C as its dependency. ';
            $msg .= 'This case would produce a CircularReferenceException.';

            throw new CircularReferenceException(sprintf($msg, implode(',', $unsequencedClasses)));
        } else {
            // We order the classes by sequence
            asort($sequenceForClasses);

            foreach ($sequenceForClasses as $class => $sequence) {
                // If fixtures were ordered
                $orderedFixtures[] = $this->fixtures[$class];
            }
        }

        $this->orderedFixtures = array_merge($this->orderedFixtures, $orderedFixtures);
    }
49134
public function arrayToFunctionElement(array $definition)
    {
        $function = new Functions;
        if (isset($definition['docblock'])) {
            $docblock = $this->arrayToDocblockElement($definition['docblock']);
            $function->setDocbloc($docblock);
        }
        if (isset($definition['public'])) {
            $function->isPublic(true);
        }
        if (isset($definition['name'])) {
            $function->setName($definition['name']);
        }
        if (isset($definition['params'])) {
            foreach ($definition['params'] as $name => $type) {
                $function->addParam($name, $type);
            }
        }
        if (isset($definition['content'])) {
            $function->setContent($definition['content']);
        }
        return $function;
    }
910460
private static function getDocumentedElement($fqsen)
    {
        $projectDescriptor = self::$descriptorBuilder->getProjectDescriptor();
        $elementList = $projectDescriptor->getIndexes()->get('elements');
        $prefixedLink = '~\\' . $fqsen;

        if (isset($elementList[$fqsen])) {
            return $elementList[$fqsen];
        } elseif (isset($elementList[$prefixedLink])) {
            return $elementList[$prefixedLink];
        }

        return false;
    }
1353713
private static Document getProjection(List<String> fieldNames) {
		Document projection = new Document();
		for ( String column : fieldNames ) {
			projection.put( column, 1 );
		}

		return projection;
	}
425750
function process( $tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace )
    {
        $params = $functionParameters;
        $loop = null;
        if ( isset( $params["loop"] ) )
        {
            $loop = $tpl->elementValue( $params["loop"], $rootNamespace, $currentNamespace, $functionPlacement );
        }
        if ( $loop !== null and !is_array( $loop ) )
        {
            $tpl->error( $functionName, "Can only loop arrays", $functionPlacement );
            return;
        }

        $name = "";
        if ( !isset( $params["name"] ) )
        {
            $tpl->missingParameter( $functionName, "name" );
            return;
        }
        $name = $tpl->elementValue( $params["name"], $rootNamespace, $currentNamespace, $functionPlacement );
        $seq_var =& $GLOBALS["eZTemplateSequence-$name"];
        if ( !is_array( $seq_var ) )
            $seq_var = array();
        if ( $loop !== null )
        {
            $seq_var["loop"] = $loop;
            $seq_var["iteration"] = 0;
            $seq_var["index"] = 0;
        }
        else
        {
            $index =& $seq_var["index"];
            $iteration =& $seq_var["iteration"];
            ++$iteration;
            ++$index;
            if ( $index >= count( $seq_var["loop"] ) )
                $index = 0 ;
        }
        $tpl->setVariable( "item", $seq_var["loop"][$seq_var["index"]], $tpl->mergeNamespace( $rootNamespace, $name ) );
        $tpl->setVariable( "iteration", $seq_var["iteration"], $tpl->mergeNamespace( $rootNamespace, $name ) );
    }
452551
public function merge(Projection $projection)
    {
        $mergeParts = $projection->parts;

        foreach ($this->parts as $thisKey => $thisPart) {
            foreach ($mergeParts as $foreignKey => $mergePart) {
                if ($thisPart->isOverlapping($mergePart)) {
                    if ($mergePart->getLength() < $thisPart->getLength()) {
                        unset($this->parts[$thisKey]);
                        continue 2;
                    }

                    unset($mergeParts[$foreignKey]);
                    continue;
                }
            }
        }

        $this->parts = array_merge($this->parts, $mergeParts);
    }
478619
protected function createOption($projections, $sort, $otherOptions = [])
    {
        $options = [];
        isset($projections) ? $options["projection"] = $this->castQuery($projections) : null;
        isset($sort) ? $options["sort"] = $this->castQuery($sort) : null;

        $options = array_merge($this->documentManager->getDefaultOptions(), $otherOptions, $options);
        return $options;
    }
1221832
public function filterWithIndex(callable $function): Seq
    {
        $result = new Seq();

        foreach ($this->data as $key => $value) {
            if (!!$function($key, $value)) {
                $result = $result->append($value);
            }
        }

        return $result;
    }
296249
public function mapElements($cssSelector, callable $function)
    {
        $elements = $this->getElementByCssSelector($cssSelector);
        $result = array();
        if (!empty($elements)) {
            $result = $this->map($elements, $function);
        }

        return $result;
    }
165412
public function withElement(ElementInterface ...$elements): CollectionElement
    {
        array_walk(
            $elements,
            function (ElementInterface $element) {
                $this->elements[$element->name()] = $element;
            }
        );

        return $this;
    }