Skip to content

Commit 63c8f1b

Browse files
committed
CS/markdownlint: various whitespace fixes
1 parent 666e9d8 commit 63c8f1b

13 files changed

+76
-13
lines changed

wiki/About-Standards-for-PHP_CodeSniffer.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ In that case, you can write your own sniff to enforce that rule.
109109
> [!IMPORTANT]
110110
> All sniffs in a standard are automatically included. There is no need to include the sniff(s) in the `ruleset.xml` via a `<rule ref=.../>`.
111111
112-
113112
There is a [Coding Standard Tutorial](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Coding-Standard-Tutorial) available on how to write a sniff.
114113

115114
<p align="right"><a href="#table-of-contents">back to top</a></p>
@@ -156,7 +155,6 @@ This means that - taking the example directory structure above into account - th
156155

157156
#### Examples
158157

159-
160158
##### Valid:
161159
```php
162160
<?php
@@ -207,7 +205,6 @@ The same note about setting the `namespace` attribute in the `ruleset.xml` file
207205

208206
Also make sure that the `installed_paths` configuration option is set correctly and points to the `MyStandard` directory.
209207

210-
211208
##### Invalid:
212209

213210
:x: Sniff name not ending on `Sniff`:

wiki/Advanced-Usage.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
## Table of contents
2+
23
* [Specifying Valid File Extensions](#specifying-valid-file-extensions)
34
* [Ignoring Files and Folders](#ignoring-files-and-folders)
45
* [Ignoring Parts of a File](#ignoring-parts-of-a-file)
@@ -19,6 +20,7 @@
1920
***
2021

2122
## Specifying Valid File Extensions
23+
2224
By default, PHP_CodeSniffer will check any file it finds with a `.inc`, `.php`, `.js` or `.css` extension, although not all standards will actually check all these file types. Sometimes, this means that PHP_CodeSniffer is not checking enough of your files. Sometimes, the opposite is true. PHP_CodeSniffer allows you to specify a list of valid file extensions using the `--extensions` command line argument. Extensions are separated by commas.
2325

2426
To only check .php files:
@@ -35,6 +37,7 @@ $ phpcs --extensions=php,inc,lib /path/to/code
3537

3638

3739
## Ignoring Files and Folders
40+
3841
Sometimes you want PHP_CodeSniffer to run over a very large number of files, but you want some files and folders to be skipped. The `--ignore` command line argument can be used to tell PHP_CodeSniffer to skip files and folders that match one or more patterns.
3942

4043
In the following example, PHP_CodeSniffer will skip all files inside the package's tests and data directories. This is useful if you are checking a package but don't want your test or data files to conform to your coding standard.
@@ -43,7 +46,7 @@ $ phpcs --ignore=*/tests/*,*/data/* /path/to/code
4346
```
4447

4548
> [!IMPORTANT]
46-
> The ignore patterns are treated as regular expressions. If you do specify a regular expression, be aware that `*` is converted to `.*` for the convenience in simple patterns, like those used in the example above. So use `*` anywhere you would normally use `.*`. Also ensure you escape any `.` characters that you want treated as a literal dot, such as when checking file extensions. So if you are checking for `.inc` in your ignore pattern, use `\.inc` instead.
49+
> The ignore patterns are treated as regular expressions. If you do specify a regular expression, be aware that `*` is converted to `.*` for the convenience in simple patterns, like those used in the example above. So use `*` anywhere you would normally use `.*`. Also ensure you escape any `.` characters that you want treated as a literal dot, such as when checking file extensions. So if you are checking for `.inc` in your ignore pattern, use `\.inc` instead.
4750
4851
You can also tell PHP_CodeSniffer to ignore a file using a special comment inserted at the top of the file. This will stop the file being checked even if it does not match the ignore pattern.
4952

@@ -78,6 +81,7 @@ $xmlPackage->send();
7881

7982

