Skip to content

Commit 17e1eb4

Browse files
authored
Add PHPStan (#47)
1 parent 03e8843 commit 17e1eb4

File tree

11 files changed

+334
-15
lines changed

11 files changed

+334
-15
lines changed

.github/workflows/lint.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Lint
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches:
7+
- main
8+
push:
9+
branches:
10+
- main
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ github.event.pull_request.number || github.sha }}
14+
cancel-in-progress: true
15+
16+
permissions: {}
17+
18+
jobs:
19+
phpstan:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v5
23+
24+
- uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: '8.4'
27+
coverage: none
28+
- uses: ramsey/composer-install@v3
29+
30+
- run: vendor/bin/phpstan analyse --error-format=github

composer.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@
3434
},
3535
"require-dev": {
3636
"mockery/mockery": "^1.6.12",
37-
"pestphp/pest": "^4.1.2"
37+
"pestphp/pest": "^4.1.2",
38+
"phpstan/extension-installer": "^1.4",
39+
"phpstan/phpstan": "^2.1",
40+
"phpstan/phpstan-deprecation-rules": "^2.0",
41+
"phpstan/phpstan-strict-rules": "^2.0",
42+
"phpstan/phpstan-symfony": "^2.0"
3843
},
3944
"autoload": {
4045
"psr-4": {
@@ -51,7 +56,8 @@
5156
],
5257
"config": {
5358
"allow-plugins": {
54-
"pestphp/pest-plugin": true
59+
"pestphp/pest-plugin": true,
60+
"phpstan/extension-installer": true
5561
},
5662
"sort-packages": true
5763
},
@@ -67,10 +73,9 @@
6773
"pest:e2e": "XDEBUG_MODE=off pest --group=e2e",
6874
"pest:feature": "pest --group=feature",
6975
"pest:unit": "pest --group=unit",
70-
"test": [
71-
"@composer normalize --dry-run",
76+
"lint": [
7277
"pint --test",
73-
"XDEBUG_MODE=off pest"
78+
"phpstan analyse"
7479
]
7580
}
7681
}

composer.lock

Lines changed: 268 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
level: max
3+
paths:
4+
- bin
5+
- src

src/Console/ConstraintCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function __invoke(
5050
return Command::FAILURE;
5151
}
5252

53-
if (empty($versions)) {
53+
if ($versions === []) {
5454
$this->printError(
5555
$io,
5656
sprintf('No PHP versions could satisfy the constraint "%s".', $constraint)

src/Console/ModeOption.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function __construct()
1515
Mode::description(),
1616
Mode::NAME,
1717
null,
18-
Mode::cases(),
18+
array_column(Mode::cases(), 'value'),
1919
);
2020
}
2121
}

src/Console/SourceOption.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function __construct()
1515
Source::description(),
1616
Source::NAME,
1717
null,
18-
Source::cases(),
18+
array_column(Source::cases(), 'value'),
1919
);
2020
}
2121
}

src/MinorOnlyMatrix.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public function satisfiedBy(string $constraint): array
2020
$versions[] = "{$major}.{$minor}";
2121
}
2222

23-
$versions = array_filter($versions);
2423
$versions = array_filter($versions, static fn (string $version) => ! str_starts_with($version, '.'));
2524
$versions = array_filter($versions, static fn (string $version) => ! str_ends_with($version, '.'));
2625
$versions = array_unique($versions);

0 commit comments

Comments
 (0)