File tree Expand file tree Collapse file tree 3 files changed +30
-1
lines changed
Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ to the root of the project and name it `phpcs.baseline.xml`.
2020``` bash
2121php vendor/bin/phpcs src tests --report=\\ DR\\ CodeSnifferBaseline\\ Reports\\ Baseline --report-file=phpcs.baseline.xml --basepath=.
2222```
23+ Or convenient wrapper for the above command:
24+ ``` bash
25+ php vendor/bin/phpcs-baseline src tests
26+ ```
2327
2428## Usage
2529Use phpcs like you normally would. With ` phpcs.baseline.xml ` in the root of your project, the baseline extension will automatically read the config
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env php
2+ <?php
3+
4+ declare (strict_types=1 );
5+
6+ // set default arguments next to src locations
7+ $ _SERVER ['argc ' ] += 3 ;
8+ $ _SERVER ['argv ' ][] = '--report= \\DR \\CodeSnifferBaseline \\Reports \\Baseline ' ;
9+ $ _SERVER ['argv ' ][] = '--report-file=phpcs.baseline.xml ' ;
10+ $ _SERVER ['argv ' ][] = '--basepath=. ' ;
11+
12+ // invoke phpcs. find it next to this file or in vendor/bin
13+ foreach ([__DIR__ . '/phpcs ' , __DIR__ . '/../vendor/bin/phpcs ' ] as $ path ) {
14+ if (file_exists ($ path )) {
15+ require $ path ;
16+ return ;
17+ }
18+ }
19+
20+ // failed to find phpcs
21+ fwrite (STDERR , 'Could not find `vendor/bin/phpcs`. Make sure to run `composer require squizlabs/php_codesniffer` ' . PHP_EOL );
22+ exit (1 );
Original file line number Diff line number Diff line change 5757 "DR\\ CodeSnifferBaseline\\ Tests\\ Unit\\ " : " tests/Unit/" ,
5858 "DR\\ CodeSnifferBaseline\\ Tests\\ " : " tests/"
5959 }
60- }
60+ },
61+ "bin" : [
62+ " bin/phpcs-baseline"
63+ ]
6164}
You can’t perform that action at this time.
0 commit comments