Skip to content

Commit 469edca

Browse files
committed
Add "back to top" links under each section
... on long pages which contain a table of contents.
1 parent c92f6f4 commit 469edca

File tree

6 files changed

+349
-9
lines changed

6 files changed

+349
-9
lines changed

wiki/Advanced-Usage.md

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ To check .php, .inc and .lib files:
2929

3030
$ phpcs --extensions=php,inc,lib /path/to/code
3131

32+
<p align="right"><a href="#table-of-contents">back to top</a></p>
33+
34+
3235
## Ignoring Files and Folders
3336
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.
3437

@@ -68,6 +71,9 @@ $xmlPackage->send();
6871
> [!NOTE]
6972
> The comment syntax note feature is only available from PHP_CodeSniffer version 3.2.0 onwards.
7073
74+
<p align="right"><a href="#table-of-contents">back to top</a></p>
75+
76+
7177
## Ignoring Parts of a File
7278
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.
7379

@@ -153,6 +159,9 @@ bar($foo,false);
153159
> [!NOTE]
154160
> The comment syntax note feature is only available from PHP_CodeSniffer version 3.2.0 onwards.
155161
162+
<p align="right"><a href="#table-of-contents">back to top</a></p>
163+
164+
156165
## Limiting Results to Specific Sniffs
157166
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.
158167

@@ -170,6 +179,9 @@ The following example will run all sniffs in the PEAR standard except for the tw
170179
> [!WARNING]
171180
> If you use both the `--sniffs` and `--exclude` command line arguments together, the `--exclude` list will be ignored.
172181
182+
<p align="right"><a href="#table-of-contents">back to top</a></p>
183+
184+
173185
## Filtering Errors and Warnings Based on Severity
174186
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.
175187

@@ -187,6 +199,9 @@ Setting the severity of warnings to `0` is the same as using the `-n` command li
187199

188200
This feature is particularly useful during manual code reviews. During normal development, or an automated build, you may want to only check code formatting issues. But while during a code review, you may wish to show less severe errors and warnings that may need manual peer review.
189201

202+
<p align="right"><a href="#table-of-contents">back to top</a></p>
203+
204+
190205
## Replacing Tabs with Spaces
191206
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.
192207

@@ -197,16 +212,25 @@ In the following example, PHP_CodeSniffer will replace all tabs in the files bei
197212
> [!NOTE]
198213
> The [included sniff](https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php) that enforces space indentation will still generate errors even if you have replaced tabs with spaces using the `--tab-width` setting. This sniff looks at the unmodified version of the code to check line indentation and so must be disabled in a [[custom ruleset.xml file|Annotated ruleset]] if you want to use tab indentation.
199214
215+
<p align="right"><a href="#table-of-contents">back to top</a></p>
216+
217+
200218
## Specifying an Encoding
201219
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.
202220

203221
$ phpcs --encoding=windows-1251 /path/to/code
204222

223+
<p align="right"><a href="#table-of-contents">back to top</a></p>
224+
225+
205226
## Using a Bootstrap File
206227
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.
207228

208229
$ phpcs --bootstrap=/path/to/boostrap.1.inc,/path/to/bootstrap.2.inc /path/to/code
209230

231+
<p align="right"><a href="#table-of-contents">back to top</a></p>
232+
233+
210234
## Using a Default Configuration File
211235
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.
212236

@@ -218,6 +242,9 @@ The `phpcs.xml` file has exactly the same format as a normal [[ruleset.xml file|
218242
> [!NOTE]
219243
> An example `phpcs.xml` file can be found in the PHP_CodeSniffer repository: [phpcs.xml.dist](https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xml.dist)
220244
245+
<p align="right"><a href="#table-of-contents">back to top</a></p>
246+
247+
221248
## Specifying php.ini Settings
222249
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.
223250

@@ -227,6 +254,9 @@ You can also specific multiple values:
227254

228255
$ phpcs -d memory_limit=32M -d include_path=.:/php/includes /path/to/code
229256

257+
<p align="right"><a href="#table-of-contents">back to top</a></p>
258+
259+
230260
## Setting Configuration Options
231261
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]].
232262

@@ -241,14 +271,19 @@ Configuration options are written to a global configuration file. If you want to
241271
> [!NOTE]
242272
> Not all configuration options can be set using the `--runtime-set` command line argument. Configuration options that provide defaults for command line arguments, such as the default standard or report type, can not be used with `--runtime-set`. To set these values for a single run only, use the dedicated CLI arguments that PHP_CodeSniffer provides. The [[Configuration Options|Configuration Options]] list provides an alternative CLI argument for each configuration option not supported by `--runtime-set`.
243273
274+
<p align="right"><a href="#table-of-contents">back to top</a></p>
275+
276+
244277
## Deleting Configuration Options
245278
PHP_CodeSniffer allows you to delete any configuration option, reverting it to its default value. [[View a full list of configuration options|Configuration Options]].
246279

247280
To delete a configuration option, use the `--config-delete` command line argument.
248281

249282
$ phpcs --config-delete <option>
250283

251-
284+
<p align="right"><a href="#table-of-contents">back to top</a></p>
285+
286+
252287
## Viewing Configuration Options
253288
To view the currently set configuration options, use the `--config-show` command line argument.
254289

@@ -259,6 +294,9 @@ To view the currently set configuration options, use the `--config-show` command
259294
[zend_ca_path] => /path/to/ZendCodeAnalyzer
260295
)
261296

297+
<p align="right"><a href="#table-of-contents">back to top</a></p>
298+
299+
262300
## Printing Verbose Tokeniser Output
263301
This feature is provided for debugging purposes only. Using this feature will dramatically increase screen output and script running time.
264302

@@ -349,6 +387,9 @@ The level map output above shows the following pieces of information about the f
349387

350388
The level map is most commonly used to determine indentation rules (e.g., a token 4 levels deep requires 16 spaces of indentation) or to determine if a particular token is within a particular scope (e.g., a function keyword is within a class scope, making it a method).
351389

390+
<p align="right"><a href="#table-of-contents">back to top</a></p>
391+
392+
352393
## Printing Verbose Token Processing Output
353394
This feature is provided for debugging purposes only. Using this feature will dramatically increase screen output and script running time.
354395

@@ -410,5 +451,10 @@ The other interesting piece of information we get from the output above is that
410451

411452
For example, the ScopeIndentSniff executes on the if statement's token only, but actually checks the indentation of every line within the if statement. The sniff uses the scope map to find all tokens within the if statement.
412453

454+
<p align="right"><a href="#table-of-contents">back to top</a></p>
455+
456+
413457
## Quieting Output
414-
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.
458+
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.
459+
460+
<p align="right"><a href="#table-of-contents">back to top</a></p>

0 commit comments

Comments
 (0)