Typing and 404

master v0.2
sheychen 2017-09-10 20:14:22 +02:00
parent 0ca0c23cee
commit 9b5983a35f
2 changed files with 5 additions and 5 deletions

View File

@ -59,11 +59,11 @@ class App{
$this->router = new Router(isset($data['router']) ? $data['router'] : Path::get('config').'/Routes.php');
}
public function run($uri = null, array $filters = array()){
public function run(string $uri = null, array $filters = array()){
$route = $this->router->run(($uri ?: $_SERVER['REQUEST_URI']), $filters);
if(!isset($route))
$this->error(new HttpException(404, 'Not Found'));
$this->error(new HttpException(404));
try{
$route->call($this, $this->config['namespace'], $this->config['controller']);

View File

@ -31,7 +31,7 @@ class Router{
* @param callable|string $callable Function to run or 'Controller#function'
* @return Route
*/
public function add(string $path, $callable):Route{
public function add(string $path, $callable): Route{
$route = new Route($path, $callable);
$this->routes[] = $route;
return $route;
@ -44,7 +44,7 @@ class Router{
* @param array $filters
* @return Route|null
*/
public function run(string $url, array $filters):?Route{
public function run(string $url, array $filters){
foreach($this->routes as $route){
if($route->match($url, $filters))
return $route;
@ -58,7 +58,7 @@ class Router{
* @param string $name
* @return Route|null
*/
public function get(string $name):?Route{
public function get(string $name){
foreach($this->routes as $route){
if($route->matchName($name))
return $route;