Skip to content

Commit

Permalink
style: also align @phpstan-type and @phpstan-var
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbalandan committed Feb 25, 2024
1 parent 609be52 commit d044f82
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
'phpstan-param',
'phpstan-property',
'phpstan-return',
'phpstan-type',
'phpstan-var',
'property',
'property-read',
'property-write',
Expand Down
23 changes: 23 additions & 0 deletions .php-cs-fixer.no-header.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
23 changes: 23 additions & 0 deletions .php-cs-fixer.user-guide.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
4 changes: 2 additions & 2 deletions app/Config/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class View extends BaseView
* { title|esc(js) }
* { created_on|date(Y-m-d)|esc(attr) }
*
* @var array<string, string>
* @var array<string, string>
* @phpstan-var array<string, ParserCallableString>
*/
public $filters = [];
Expand All @@ -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<string, array<string>|callable|string>
* @var array<string, array<string>|callable|string>
* @phpstan-var array<string, array<ParserCallableString>|ParserCallableString|ParserCallable>
*/
public $plugins = [];
Expand Down
12 changes: 6 additions & 6 deletions system/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@
* - process various callbacks
* - allow intermingling calls to the db connection
*
* @phpstan-type row_array array<int|string, float|int|null|object|string>
* @phpstan-type row_array array<int|string, float|int|null|object|string>
* @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<int|string>, data: row_array|list<row_array>|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<int|string>, data: row_array|list<row_array>|object|null, method: string, singleton: bool}
* @phpstan-type event_data_beforeupdate array{id: null|list<int|string>, data: row_array}
* @phpstan-type event_data_afterupdate array{id: null|list<int|string>, data: row_array|object, result: bool}
* @phpstan-type event_data_afterupdate array{id: null|list<int|string>, data: row_array|object, result: bool}
* @phpstan-type event_data_beforedelete array{id: null|list<int|string>, purge: bool}
* @phpstan-type event_data_afterdelete array{id: null|list<int|string>, data: null, purge: bool, result: bool}
* @phpstan-type event_data_afterdelete array{id: null|list<int|string>, data: null, purge: bool, result: bool}
*/
abstract class BaseModel
{
Expand Down
8 changes: 4 additions & 4 deletions system/Config/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class View extends BaseConfig
*
* @psalm-suppress UndefinedDocblockClass
*
* @var array<string, string>
* @var array<string, string>
* @phpstan-var array<string, parser_callable_string>
*/
public $filters = [];
Expand All @@ -51,15 +51,15 @@ class View extends BaseConfig
*
* @psalm-suppress UndefinedDocblockClass
*
* @var array<string, array<string>|callable|string>
* @var array<string, array<string>|callable|string>
* @phpstan-var array<string, array<parser_callable_string>|parser_callable_string|parser_callable>
*/
public $plugins = [];

/**
* Built-in View filters.
*
* @var array<string, string>
* @var array<string, string>
* @phpstan-var array<string, parser_callable_string>
*/
protected $coreFilters = [
Expand Down Expand Up @@ -89,7 +89,7 @@ class View extends BaseConfig
/**
* Built-in View plugins.
*
* @var array<string, array<string>|callable|string>
* @var array<string, array<string>|callable|string>
* @phpstan-var array<string, array<parser_callable_string>|parser_callable_string|parser_callable>
*/
protected $corePlugins = [
Expand Down
4 changes: 2 additions & 2 deletions system/Database/BaseConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ abstract class BaseConnection implements ConnectionInterface
/**
* Connection ID
*
* @var false|object|resource
* @var false|object|resource
* @phpstan-var false|TConnection
*/
public $connID = false;

/**
* Result ID
*
* @var false|object|resource
* @var false|object|resource
* @phpstan-var false|TResult
*/
public $resultID = false;
Expand Down
4 changes: 2 additions & 2 deletions system/Database/BasePreparedQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -59,7 +59,7 @@ abstract class BasePreparedQuery implements PreparedQueryInterface
/**
* A reference to the db connection to use.
*
* @var BaseConnection
* @var BaseConnection
* @phpstan-var BaseConnection<TConnection, TResult>
*/
protected $db;
Expand Down
4 changes: 2 additions & 2 deletions system/Database/BaseResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ abstract class BaseResult implements ResultInterface
/**
* Connection ID
*
* @var object|resource
* @var object|resource
* @phpstan-var TConnection
*/
public $connID;

/**
* Result ID
*
* @var false|object|resource
* @var false|object|resource
* @phpstan-var false|TResult
*/
public $resultID;
Expand Down
2 changes: 1 addition & 1 deletion system/View/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Parser extends View
/**
* Stores any plugins registered at run-time.
*
* @var array<string, array<string>|callable|string>
* @var array<string, array<string>|callable|string>
* @phpstan-var array<string, array<parser_callable_string>|parser_callable_string|parser_callable>
*/
protected $plugins = [];
Expand Down

0 comments on commit d044f82

Please sign in to comment.