public static function sortAdvices(array $advices): array
    {
        $sortedAdvices = $advices;
        uasort($sortedAdvices, function (Advice $first, Advice $second) {
            switch (true) {
                case $first instanceof AdviceBefore && !($second instanceof AdviceBefore):
                    return -1;

                case $first instanceof AdviceAround && !($second instanceof AdviceAround):
                    return 1;

                case $first instanceof AdviceAfter && !($second instanceof AdviceAfter):
                    return $second instanceof AdviceBefore ? 1 : -1;

                case ($first instanceof OrderedAdvice && $second instanceof OrderedAdvice):
                    return $first->getAdviceOrder() - $second->getAdviceOrder();

                default:
                    return 0;
            }
        });

        return $sortedAdvices;
    }
public static function sortAdvices(array $advices): array
    {
        $sortedAdvices = $advices;
        uasort($sortedAdvices, function (Advice $first, Advice $second) {
            switch (true) {
                case $first instanceof AdviceBefore && !($second instanceof AdviceBefore):
                    return -1;

                case $first instanceof AdviceAround && !($second instanceof AdviceAround):
                    return 1;

                case $first instanceof AdviceAfter && !($second instanceof AdviceAfter):
                    return $second instanceof AdviceBefore ? 1 : -1;

                case ($first instanceof OrderedAdvice && $second instanceof OrderedAdvice):
                    return $first->getAdviceOrder() - $second->getAdviceOrder();

                default:
                    return 0;
            }
        });

        return $sortedAdvices;
    }
public static function sortAdvices ( array $ advices ) : array { $ sortedAdvices = $ advices ; uasort ( $ sortedAdvices , function ( Advice $ first , Advice $ second ) { switch ( true ) { case $ first instanceof AdviceBefore && ! ( $ second instanceof AdviceBefore ) : return - 1 ; case $ first instanceof AdviceAround && ! ( $ second instanceof AdviceAround ) : return 1 ; case $ first instanceof AdviceAfter && ! ( $ second instanceof AdviceAfter ) : return $ second instanceof AdviceBefore ? 1 : - 1 ; case ( $ first instanceof OrderedAdvice && $ second instanceof OrderedAdvice ) : return $ first -> getAdviceOrder ( ) - $ second -> getAdviceOrder ( ) ; default : return 0 ; } } ) ; return $ sortedAdvices ; }
Sorts advices by priority

@param array|Advice[] $advices
@return array|Advice[] Sorted list of advices
Sorts advices by priority