File tree Expand file tree Collapse file tree 2 files changed +27
-4
lines changed
build/wiki-code-samples/tutorial Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change @@ -185,17 +185,23 @@ if ($obj->contentsAreValid($array)) {
185
185
```
186
186
187
187
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
+ -->
188
194
``` bash
189
195
$ phpcs --standard=MyStandard test.php
190
196
191
197
FILE: test.php
192
- --------------------------------------------------------------------------------
193
- FOUND 3 ERROR(S) AFFECTING 3 LINE(S)
194
- --------------------------------------------------------------------------------
198
+ -------------------------------------------------------------------------------------
199
+ FOUND 3 ERRORS AFFECTING 3 LINES
200
+ -------------------------------------------------------------------------------------
195
201
7 | ERROR | Hash comments are prohibited; found # Hash comments should be flagged.
196
202
11 | ERROR | Hash comments are prohibited; found # Value needs to be an array.
197
203
13 | ERROR | Hash comments are prohibited; found # Error.
198
- --------------------------------------------------------------------------------
204
+ -------------------------------------------------------------------------------------
199
205
```
200
206
201
207
<p align =" right " ><a href =" #table-of-contents " >back to top</a ></p >
You can’t perform that action at this time.
0 commit comments