You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: wiki/About-Standards-for-PHP_CodeSniffer.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,14 +26,14 @@ The typical differences between project-specific rulesets and standards are:
26
26
| Will automatically be used when no standard is provided on the command line ? | Yes | No |
27
27
| Can have custom sniffs ? | No | Yes |
28
28
| Can be installed ? | No | Yes |
29
-
|Reusability by other projects ?| Limited | Yes |
29
+
|Re-usability by other projects ? | Limited | Yes |
30
30
31
-
For optimal reusability, it is in most cases a good idea for a standard to be in its own repository and to be maintained as a separate project.
31
+
For optimal re-usability, it is in most cases a good idea for a standard to be in its own repository and to be maintained as a separate project.
32
32
33
33
A `[.]phpcs.xml[.dist]` file and a `ruleset.xml` file can largely contain the same type of directives.
34
34
The [Annotated ruleset](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Annotated-Ruleset) page contains information on all the directives you can use.
35
35
36
-
Keep in mind that for a _standard_ to be optimally reusable, it should not contain project specific information, such as `<file>` directives or `<exclude-patterns>`, while a project specific `[.]phpcs.xml[.dist]` ruleset file _can_ contain that information.
36
+
Keep in mind that for a _standard_ to be optimally re-usable, it should not contain project specific information, such as `<file>` directives or `<exclude-patterns>`, while a project specific `[.]phpcs.xml[.dist]` ruleset file _can_ contain that information.
37
37
38
38
You may also find the [Customisable Sniff Properties](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties) page a handy reference for customisations which can be made to PHP_CodeSniffer native sniffs.
39
39
@@ -245,7 +245,7 @@ use PHP_CodeSniffer\Sniffs\Sniff;
245
245
class OperatorSpacingSniff implements Sniff {...}
246
246
```
247
247
248
-
:x: Not following the required directory structure (missing `[CategoryName]`subdirectory):
248
+
:x: Not following the required directory structure (missing `[CategoryName]`sub-directory):
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.
245
+
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 tasks as manipulating the internal settings of PHP_CodeSniffer that are not exposed through command line arguments. Multiple bootstrap files are separated by commas.
<palign="right"><ahref="#table-of-contents">back to top</a></p>
@@ -334,13 +334,13 @@ Array
334
334
<palign="right"><ahref="#table-of-contents">back to top</a></p>
335
335
336
336
337
-
## Printing Verbose Tokeniser Output
337
+
## Printing Verbose Tokenizer Output
338
338
339
339
This feature is provided for debugging purposes only. Using this feature will dramatically increase screen output and script running time.
340
340
341
-
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.
341
+
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 tokenizer output.
342
342
343
-
The output of the PHP_CodeSniffer tokeniser shows the step-by-step creation of the scope map and the level map.
343
+
The output of the PHP_CodeSniffer tokenizer shows the step-by-step creation of the scope map and the level map.
344
344
345
345
### The Scope Map
346
346
@@ -439,7 +439,7 @@ The level map is most commonly used to determine indentation rules (e.g., a toke
439
439
440
440
This feature is provided for debugging purposes only. Using this feature will dramatically increase screen output and script running time.
441
441
442
-
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.
442
+
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 (tokenizer output) as well as token processing output with sniff running times.
443
443
444
444
The token processing output is best explained with an example. For the following file:
Copy file name to clipboardExpand all lines: wiki/Coding-Standard-Tutorial.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -128,7 +128,7 @@ final class DisallowHashCommentsSniff implements Sniff
128
128
}
129
129
```
130
130
131
-
By default, PHP_CodeSniffer assumes all sniffs are designed to check PHP code only. You can specify a list of tokenizers that your sniff supports, allowing it to be used wth PHP, JavaScript or CSS files, or any combination of the three. You do this by setting the `$supportedTokenizers` property in your sniff. Adding the following code to your sniff will tell PHP_CodeSniffer that it can be used to check both PHP and JavaScript code:
131
+
By default, PHP_CodeSniffer assumes all sniffs are designed to check PHP code only. You can specify a list of tokenizers that your sniff supports, allowing it to be used with PHP, JavaScript or CSS files, or any combination of the three. You do this by setting the `$supportedTokenizers` property in your sniff. Adding the following code to your sniff will tell PHP_CodeSniffer that it can be used to check both PHP and JavaScript code:
## Ignoring non-auto-fixable issues when generating the exit code (PHP_CodeSniffer >= 4.0.0)
220
220
221
-
By default, PHP_CodeSniffer will exit with a non-zero code if any errors or warnings are found, whethere these are auto-fixable or not.
222
-
If you want to display non-autofixable errors and warnings to the user, but still return with a zero exit code if non-auto-fixable issues are found, you can set the `ignore_non_auto_fixable_on_exit` configuration option.
221
+
By default, PHP_CodeSniffer will exit with a non-zero code if any errors or warnings are found, whether these are auto-fixable or not.
222
+
If you want to display non-auto-fixable errors and warnings to the user, but still return with a zero exit code if non-auto-fixable issues are found, you can set the `ignore_non_auto_fixable_on_exit` configuration option.
223
223
This option is typically used by automated build tools so that a `phpcbf` run can exit with `0`if it fixed all fixable issues, but there are still some non-auto-fixable issues remaining.
Copy file name to clipboardExpand all lines: wiki/Customisable-Sniff-Properties.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -911,7 +911,7 @@ $rootNode
911
911
->end()
912
912
->end();
913
913
```
914
-
If you want to allow mutli-level indenting, set the `multilevel` property to `true`. This will allow each line to be indented 1 more or 1 less level than the previous line, while still ensuring that all lines are indented at least once.
914
+
If you want to allow multi-level indenting, set the `multilevel` property to `true`. This will allow each line to be indented 1 more or 1 less level than the previous line, while still ensuring that all lines are indented at least once.
> 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`.
336
+
> 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/` sub-directory to the Windows system `PATH`.
337
337
338
338
<p align="right"><a href="#table-of-contents">back to top</a></p>
339
339
340
340
341
341
## Printing an Emacs Report
342
342
343
-
PHP_CodeSniffer can output a report in a format the compiler built into the GNU Emacs text editor can understand. This lets you use the built-in complier to run PHP_CodeSniffer on a file you are editing and navigate between errors and warnings within the file. To print an Emacs report, use the `--report=emacs` command line argument. The output will look like this:
343
+
PHP_CodeSniffer can output a report in a format the compiler built into the GNU Emacs text editor can understand. This lets you use the built-in compiler to run PHP_CodeSniffer on a file you are editing and navigate between errors and warnings within the file. To print an Emacs report, use the `--report=emacs` command line argument. The output will look like this:
344
344
345
345
```bash
346
346
$ phpcs --report=emacs /path/to/code
@@ -368,7 +368,7 @@ Now you can use the compile command and associated shortcuts to move between err
368
368
369
369
## Printing a Git Blame Report
370
370
371
-
PHP_CodeSniffer can make use of the `git blame` command to try and determine who committed each error and warning to a Git respository. To print a Git Blame report, use the `--report=gitblame` command line argument. The output will look like this:
371
+
PHP_CodeSniffer can make use of the `git blame` command to try and determine who committed each error and warning to a Git repository. To print a Git Blame report, use the `--report=gitblame` command line argument. The output will look like this:
372
372
373
373
```bash
374
374
$ phpcs --report=gitblame /path/to/code
@@ -556,7 +556,7 @@ PHP_CodeSniffer can output a sniff performance report showing you which sniffs i
556
556
When the `--colors` option is enabled, sniffs which take more than twice the average run time per sniff will be displayed in orange and sniffs with a cumulative listener run time of more than three times the average run time per sniff will display in red.
557
557
558
558
> [!NOTE]
559
-
> The Performance report will only be useful when run without using the cache as otherwise the cache functionality will interfer with accurately measuring the runtime of sniffs.
559
+
> The Performance report will only be useful when run without using the cache as otherwise the cache functionality will interfere with accurately measuring the runtime of sniffs.
560
560
> So make sure to always use the `--no-cache` feature when running Performance reports.
Copy file name to clipboardExpand all lines: wiki/Version-3.0-Upgrade-Guide.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -280,7 +280,7 @@ public function generate(
280
280
281
281
### Supporting Concurrency
282
282
283
-
PHP_CodeSniffer version 3 supports processing multiple files concurrently, so reports can no longer rely on getting file results one at a time. Reports that used to write to local member vars can no longer do so as multiple forks of the PHP_CodeSniffer process will all be writing to a different instance of the report class at the same time and these cache values will never be merged. Instead, reports need to output their cached data directly. They will later be given a chance to read in the entire cached output and generate a final clean report.
283
+
PHP_CodeSniffer version 3 supports processing multiple files concurrently, so reports can no longer rely on getting file results one at a time. Reports that used to write to local member variables can no longer do so as multiple forks of the PHP_CodeSniffer process will all be writing to a different instance of the report class at the same time and these cache values will never be merged. Instead, reports need to output their cached data directly. They will later be given a chance to read in the entire cached output and generate a final clean report.
284
284
285
285
> [!NOTE]
286
286
> Reports that output content in a way where the order or formatting is not important do not need to worry about caching data and can continue to produce reports they way they do now. Examples of these reports include the CSV report and the XML report.
Copy file name to clipboardExpand all lines: wiki/Version-4.0-Developer-Upgrade-Guide.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ There is a separate [[Upgrade Guide for Ruleset Maintainers and End-Users|Versio
24
24
It is highly recommended to upgrade external standards and integrations as soon as you are able.
25
25
26
26
Once PHP_CodeSniffer 4.0 has been released, the PHP_CodeSniffer 3.x branch will no longer receive updates, with the exception of security fixes and runtime compatibility fixes for new PHP versions.
27
-
This "limited support" will last a maximum of one year from the date of the PHP_Codesniffer 4.0.0 release.
27
+
This "limited support" will last a maximum of one year from the date of the PHP_CodeSniffer 4.0.0 release.
28
28
29
29
> [!IMPORTANT]
30
30
> This also means that support for new PHP syntaxes will only land in PHP_CodeSniffer 4.x and will **NOT** be backported to the 3.x branch.
@@ -36,9 +36,9 @@ There are basically two upgrade strategies:
36
36
1. Drop support for PHP_CodeSniffer 3.x completely and adopt support for PHP_CodeSniffer 4.x.
37
37
2. Make your package cross-version compatible with both PHP_CodeSniffer 3.x as well as 4.x.
38
38
39
-
Which strategy is best suited for your project will depend on your userbase.
39
+
Which strategy is best suited for your project will depend on your user-base.
40
40
41
-
If your userbase is known to often combine multiple external standards, making the package PHPCS cross-version compatible may be preferred to allow users to upgrade as soon as possible, while still benefitting from updates to your package if they can't upgrade to PHPCS 4.x yet.
41
+
If your user-base is known to often combine multiple external standards, making the package PHPCS cross-version compatible may be preferred to allow users to upgrade as soon as possible, while still benefiting from updates to your package if they can't upgrade to PHPCS 4.x yet.
42
42
43
43
The vast majority of the below upgrade tasks will need to be executed in both cases, but there are some upgrade tasks which can only be executed once support for PHP_CodeSniffer 3.x is being dropped.
44
44
@@ -276,7 +276,7 @@ The following tokens have been removed:
276
276
277
277
If these tokens are used in PHP-only sniffs, they can be safely removed.
278
278
If these tokens are used in JS/CSS only sniffs, as mentioned in ["Support for JS/CSS has been removed"](#support-for-jscss-has-been-removed): deprecate or remove the sniff.
279
-
If these tokens are used in mixed sniffs, which also scan PHP files, remove the CSS/JS specific code or, for cross-version compatibility, check for the existance of the tokens before using them.
279
+
If these tokens are used in mixed sniffs, which also scan PHP files, remove the CSS/JS specific code or, for cross-version compatibility, check for the existence of the tokens before using them.
280
280
281
281
<p align="right"><a href="#table-of-contents">back to top</a></p>
Copy file name to clipboardExpand all lines: wiki/Version-4.0-User-Upgrade-Guide.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ There is a separate [[Upgrade Guide for Sniff Developers and Integrators|Version
20
20
It is highly recommended to upgrade as soon as you are able.
21
21
22
22
The PHP_CodeSniffer 3.x branch will no longer receive updates, with the exception of security fixes and runtime compatibility fixes for new PHP versions.
23
-
This "limited support" will last a maximum of one year from the date of the PHP_Codesniffer 4.0.0 release.
23
+
This "limited support" will last a maximum of one year from the date of the PHP_CodeSniffer 4.0.0 release.
24
24
25
25
### External Standards
26
26
@@ -284,7 +284,7 @@ CI scripts or git pre-commit hooks may be checking explicitly for specific exit
284
284
<palign="right"><ahref="#table-of-contents">back to top</a></p>
285
285
286
286
287
-
### [Upcoming] Branch rename in the PHP_CodeSniffer repo
287
+
### [Upcoming] Branch rename in the PHP_CodeSniffer repository
288
288
289
289
Just before the final 4.0.0 release, the PHP_CodeSniffer `master` branch will be renamed to `3.x` and the default branch will change to `4.x`.
290
290
@@ -306,7 +306,7 @@ Example changeset:
306
306
307
307
Relative file references like `xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd"` will continue to be valid.
308
308
309
-
##### Referencing the main branches in the repo
309
+
##### Referencing the main branches in the repository
310
310
311
311
If you reference a development version of PHP_CodeSniffer in your `composer.json` file or in CI scripts, those references will need to be updated.
312
312
What to update these to, depends on your use-case.
0 commit comments