Skip to content

Commit 2b8add3

Browse files
committed
refactor: split phpstan-baseline into smaller files
1 parent f0536a1 commit 2b8add3

File tree

80 files changed

+15798
-18073
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+15798
-18073
lines changed

composer.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,19 @@
1717
"psr/log": "^3.0"
1818
},
1919
"require-dev": {
20-
"codeigniter/phpstan-codeigniter": "^1.4",
20+
"codeigniter/phpstan-codeigniter": "^1.5",
2121
"fakerphp/faker": "^1.9",
2222
"kint-php/kint": "^5.0.4",
2323
"mikey179/vfsstream": "^1.6",
2424
"nexusphp/tachycardia": "^2.0",
2525
"phpstan/extension-installer": "^1.4",
26-
"phpstan/phpstan": "^1.11",
27-
"phpstan/phpstan-strict-rules": "^1.6",
26+
"phpstan/phpstan": "^2.0",
27+
"phpstan/phpstan-strict-rules": "^2.0",
2828
"phpunit/phpcov": "^9.0.2 || ^10.0",
2929
"phpunit/phpunit": "^10.5.16 || ^11.2",
3030
"predis/predis": "^1.1 || ^2.0",
31-
"rector/rector": "1.2.10"
31+
"rector/rector": "2.0.0-rc3",
32+
"shipmonk/phpstan-baseline-per-identifier": "^2.0"
3233
},
3334
"replace": {
3435
"codeigniter4/framework": "self.version"
@@ -110,7 +111,12 @@
110111
"utils/vendor/bin/php-cs-fixer fix --ansi --verbose --diff"
111112
],
112113
"metrics": "utils/vendor/bin/phpmetrics --config=phpmetrics.json",
113-
"phpstan:baseline": "vendor/bin/phpstan analyse --ansi --generate-baseline=phpstan-baseline.php",
114+
"phpstan:baseline": [
115+
"bash -c \"rm -rf utils/phpstan-baseline/*.neon\"",
116+
"bash -c \"touch utils/phpstan-baseline/loader.neon\"",
117+
"phpstan analyse --ansi --generate-baseline=utils/phpstan-baseline/loader.neon",
118+
"split-phpstan-baseline utils/phpstan-baseline/loader.neon"
119+
],
114120
"phpstan:check": "vendor/bin/phpstan analyse --verbose --ansi",
115121
"sa": "@analyze",
116122
"style": "@cs-fix",

phpstan-baseline.php

Lines changed: 0 additions & 18053 deletions
This file was deleted.

phpstan.neon.dist

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
includes:
2-
- phpstan-baseline.php
2+
- utils/phpstan-baseline/loader.neon
33

44
parameters:
55
phpVersion: 80100
@@ -33,5 +33,10 @@ parameters:
3333
allRules: false
3434
disallowedLooseComparison: true
3535
booleansInConditions: true
36-
disallowedConstructs: true
36+
disallowedBacktick: true
37+
disallowedEmpty: true
38+
disallowedImplicitArrayCreation: true
39+
disallowedShortTernary: true
3740
matchingInheritedMethodNames: true
41+
shipmonkBaselinePerIdentifier:
42+
directory: %currentWorkingDirectory%

rector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
__DIR__ . '/phpstan.neon.dist',
8484
__DIR__ . '/vendor/codeigniter/phpstan-codeigniter/extension.neon',
8585
__DIR__ . '/vendor/phpstan/phpstan-strict-rules/rules.neon',
86+
__DIR__ . '/vendor/shipmonk/phpstan-baseline-per-identifier/extension.neon',
8687
])
8788
// is there a file you need to skip?
8889
->withSkip([

system/Validation/Rules.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,8 @@ public function required_with($str = null, ?string $fields = null, array $data =
359359

360360
foreach (explode(',', $fields) as $field) {
361361
if (
362-
(array_key_exists($field, $data)
363-
&& ! empty($data[$field])) // @phpstan-ignore-line Use empty()
364-
|| (str_contains($field, '.')
365-
&& ! empty(dot_array_search($field, $data))) // @phpstan-ignore-line Use empty()
362+
(array_key_exists($field, $data) && ! empty($data[$field]))
363+
|| (str_contains($field, '.') && ! empty(dot_array_search($field, $data)))
366364
) {
367365
$requiredFields[] = $field;
368366
}
@@ -409,7 +407,7 @@ public function required_without(
409407
if (
410408
(! str_contains($otherField, '.'))
411409
&& (! array_key_exists($otherField, $data)
412-
|| empty($data[$otherField])) // @phpstan-ignore-line Use empty()
410+
|| empty($data[$otherField]))
413411
) {
414412
return false;
415413
}
@@ -424,7 +422,7 @@ public function required_without(
424422
$fieldKey = $fieldSplitArray[1];
425423

426424
if (is_array($fieldData)) {
427-
return ! empty(dot_array_search($otherField, $data)[$fieldKey]); // @phpstan-ignore-line Use empty()
425+
return ! empty(dot_array_search($otherField, $data)[$fieldKey]);
428426
}
429427
$nowField = str_replace('*', $fieldKey, $otherField);
430428
$nowFieldVaule = dot_array_search($nowField, $data);

system/View/Filters.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ public static function date_modify($value, string $adjustment)
7171
*/
7272
public static function default($value, string $default): string
7373
{
74-
return empty($value) // @phpstan-ignore-line
75-
? $default
76-
: $value;
74+
return empty($value) ? $default : $value;
7775
}
7876

7977
/**

tests/system/Database/Live/MetadataTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function testListTablesUnconstrainedByPrefixReturnsAllTables(): void
101101
$expectedTables[] = 'tmp_widgets';
102102

103103
sort($tables);
104-
$this->assertSame($expectedTables, array_values($tables));
104+
$this->assertSame($expectedTables, $tables);
105105
} finally {
106106
$this->dropExtraneousTable();
107107
}
@@ -117,7 +117,7 @@ public function testListTablesConstrainedByPrefixReturnsOnlyTablesWithMatchingPr
117117
$this->assertNotSame([], $tables);
118118

119119
sort($tables);
120-
$this->assertSame($this->expectedTables, array_values($tables));
120+
$this->assertSame($this->expectedTables, $tables);
121121
} finally {
122122
$this->dropExtraneousTable();
123123
}
@@ -138,7 +138,7 @@ public function testListTablesConstrainedByExtraneousPrefixReturnsOnlyTheExtrane
138138
$this->assertNotSame([], $tables);
139139

140140
sort($tables);
141-
$this->assertSame(['tmp_widgets'], array_values($tables));
141+
$this->assertSame(['tmp_widgets'], $tables);
142142
} finally {
143143
$this->db->setPrefix($oldPrefix);
144144
$this->dropExtraneousTable();

tests/system/Debug/ExceptionsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function testDeprecationsOnPhp81DoNotThrow(): void
7373
// We test DEPRECATED error, so cannot set `declare(strict_types=1)` in this file.
7474
strlen($maybeNull);
7575
$this->assertLogContains('error', '[DEPRECATED] strlen(): ');
76-
} catch (ErrorException) {
76+
} catch (ErrorException $e) {
7777
$this->fail('The catch block should not be reached.');
7878
} finally {
7979
restore_error_handler();

0 commit comments

Comments
 (0)