From d044f828d00f56159f59d71ac67b6cb8485a03b4 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Fri, 16 Feb 2024 23:14:47 +0800 Subject: [PATCH] style: also align `@phpstan-type` and `@phpstan-var` --- .php-cs-fixer.dist.php | 2 ++ .php-cs-fixer.no-header.php | 23 +++++++++++++++++++++++ .php-cs-fixer.user-guide.php | 23 +++++++++++++++++++++++ app/Config/View.php | 4 ++-- system/BaseModel.php | 12 ++++++------ system/Config/View.php | 8 ++++---- system/Database/BaseConnection.php | 4 ++-- system/Database/BasePreparedQuery.php | 4 ++-- system/Database/BaseResult.php | 4 ++-- system/View/Parser.php | 2 +- 10 files changed, 67 insertions(+), 19 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 3352a832686e..ab5069bcad13 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -63,6 +63,8 @@ 'phpstan-param', 'phpstan-property', 'phpstan-return', + 'phpstan-type', + 'phpstan-var', 'property', 'property-read', 'property-write', diff --git a/.php-cs-fixer.no-header.php b/.php-cs-fixer.no-header.php index 15957b5e5d00..2f5b471f5b74 100644 --- a/.php-cs-fixer.no-header.php +++ b/.php-cs-fixer.no-header.php @@ -31,6 +31,29 @@ $overrides = [ 'phpdoc_array_type' => true, + 'phpdoc_align' => [ + 'align' => 'vertical', + 'spacing' => 1, + 'tags' => [ + 'method', + 'param', + 'phpstan-assert', + 'phpstan-assert-if-true', + 'phpstan-assert-if-false', + 'phpstan-param', + 'phpstan-property', + 'phpstan-return', + 'phpstan-type', + 'phpstan-var', + 'property', + 'property-read', + 'property-write', + 'return', + 'throws', + 'type', + 'var', + ], + ], ]; $options = [ diff --git a/.php-cs-fixer.user-guide.php b/.php-cs-fixer.user-guide.php index c61866e98c91..b46bd6112b8b 100644 --- a/.php-cs-fixer.user-guide.php +++ b/.php-cs-fixer.user-guide.php @@ -40,6 +40,29 @@ 'leading_backslash_in_global_namespace' => true, ], 'phpdoc_array_type' => true, + 'phpdoc_align' => [ + 'align' => 'vertical', + 'spacing' => 1, + 'tags' => [ + 'method', + 'param', + 'phpstan-assert', + 'phpstan-assert-if-true', + 'phpstan-assert-if-false', + 'phpstan-param', + 'phpstan-property', + 'phpstan-return', + 'phpstan-type', + 'phpstan-var', + 'property', + 'property-read', + 'property-write', + 'return', + 'throws', + 'type', + 'var', + ], + ], ]; $options = [ diff --git a/app/Config/View.php b/app/Config/View.php index 98f8e0f602b1..5a0e2ce6c040 100644 --- a/app/Config/View.php +++ b/app/Config/View.php @@ -34,7 +34,7 @@ class View extends BaseView * { title|esc(js) } * { created_on|date(Y-m-d)|esc(attr) } * - * @var array + * @var array * @phpstan-var array */ public $filters = []; @@ -44,7 +44,7 @@ class View extends BaseView * by the core Parser by creating aliases that will be replaced with * any callable. Can be single or tag pair. * - * @var array|callable|string> + * @var array|callable|string> * @phpstan-var array|ParserCallableString|ParserCallable> */ public $plugins = []; diff --git a/system/BaseModel.php b/system/BaseModel.php index b4be52f42a67..7540f84df4a5 100644 --- a/system/BaseModel.php +++ b/system/BaseModel.php @@ -42,15 +42,15 @@ * - process various callbacks * - allow intermingling calls to the db connection * - * @phpstan-type row_array array + * @phpstan-type row_array array * @phpstan-type event_data_beforeinsert array{data: row_array} - * @phpstan-type event_data_afterinsert array{id: int|string, data: row_array, result: bool} - * @phpstan-type event_data_beforefind array{id?: int|string, method: string, singleton: bool, limit?: int, offset?: int} - * @phpstan-type event_data_afterfind array{id: int|string|null|list, data: row_array|list|object|null, method: string, singleton: bool} + * @phpstan-type event_data_afterinsert array{id: int|string, data: row_array, result: bool} + * @phpstan-type event_data_beforefind array{id?: int|string, method: string, singleton: bool, limit?: int, offset?: int} + * @phpstan-type event_data_afterfind array{id: int|string|null|list, data: row_array|list|object|null, method: string, singleton: bool} * @phpstan-type event_data_beforeupdate array{id: null|list, data: row_array} - * @phpstan-type event_data_afterupdate array{id: null|list, data: row_array|object, result: bool} + * @phpstan-type event_data_afterupdate array{id: null|list, data: row_array|object, result: bool} * @phpstan-type event_data_beforedelete array{id: null|list, purge: bool} - * @phpstan-type event_data_afterdelete array{id: null|list, data: null, purge: bool, result: bool} + * @phpstan-type event_data_afterdelete array{id: null|list, data: null, purge: bool, result: bool} */ abstract class BaseModel { diff --git a/system/Config/View.php b/system/Config/View.php index dff8672906b9..f527854813d6 100644 --- a/system/Config/View.php +++ b/system/Config/View.php @@ -39,7 +39,7 @@ class View extends BaseConfig * * @psalm-suppress UndefinedDocblockClass * - * @var array + * @var array * @phpstan-var array */ public $filters = []; @@ -51,7 +51,7 @@ class View extends BaseConfig * * @psalm-suppress UndefinedDocblockClass * - * @var array|callable|string> + * @var array|callable|string> * @phpstan-var array|parser_callable_string|parser_callable> */ public $plugins = []; @@ -59,7 +59,7 @@ class View extends BaseConfig /** * Built-in View filters. * - * @var array + * @var array * @phpstan-var array */ protected $coreFilters = [ @@ -89,7 +89,7 @@ class View extends BaseConfig /** * Built-in View plugins. * - * @var array|callable|string> + * @var array|callable|string> * @phpstan-var array|parser_callable_string|parser_callable> */ protected $corePlugins = [ diff --git a/system/Database/BaseConnection.php b/system/Database/BaseConnection.php index 289aa422bc2d..3ca7c4988ca7 100644 --- a/system/Database/BaseConnection.php +++ b/system/Database/BaseConnection.php @@ -195,7 +195,7 @@ abstract class BaseConnection implements ConnectionInterface /** * Connection ID * - * @var false|object|resource + * @var false|object|resource * @phpstan-var false|TConnection */ public $connID = false; @@ -203,7 +203,7 @@ abstract class BaseConnection implements ConnectionInterface /** * Result ID * - * @var false|object|resource + * @var false|object|resource * @phpstan-var false|TResult */ public $resultID = false; diff --git a/system/Database/BasePreparedQuery.php b/system/Database/BasePreparedQuery.php index 4e9d816686f9..ea16de594c2b 100644 --- a/system/Database/BasePreparedQuery.php +++ b/system/Database/BasePreparedQuery.php @@ -29,7 +29,7 @@ abstract class BasePreparedQuery implements PreparedQueryInterface /** * The prepared statement itself. * - * @var object|resource|null + * @var object|resource|null * @phpstan-var TStatement|null */ protected $statement; @@ -59,7 +59,7 @@ abstract class BasePreparedQuery implements PreparedQueryInterface /** * A reference to the db connection to use. * - * @var BaseConnection + * @var BaseConnection * @phpstan-var BaseConnection */ protected $db; diff --git a/system/Database/BaseResult.php b/system/Database/BaseResult.php index 30352fba65ed..b4d8c6a43fe5 100644 --- a/system/Database/BaseResult.php +++ b/system/Database/BaseResult.php @@ -25,7 +25,7 @@ abstract class BaseResult implements ResultInterface /** * Connection ID * - * @var object|resource + * @var object|resource * @phpstan-var TConnection */ public $connID; @@ -33,7 +33,7 @@ abstract class BaseResult implements ResultInterface /** * Result ID * - * @var false|object|resource + * @var false|object|resource * @phpstan-var false|TResult */ public $resultID; diff --git a/system/View/Parser.php b/system/View/Parser.php index ff5656a53863..4db85195addd 100644 --- a/system/View/Parser.php +++ b/system/View/Parser.php @@ -63,7 +63,7 @@ class Parser extends View /** * Stores any plugins registered at run-time. * - * @var array|callable|string> + * @var array|callable|string> * @phpstan-var array|parser_callable_string|parser_callable> */ protected $plugins = [];