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/Version-4.0-User-Upgrade-Guide.md
+15-15Lines changed: 15 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -36,8 +36,8 @@ There is a separate [[Upgrade Guide for Sniff Developers and Integrators|Version
36
36
37
37
It is highly recommended to upgrade as soon as you are able.
38
38
39
-
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.
40
-
This "limited support" will last a maximum of one year from the date of the PHP_Codesniffer 4.0.0 release.
39
+
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.
40
+
This "limited support" will last a maximum of one year from the date of the PHP_CodeSniffer 4.0.0 release.
41
41
42
42
### External Standards
43
43
@@ -72,7 +72,7 @@ If you want, you can even silence them by running PHP_CodeSniffer in quiet mode
72
72
73
73
### The minimum PHP version is now PHP 7.2.0
74
74
75
-
This has no impact on the "code under scan", it just means that when running PHP_CodeSniffer, the minimum PHP version needs to be PHP 7.2.
75
+
This has no impact on the "code under scan", it just means that when running PHP_CodeSniffer, the minimum PHP version needs to be PHP 7.2.
76
76
As an example, you can run PHP_CodeSniffer on PHP 8.4 to scan a code base which is supposed to run on PHP 5.6.
77
77
78
78
<palign="right"><ahref="#table-of-contents">back to top</a></p>
@@ -112,25 +112,25 @@ To continue running code style and code quality checks on JS and/or CSS files, u
112
112
#### Upgrading
113
113
114
114
There are two kinds of sniffs which are affected by this:
115
-
1. Sniffs which are specific to JS/CSS and only target JS/CSS code.
115
+
1. Sniffs which are specific to JS/CSS and only target JS/CSS code.
116
116
If you use JS/CSS specific sniffs from either PHP_CodeSniffer itself or from an external standard, remove references to these sniffs from your ruleset.
117
-
2. "Mixed" sniffs, i.e. sniffs which target both PHP as well as JS and/or CSS code.
117
+
2. "Mixed" sniffs, i.e. sniffs which target both PHP as well as JS and/or CSS code.
118
118
If an external standard you include in your ruleset contains these type of "mixed" sniffs, contact the maintainer of that standard about making the sniff compatible with PHP_CodeSniffer 4.0.
119
119
120
120
PHP_CodeSniffer >= 3.13.0 will show you deprecation notices for these sniffs to help you find them.
121
121
122
122
Secondly, review your `extensions` settings.
123
-
* If you have `extensions` set in a ruleset, like `<arg name="extensions" value="php,inc/php" />`, be sure to remove any non-PHP extensions.
123
+
* If you have `extensions` set in a ruleset, like `<arg name="extensions" value="php,inc/php" />`, be sure to remove any non-PHP extensions.
124
124
You can also remove the language part, i.e. `php,inc/php` becomes `php,inc`.
125
-
* Next, make sure to also check for any hard-coded commands which pass the `--extensions=...` CLI argument, like in continuous integration scripts.
125
+
* Next, make sure to also check for any hard-coded commands which pass the `--extensions=...` CLI argument, like in continuous integration scripts.
126
126
The same applies there: remove any non-PHP extensions and remove any potential language settings.
127
127
128
128
<palign="right"><ahref="#table-of-contents">back to top</a></p>
129
129
130
130
131
131
### Setting array properties for sniffs
132
132
133
-
PHP_CodeSniffer 3.3.0 introduced a new syntax to set the value of array properties for sniffs by specifying array elements using a new `element` tag with `key` and `value` attributes. The old syntax was deprecated in the same PHP_CodeSniffer version.
133
+
PHP_CodeSniffer 3.3.0 introduced a new syntax to set the value of array properties for sniffs by specifying array elements using a new `element` tag with `key` and `value` attributes. The old syntax was deprecated in the same PHP_CodeSniffer version.
134
134
Support for the old syntax has been removed in PHP_CodeSniffer 4.0.0.
135
135
136
136
#### Upgrading
@@ -190,7 +190,7 @@ If you haven't done so already, search your `[.]phpcs.xml[.dist]` file for...
190
190
191
191
### Removed error codes
192
192
193
-
As of PHP_CodeSniffer 4.0, PHP_CodeSniffer will no longer throw warnings about potential parse errors.
193
+
As of PHP_CodeSniffer 4.0, PHP_CodeSniffer will no longer throw warnings about potential parse errors.
194
194
This was only done in a few places anyway, while the vast majority of sniffs would try to silently ignore code with parse errors.
195
195
196
196
> [!NOTE]
@@ -291,7 +291,7 @@ If you haven't done so already, execute a search & replace on your code base.
291
291
292
292
The exit codes used by PHP_CodeSniffer have changed. This change was made primarily to allow for `phpcbf` to exit with a `0` exit code if all fixable issues were fixed and there are no non-auto-fixable issues remaining.
293
293
294
-
The pre-existing [`ignore_warnings_on_exit`](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Configuration-Options#ignoring-warnings-when-generating-the-exit-code) and [`ignore_errors_on_exit`](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Configuration-Options#ignoring-errors-when-generating-the-exit-code) config flags will still be respected.
294
+
The pre-existing [`ignore_warnings_on_exit`](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Configuration-Options#ignoring-warnings-when-generating-the-exit-code) and [`ignore_errors_on_exit`](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Configuration-Options#ignoring-errors-when-generating-the-exit-code) config flags will still be respected.
295
295
Additionally, you can now use the new `ignore_non_auto_fixable_on_exit` config flag to ignore non-auto-fixable issues when the exit code is generated.
296
296
297
297
#### Upgrading
@@ -309,8 +309,8 @@ Just before the final 4.0.0 release, the PHP_CodeSniffer `master` branch will be
309
309
310
310
##### Referencing the PHP_CodeSniffer XSD file for rulesets
311
311
312
-
If your ruleset includes a reference to the PHP_CodeSniffer XSD file via a URL, that URL will become invalid.
313
-
As of mid May 2025, the current PHP_CodeSniffer ruleset XSD file can be referenced via the following permalink: `https://schema.phpcodesniffer.com/phpcs.xsd`.
312
+
If your ruleset includes a reference to the PHP_CodeSniffer XSD file via a URL, that URL will become invalid.
313
+
As of mid May 2025, the current PHP_CodeSniffer ruleset XSD file can be referenced via the following permalink: `https://schema.phpcodesniffer.com/phpcs.xsd`.
314
314
Permalinks to the XSD file for specific minors are also available in the following format: `https://schema.phpcodesniffer.com/#.#/phpcs.xsd`.
315
315
316
316
Example changeset:
@@ -325,7 +325,7 @@ Relative file references like `xsi:noNamespaceSchemaLocation="./vendor/squizlabs
325
325
326
326
##### Referencing the main branches in the repo
327
327
328
-
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.
328
+
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.
329
329
What to update these to, depends on your use-case.
330
330
331
331
* If you want to use the latest development version of PHP_CodeSniffer, use the `4.x` branch. For Composer, references to the branch will need to look like this: `4.x-dev`.
@@ -367,7 +367,7 @@ Previously a ruleset could already "extend" an array property for a sniff set by
367
367
368
368
As of PHP_CodeSniffer 4.0, a ruleset can also "extend" the default value of an array property as set in the sniff itself.
369
369
370
-
The upside of this is, that if you want to default value + some extras, you no longer need to duplicate the default values from sniff array properties in your ruleset.
370
+
The upside of this is, that if you want to default value + some extras, you no longer need to duplicate the default values from sniff array properties in your ruleset.
371
371
The downside is, of course, that if the default value of the property in the sniff changes, your scans may start failing without warning.
372
372
373
373
#### Upgrading
@@ -403,7 +403,7 @@ Now you can "inherit" the default value and add to it by using `extend="true"`:
403
403
<palign="right"><ahref="#table-of-contents">back to top</a></p>
404
404
405
405
406
-
### My scans are failing on a "No files were checked" error...
406
+
### My scans are failing on a "No files were checked" error
407
407
408
408
Between the extension filtering via `--extensions=...` (CLI) / `<arg name="extensions" value="..."/>` (ruleset), potential `--ignore=...` (CLI) / `<exclude-pattern>...` (ruleset) directives being followed, and potential `--filter=...` directives, there are no files eligible for scanning.
0 commit comments