Fixed deprecated notice when using class type hinting (issue: #538)

This commit is contained in:
Simon Sessingø
2021-04-28 09:57:47 +02:00
parent 718d60c53b
commit c66d7f7df7
4 changed files with 15 additions and 9 deletions
+8 -1
View File
@@ -76,6 +76,11 @@ abstract class Route implements IRoute
if (is_callable($callback) === true) {
$router->debug('Executing callback');
/* Load class from type hinting */
if (is_array($callback) === true && isset($callback[0], $callback[1]) === true) {
$callback[0] = $router->getClassLoader()->loadClass($callback[0]);
}
/* When the callback is a function */
return $router->getClassLoader()->loadClosure($callback, $parameters);
}
@@ -160,7 +165,7 @@ abstract class Route implements IRoute
foreach ((array)$parameters[1] as $name) {
// Ignore parent parameters
if(isset($groupParameters[$name]) === true) {
if (isset($groupParameters[$name]) === true) {
$lastParams[$name] = $matches[$name];
continue;
}
@@ -244,6 +249,7 @@ abstract class Route implements IRoute
$this->group = $group;
/* Add/merge parent settings with child */
return $this->setSettings($group->toArray(), true);
}
@@ -576,6 +582,7 @@ abstract class Route implements IRoute
public function setFilterEmptyParams(bool $enabled): IRoute
{
$this->filterEmptyParams = $enabled;
return $this;
}