Skip to content

Commit 7d5bdc9

Browse files
committed
Update/add table of contents for various pages
Generated table of contents using https://bitdowntoc.derlin.ch/ Includes adding additional "back to top" links.
1 parent 63c8f1b commit 7d5bdc9

8 files changed

+72
-10
lines changed

wiki/About-Standards-for-PHP_CodeSniffer.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
* [Creating an external standard for PHP_CodeSniffer](#creating-an-external-standard-for-php_codesniffer)
66
* [Creating new rules](#creating-new-rules)
77
* [Naming conventions](#naming-conventions)
8+
* [1. Directory structure](#1-directory-structure)
9+
* [2. Sniff file name](#2-sniff-file-name)
10+
* [3. Namespace and class name](#3-namespace-and-class-name)
11+
* [Examples](#examples)
812

913
***
1014

wiki/Advanced-Usage.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* [Deleting Configuration Options](#deleting-configuration-options)
1515
* [Viewing Configuration Options](#viewing-configuration-options)
1616
* [Printing Verbose Tokeniser Output](#printing-verbose-tokeniser-output)
17+
* [The Scope Map](#the-scope-map)
18+
* [The Level Map](#the-level-map)
1719
* [Printing Verbose Token Processing Output](#printing-verbose-token-processing-output)
1820
* [Quieting Output](#quieting-output)
1921

wiki/Configuration-Options.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,5 @@ The Zend coding standard [includes a sniff](https://github.com/PHPCSStandards/PH
314314
```bash
315315
$ phpcs --config-set zend_ca_path /path/to/ZendCodeAnalyzer
316316
```
317+
318+
<p align="right"><a href="#table-of-contents">back to top</a></p>

wiki/Customisable-Sniff-Properties.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ For more information about changing sniff behaviour by customising your ruleset,
44

55
## Table of contents
66

7-
* Generic Sniffs
7+
* [Generic Sniffs](#generic-sniffs)
88
* [Generic.Arrays.ArrayIndent](#genericarraysarrayindent)
99
* [Generic.CodeAnalysis.UnusedFunctionParameter](#genericcodeanalysisunusedfunctionparameter)
1010
* [Generic.ControlStructures.InlineControlStructure](#genericcontrolstructuresinlinecontrolstructure)
@@ -26,7 +26,7 @@ For more information about changing sniff behaviour by customising your ruleset,
2626
* [Generic.WhiteSpace.ArbitraryParenthesesSpacing](#genericwhitespacearbitraryparenthesesspacing)
2727
* [Generic.WhiteSpace.ScopeIndent](#genericwhitespacescopeindent)
2828
* [Generic.WhiteSpace.SpreadOperatorSpacingAfter](#genericwhitespacespreadoperatorspacingafter)
29-
* PEAR Sniffs
29+
* [PEAR Sniffs](#pear-sniffs)
3030
* [PEAR.Commenting.FunctionComment](#pearcommentingfunctioncomment)
3131
* [PEAR.ControlStructures.ControlSignature](#pearcontrolstructurescontrolsignature)
3232
* [PEAR.ControlStructures.MultiLineCondition](#pearcontrolstructuresmultilinecondition)
@@ -36,18 +36,18 @@ For more information about changing sniff behaviour by customising your ruleset,
3636
* [PEAR.WhiteSpace.ObjectOperatorIndent](#pearwhitespaceobjectoperatorindent)
3737
* [PEAR.WhiteSpace.ScopeClosingBrace](#pearwhitespacescopeclosingbrace)
3838
* [PEAR.WhiteSpace.ScopeIndent](#pearwhitespacescopeindent)
39-
* PSR2 Sniffs
39+
* [PSR2 Sniffs](#psr2-sniffs)
4040
* [PSR2.Classes.ClassDeclaration](#psr2classesclassdeclaration)
4141
* [PSR2.ControlStructures.ControlStructureSpacing](#psr2controlstructurescontrolstructurespacing)
4242
* [PSR2.ControlStructures.SwitchDeclaration](#psr2controlstructuresswitchdeclaration)
4343
* [PSR2.Methods.FunctionCallSignature](#psr2methodsfunctioncallsignature)
44-
* PSR12 Sniffs
44+
* [PSR12 Sniffs](#psr12-sniffs)
4545
* [PSR12.Classes.AnonClassDeclaration](#psr12classesanonclassdeclaration)
4646
* [PSR12.ControlStructures.BooleanOperatorPlacement](#psr12controlstructuresbooleanoperatorplacement)
4747
* [PSR12.ControlStructures.ControlStructureSpacing](#psr12controlstructurescontrolstructurespacing)
4848
* [PSR12.Namespaces.CompoundNamespaceDepth](#psr12namespacescompoundnamespacedepth)
4949
* [PSR12.Operators.OperatorSpacing](#psr12operatorsoperatorspacing)
50-
* Squiz Sniffs
50+
* [Squiz Sniffs](#squiz-sniffs)
5151
* [Squiz.Classes.ClassDeclaration](#squizclassesclassdeclaration)
5252
* [Squiz.Commenting.FunctionComment](#squizcommentingfunctioncomment)
5353
* [Squiz.Commenting.LongConditionClosingComment](#squizcommentinglongconditionclosingcomment)

wiki/FAQ.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
1+
## Table of contents
2+
3+
* [Does PHP_CodeSniffer perform any code coverage or unit testing?](#does-php_codesniffer-perform-any-code-coverage-or-unit-testing)
4+
* [My code is fine! Why do I need PHP_CodeSniffer?](#my-code-is-fine-why-do-i-need-php_codesniffer)
5+
* [Does PHP_CodeSniffer parse my code to ensure it will execute?](#does-php_codesniffer-parse-my-code-to-ensure-it-will-execute)
6+
* [I don't agree with your coding standards! Can I make PHP_CodeSniffer enforce my own?](#i-dont-agree-with-your-coding-standards-can-i-make-php_codesniffer-enforce-my-own)
7+
* [How come PHP_CodeSniffer reported errors, I fixed them, now I get even more?](#how-come-php_codesniffer-reported-errors-i-fixed-them-now-i-get-even-more)
8+
* [What does PHP_CodeSniffer use to tokenize my code?](#what-does-php_codesniffer-use-to-tokenize-my-code)
9+
10+
***
11+
112
## Does PHP_CodeSniffer perform any code coverage or unit testing?
213

314
No. PHP_CodeSniffer is not a tool for testing that your PHP application works correctly. All PHP_CodeSniffer will do is ensure your PHP code meets the standards that you are following.
415

16+
<p align="right"><a href="#table-of-contents">back to top</a></p>
17+
18+
519
## My code is fine! Why do I need PHP_CodeSniffer?
620

721
Maybe you don't, but if you want to ensure you adhere to a set of coding standards, PHP_CodeSniffer is a quick and easy way to do that. PHP_CodeSniffer is a replacement for the more manual task of checking coding standards in code reviews. With PHP_CodeSniffer, you can reserve code reviews for the checking of code correctness.
822

923
Coding standards are a good thing. They will make your code easier to read and maintain, especially when multiple developers are working on the same application. Consider using coding standards if you don't already.
1024

25+
<p align="right"><a href="#table-of-contents">back to top</a></p>
26+
27+
1128
## Does PHP_CodeSniffer parse my code to ensure it will execute?
1229

1330
No. PHP_CodeSniffer does not actually parse your code, and so cannot accurately tell if your code contains parse errors. PHP_CodeSniffer does know about some parse errors and will warn you if it finds code that it is unable to sniff correctly due to a suspected parse error. However, as there is no actual parsing taking place, PHP_CodeSniffer may return an incorrect number of errors when checking code that does contain parse errors.
@@ -19,18 +36,29 @@ $ php -l /path/to/code/myfile.inc
1936
No syntax errors detected in /path/to/code/myfile.inc
2037
```
2138

39+
<p align="right"><a href="#table-of-contents">back to top</a></p>
40+
41+
2242
## I don't agree with your coding standards! Can I make PHP_CodeSniffer enforce my own?
2343

2444
Yes. At its core, PHP_CodeSniffer is just a framework for enforcing coding standards. PHP_CodeSniffer is released with some sample coding standards to help developers get started on projects where there is no standard defined. If you want to write your own standard, read the tutorial on creating coding standards.
2545

46+
<p align="right"><a href="#table-of-contents">back to top</a></p>
47+
48+
2649
## How come PHP_CodeSniffer reported errors, I fixed them, now I get even more?
2750

2851
Sometimes, errors mask the existence of other errors, or new errors are created as you fix others. For example, PHP_CodeSniffer might tell you that an inline IF statement needs to be defined with braces. Once you make this change, PHP_CodeSniffer may report that the braces you added are not correctly aligned.
2952

3053
Always run PHP_CodeSniffer until you get a passing result. Once you've made the changes PHP_CodeSniffer recommends, run PHP_CodeSniffer again to ensure no new errors have been added.
3154

55+
<p align="right"><a href="#table-of-contents">back to top</a></p>
56+
57+
3258
## What does PHP_CodeSniffer use to tokenize my code?
3359

3460
For PHP files, PHP_CodeSniffer uses [PHP's inbuilt tokenizer functions](http://www.php.net/tokenizer) to parse your code. It then modifies that output to include much more data about the file, such as matching function braces to function keywords.
3561

3662
For all other file types, PHP_CodeSniffer includes a custom tokenizer that either makes use of PHP's inbuilt tokenizer or emulates it. In both cases, the token array must be checked and changed manually before all the standard PHP_CodeSniffer matching rules are applied, making tokenizing a bit slower for these file types.
63+
64+
<p align="right"><a href="#table-of-contents">back to top</a></p>

wiki/Fixing-Errors-Automatically.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
PHP_CodeSniffer is able to fix many errors and warnings automatically. The `diff` report can be used to generate a diff that can be applied using the `patch` command. Alternatively, the PHP Code Beautifier and Fixer (`phpcbf`) can be used in place of `phpcs` to automatically generate and apply the diff for you.
1+
## Table of contents
2+
3+
* [About Automatic Fixing](#about-automatic-fixing)
4+
* [Printing a Diff Report](#printing-a-diff-report)
5+
* [Using the PHP Code Beautifier and Fixer](#using-the-php-code-beautifier-and-fixer)
6+
* [Viewing Debug Information](#viewing-debug-information)
7+
8+
***
9+
10+
## About Automatic Fixing
11+
12+
PHP_CodeSniffer is able to fix many errors and warnings automatically. The `diff` report can be used to generate a diff that can be applied using the `patch` command. Alternatively, the PHP Code Beautifier and Fixer (`phpcbf`) can be used instead of `phpcs` to automatically generate and apply the diff for you.
213

314
Screen-based reports, such as the [full](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Reporting#printing-full-and-summary-reports), [summary](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Reporting#printing-full-and-summary-reports) and [source](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Reporting#printing-a-source-report) reports, provide information about how many errors and warnings are found. If any of the issues can be fixed automatically by `phpcbf`, additional information will be printed:
415

@@ -20,6 +31,9 @@ PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
2031
--------------------------------------------------------------------------------
2132
```
2233

34+
<p align="right"><a href="#table-of-contents">back to top</a></p>
35+
36+
2337
## Printing a Diff Report
2438

2539
PHP_CodeSniffer can output a diff file that can be applied using the `patch` command. The suggested changes will fix some of the sniff violations that are present in the source code. To print a diff report, use the `--report=diff` command line argument. The output will look like this:
@@ -53,6 +67,9 @@ patching file /path/to/code/file.php
5367
> [!NOTE]
5468
> The `*nix` `diff` command is required for generating reports in `diff` format. Windows users may need to ensure that the `diff` command is available by either installing [DiffUtils](http://gnuwin32.sourceforge.net/packages/diffutils.htm) or, if available, adding the Git `/usr/bin/` subdirectory to the Windows system `PATH`.
5569
70+
<p align="right"><a href="#table-of-contents">back to top</a></p>
71+
72+
5673
## Using the PHP Code Beautifier and Fixer
5774
5875
To automatically fix as many sniff violations as possible, use the `phpcbf` command in place of the `phpcs` command. While most of the PHPCS command line arguments can be used by PHPCBF, some are specific to reporting and will be ignored. Running PHPCBF with the `-h` or `--help` command line arguments will print a list of commands that PHPCBF will respond to. The output of `phpcbf -h` is shown below.
@@ -157,6 +174,9 @@ Fixed 2 files
157174
Time: 2.55 secs, Memory: 25.00Mb
158175
```
159176
177+
<p align="right"><a href="#table-of-contents">back to top</a></p>
178+
179+
160180
## Viewing Debug Information
161181
162182
To see the fixes that are being made to a file, specify the `-vv` command line argument when generating a diff report. There is quite a lot of debug output concerning the standard being used and the tokenizing of the file, but the end of the output will look like this:
@@ -189,3 +209,5 @@ Squiz_Sniffs_WhiteSpace_OperatorSpacingSniff (line 259) replaced token 4 (T_EQUA
189209
* fixed 1 violations, starting loop 3 *
190210
*** END FILE FIXING ***
191211
```
212+
213+
<p align="right"><a href="#table-of-contents">back to top</a></p>

wiki/Usage.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,3 +327,5 @@ Squiz (1 sniff)
327327
---------------
328328
Squiz.Classes.ValidClassName
329329
```
330+
331+
<p align="right"><a href="#table-of-contents">back to top</a></p>

wiki/Version-3.0-Upgrade-Guide.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ PHP_CodeSniffer version 3 contains a large number of core changes and breaks bac
1313
* [AbstractVariableSniff](#abstractvariablesniff)
1414
* [AbstractPatternSniff](#abstractpatternsniff)
1515
* [AbstractScopeSniff](#abstractscopesniff)
16-
* [New Class Names](#new-class-names)
17-
* [PHP_CodeSniffer_File](#php_codesniffer_file)
18-
* [PHP_CodeSniffer_Tokens](#php_codesniffer_tokens)
19-
* [PHP_CodeSniffer](#php_codesniffer)
16+
* [New Class Names](#new-class-names)
17+
* [PHP_CodeSniffer_File](#php_codesniffer_file)
18+
* [PHP_CodeSniffer_Tokens](#php_codesniffer_tokens)
19+
* [PHP_CodeSniffer](#php_codesniffer)
2020
* [Upgrading Unit Tests](#upgrading-unit-tests)
2121
* [Setting CLI Values](#setting-cli-values)
2222
* [Upgrading Custom Reports](#upgrading-custom-reports)
@@ -337,3 +337,5 @@ foreach ($lines as $line) {
337337
...
338338
}
339339
```
340+
341+
<p align="right"><a href="#table-of-contents">back to top</a></p>

0 commit comments

Comments
 (0)