Closed
Description
Q | A |
---|---|
Bug report? | yes |
Feature request? | no |
BC Break report? | no |
RFC? | no |
Symfony version | 4.0.0 |
I faced with the error that when you have routes with same paths, different methods and one of the routes has a condition. If the condition will fail during matching, UrlMatcher
will throw MethodNotAllowedException
with an incorrect set of allowed methods while it seems supposed to throw ResourceNotFoundException
on a failed condition.
This test can reproduce the issue:
/**
* @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
*/
public function testRequirementFailureIsNotOverridenWithMethodFailure()
{
$coll = new RouteCollection();
$coll->add('foo1', new Route('/foo', array(), array(), array(), '', array(), array('get')));
$coll->add('foo2', new Route('/foo', array(), array(), array(), '', array('https'), array('post')));
$matcher = new UrlMatcher($coll, new RequestContext('', 'POST'));
$matcher->match('/foo');
}
The solution for UrlMatcher
should not be a hard task but there is also the matcher produced by PhpMatcherDumper
which logic seems inverted towards UrlMatcher
's logic (i.e.: the condition is checked before the method).