Skip to content

Commit

Permalink
Revert "[8.x] Use parents to resolve middleware priority (#39647)" (#…
Browse files Browse the repository at this point in the history
…39706)

This reverts commit cfab148.
  • Loading branch information
driesvints committed Nov 20, 2021
1 parent f60e5ce commit fbdc972
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 63 deletions.
8 changes: 0 additions & 8 deletions src/Illuminate/Routing/SortedMiddleware.php
Expand Up @@ -101,14 +101,6 @@ protected function middlewareNames($middleware)
yield $interface;
}
}

$parents = @class_parents($stripped);

if ($parents !== false) {
foreach ($parents as $parent) {
yield $parent;
}
}
}

/**
Expand Down
55 changes: 0 additions & 55 deletions tests/Routing/RoutingSortedMiddlewareTest.php
Expand Up @@ -64,59 +64,4 @@ public function testItDoesNotMoveNonStringValues()
$this->assertEquals(['a', $closure, 'b', $closure2, 'foo'], (new SortedMiddleware(['a', 'b'], ['a', $closure, 'b', $closure2, 'foo']))->all());
$this->assertEquals([$closure, $closure2, 'foo', 'a'], (new SortedMiddleware(['a', 'b'], [$closure, $closure2, 'foo', 'a']))->all());
}

public function testItSortsUsingParentsAndContracts()
{
$priority = [
FirstContractStub::class,
SecondStub::class,
'Third',
];

$middleware = [
'Something',
'Something',
'Something',
'Something',
SecondChildStub::class,
'Otherthing',
FirstStub::class.':api',
'Third:foo',
FirstStub::class.':foo,bar',
'Third',
SecondChildStub::class,
];

$expected = [
'Something',
FirstStub::class.':api',
FirstStub::class.':foo,bar',
SecondChildStub::class,
'Otherthing',
'Third:foo',
'Third',
];

$this->assertEquals($expected, (new SortedMiddleware($priority, $middleware))->all());
}
}

interface FirstContractStub
{
//
}

class FirstStub implements FirstContractStub
{
//
}

class SecondStub
{
//
}

class SecondChildStub extends SecondStub
{
//
}

0 comments on commit fbdc972

Please sign in to comment.