Skip to content

Commit cd989d3

Browse files
committed
Wiki/Tutorial: update example output for the sniff
1 parent 222efc6 commit cd989d3

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
// Slash comments should be ignored.
4+
5+
/* Star comments should also be ignored. */
6+
7+
# Hash comments should be flagged.
8+
if ($obj->contentsAreValid($array)) {
9+
$value = $obj->getValue();
10+
11+
# Value needs to be an array.
12+
if (is_array($value) === false) {
13+
# Error.
14+
$obj->throwError();
15+
exit();
16+
}
17+
}

wiki/Coding-Standard-Tutorial.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,17 +185,23 @@ if ($obj->contentsAreValid($array)) {
185185
```
186186

187187
When PHP_CodeSniffer is run on the file using our new coding standard, 3 errors will be reported:
188+
<!--
189+
Regenerate the below output snippet by:
190+
1. Placing the example sniff code somewhere in a standard which is included in your `installed_paths`
191+
2. And then running the following command:
192+
$ phpcs ./build/wiki-code-samples/tutorial --basepath=build/wiki-code-samples/tutorial --standard=MyStandard --sniffs=MyStandard.Commenting.DisallowHashComments --report-width=100
193+
-->
188194
```bash
189195
$ phpcs --standard=MyStandard test.php
190196

191197
FILE: test.php
192-
--------------------------------------------------------------------------------
193-
FOUND 3 ERROR(S) AFFECTING 3 LINE(S)
194-
--------------------------------------------------------------------------------
198+
-------------------------------------------------------------------------------------
199+
FOUND 3 ERRORS AFFECTING 3 LINES
200+
-------------------------------------------------------------------------------------
195201
7 | ERROR | Hash comments are prohibited; found # Hash comments should be flagged.
196202
11 | ERROR | Hash comments are prohibited; found # Value needs to be an array.
197203
13 | ERROR | Hash comments are prohibited; found # Error.
198-
--------------------------------------------------------------------------------
204+
-------------------------------------------------------------------------------------
199205
```
200206

201207
<p align="right"><a href="#table-of-contents">back to top</a></p>

0 commit comments

Comments
 (0)