@param Sort|null $sortAnnotation

@return array
493996
protected function extractSortInfo($sortAnnotation)
    {
        $sortInfo = ['direction' => null, 'column' => null];
        if ($sortAnnotation) {
            $direction = $sortAnnotation->direction;
            $sortInfo['direction'] = $direction;
            $column = $sortAnnotation->column;
            $sortInfo['column'] = $column;
        }

        return $sortInfo;
    }
460701
public static function fetchAnnotationsFromDocblock($annotation, $docblock)
    {
        if (preg_match_all(sprintf(self::$regex, $annotation), $docblock, $matched)) {
            return $matched[1];
        }
        return [];
    }
1110117
public function aSort($sort = null)
    {
        if ($sort !== null && ! is_int($sort)) {
            throw new \InvalidArgumentException(
                'Invalid sort type. Sort type must ne integer.',
                E_USER_ERROR
            );
        }

        return $sort === null
            ? asort($this->storedData)
            : asort($this->storedData, $sort);
    }
368565
public static function parseDays(string $annotation)
	{
		static $validValues = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun',];

		$days = NULL;
		$annotation = Strings::trim($annotation);
		if (Strings::length($annotation)) {
			$days = static::translateToDayNames($annotation);
			$days = static::expandDaysRange($days);
			foreach ($days as $day) {
				if (!in_array($day, $validValues)) {
					throw new InvalidParameterException(
						"Given day parameter '" . $day . "' must be one from " . implode(', ', $validValues) . "."
					);
				}
			}
			$days = array_values(array_intersect($validValues, $days));
		}

		return $days ?: NULL;
	}
624013
public function find($key, $filter = null) {
		if (!$this->has($key)) {
			return [];
		}
		
		$annotations = [];
		
		foreach ($this->names[$key] as $index) {
			if (!is_int($filter)) {
				$annotations[] = $this->annotations[$index];
				continue;
			}
			
			$annotation = $this->annotations[$index];
			$flags = 0;
			
			//match value type
			if ($filter & Filter::TYPE_ALL) {
				$value = $annotation->getValue();
				if (is_null($value)) {
					$flags |= Filter::TYPE_NULL;
				}
				elseif (is_string($value)) {
					$flags |= Filter::TYPE_STRING;
				}
				elseif (is_int($value)) {
					$flags |= Filter::TYPE_INTEGER;
				}
				elseif (is_float($value)) {
					$flags |= Filter::TYPE_FLOAT;
				}
				elseif (is_bool($value)) {
					$flags |= Filter::TYPE_BOOLEAN;
				}
				elseif (is_array($value)) {
					$flags |= Filter::TYPE_ARRAY;
				}
				elseif (id_object($value)) {
					$flags |= Filter::TYPE_OBJECT;
				}
			}
			
			//match argument filter
			if ($filter & Filter::HAS_ARGUMENT || $filter & Filter::NOT_HAS_ARGUMENT) {
				if ($annotation->getArgument()) {
					$flags |= Filter::HAS_ARGUMENT;
				}
				else {
					$flags |= Filter::NOT_HAS_ARGUMENT;
				}
			}
			
			//add annotation if it meets all requirements
			if (($flags & $filter) == $flags) {
				$annotations[] = $annotation;
			}
		}
		
		return $annotations;
	}
444611
private function filterAnnotations(array $annotations): array
    {
        $annotations = \array_filter($annotations, function ($annotation) {
            $ref = new \ReflectionObject($annotation);

            return 0 === \mb_strpos($ref->getNamespaceName(), 'TSantos\Serializer');
        });

        return $annotations;
    }
246875
protected function getRouteConfig(Route $annotation)
    {
        return [
            $annotation->getName() => [
                'type' => $annotation->getType(),
                'options' => [
                    'route' => $annotation->getRoute(),
                    'defaults' => $annotation->getDefaults(),
                    'constraints' => $annotation->getConstraints()
                ],
                'priority' => (int) $annotation->getPriority(),
                'may_terminate' => (bool) $annotation->getMayTerminate(),
                'child_routes' => []
            ]
        ];
    }
