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
4.0 | Wiki: updates for change of the default standard from PEAR to PSR12
Includes automating various output example blocks via the automated replacement mechanism.
:warning: This commit should only be merged AFTER the PHPCS 4.0 release! The code samples used for the auto-generated output are specifically crafted to give errors/warnings against PSR12, not against the PEAR standard. :warning:
Note: this also means that the artifact containing the preprocessed output will need to be regenerated after the PHPCS 4.0 release to get an accurate representation of the updated wiki pages.
Where auto-generated output blocks was not an option, like when the output block in the documentation only displays part of a larger output stream, the command used to manually update the existing output block has been added as an inline comment.
As for the "info" report, while this could be auto-generated using something like `{{COMMAND-OUTPUT "phpcs --parallel=1 --no-cache --no-colors --report-width=100 --report=info --basepath=build/wiki-code-samples build/wiki-code-samples/path/to/code/fileB.php build/wiki-code-samples/path/to/code/fileC.php"}}`, I believe the existing report example demonstrates the usecase for this report better, so I have deliberately not updated it.
Copy file name to clipboardExpand all lines: wiki/Configuration-Options.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@
7
7
8
8
## Setting the default coding standard
9
9
10
-
By default, PHP_CodeSniffer will use the PEAR coding standard if no standard is supplied on the command line. You can change the default standard by setting the `default_standard` configuration option.
10
+
By default, PHP_CodeSniffer will use the PSR12 coding standard if no standard is supplied on the command line. You can change the default standard by setting the `default_standard` configuration option.
> This configuration option cannot be set using the `--runtime-set` command line argument. To set the coding standard for a single run only, use the `--standard` command line argument.
18
18
19
+
> [!NOTE]
20
+
> Prior to PHP_CodeSniffer 4.0.0, PHP_CodeSniffer would default to the PEAR coding standard.
21
+
19
22
<palign="right"><ahref="#table-of-contents">back to top</a></p>
Copy file name to clipboardExpand all lines: wiki/Fixing-Errors-Automatically.md
+37-27Lines changed: 37 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,21 +12,8 @@ PHP_CodeSniffer is able to fix many errors and warnings automatically. The PHP C
12
12
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`, this will be annotated in the report with the `[x]` markings:
<palign="right"><ahref="#table-of-contents">back to top</a></p>
@@ -97,32 +84,55 @@ A TOTAL OF 984 ERRORS WERE FIXED IN 2 FILES
97
84
98
85
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:
99
86
87
+
<!--
88
+
Regenerate the below output snippet by running the following command:
E: [Line 3] PHP keywords must be lowercase; expected "namespace" but found "NAMESPACE" (Generic.PHP.LowerCaseKeyword.Found)
96
+
Generic.PHP.LowerCaseKeyword:76 replaced token 3 (T_NAMESPACE on line 3) "NAMESPACE" =>"namespace"
106
97
* fixed 1 violations, starting loop 2 *
107
98
*** END FILE FIXING ***
108
99
```
109
100
110
101
Sometimes the file may need to be processed multiple times in order to fix all the violations. This can happen when multiple sniffs need to modify the same part of a file, or if a fix causes a new sniff violation somewhere else in the standard. When this happens, the output will look like this:
111
102
103
+
<!--
104
+
Regenerate the below output snippet by running the following command:
Copy file name to clipboardExpand all lines: wiki/Home.md
+6-34Lines changed: 6 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,49 +6,21 @@ PHP_CodeSniffer is an essential development tool that ensures your code remains
6
6
7
7
A coding standard in PHP_CodeSniffer is a collection of sniff files. Each sniff file checks one part of the coding standard only. Each sniff can yield multiple error codes, a different one for each aspect of the code which was checked and found non-compliant.
8
8
9
-
Multiple coding standards can be used within PHP_CodeSniffer so that the one installation can be used across multiple projects. The default coding standard used by PHP_CodeSniffer is the PEAR coding standard.
9
+
Multiple coding standards can be used within PHP_CodeSniffer so that the one installation can be used across multiple projects.
10
+
As of PHP_CodeSniffer 4.0.0, the default coding standard used by PHP_CodeSniffer is the PSR12 coding standard (previously, this was the PEAR standard).
10
11
11
12
## Example
12
13
13
-
To check a file against the PEAR coding standard, simply specify the file's location.
14
+
To check a file against the PSR12 coding standard, simply specify the file's location.
0 commit comments