Skip to content

Commit

Permalink
style: apply new options to phpdoc_align fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbalandan committed Jan 26, 2024
1 parent ffb2027 commit b9d9bf5
Show file tree
Hide file tree
Showing 30 changed files with 198 additions and 139 deletions.
22 changes: 21 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,27 @@
__DIR__ . '/spark',
]);

$overrides = [];
$overrides = [
'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',
'property',
'return',
'throws',
'type',
'var',
],
],
];

$options = [
'cacheFile' => 'build/.php-cs-fixer.cache',
Expand Down
22 changes: 21 additions & 1 deletion .php-cs-fixer.no-header.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,27 @@
__DIR__ . '/admin/starter/builds',
]);

$overrides = [];
$overrides = [
'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',
'property',
'return',
'throws',
'type',
'var',
],
],
];

$options = [
'cacheFile' => 'build/.php-cs-fixer.no-header.cache',
Expand Down
19 changes: 19 additions & 0 deletions .php-cs-fixer.user-guide.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,25 @@
'import_symbols' => false,
'leading_backslash_in_global_namespace' => 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',
'property',
'return',
'throws',
'type',
'var',
],
],
];

$options = [
Expand Down
72 changes: 36 additions & 36 deletions system/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ abstract protected function doFirst();
* Inserts data into the current database.
* This method works only with dbCalls.
*
* @param array $row Row data
* @param array $row Row data
* @phpstan-param row_array $row
*
* @return bool
Expand All @@ -424,9 +424,9 @@ abstract protected function doInsertBatch(?array $set = null, ?bool $escape = nu
* Updates a single record in the database.
* This method works only with dbCalls.
*
* @param array|int|string|null $id ID
* @param array|null $row Row data
* @phpstan-param row_array|null $row
* @param array|int|string|null $id ID
* @param array|null $row Row data
* @phpstan-param row_array|null $row
*/
abstract protected function doUpdate($id = null, $row = null): bool;

Expand Down Expand Up @@ -480,9 +480,9 @@ abstract protected function doOnlyDeleted();
* Compiles a replace and runs the query.
* This method works only with dbCalls.
*
* @param array|null $row Row data
* @param array|null $row Row data
* @phpstan-param row_array|null $row
* @param bool $returnSQL Set to true to return Query String
* @param bool $returnSQL Set to true to return Query String
*
* @return BaseResult|false|Query|string
*/
Expand Down Expand Up @@ -511,7 +511,7 @@ abstract protected function idValue($data);
* Public getter to return the id value using the idValue() method.
* For example with SQL this will return $data->$this->primaryKey.
*
* @param array|object $row Row data
* @param array|object $row Row data
* @phpstan-param row_array|object $row
*
* @return array|int|string|null
Expand Down Expand Up @@ -552,7 +552,7 @@ abstract public function chunk(int $size, Closure $userFunc);
*
* @param array|int|string|null $id One primary key or an array of primary keys
*
* @return array|object|null The resulting row of data, or null.
* @return array|object|null The resulting row of data, or null.
* @phpstan-return ($id is int|string ? row_array|object|null : list<row_array|object>)
*/
public function find($id = null)
Expand Down Expand Up @@ -696,7 +696,7 @@ public function first()
* you must ensure that the class will provide access to the class
* variables, even if through a magic method.
*
* @param array|object $row Row data
* @param array|object $row Row data
* @phpstan-param row_array|object $row
*
* @throws ReflectionException
Expand Down Expand Up @@ -724,7 +724,7 @@ public function save($row): bool
* This method is called on save to determine if entry have to be updated.
* If this method returns false insert operation will be executed
*
* @param array|object $row Row data
* @param array|object $row Row data
* @phpstan-param row_array|object $row
*/
protected function shouldUpdate($row): bool
Expand All @@ -748,11 +748,11 @@ public function getInsertID()
* Inserts data into the database. If an object is provided,
* it will attempt to convert it to an array.
*
* @param array|object|null $row Row data
* @param array|object|null $row Row data
* @phpstan-param row_array|object|null $row
* @param bool $returnID Whether insert ID should be returned or not.
* @param bool $returnID Whether insert ID should be returned or not.
*
* @return bool|int|string insert ID or true on success. false on failure.
* @return bool|int|string insert ID or true on success. false on failure.
* @phpstan-return ($returnID is true ? int|string|false : bool)
*
* @throws ReflectionException
Expand Down Expand Up @@ -826,8 +826,8 @@ public function insert($row = null, bool $returnID = true)
/**
* Set datetime to created field.
*
* @phpstan-param row_array $row
* @param int|string $date timestamp or datetime string
* @phpstan-param row_array $row
* @param int|string $date timestamp or datetime string
*/
protected function setCreatedField(array $row, $date): array
{
Expand All @@ -841,8 +841,8 @@ protected function setCreatedField(array $row, $date): array
/**
* Set datetime to updated field.
*
* @phpstan-param row_array $row
* @param int|string $date timestamp or datetime string
* @phpstan-param row_array $row
* @param int|string $date timestamp or datetime string
*/
protected function setUpdatedField(array $row, $date): array
{
Expand All @@ -856,11 +856,11 @@ protected function setUpdatedField(array $row, $date): array
/**
* Compiles batch insert runs the queries, validating each row prior.
*
* @param list<array|object>|null $set an associative array of insert values
* @param list<array|object>|null $set an associative array of insert values
* @phpstan-param list<row_array|object>|null $set
* @param bool|null $escape Whether to escape values
* @param int $batchSize The size of the batch to run
* @param bool $testing True means only number of records is returned, false will execute the query
* @param bool|null $escape Whether to escape values
* @param int $batchSize The size of the batch to run
* @param bool $testing True means only number of records is returned, false will execute the query
*
* @return bool|int Number of rows inserted or FALSE on failure
*
Expand Down Expand Up @@ -937,8 +937,8 @@ public function insertBatch(?array $set = null, ?bool $escape = null, int $batch
* Updates a single record in the database. If an object is provided,
* it will attempt to convert it into an array.
*
* @param array|int|string|null $id
* @param array|object|null $row Row data
* @param array|int|string|null $id
* @param array|object|null $row Row data
* @phpstan-param row_array|object|null $row
*
* @throws ReflectionException
Expand Down Expand Up @@ -999,11 +999,11 @@ public function update($id = null, $row = null): bool
/**
* Compiles an update and runs the query.
*
* @param list<array|object>|null $set an associative array of insert values
* @param list<array|object>|null $set an associative array of insert values
* @phpstan-param list<row_array|object>|null $set
* @param string|null $index The where key
* @param int $batchSize The size of the batch to run
* @param bool $returnSQL True means SQL is returned, false will execute the query
* @param string|null $index The where key
* @param int $batchSize The size of the batch to run
* @param bool $returnSQL True means SQL is returned, false will execute the query
*
* @return false|int|string[] Number of rows affected or FALSE on failure, SQL array when testMode
*
Expand Down Expand Up @@ -1173,9 +1173,9 @@ public function onlyDeleted()
/**
* Compiles a replace and runs the query.
*
* @param array|null $row Row data
* @param array|null $row Row data
* @phpstan-param row_array|null $row
* @param bool $returnSQL Set to true to return Query String
* @param bool $returnSQL Set to true to return Query String
*
* @return BaseResult|false|Query|string
*/
Expand Down Expand Up @@ -1279,7 +1279,7 @@ public function protect(bool $protect = true)
* @used-by update() to protect against mass assignment vulnerabilities.
* @used-by updateBatch() to protect against mass assignment vulnerabilities.
*
* @param array $row Row data
* @param array $row Row data
* @phpstan-param row_array $row
*
* @throws DataException
Expand Down Expand Up @@ -1310,7 +1310,7 @@ protected function doProtectFields(array $row): array
* @used-by insert() to protect against mass assignment vulnerabilities.
* @used-by insertBatch() to protect against mass assignment vulnerabilities.
*
* @param array $row Row data
* @param array $row Row data
* @phpstan-param row_array $row
*
* @throws DataException
Expand Down Expand Up @@ -1505,7 +1505,7 @@ public function cleanRules(bool $choice = false)
* Validate the row data against the validation rules (or the validation group)
* specified in the class property, $validationRules.
*
* @param array|object $row Row data
* @param array|object $row Row data
* @phpstan-param row_array|object $row
*/
public function validate($row): bool
Expand Down Expand Up @@ -1575,8 +1575,8 @@ public function getValidationMessages(): array
* currently so that rules don't block updating when only updating
* a partial row.
*
* @param array $rules Array containing field name and rule
* @param array $row Row data (@TODO Remove null in param type)
* @param array $rules Array containing field name and rule
* @param array $row Row data (@TODO Remove null in param type)
* @phpstan-param row_array $row
*/
protected function cleanValidationRules(array $rules, ?array $row = null): array
Expand Down Expand Up @@ -1760,9 +1760,9 @@ protected function objectToRawArray($object, bool $onlyChanged = true, bool $rec
/**
* Transform data to array.
*
* @param array|object|null $row Row data
* @param array|object|null $row Row data
* @phpstan-param row_array|object|null $row
* @param string $type Type of data (insert|update)
* @param string $type Type of data (insert|update)
*
* @throws DataException
* @throws InvalidArgumentException
Expand Down
22 changes: 11 additions & 11 deletions system/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function app_timezone(): string
* cache()->save('foo', 'bar');
* $foo = cache('bar');
*
* @return array|bool|CacheInterface|float|int|object|string|null
* @return array|bool|CacheInterface|float|int|object|string|null
* @phpstan-return ($key is null ? CacheInterface : array|bool|float|int|object|string|null)
*/
function cache(?string $key = null)
Expand Down Expand Up @@ -207,7 +207,7 @@ function command(string $command)
*
* @param class-string<ConfigTemplate>|string $name
*
* @return ConfigTemplate|null
* @return ConfigTemplate|null
* @phpstan-return ($name is class-string<ConfigTemplate> ? ConfigTemplate : object|null)
*/
function config(string $name, bool $getShared = true)
Expand Down Expand Up @@ -414,11 +414,11 @@ function env(string $key, $default = null)
* If $data is an array, then it loops over it, escaping each
* 'value' of the key/value pairs.
*
* @param array|string $data
* @param array|string $data
* @phpstan-param 'html'|'js'|'css'|'url'|'attr'|'raw' $context
* @param string|null $encoding Current encoding for escaping.
* If not UTF-8, we convert strings from this encoding
* pre-escaping and back to this encoding post-escaping.
* @param string|null $encoding Current encoding for escaping.
* If not UTF-8, we convert strings from this encoding
* pre-escaping and back to this encoding post-escaping.
*
* @return array|string
*
Expand Down Expand Up @@ -805,7 +805,7 @@ function log_message(string $level, string $message, array $context = [])
*
* @param class-string<ModelTemplate>|string $name
*
* @return ModelTemplate|null
* @return ModelTemplate|null
* @phpstan-return ($name is class-string<ModelTemplate> ? ModelTemplate : object|null)
*/
function model(string $name, bool $getShared = true, ?ConnectionInterface &$conn = null)
Expand All @@ -819,8 +819,8 @@ function model(string $name, bool $getShared = true, ?ConnectionInterface &$conn
* Provides access to "old input" that was set in the session
* during a redirect()->withInput().
*
* @param string|null $default
* @param false|string $escape
* @param string|null $default
* @param false|string $escape
* @phpstan-param false|'attr'|'css'|'html'|'js'|'raw'|'url' $escape
*
* @return array|string|null
Expand Down Expand Up @@ -974,7 +974,7 @@ function route_to(string $method, ...$params)
* session()->set('foo', 'bar');
* $foo = session('bar');
*
* @return array|bool|float|int|object|Session|string|null
* @return array|bool|float|int|object|Session|string|null
* @phpstan-return ($val is null ? Session : array|bool|float|int|object|string|null)
*/
function session(?string $val = null)
Expand Down Expand Up @@ -1128,7 +1128,7 @@ function stringify_attributes($attributes, bool $js = false): string
* @param non-empty-string|null $name
* @param (callable(): mixed)|null $callable
*
* @return mixed|Timer
* @return mixed|Timer
* @phpstan-return ($name is null ? Timer : ($callable is (callable(): mixed) ? mixed : Timer))
*/
function timer(?string $name = null, ?callable $callable = null)
Expand Down
Loading

0 comments on commit b9d9bf5

Please sign in to comment.