src/Fixer/Phpdoc/PhpdocTypesOrderFixer.php
private function sortTypes(array $types)
    {
        foreach ($types as $index => $type) {
            $types[$index] = Preg::replaceCallback('/^([^<]+)<(?:([\w\|]+?)(,\s*))?(.*)>$/', function (array $matches) {
                return $matches[1].'<'.$this->sortJoinedTypes($matches[2]).$matches[3].$this->sortJoinedTypes($matches[4]).'>';
            }, $type);
        }

        if ('alpha' === $this->configuration['sort_algorithm']) {
            $types = Utils::stableSort(
                $types,
                static function ($type) { return $type; },
                static function ($typeA, $typeB) {
                    $regexp = '/^\\??\\\?/';

                    return strcasecmp(
                        Preg::replace($regexp, '', $typeA),
                        Preg::replace($regexp, '', $typeB)
                    );
                }
            );
        }

        if ('none' !== $this->configuration['null_adjustment']) {
            $nulls = [];
            foreach ($types as $index => $type) {
                if (Preg::match('/^\\\?null$/i', $type)) {
                    $nulls[$index] = $type;
                    unset($types[$index]);
                }
            }

            if (\count($nulls)) {
                if ('always_last' === $this->configuration['null_adjustment']) {
                    array_push($types, ...$nulls);
                } else {
                    array_unshift($types, ...$nulls);
                }
            }
        }

        return $types;
    }
private function sortTypes(array $types)
    {
        foreach ($types as $index => $type) {
            $types[$index] = Preg::replaceCallback('/^([^<]+)<(?:([\w\|]+?)(,\s*))?(.*)>$/', function (array $matches) {
                return $matches[1].'<'.$this->sortJoinedTypes($matches[2]).$matches[3].$this->sortJoinedTypes($matches[4]).'>';
            }, $type);
        }

        if ('alpha' === $this->configuration['sort_algorithm']) {
            $types = Utils::stableSort(
                $types,
                static function ($type) { return $type; },
                static function ($typeA, $typeB) {
                    $regexp = '/^\\??\\\?/';

                    return strcasecmp(
                        Preg::replace($regexp, '', $typeA),
                        Preg::replace($regexp, '', $typeB)
                    );
                }
            );
        }

        if ('none' !== $this->configuration['null_adjustment']) {
            $nulls = [];
            foreach ($types as $index => $type) {
                if (Preg::match('/^\\\?null$/i', $type)) {
                    $nulls[$index] = $type;
                    unset($types[$index]);
                }
            }

            if (\count($nulls)) {
                if ('always_last' === $this->configuration['null_adjustment']) {
                    array_push($types, ...$nulls);
                } else {
                    array_unshift($types, ...$nulls);
                }
            }
        }

        return $types;
    }
private function sortTypes ( array $ types ) { foreach ( $ types as $ index => $ type ) { $ types [ $ index ] = Preg :: replaceCallback ( '/^([^<]+)<(?:([\w\|]+?)(,\s*))?(.*)>$/' , function ( array $ matches ) { return $ matches [ 1 ] . '<' . $ this -> sortJoinedTypes ( $ matches [ 2 ] ) . $ matches [ 3 ] . $ this -> sortJoinedTypes ( $ matches [ 4 ] ) . '>' ; } , $ type ) ; } if ( 'alpha' === $ this -> configuration [ 'sort_algorithm' ] ) { $ types = Utils :: stableSort ( $ types , static function ( $ type ) { return $ type ; } , static function ( $ typeA , $ typeB ) { $ regexp = '/^\\??\\\?/' ; return strcasecmp ( Preg :: replace ( $ regexp , '' , $ typeA ) , Preg :: replace ( $ regexp , '' , $ typeB ) ) ; } ) ; } if ( 'none' !== $ this -> configuration [ 'null_adjustment' ] ) { $ nulls = [ ] ; foreach ( $ types as $ index => $ type ) { if ( Preg :: match ( '/^\\\?null$/i' , $ type ) ) { $ nulls [ $ index ] = $ type ; unset ( $ types [ $ index ] ) ; } } if ( \ count ( $ nulls ) ) { if ( 'always_last' === $ this -> configuration [ 'null_adjustment' ] ) { array_push ( $ types , ... $ nulls ) ; } else { array_unshift ( $ types , ... $ nulls ) ; } } } return $ types ; }
@param string[] $types

@return string[]
@param string [] $types