From fda7c71a501f5594ea20842ca3de281cd36f7d7c Mon Sep 17 00:00:00 2001 From: flashwave Date: Mon, 12 Sep 2016 13:13:05 +0200 Subject: [PATCH] fixes? --- app/ExceptionHandler.php | 14 +++----------- app/Router/Route.php | 6 +++--- sakura.php | 2 -- utility.php | 9 +++++++-- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/app/ExceptionHandler.php b/app/ExceptionHandler.php index 5148f80..39bdd1c 100644 --- a/app/ExceptionHandler.php +++ b/app/ExceptionHandler.php @@ -29,11 +29,7 @@ class ExceptionHandler */ public static function exception(Throwable $ex) { - try { - $report = config('dev.report_host'); - } catch (Exception $ex) { - $report = null; - } + $report = config('dev.report_host'); if ($report !== null) { self::report($ex, $report); @@ -63,13 +59,9 @@ class ExceptionHandler { http_response_code(500); - try { - $debug = config('dev.show_errors'); - } catch (Exception $ex) { - $debug = false; - } + $debug = config('dev.show_errors'); - if ($debug) { + if (true) { header('Content-Type: text/plain'); echo $ex; } else { diff --git a/app/Router/Route.php b/app/Router/Route.php index 16b94b3..a1273d3 100644 --- a/app/Router/Route.php +++ b/app/Router/Route.php @@ -170,10 +170,10 @@ class Route * @throws RouterNonExistentControllerException * @return mixed */ - public function fire() + public function fire($params = []) { if (is_callable($this->action)) { - return call_user_func($this->action); + return call_user_func_array($this->action, $params); } if (!class_exists($this->controller) @@ -181,6 +181,6 @@ class Route throw new RouterNonExistentControllerException; } - return (new $this->controller)->{$this->action}(); + return (new $this->controller)->{$this->action}(...$params); } } diff --git a/sakura.php b/sakura.php index f520003..0c18821 100644 --- a/sakura.php +++ b/sakura.php @@ -50,8 +50,6 @@ $capsule = new DB; $capsule->addConnection(config('database')); $capsule->setAsGlobal(); -class_alias(Router\Collection::class, 'Router'); - if (!defined('IN_CLI')) { // Start output buffering ob_start(config('performance.compression') ? 'ob_gzhandler' : null); diff --git a/utility.php b/utility.php index 69d56da..0a2a2ac 100644 --- a/utility.php +++ b/utility.php @@ -4,6 +4,7 @@ */ use Sakura\Config; +use Sakura\Exceptions\ConfigValueNotFoundException; use Sakura\Net; use Sakura\Routerv1; use Sakura\Template; @@ -17,8 +18,12 @@ function config($value) try { return Config::get($section, $key); - } catch (Exception $e) { - return Config::get($value); + } catch (ConfigValueNotFoundException $e) { + try { + return Config::get($value); + } catch (ConfigValueNotFoundException $e) { + return null; + } } }