Commit 0702073
committed
PHP 8.3 | Ruleset: fix deprecation notice
On PHP 8.3, using the `-e` (explain) command would show a `Deprecated: Increment on non-alphanumeric string is deprecated in path/to/src/Ruleset.php on line 297` notice after the very first sniff being listed.
As the `$lastCount` variable is used as a counter, it should have an integer default (start) value, not a text string.
Fixed now.
Testable via the command-line using the following command:
```bash
phpcs -e --standard=PSR1
```
Output without this fix:
```
The PSR1 standard contains 8 sniffs
Generic (4 sniffs)
------------------
Generic.Files.ByteOrderMark
Deprecated: Increment on non-alphanumeric string is deprecated in D:\000_GitHub\PHPCS\PHP_CodeSniffer\src\Ruleset.php on line 297
Generic.NamingConventions.UpperCaseConstantName
Generic.PHP.DisallowAlternativePHPTags
Generic.PHP.DisallowShortOpenTag
PSR1 (3 sniffs)
---------------
PSR1.Classes.ClassDeclaration
PSR1.Files.SideEffects
PSR1.Methods.CamelCapsMethodName
Squiz (1 sniff)
----------------
Squiz.Classes.ValidClassName
```
Output with this fix:
```
The PSR1 standard contains 8 sniffs
Generic (4 sniffs)
------------------
Generic.Files.ByteOrderMark
Generic.NamingConventions.UpperCaseConstantName
Generic.PHP.DisallowAlternativePHPTags
Generic.PHP.DisallowShortOpenTag
PSR1 (3 sniffs)
---------------
PSR1.Classes.ClassDeclaration
PSR1.Files.SideEffects
PSR1.Methods.CamelCapsMethodName
Squiz (1 sniff)
----------------
Squiz.Classes.ValidClassName
```
Note: yes, I'd like to add some tests for this, but it would be much easier to do so without the (partially unclosed) output buffers being created by this function, so I'm pulling this fix first and will refactor the method and add some tests at some point in the future.1 parent b0d171b commit 0702073
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
246 | | - | |
| 246 | + | |
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| |||
0 commit comments