Don't declare $params until it's neededd
This commit is contained in:
parent
4f5f2599f5
commit
49819b41bd
|
@ -70,9 +70,6 @@ class SegmentRouter implements RouterInterface
|
|||
// node is a reference to our current location in the node tree
|
||||
$node = $this->routes;
|
||||
|
||||
// params will hold any dynamic segments we find
|
||||
$params = [];
|
||||
|
||||
// if the URI is just a slash, we can return the handler for the root node
|
||||
if ($uri === '/') {
|
||||
return isset($node[$method])
|
||||
|
@ -80,6 +77,9 @@ class SegmentRouter implements RouterInterface
|
|||
: ['code' => 405, 'handler' => null, 'params' => null];
|
||||
}
|
||||
|
||||
// params will hold any dynamic segments we find
|
||||
$params = [];
|
||||
|
||||
// We'll split up the URI into segments and traverse the node tree
|
||||
foreach (explode('/', trim($uri, '/')) as $segment) {
|
||||
// if there is a node for this segment, move to it
|
||||
|
|
Loading…
Reference in New Issue
Block a user