1070501
public function sort($sortBy = self::SORT_BY_KEYS_ASC, $sortFlags = SORT_REGULAR)
    {
        /** @noinspection SpellCheckingInspection */
        $sortFunctions = [
            self::SORT_BY_KEYS_ASC    => 'ksort',
            self::SORT_BY_KEYS_DESC   => 'krsort',
            self::SORT_BY_VALUES_ASC  => 'asort',
            self::SORT_BY_VALUES_DESC => 'arsort',
        ];

        if (!isset($sortFunctions[$sortBy])) {
            throw new InvalidArgumentException("SortBy {$sortBy} not supported");
        }

        $function = $sortFunctions[$sortBy];
        $function($this->data, $sortFlags);

        return $this;
    }
1031348
private function getParamsFromAnnotationArray(array $annotations)
    {
        $params = array();
        foreach ($annotations as $annotation) {
            if ($annotation instanceof ParamInterface) {
                $params[$annotation->getName()] = $annotation;
            }
        }

        return $params;
    }
1262226
protected static function convertSort($sort)
  {
    /** @var RSort $convertedSort */
    $convertedSort = null;
    if (!empty($sort)) {
      $convertedSort = new RSort();
      $convertedSort->setField($sort->getField());
      switch ($sort->getOrder()) {
        case MSort\Order::Ascending:
          $convertedSort->setOrder(RSort\Order::Ascending);
          break;
        case MSort\Order::Descending:
          $convertedSort->setOrder(RSort\Order::Descending);
          break;
      }
    }
    return $convertedSort;
  }
470456
public function kSort($sort = null)
    {
        if ($sort !== null && ! is_int($sort)) {
            throw new \InvalidArgumentException(
                'Invalid sort type. Sort type must ne integer.',
                E_USER_ERROR
            );
        }

        return ksort($this->storedData, $sort);
    }
739243
public function getOrdered($collection, $sort = null)
    {
        if (!$sort) {
            return $collection;
        }

        $unordered = [];
        foreach ($collection as $content) {
            $unordered[$content->getId()] = $content;
        }

        $ordered = [];
        foreach ($sort as $id) {
            if (isset($unordered[$id])) {
                $ordered[] = $unordered[$id];
            }
        }

        return $ordered;
    }
424885
public function getResults($sort = null)
    {
        $results = $this->results;

        if ($sort) {
            (strtolower($sort) == static::SORT_DESC) ? arsort($results) : asort($results);
        }

        return $results;
    }
189503
protected function filterContractAnnotation(array $annotations): array
    {
        $contractAnnotations = [];

        foreach ($annotations as $annotation) {
            $annotationClass = \get_class($annotation);

            if (\in_array($annotationClass, $this->expectedAnnotationTypes, true)) {
                $contractAnnotations[] = $annotation;
            }
        }

        return $contractAnnotations;
    }
27287
public function fetchAll($sort = null)
    {
        $select = $this->getSelect();
        $select = $this->setSortOrder($select, $sort);

        $resultSet = $this->fetchResult($select);

        return $resultSet;
    }
441116
public function sort(Sorting $sorting)
	{
		if (is_callable($sorting->getSortCallback())) {
			call_user_func(
				$sorting->getSortCallback(),
				$this->data_source,
				$sorting->getSort()
			);

			return $this;
		}

		$sort = $sorting->getSort();

		if (!empty($sort)) {
			$this->data_source->removeClause('ORDER BY');
			$this->data_source->orderBy($sort);
		} else {
			/**
			 * Has the statement already a order by clause?
			 */
			$this->data_source->clause('ORDER BY');

			if ($this->data_source instanceof Dibi\Fluent) {
				$reflection = new \ReflectionClass('Dibi\Fluent');
			} else {
				$reflection = new \ReflectionClass('DibiFluent');
			}

			$cursor_property = $reflection->getProperty('cursor');
			$cursor_property->setAccessible(true);
			$cursor = $cursor_property->getValue($this->data_source);

			if (!$cursor) {
				$this->data_source->orderBy($this->primary_key);
			}
		}

		return $this;
	}
1243428
public function sort($sort = null)
    {
        deprecationWarning(
            'BelongToMany::sort() is deprecated. ' .
            'Use setSort()/getSort() instead.'
        );
        if ($sort !== null) {
            $this->setSort($sort);
        }

        return $this->getSort();
    }