Skip to content

Commit dd4cd8e

Browse files
committed
chore: register as composer scripts
1 parent 8717258 commit dd4cd8e

4 files changed

Lines changed: 18 additions & 12 deletions

File tree

‎.github/workflows/test-phpstan.yml‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,7 @@ jobs:
9696
- name: Run static analysis
9797
run: composer phpstan:check
9898

99-
- name: Run static analysis on the user guide samples
100-
run: php admin/lint-docs-samples.php --phpstan
101-
10299
- name: Check that the baseline of the user guide samples is up to date
103100
run: |
104-
php admin/lint-docs-samples.php --generate-baseline
101+
composer phpstan:docs-baseline
105102
git diff --exit-code admin/docs-phpstan-baseline.php

‎admin/lint-docs-samples.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,18 +191,19 @@ function analyse_with_phpstan(string $root, string $work, array $found, array $f
191191
"includes:\n - %s\n\nparameters: %s\n",
192192
$config,
193193
json_encode([
194+
'tmpDir' => $root . '/build/phpstan-docs',
194195
'excludePaths' => ['analyse' => $expand($excludePaths)],
195196
'ignoreErrors' => $validIgnoreErrors,
196197
], JSON_UNESCAPED_SLASHES),
197198
));
198199

199200
exec(sprintf(
200-
'cd %s && %s %s analyse --configuration=%s %s --no-progress --memory-limit=1G %s 2>&1',
201+
'cd %s && %s %s analyse --configuration=%s %s --memory-limit=1G %s 2>&1',
201202
escapeshellarg($root),
202203
escapeshellarg(PHP_BINARY),
203204
escapeshellarg($root . '/vendor/bin/phpstan'),
204205
escapeshellarg($work . '/phpstan.neon'),
205-
$generate ? '--error-format=json' : '--ansi',
206+
$generate ? '--error-format=json --no-progress' : '--ansi --verbose',
206207
escapeshellarg($work),
207208
), $output, $status);
208209

‎composer.json‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,15 @@
116116
],
117117
"phpstan:baseline": [
118118
"phpstan analyse --ansi --generate-baseline=utils/phpstan-baseline/loader.neon",
119-
"split-phpstan-baseline utils/phpstan-baseline/loader.neon"
119+
"split-phpstan-baseline utils/phpstan-baseline/loader.neon",
120+
"@phpstan:docs-baseline"
120121
],
121-
"phpstan:check": "vendor/bin/phpstan analyse --verbose --ansi --memory-limit=512M",
122+
"phpstan:check": [
123+
"vendor/bin/phpstan analyse --verbose --ansi --memory-limit=512M",
124+
"@phpstan:docs"
125+
],
126+
"phpstan:docs": "@php admin/lint-docs-samples.php --phpstan",
127+
"phpstan:docs-baseline": "@php admin/lint-docs-samples.php --generate-baseline",
122128
"sa": "@analyze",
123129
"style": "@cs-fix",
124130
"test": "phpunit"
@@ -127,8 +133,10 @@
127133
"analyze": "Run static analysis",
128134
"cs": "Check the coding style",
129135
"cs-fix": "Fix the coding style",
130-
"phpstan:baseline": "Run PHPStan then dump all errors to baseline",
131-
"phpstan:check": "Run PHPStan with support for identifiers",
136+
"phpstan:baseline": "Run PHPStan then dump all errors to baseline, including those of the user guide samples",
137+
"phpstan:check": "Run PHPStan with support for identifiers, including on the user guide samples",
138+
"phpstan:docs": "Run PHPStan on the PHP samples of the user guide",
139+
"phpstan:docs-baseline": "Regenerate the baseline of the PHP samples of the user guide",
132140
"test": "Run unit tests"
133141
}
134142
}

‎contributing/documentation.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@ A PHP sample that starts with `<?php` and parses is checked by `composer cs`, an
167167
it in place. To skip a sample, such as CodeIgniter 3 code, put `<!-- lint-ignore -->` on the line above its fence.
168168

169169
These are also analysed by PHPStan, with the configuration at the root of the project,
170-
when you run `php admin/lint-docs-samples.php --phpstan`. Each error is reported against its page and line.
170+
when you run `composer phpstan:docs`. Each error is reported against its page and line.
171171
An error that a sample cannot avoid is recorded in **admin/docs-phpstan-baseline.php**, by the line of the
172-
opening fence of the sample. After you change a sample, run `php admin/lint-docs-samples.php --generate-baseline`
172+
opening fence of the sample. After you change a sample, run `composer phpstan:docs-baseline`
173173
to rewrite that part of the file, and commit the result. The pull request fails when the file is out of date.
174174
The general ignores at the top of the file, which apply to every sample, are written by hand.
175175

0 commit comments

Comments
 (0)