From 42ec161d8a1f3da5dc26767e24d74677d8d898cd Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Mon, 4 Dec 2023 17:38:10 -0400 Subject: [PATCH] Added code format --- .editorconfig | 12 ++++++++++++ .gitignore | 1 + composer.json | 5 ++++- flight.sublime-project | 21 +++++++++++++++++++++ flight/Engine.php | 23 ++++++++++++++--------- flight/Flight.php | 7 ++++--- flight/net/Response.php | 3 ++- flight/util/ReturnTypeWillChange.php | 3 +++ phpstan.neon | 14 +++++++------- 9 files changed, 68 insertions(+), 21 deletions(-) create mode 100644 .editorconfig create mode 100644 flight.sublime-project create mode 100644 flight/util/ReturnTypeWillChange.php diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..e8d15f4 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +indent_size = 2 diff --git a/.gitignore b/.gitignore index a5ec20f..c92307c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ vendor/ composer.phar composer.lock +*.sublime-workspace diff --git a/composer.json b/composer.json index 325ba7f..2becdbc 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,10 @@ "ext-json": "*" }, "autoload": { - "files": [ "flight/autoload.php", "flight/Flight.php" ] + "files": [ + "flight/autoload.php", + "flight/Flight.php" + ] }, "require-dev": { "phpunit/phpunit": "^9.5", diff --git a/flight.sublime-project b/flight.sublime-project new file mode 100644 index 0000000..26552b2 --- /dev/null +++ b/flight.sublime-project @@ -0,0 +1,21 @@ +{ + "folders": [ + { + "path": ".", + } + ], + "settings": { + "LSP": { + "LSP-intelephense": { + "settings": { + "intelephense.environment.phpVersion": "7.4.0", + "intelephense.format.braces": "psr12", + }, + }, + "formatters": + { + "embedding.php": "LSP-intelephense" + }, + }, + }, +} diff --git a/flight/Engine.php b/flight/Engine.php index 3406081..66442fc 100644 --- a/flight/Engine.php +++ b/flight/Engine.php @@ -397,9 +397,10 @@ class Engine */ public function _error($e): void { - $msg = sprintf('

500 Internal Server Error

' . - '

%s (%s)

' . - '
%s
', + $msg = sprintf( + '

500 Internal Server Error

' . + '

%s (%s)

' . + '
%s
', $e->getMessage(), $e->getCode(), $e->getTraceAsString() @@ -524,8 +525,8 @@ class Engine ->status(404) ->write( '

404 Not Found

' . - '

The page you have requested could not be found.

' . - str_repeat(' ', 512) + '

The page you have requested could not be found.

' . + str_repeat(' ', 512) ) ->send(); } @@ -644,8 +645,10 @@ class Engine $this->response()->header('ETag', $id); - if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && - $_SERVER['HTTP_IF_NONE_MATCH'] === $id) { + if ( + isset($_SERVER['HTTP_IF_NONE_MATCH']) && + $_SERVER['HTTP_IF_NONE_MATCH'] === $id + ) { $this->halt(304); } } @@ -659,8 +662,10 @@ class Engine { $this->response()->header('Last-Modified', gmdate('D, d M Y H:i:s \G\M\T', $time)); - if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && - strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) === $time) { + if ( + isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && + strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) === $time + ) { $this->halt(304); } } diff --git a/flight/Flight.php b/flight/Flight.php index 2bca787..e6cdcac 100644 --- a/flight/Flight.php +++ b/flight/Flight.php @@ -23,7 +23,7 @@ use flight\template\View; * @method static void stop() Stops the framework and sends a response. * @method static void halt(int $code = 200, string $message = '') Stop the framework with an optional status code and message. * - * @method static void route(string $pattern, callable $callback) Maps a URL pattern to a callback. + * @method static void route(string $pattern, callable $callback, bool $pass_route = false) Maps a URL pattern to a callback. * @method static Router router() Returns Router instance. * * @method static void map(string $name, callable $callback) Creates a custom framework method. @@ -80,8 +80,9 @@ class Flight * @param ?Closure(T $instance): void $callback Perform actions with the instance * @return void */ - static function register($name, $class, $params = array(), $callback = null) { - static::__callStatic('register', func_get_args()); + static function register($name, $class, $params = array(), $callback = null) + { + static::__callStatic('register', func_get_args()); } /** diff --git a/flight/net/Response.php b/flight/net/Response.php index 5873ec7..6b69c67 100644 --- a/flight/net/Response.php +++ b/flight/net/Response.php @@ -251,7 +251,8 @@ class Response '%s %d %s', $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.1', $this->status, - self::$codes[$this->status]), + self::$codes[$this->status] + ), true, $this->status ); diff --git a/flight/util/ReturnTypeWillChange.php b/flight/util/ReturnTypeWillChange.php new file mode 100644 index 0000000..3ed841b --- /dev/null +++ b/flight/util/ReturnTypeWillChange.php @@ -0,0 +1,3 @@ +