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-Developer-Upgrade-Guide.md
+36-1Lines changed: 36 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -482,7 +482,42 @@ The `protected` `getDeclarationNameWithNamespace()` and `getNamespaceOfScope()`
482
482
<palign="right"><ahref="#table-of-contents">back to top</a></p>
483
483
484
484
485
-
## Miscellaneous other changes which may affect code extending PHP_CodeSniffer
485
+
## Other changes which may affect code extending PHP_CodeSniffer
486
+
487
+
### Methods now have more parameter types
488
+
489
+
Previously a lot of the PHPCS methods already included parameter type declarations for classes and arrays.
490
+
Now support for PHP < 7.2 has been dropped, all method signatures have been reviewed and additional scalar and nullable parameter type declarations have been added.
491
+
492
+
As parameter types are contravariant, this is **_not_** a breaking change and overloaded methods in external standards and/or integrations which do not have the corresponding type declaration will not cause any errors.
493
+
494
+
**Upgrading**
495
+
496
+
This is typically one of those changes where no action should be taken until support for PHP_CodeSniffer 3.x will be dropped by the external standard and/or integration.
497
+
498
+
Only once support for PHP_CodeSniffer 3.x has been dropped, add the parameter type declarations.
499
+
500
+
The method signature changes which are expected to cause the most frequent updates, are as follows:
501
+
* `PHP_CodeSniffer\Sniffs\Sniff::process(File $phpcsFile, int $stackPtr)`
502
+
* `PHP_CodeSniffer\Sniffs\AbstractArraySniff::processSingleLineArray(File $phpcsFile, int $stackPtr, int $arrayStart, int $arrayEnd, array $indices)`
503
+
* `PHP_CodeSniffer\Sniffs\AbstractArraySniff::processMultiLineArray(File $phpcsFile, int $stackPtr, int $arrayStart, int $arrayEnd, array $indices)`
504
+
* `PHP_CodeSniffer\Sniffs\AbstractScopeSniff::processTokenWithinScope(File $phpcsFile, int $stackPtr, int $currScope)`
505
+
* `PHP_CodeSniffer\Sniffs\AbstractScopeSniff::processTokenOutsideScope(File $phpcsFile, int $stackPtr)`
506
+
* `PHP_CodeSniffer\Sniffs\AbstractVariableSniff::processMemberVar(File $phpcsFile, int $stackPtr)`
507
+
* `PHP_CodeSniffer\Sniffs\AbstractVariableSniff::processVariable(File $phpcsFile, int $stackPtr)`
508
+
* `PHP_CodeSniffer\Sniffs\AbstractVariableSniff::processVariableInString(File $phpcsFile, int $stackPtr)`
For a full list of parameter types added in the typical public API, please refer to [issue #390](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/390).
513
+
514
+
> [!TIP]
515
+
> For efficiency, you may want to add the [proposed _return_ type declarations which will be added in PHP_CodeSniffer 5.0](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/391) in one go.
516
+
517
+
<palign="right"><ahref="#table-of-contents">back to top</a></p>
518
+
519
+
520
+
### Miscellaneous other changes
486
521
487
522
* The `PHP_CodeSniffer\Config::setSettings()` method no longer returns any value.
488
523
It was always declared as a `void` method, but was previously returning the set value.
0 commit comments