forked from PHP/Router
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 is a reference to our current location in the node tree
|
||||||
$node = $this->routes;
|
$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 the URI is just a slash, we can return the handler for the root node
|
||||||
if ($uri === '/') {
|
if ($uri === '/') {
|
||||||
return isset($node[$method])
|
return isset($node[$method])
|
||||||
|
@ -80,6 +77,9 @@ class SegmentRouter implements RouterInterface
|
||||||
: ['code' => 405, 'handler' => null, 'params' => null];
|
: ['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
|
// We'll split up the URI into segments and traverse the node tree
|
||||||
foreach (explode('/', trim($uri, '/')) as $segment) {
|
foreach (explode('/', trim($uri, '/')) as $segment) {
|
||||||
// if there is a node for this segment, move to it
|
// if there is a node for this segment, move to it
|
||||||
|
|
Loading…
Reference in New Issue
Block a user