8083
## Ignoring Parts of a File
84+
8185
Some parts of your code may be unable to conform to your coding standard. For example, you might have to break your standard to integrate with an external library or web service. To stop PHP_CodeSniffer generating errors for this code, you can wrap it in special comments. PHP_CodeSniffer will then hide all errors and warnings that are generated for these lines of code.
8286

8387
```php
@@ -166,6 +170,7 @@ bar($foo,false);
166170

167171

168172
## Limiting Results to Specific Sniffs
173+
169174
By default, PHP_CodeSniffer will check your code using all sniffs in the specified standard. Sometimes you may want to find all occurrences of a single error to eliminate it more quickly, or to exclude sniffs to see if they are causing conflicts in your standard. PHP_CodeSniffer allows you to specify a list of sniffs to limit results to using the `--sniffs` command line argument, or a list of sniffs to exclude using the `--exclude` command line argument. Sniff codes are separated by commas.
170175

171176
> [!NOTE]
@@ -197,6 +202,7 @@ $ phpcs --standard=PEAR --exclude=Generic.PHP.LowerCaseConstant,PEAR.WhiteSpace.
197202

198203

199204
## Filtering Errors and Warnings Based on Severity
205+
200206
By default, PHP_CodeSniffer assigns a severity of 5 to all errors and warnings. Standards may change the severity of some messages so they are hidden by default or even so that they are raised to indicate greater importance. PHP_CodeSniffer allows you to decide what the minimum severity level must be to show a message in its report using the `--severity` command line argument.
201207

202208
To hide errors and warnings with a severity less than 3:
@@ -219,6 +225,7 @@ This feature is particularly useful during manual code reviews. During normal de
219225

220226

221227
## Replacing Tabs with Spaces
228+
222229
Most of the sniffs written for PHP_CodeSniffer do not support the usage of tabs for indentation and alignment. You can write your own sniffs that check for tabs instead of spaces, but you can also get PHP_CodeSniffer to convert your tabs into spaces before a file is checked. This allows you to use the existing space-based sniffs on your tab-based files.
223230

224231
In the following example, PHP_CodeSniffer will replace all tabs in the files being checked with between 1 and 4 spaces, depending on the column the tab indents to.
@@ -233,6 +240,7 @@ $ phpcs --tab-width=4 /path/to/code
233240

234241

235242
## Specifying an Encoding
243+
236244
By default, PHP_CodeSniffer will treat all source files as if they use UTF-8 encoding. If you need your source files to be processed using a specific encoding, you can specify the encoding using the `--encoding` command line argument.
237245
```bash
238246
$ phpcs --encoding=windows-1251 /path/to/code
@@ -242,6 +250,7 @@ $ phpcs --encoding=windows-1251 /path/to/code
242250

243251

244252
## Using a Bootstrap File
253+
245254
PHP_CodeSniffer can optionally include one or more custom bootstrap files before beginning the run. Bootstrap files are included after command line arguments and rulesets have been parsed, and right before files begin to process. These custom files may be used to perform such taks as manipulating the internal settings of PHP_CodeSniffer that are not exposed through command line arguments. Multiple bootstrap files are seperated by commas.
246255
```bash
247256
$ phpcs --bootstrap=/path/to/boostrap.1.inc,/path/to/bootstrap.2.inc /path/to/code
@@ -251,6 +260,7 @@ $ phpcs --bootstrap=/path/to/boostrap.1.inc,/path/to/bootstrap.2.inc /path/to/co
251260

252261

253262
## Using a Default Configuration File
263+
254264
If you run PHP_CodeSniffer without specifying a coding standard, PHP_CodeSniffer will look in the current directory, and all parent directories, for a file called either `.phpcs.xml`, `phpcs.xml`, `.phpcs.xml.dist`, or `phpcs.xml.dist`. If found, configuration information will be read from this file, including the files to check, the coding standard to use, and any command line arguments to apply.
255265

256266
> [!IMPORTANT]
@@ -265,6 +275,7 @@ The `phpcs.xml` file has exactly the same format as a normal [[ruleset.xml file|
265275

266276

267277
## Specifying php.ini Settings
278+
268279
PHP_CodeSniffer allows you to set temporary php.ini settings during a run using the `-d` command line argument. The name of the php.ini setting must be specified on the command line, but the value is optional. If no value is set, the php.ini setting will be given a value of TRUE.
269280

270281
```bash
@@ -281,6 +292,7 @@ $ phpcs -d memory_limit=32M -d include_path=.:/php/includes /path/to/code
281292

