From b1011df59d64f71ec61ec5bfed8bf0093511a710 Mon Sep 17 00:00:00 2001 From: Joanhey Date: Tue, 8 Aug 2023 14:10:17 +0200 Subject: [PATCH 1/4] Use non full qualified name in http classes --- src/App.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/App.php b/src/App.php index ecceb69..2a24a9d 100755 --- a/src/App.php +++ b/src/App.php @@ -114,15 +114,15 @@ public function loadViewEngines() private function setupDefaultContainer() { $this->container->singleton('request', function () { - return new \Leaf\Http\Request(); + return new Http\Request(); }); $this->container->singleton('response', function () { - return new \Leaf\Http\Response(); + return new Http\Response(); }); $this->container->singleton('headers', function () { - return new \Leaf\Http\Headers(); + return new Http\Headers(); }); Config::set('mode', _env('APP_ENV', $this->config('mode'))); From dc80a8d67f02ec312c6586903f37bc546730419f Mon Sep 17 00:00:00 2001 From: Joanhey Date: Tue, 8 Aug 2023 14:11:39 +0200 Subject: [PATCH 2/4] Accesors add typed return For better intelissence --- src/App.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/App.php b/src/App.php index 2a24a9d..52f80d7 100755 --- a/src/App.php +++ b/src/App.php @@ -271,27 +271,24 @@ public function logger() /** * Get the Request Headers - * @return \Leaf\Http\Headers */ - public function headers() + public function headers(): Http\Headers { return $this->headers; } /** * Get the Request object - * @return \Leaf\Http\Request */ - public function request() + public function request(): Http\Request { return $this->request; } /** * Get the Response object - * @return \Leaf\Http\Response */ - public function response() + public function response(): Http\Response { return $this->response; } From 319533ed0dd4d0acc127388481e68ee290dec628 Mon Sep 17 00:00:00 2001 From: Joanhey Date: Tue, 8 Aug 2023 14:13:34 +0200 Subject: [PATCH 3/4] Type hint the properties in App --- src/App.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/App.php b/src/App.php index 52f80d7..86677dc 100755 --- a/src/App.php +++ b/src/App.php @@ -19,14 +19,13 @@ class App extends Router { /** * Leaf container instance - * @var \Leaf\Helpers\Container */ - protected $container; + protected Helpers\Container $container; /** * Callable to be invoked on application error */ - protected $errorHandler; + protected Exception\Run $errorHandler; /******************************************************************************** * Instantiation and Configuration From 90d0274d321af33aacbf6af002678038a2175139 Mon Sep 17 00:00:00 2001 From: Joanhey Date: Tue, 8 Aug 2023 14:15:35 +0200 Subject: [PATCH 4/4] More namespace unify --- src/App.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/App.php b/src/App.php index 86677dc..f88c9b3 100755 --- a/src/App.php +++ b/src/App.php @@ -38,12 +38,12 @@ class App extends Router public function __construct(array $userSettings = []) { $this->setupErrorHandler(); - $this->container = new \Leaf\Helpers\Container(); + $this->container = new Helpers\Container(); $this->loadConfig($userSettings); if (!empty($this->config('scripts'))) { foreach ($this->config('scripts') as $script) { - call_user_func($script, $this, \Leaf\Config::get()); + call_user_func($script, $this, Config::get()); } $this->loadConfig(); @@ -62,7 +62,7 @@ protected function loadConfig(array $userSettings = []) protected function setupErrorHandler() { - $this->errorHandler = (new \Leaf\Exception\Run()); + $this->errorHandler = (new Exception\Run()); $this->errorHandler->register(); } @@ -73,11 +73,11 @@ protected function setupErrorHandler() public function setErrorHandler($handler) { if (Anchor::toBool($this->config('debug')) === false) { - if ($this->errorHandler instanceof \Leaf\Exception\Run) { + if ($this->errorHandler instanceof Exception\Run) { $this->errorHandler->unregister(); } - $this->errorHandler = new \Leaf\Exception\Run(); + $this->errorHandler = new Exception\Run(); $this ->errorHandler ->pushHandler($handler) @@ -185,7 +185,7 @@ public function config($name, $value = null) */ public function attach(callable $code) { - call_user_func($code, $this, \Leaf\Config::get()); + call_user_func($code, $this, Config::get()); $this->loadConfig(); $this->setupErrorHandler(); }