You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While reviewing #85 I found a dubious section of code in RouteSubscriber::alterRoutes() and no comments are given on why this is needed:
// Replace the core register route controller.
$route = $collection->get('user.register');
if ($route instanceof Route) {
// ...
}
Why is it here assumed that RouteCollection::get() would return objects which are not Route objects? If this can happen, why would we ignore this silently?
I see from the definition of \Symfony\Component\Routing\RouteCollection::get() that it only returns Route or NULL:
/**
* Gets a route by name.
*
* @param string $name The route name
*
* @return Route|null A Route instance or null when not found
*/
public function get($name);
I'm not sure if something came up during testing that necessitated this if statement, but it seems more likely that this is just a mistake and the if statement can be simply removed. If is is necessary then we should have some clear documentation on why this can happen, and a test to prove that we handle the case correctly.
This entire class could use an overhaul by the way, there is almost no documentation, except for some comments that explain what the code is doing, but not why.
The text was updated successfully, but these errors were encountered:
While reviewing #85 I found a dubious section of code in
RouteSubscriber::alterRoutes()
and no comments are given on why this is needed:Why is it here assumed that
RouteCollection::get()
would return objects which are notRoute
objects? If this can happen, why would we ignore this silently?I see from the definition of
\Symfony\Component\Routing\RouteCollection::get()
that it only returnsRoute
orNULL
:I'm not sure if something came up during testing that necessitated this if statement, but it seems more likely that this is just a mistake and the
if
statement can be simply removed. If is is necessary then we should have some clear documentation on why this can happen, and a test to prove that we handle the case correctly.Ref. https://github.com/openeuropa/oe_authentication/blame/master/src/Routing/RouteSubscriber.php#L37
This entire class could use an overhaul by the way, there is almost no documentation, except for some comments that explain what the code is doing, but not why.
The text was updated successfully, but these errors were encountered: