You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 8b6fc76
Browse filesBrowse the repository at this point in the historyBrowse files
Document the code style check of the PHP blocks in feature files
Adds a section alongside the one for the static analysis, covering which
docstrings are checked and why a docstring merely opening with `<?php` is
not among them, where the defaults live, and how a package replaces them.
The README is regenerated from the partials on push to main.
Copy file name to clipboardExpand all lines: .readme-partials/USING.md
+52Lines changed: 52 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,6 +78,8 @@ To make use of the WP-CLI testing framework, you need to complete the following
78
78
```
79
79
80
80
All other [PHPCS configuration options](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Annotated-Ruleset) are, of course, available.
81
+
The PHP snippets embedded in your feature files are checked along with the rest of the package. See [Checking the code style of the PHP blocks in feature files](#checking-the-code-style-of-the-php-blocks-in-feature-files) below.
82
+
81
83
6. Optionally add a `phpstan-feature-files.neon.dist` file to the package root to also run PHPStan over the PHP snippets embedded in your feature files. See [Analysing the PHP blocks in feature files](#analysing-the-php-blocks-in-feature-files) below.
82
84
83
85
7. Update your composer dependencies and regenerate your autoloader and binary folders:
@@ -165,6 +167,56 @@ Two kinds of blocks are left out of the analysis, and are listed at the end of t
165
167
Blocks that declare the same class or function as another block are analysed separately from each
166
168
other, so that PHPStan does not resolve a name to the wrong block's declaration.
167
169
170
+
### Checking the code style of the PHP blocks in feature files
171
+
172
+
`composer phpcs` also checks the PHP snippets that feature files embed in docstrings, and
173
+
`composer phpcbf` fixes them in place. No configuration is needed, and like the analysis above the
174
+
blocks are padded so that findings are reported against the feature file itself:
The blocks are left alone when a run is narrowed down to a path, as in`composer phpcs -- src/`,
218
+
since such an argument is about the files of the package itself.
219
+
168
220
### Controlling what to test
169
221
170
222
To send one or more arguments to one of the test tools, prepend the argument(s) with a double dash. As an example, here's how to run the functional tests for a specific feature file only:
0 commit comments