282293

283294
## Setting Configuration Options
295+
284296
PHP_CodeSniffer has some configuration options that can be set. Individual coding standards may also require configuration options to be set before functionality can be used. [[View a full list of configuration options|Configuration Options]].
285297

286298
To set a configuration option, use the `--config-set` command line argument.
@@ -302,6 +314,7 @@ $ phpcs --runtime-set <option> <value> /path/to/code
302314

303315

304316
## Deleting Configuration Options
317+
305318
PHP_CodeSniffer allows you to delete any configuration option, reverting it to its default value. [[View a full list of configuration options|Configuration Options]].
306319

307320
To delete a configuration option, use the `--config-delete` command line argument.
@@ -314,6 +327,7 @@ $ phpcs --config-delete <option>
314327

315328

316329
## Viewing Configuration Options
330+
317331
To view the currently set configuration options, use the `--config-show` command line argument.
318332

319333
```bash
@@ -329,13 +343,15 @@ Array
329343

330344

331345
## Printing Verbose Tokeniser Output
346+
332347
This feature is provided for debugging purposes only. Using this feature will dramatically increase screen output and script running time.
333348

334349
PHP_CodeSniffer contains multiple verbosity levels. Level 2 (indicated by the command line argument `-vv`) will print all verbosity information for level 1 (file specific token and line counts with running times) as well as verbose tokeniser output.
335350

336351
The output of the PHP_CodeSniffer tokeniser shows the step-by-step creation of the scope map and the level map.
337352

338353
### The Scope Map
354+
339355
The scope map is best explained with an example. For the following file:
340356

341357
```php
@@ -376,7 +392,8 @@ The scope map output above shows the following pieces of information about the f
376392

377393
The scope map output is most useful when debugging PHP_CodeSniffer's scope map, which is critically important to the successful checking of a file, but is also useful for checking the type of a particular token. For example, if you are unsure of the token type for an opening curly brace, the scope map output shows you that the type is T_OPEN_CURLY_BRACKET and not, for example, T_OPEN_CURLY_BRACE.
378394

379-
### The Level Map
395+
### The Level Map
396+
380397
The level map is best explained with an example. For the following file:
381398

382399
```php
@@ -427,6 +444,7 @@ The level map is most commonly used to determine indentation rules (e.g., a toke
427444

428445

429446
## Printing Verbose Token Processing Output
447+
430448
This feature is provided for debugging purposes only. Using this feature will dramatically increase screen output and script running time.
431449

432450
PHP_CodeSniffer contains multiple verbosity levels. Level 3 (indicated by the command line argument `-vvv`) will print all verbosity information for level 1 (file specific token and line counts with running times), level 2 (tokeniser output) as well as token processing output with sniff running times.
@@ -494,6 +512,7 @@ For example, the ScopeIndentSniff executes on the if statement's token only, but
494512

495513

496514
## Quieting Output
515+
497516
If a coding standard or configuration file includes settings to print progress or verbose output while running PHP_CodeSniffer, it can make it difficult to use the standard with automated checking tools and build scripts as these typically only expect an error report. If you have this problem, or just want less output, you can quieten the output of PHP_CodeSniffer by using the `-q` command line argument. When using this quiet mode, PHP_CodeSniffer will only print report output, and only if errors or warnings are found. No progress or verbose output will be printed.
498517

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

0 commit comments

Comments
 (0)