Skip to content

Commit c133a7f

Browse files
ruudkostrolucky
authored andcommitted
Sort middleware without maintaining index association
While debugging an issue with a custom DBAL Driver with Xdebug, I noticed that the order of the middleware was not with what I was expecting. It turns out this was an issue with Xdebug, because I had the option "Sort Variables Alphabetically" enabled. But it lead me to discover this. The MiddlewarePass sorts the middleware based on priority. And it works as expected. But it sorts it while maintaining index association. There is no point in keeping that. It only confuses others.
1 parent 33bec0e commit c133a7f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/DependencyInjection/Compiler/MiddlewaresPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use function array_values;
1515
use function is_subclass_of;
1616
use function sprintf;
17-
use function uasort;
17+
use function usort;
1818

1919
final class MiddlewaresPass implements CompilerPassInterface
2020
{
@@ -77,7 +77,7 @@ public function process(ContainerBuilder $container): void
7777
array_keys($middlewareRefs),
7878
array_values($middlewareRefs),
7979
);
80-
uasort($middlewareRefs, static fn (array $a, array $b): int => $b[0] <=> $a[0] ?: $a[1] <=> $b[1]);
80+
usort($middlewareRefs, static fn (array $a, array $b): int => $b[0] <=> $a[0] ?: $a[1] <=> $b[1]);
8181
$middlewareRefs = array_map(static fn (array $value): Reference => $value[2], $middlewareRefs);
8282

8383
$container

0 commit comments

Comments
 (0)