Skip to content

Commit 1f2fdf7

Browse files
authored
style: fix code styles from php-cs-fixer v3.76 (#9626)
* remove PHP_CS_FIXER_IGNORE_ENV * Bump versions in utils/composer.json * Manually fix cs errors * Remove deprecated fixers
1 parent 228ba7d commit 1f2fdf7

File tree

8 files changed

+37
-61
lines changed

8 files changed

+37
-61
lines changed

.github/workflows/test-coding-standards.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,3 @@ jobs:
6565

6666
- name: Run lint
6767
run: composer cs
68-
env:
69-
PHP_CS_FIXER_IGNORE_ENV: ${{ matrix.php-version == '8.4' }}

.php-cs-fixer.dist.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
use CodeIgniter\CodingStandard\CodeIgniter4;
1515
use Nexus\CsConfig\Factory;
16-
use Nexus\CsConfig\Fixer\Comment\NoCodeSeparatorCommentFixer;
17-
use Nexus\CsConfig\FixerGenerator;
1816
use PhpCsFixer\Finder;
1917

2018
$finder = Finder::create()
@@ -44,12 +42,8 @@
4442
];
4543

4644
$options = [
47-
'cacheFile' => 'build/.php-cs-fixer.cache',
48-
'finder' => $finder,
49-
'customFixers' => FixerGenerator::create('utils/vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'),
50-
'customRules' => [
51-
NoCodeSeparatorCommentFixer::name() => true,
52-
],
45+
'cacheFile' => 'build/.php-cs-fixer.cache',
46+
'finder' => $finder,
5347
];
5448

