Repository: symfony/symfony
File: src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php (PHP)

Code before:
        $maxPriority = [];
        foreach ($services as $service => $tags) {
            $maxPriority[$service] = \PHP_INT_MIN;
            foreach ($tags as $tag) {
                $currentPriority = $tag['priority'] ?? 0;
                if ($maxPriority[$service] < $currentPriority) {
                    $maxPriority[$service] = $currentPriority;
                }
            }
        }
        uasort($maxPriority, static fn ($a, $b) => $b <=> $a);

        return array_keys($maxPriority);
    }

    protected function sortTagsByPriority(array $tags): array
    {
        $sortedTags = [];
        foreach ($tags as $tagName => $tag) {
            $sortedTags[$tagName] = $this->sortByPriority($tag);
        }

        return $sortedTags;
    }

    protected function resolveServiceTags(ContainerBuilder $container, Definition $definition, ?string $tagName = null): array
    {
        $tags = null !== $tagName ? $definition->getTag($tagName) : $definition->getTags();

        $priority = ($container->getReflectionClass($definition->getClass())?->getAttributes(AsTaggedItem::class)[0] ?? null)?->newInstance()->priority;
        if (!$priority) {
            return $tags;
        }

        if (null !== $tagName) {
            foreach ($tags as &$tag) {
                $tag['priority'] ??= $priority;
            }
        } else {
            foreach ($tags as &$tagConfigs) {
                foreach ($tagConfigs as &$tag) {
                    $tag['priority'] ??= $priority;
                }
            }
        }

        return $tags;
    }

    protected function sortByPriority(array $tag): array
    {

Review comment (suggestion):
```suggestion
    protected function resolvePriorityServiceTags(ContainerBuilder $container, Definition $definition, ?string $tagName = null): array
```

Code after:
        $maxPriority = [];
        foreach ($services as $service => $tags) {
            $maxPriority[$service] = \PHP_INT_MIN;
            foreach ($tags as $tag) {
                $currentPriority = $tag['priority'] ?? 0;
                if ($maxPriority[$service] < $currentPriority) {
                    $maxPriority[$service] = $currentPriority;
                }
            }
        }
        uasort($maxPriority, static fn ($a, $b) => $b <=> $a);

        return array_keys($maxPriority);
    }

    protected function sortTagsByPriority(array $tags): array
    {
        $sortedTags = [];
        foreach ($tags as $tagName => $tag) {
            $sortedTags[$tagName] = $this->sortByPriority($tag);
        }

        return $sortedTags;
    }

    protected function resolvePriorityServiceTags(ContainerBuilder $container, Definition $definition, ?string $tagName = null): array
    {
        $tags = null !== $tagName ? $definition->getTag($tagName) : $definition->getTags();

        $priority = ($container->getReflectionClass($definition->getClass())?->getAttributes(AsTaggedItem::class)[0] ?? null)?->newInstance()->priority;
        if (!$priority) {
            return $tags;
        }

        if (null !== $tagName) {
            foreach ($tags as &$tag) {
                $tag['priority'] ??= $priority;
            }
        } else {
            foreach ($tags as &$tagConfigs) {
                foreach ($tagConfigs as &$tag) {
                    $tag['priority'] ??= $priority;
                }
            }
        }

        return $tags;
    }

    protected function sortByPriority(array $tag): array
    {