Skip to content

Commit 5508b43

Browse files
committed
4.0 dev upgrade guide: add section about the new parameter types
As per the proposal in PHPCSStandards/PHP_CodeSniffer 390 and executed in PHPCSStandards/PHP_CodeSniffer 1237.
1 parent 36df624 commit 5508b43

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

wiki/Version-4.0-Developer-Upgrade-Guide.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,42 @@ The `protected` `getDeclarationNameWithNamespace()` and `getNamespaceOfScope()`
482482
<p align="right"><a href="#table-of-contents">back to top</a></p>
483483

484484

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)`
509+
* `PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest::getTestFiles(string $testFileBase)`
510+
* `PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest::setCliValues(string $filename, \PHP_CodeSniffer\Config $config)`
511+
512+
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+
<p align="right"><a href="#table-of-contents">back to top</a></p>
518+
519+
520+
### Miscellaneous other changes
486521

487522
* The `PHP_CodeSniffer\Config::setSettings()` method no longer returns any value.
488523
It was always declared as a `void` method, but was previously returning the set value.

0 commit comments

Comments
 (0)