99use Bow \Container \Action ;
1010use Bow \Configuration \Loader ;
1111use Bow \Contracts \ResponseInterface ;
12+ use Bow \Http \Exception \BadRequestException ;
1213use Bow \Http \Exception \HttpException ;
1314use Bow \Http \Request ;
1415use Bow \Http \Response ;
1516use Bow \Router \Exception \RouterException ;
1617use Bow \Router \Resource ;
1718use Bow \Router \Router ;
1819use Bow \Router \Route ;
20+ use ReflectionException ;
1921
2022class Application extends Router
2123{
@@ -24,21 +26,21 @@ class Application extends Router
2426 *
2527 * @var Capsule
2628 */
27- private $ capsule ;
29+ private Capsule $ capsule ;
2830
2931 /**
3032 * The booting flag
3133 *
3234 * @var bool
3335 */
34- private $ booted = false ;
36+ private bool $ booted = false ;
3537
3638 /**
3739 * The Application instance
3840 *
3941 * @var Application
4042 */
41- private static $ instance ;
43+ private static Application $ instance ;
4244
4345 /**
4446 * The HTTP Request
@@ -62,7 +64,7 @@ class Application extends Router
6264 private Loader $ config ;
6365
6466 /**
65- * This define if the X-powered-By header must be put in response
67+ * This defines if the X-powered-By header must be put in response
6668 *
6769 * @var bool
6870 */
@@ -74,6 +76,7 @@ class Application extends Router
7476 * @param Request $request
7577 * @param Response $response
7678 * @return void
79+ * @throws BadRequestException
7780 */
7881 public function __construct (Request $ request , Response $ response )
7982 {
@@ -87,6 +90,7 @@ public function __construct(Request $request, Response $response)
8790 $ this ->capsule ->instance ('app ' , $ this );
8891
8992 $ this ->request ->capture ();
93+
9094 parent ::__construct ($ request ->method (), $ request ->get ('_method ' ));
9195 }
9296
@@ -114,7 +118,7 @@ public function bind(Loader $config): void
114118 $ this ->setBaseRoute ($ config ['app ' ]['root ' ]);
115119 }
116120
117- // We active the auto csrf switcher
121+ // We activate the auto csrf switcher
118122 $ this ->setAutoCsrf ($ config ['app ' ]['auto_csrf ' ] ?? false );
119123
120124 $ this ->capsule ->instance ('config ' , $ config );
@@ -144,6 +148,7 @@ private function boot(): void
144148 * @param Request $request
145149 * @param Response $response
146150 * @return Application
151+ * @throws BadRequestException
147152 */
148153 public static function make (Request $ request , Response $ response ): Application
149154 {
@@ -155,7 +160,7 @@ public static function make(Request $request, Response $response): Application
155160 }
156161
157162 /**
158- * Check if is running on php cli
163+ * Check if it is running on php cli
159164 *
160165 * @return bool
161166 */
@@ -168,7 +173,7 @@ public function isRunningOnCli(): bool
168173 * Launcher of the application
169174 *
170175 * @return ?bool
171- * @throws RouterException
176+ * @throws RouterException|ReflectionException
172177 */
173178 public function send (): ?bool
174179 {
@@ -244,7 +249,7 @@ public function send(): ?bool
244249 *
245250 * @param mixed $response
246251 * @param int $code
247- * @return null
252+ * @return void
248253 */
249254 private function sendResponse (mixed $ response , int $ code = 200 ): void
250255 {
@@ -267,7 +272,7 @@ public function disablePoweredByMention(): void
267272 }
268273
269274 /**
270- * Make the REST API base on route and ressource controller.
275+ * Make the REST API base on route and resource controller.
271276 *
272277 * @param string $url
273278 * @param string|array $controller_name
@@ -305,7 +310,7 @@ public function rest(string $url, string|array $controller_name, array $where =
305310 }
306311 }
307312
308- if (is_null ( $ controller ) || !is_string ($ controller )) {
313+ if (!is_string ($ controller )) {
309314 throw new ApplicationException (
310315 "[REST] No defined controller! " ,
311316 E_ERROR
@@ -346,7 +351,7 @@ public function abort(int $code = 500, string $message = '', array $headers = []
346351 }
347352
348353 /**
349- * Build dependance
354+ * Build dependence
350355 *
351356 * @param ?string $name
352357 * @param ?callable $callable
@@ -378,7 +383,7 @@ public function container(?string $name = null, ?callable $callable = null): mix
378383 * This point method on the container system
379384 *
380385 * @param array $params
381- * @return Capsule
386+ * @return mixed
382387 * @throws ApplicationException
383388 */
384389 public function __invoke (...$ params ): mixed
0 commit comments