5549
return Factory::create(new CodeIgniter4(), $overrides, $options)->forLibrary(

system/BaseModel.php

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,8 @@ abstract protected function doOnlyDeleted();
532532
* Compiles a replace and runs the query.
533533
* This method works only with dbCalls.
534534
*
535-
* @param array|null $row Row data
536-
* @phpstan-param row_array|null $row
537-
* @param bool $returnSQL Set to true to return Query String
535+
* @param row_array|null $row Row data
536+
* @param bool $returnSQL Set to true to return Query String
538537
*
539538
* @return BaseResult|false|Query|string
540539
*/
@@ -552,8 +551,7 @@ abstract protected function doErrors();
552551
* Public getter to return the id value using the idValue() method.
553552
* For example with SQL this will return $data->$this->primaryKey.
554553
*
555-
* @param array|object $row Row data
556-
* @phpstan-param row_array|object $row
554+
* @param object|row_array $row Row data
557555
*
558556
* @return array|int|string|null
559557
*/
@@ -737,8 +735,7 @@ public function first()
737735
* you must ensure that the class will provide access to the class
738736
* variables, even if through a magic method.
739737
*
740-
* @param array|object $row Row data
741-
* @phpstan-param row_array|object $row
738+
* @param object|row_array $row Row data
742739
*
743740
* @throws ReflectionException
744741
*/
@@ -789,9 +786,8 @@ public function getInsertID()
789786
* Inserts data into the database. If an object is provided,
790787
* it will attempt to convert it to an array.
791788
*
792-
* @param array|object|null $row Row data
793-
* @phpstan-param row_array|object|null $row
794-
* @param bool $returnID Whether insert ID should be returned or not.
789+
* @param object|row_array|null $row Row data
790+
* @param bool $returnID Whether insert ID should be returned or not.
795791
*
796792
* @return ($returnID is true ? false|int|string : bool)
797793
*
@@ -866,8 +862,8 @@ public function insert($row = null, bool $returnID = true)
866862
/**
867863
* Set datetime to created field.
868864
*
869-
* @phpstan-param row_array $row
870-
* @param int|string $date timestamp or datetime string
865+
* @param row_array $row
866+
* @param int|string $date timestamp or datetime string
871867
*/
872868
protected function setCreatedField(array $row, $date): array
873869
{
@@ -881,8 +877,8 @@ protected function setCreatedField(array $row, $date): array
881877
/**
882878
* Set datetime to updated field.
883879
*
884-
* @phpstan-param row_array $row
885-
* @param int|string $date timestamp or datetime string
880+
* @param row_array $row
881+
* @param int|string $date timestamp or datetime string
886882
*/
887883
protected function setUpdatedField(array $row, $date): array
888884
{
@@ -896,11 +892,10 @@ protected function setUpdatedField(array $row, $date): array
896892
/**
897893
* Compiles batch insert runs the queries, validating each row prior.
898894
*
899-
* @param list<array|object>|null $set an associative array of insert values
900-
* @phpstan-param list<row_array|object>|null $set
901-
* @param bool|null $escape Whether to escape values
902-
* @param int $batchSize The size of the batch to run
903-
* @param bool $testing True means only number of records is returned, false will execute the query
895+
* @param list<object|row_array>|null $set an associative array of insert values
896+
* @param bool|null $escape Whether to escape values
897+
* @param int $batchSize The size of the batch to run
898+
* @param bool $testing True means only number of records is returned, false will execute the query
904899
*
905900
* @return bool|int Number of rows inserted or FALSE on failure
906901
*
@@ -1042,11 +1037,10 @@ public function update($id = null, $row = null): bool
10421037
/**
10431038
* Compiles an update and runs the query.
10441039
*
1045-
* @param list<array|object>|null $set an associative array of insert values
1046-
* @phpstan-param list<row_array|object>|null $set
1047-
* @param string|null $index The where key
1048-
* @param int $batchSize The size of the batch to run
1049-
* @param bool $returnSQL True means SQL is returned, false will execute the query
1040+
* @param list<object|row_array>|null $set an associative array of insert values
1041+
* @param string|null $index The where key
1042+
* @param int $batchSize The size of the batch to run
1043+
* @param bool $returnSQL True means SQL is returned, false will execute the query
10501044
*
10511045
* @return false|int|list<string> Number of rows affected or FALSE on failure, SQL array when testMode
10521046
*
@@ -1125,8 +1119,8 @@ public function updateBatch(?array $set = null, ?string $index = null, int $batc
11251119
/**
11261120
* Deletes a single record from the database where $id matches.
11271121
*
1128-
* @param array|int|string|null $id The rows primary key(s)
1129-
* @param bool $purge Allows overriding the soft deletes setting.
1122+
* @param int|list<int|string>|string|null $id The rows primary key(s)
1123+
* @param bool $purge Allows overriding the soft deletes setting.
11301124
*
11311125
* @return BaseResult|bool
11321126
*
@@ -1214,9 +1208,8 @@ public function onlyDeleted()
12141208
/**
12151209
* Compiles a replace and runs the query.
12161210
*
1217-
* @param array|null $row Row data
1218-
* @phpstan-param row_array|null $row
1219-
* @param bool $returnSQL Set to true to return Query String
1211+
* @param row_array|null $row Row data
1212+
* @param bool $returnSQL Set to true to return Query String
12201213
*
12211214
* @return BaseResult|false|Query|string
12221215
*/
@@ -1810,9 +1803,8 @@ protected function objectToRawArray($object, bool $onlyChanged = true, bool $rec
18101803
/**
18111804
* Transform data to array.
18121805
*
1813-
* @param array|object|null $row Row data
1814-
* @phpstan-param row_array|object|null $row
1815-
* @param string $type Type of data (insert|update)
1806+
* @param object|row_array|null $row Row data
1807+
* @param string $type Type of data (insert|update)
18161808
*
18171809
* @throws DataException
18181810
* @throws InvalidArgumentException

system/Model.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,8 @@ protected function doOnlyDeleted()
551551
* Compiles a replace into string and runs the query
552552
* This method works only with dbCalls.
553553
*
554-
* @param array|null $row Data
555-
* @phpstan-param row_array|null $row
556-
* @param bool $returnSQL Set to true to return Query String
554+
* @param row_array|null $row Data
555+
* @param bool $returnSQL Set to true to return Query String
557556
*
558557
* @return BaseResult|false|Query|string
559558
*/
@@ -774,9 +773,8 @@ protected function shouldUpdate($row): bool
774773
* Inserts data into the database. If an object is provided,
775774
* it will attempt to convert it to an array.
776775
*
777-
* @param array|object|null $row
778-
* @phpstan-param row_array|object|null $row
779-
* @param bool $returnID Whether insert ID should be returned or not.
776+
* @param object|row_array|null $row
777+
* @param bool $returnID Whether insert ID should be returned or not.
780778
*
781779
* @return ($returnID is true ? false|int|string : bool)
782780
*

system/Test/Interfaces/FabricatorModel.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,16 @@ interface FabricatorModel
3939
*
4040
* @param int|list<int|string>|string|null $id One primary key or an array of primary keys
4141
*
42-
* @phpstan-return ($id is int|string ? row_array|object|null : list<row_array|object>)
42+
* @return ($id is int|string ? object|row_array|null : list<object|row_array>)
4343
*/
4444
public function find($id = null);
4545

4646
/**
4747
* Inserts data into the current table. If an object is provided,
4848
* it will attempt to convert it to an array.
4949
*
50-
* @param array|object|null $row
51-
* @phpstan-param row_array|object|null $row
52-
* @param bool $returnID Whether insert ID should be returned or not.
50+
* @param object|row_array|null $row
51+
* @param bool $returnID Whether insert ID should be returned or not.
5352
*
5453
* @return bool|int|string
5554
*

utils/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"php": "^8.1",
44
"codeigniter/coding-standard": "^1.7",
55
"ergebnis/composer-normalize": "^2.28",
6-
"friendsofphp/php-cs-fixer": "^3.63.2",
7-
"nexusphp/cs-config": "^3.6",
6+
"friendsofphp/php-cs-fixer": "^3.76",
7+
"nexusphp/cs-config": "^3.26",
88
"phpmetrics/phpmetrics": "^2.8 || ^3.0rc6",
99
"vimeo/psalm": "^5.0"
1010
},

utils/phpstan-baseline/loader.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 2866 errors
1+
# total 2865 errors
22
includes:
33
- argument.type.neon
44
- assign.propertyType.neon

utils/phpstan-baseline/missingType.iterableValue.neon

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 1436 errors
1+
# total 1435 errors
22

33
parameters:
44
ignoreErrors:
@@ -27,11 +27,6 @@ parameters:
2727
count: 1
2828
path: ../../system/BaseModel.php
2929

30-
-
31-
message: '#^Method CodeIgniter\\BaseModel\:\:delete\(\) has parameter \$id with no value type specified in iterable type array\.$#'
32-
count: 1
33-
path: ../../system/BaseModel.php
34-
3530
-
3631
message: '#^Method CodeIgniter\\BaseModel\:\:doDelete\(\) has parameter \$id with no value type specified in iterable type array\.$#'
3732
count: 1

0 commit comments

Comments
 (0)