Skip to content

Commit 3a67d33

Browse files
committed
Add phpcs-baseline command for convenience
1 parent 01166ab commit 3a67d33

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ php vendor/bin/phpcs src tests --report=\\DR\\CodeSnifferBaseline\\Reports\\Base
2222
```
2323
Or convenient wrapper for the above command:
2424
```bash
25-
php vendor/bin/phpcs-baseline src tests
25+
php vendor/bin/phpcs-baseline src tests [--no-exit-code]
2626
```
2727

2828
## Usage

bin/phpcs-baseline

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,20 @@ $_SERVER['argv'][] = '--report=\\DR\\CodeSnifferBaseline\\Reports\\Baseline';
99
$_SERVER['argv'][] = '--report-file=phpcs.baseline.xml';
1010
$_SERVER['argv'][] = '--basepath=.';
1111

12+
// check for --no-exit-code argument
13+
foreach ($_SERVER['argv'] as $index => $argument) {
14+
if ($argument === '--no-exit-code') {
15+
unset($_SERVER['argv'][$index]);
16+
register_shutdown_function(static fn() => exit(0));
17+
break;
18+
}
19+
}
20+
1221
// invoke phpcs. find it next to this file or in vendor/bin
13-
foreach([__DIR__ . '/phpcs', __DIR__ . '/../vendor/bin/phpcs', __DIR__ . '/../../../bin/phpcs'] as $path) {
22+
foreach ([__DIR__ . '/phpcs', __DIR__ . '/../vendor/bin/phpcs', __DIR__ . '/../../../bin/phpcs'] as $path) {
1423
if (file_exists($path)) {
1524
require $path;
25+
1626
return;
1727
}
1828
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
},
3131
"scripts": {
3232
"baseline": ["@baseline:phpcs", "@baseline:phpmd", "@baseline:phpstan", "@baseline:phpcqc"],
33-
"baseline:phpcs": "phpcs --report=\\\\DR\\\\CodeSnifferBaseline\\\\Reports\\\\Baseline --report-file=phpcs.baseline.xml --basepath=.",
33+
"baseline:phpcs": "@php bin/phpcs-baseline src tests --no-exit-code",
3434
"baseline:phpmd": "@check:phpmd --generate-baseline",
3535
"baseline:phpstan": "phpstan --generate-baseline",
3636
"run:plugin": "DR\\CodeSnifferBaseline\\Plugin\\Plugin::run",

0 commit comments

Comments
 (0)