Skip to content

Commit

Permalink
Docs: improve type declarations
Browse files Browse the repository at this point in the history
This initial commit addresses the `@return` tag for all sniff `register()` methods.

PHP native tokens will always be integers.
PHP_CodeSniffer polyfilled and PHP_CodeSniffer native tokens will always be strings.

While some sniffs only return one or the other, I've chosen to update these tags to be the same across all sniffs for consistency.
  • Loading branch information
jrfnl committed Dec 26, 2023
1 parent 5b9078f commit d56f5d3
Show file tree
Hide file tree
Showing 205 changed files with 213 additions and 213 deletions.
2 changes: 1 addition & 1 deletion src/Sniffs/AbstractArraySniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ abstract class AbstractArraySniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
final public function register()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Sniffs/AbstractPatternSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function __construct($ignoreComments=null)
* Classes extending <i>AbstractPatternTest</i> should implement the
* <i>getPatterns()</i> method to register the patterns they wish to test.
*
* @return int[]
* @return array<int|string>
* @see process()
*/
final public function register()
Expand Down
2 changes: 1 addition & 1 deletion src/Sniffs/AbstractScopeSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function __construct(
* DO NOT OVERRIDE THIS METHOD. Use the constructor of this class to register
* for the desired tokens and scope.
*
* @return int[]
* @return array<int|string>
* @see __constructor()
*/
final public function register()
Expand Down
10 changes: 5 additions & 5 deletions src/Sniffs/Sniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ interface Sniff
*
* <code>
* return array(
* T_WHITESPACE,
* T_DOC_COMMENT,
* T_COMMENT,
* );
* T_WHITESPACE,
* T_DOC_COMMENT,
* T_COMMENT,
* );
* </code>
*
* @return mixed[]
* @return array<int|string>
* @see Tokens.php
*/
public function register();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DisallowLongArraySyntaxSniff implements Sniff
/**
* Registers the tokens that this sniff wants to listen for.
*
* @return int[]
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DuplicateClassNameSniff implements Sniff
/**
* Registers the tokens that this sniff wants to listen for.
*
* @return int[]
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class OpeningBraceSameLineSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class AssignmentInConditionSniff implements Sniff
/**
* Registers the tokens that this sniff wants to listen for.
*
* @return int[]
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class EmptyPHPStatementSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return int[]
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class EmptyStatementSniff implements Sniff
/**
* Registers the tokens that this sniff wants to listen for.
*
* @return int[]
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ForLoopShouldBeWhileLoopSniff implements Sniff
/**
* Registers the tokens that this sniff wants to listen for.
*
* @return int[]
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ForLoopWithTestFunctionCallSniff implements Sniff
/**
* Registers the tokens that this sniff wants to listen for.
*
* @return int[]
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class JumbledIncrementerSniff implements Sniff
/**
* Registers the tokens that this sniff wants to listen for.
*
* @return int[]
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class UnconditionalIfStatementSniff implements Sniff
/**
* Registers the tokens that this sniff wants to listen for.
*
* @return int[]
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class UnnecessaryFinalModifierSniff implements Sniff
/**
* Registers the tokens that this sniff wants to listen for.
*
* @return int[]
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class UnusedFunctionParameterSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class UselessOverridingMethodSniff implements Sniff
/**
* Registers the tokens that this sniff wants to listen for.
*
* @return int[]
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DocCommentSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
public function register()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class FixmeSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
public function register()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Standards/Generic/Sniffs/Commenting/TodoSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TodoSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class DisallowYodaConditionsSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class InlineControlStructureSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
public function register()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CSSLintSniff implements Sniff
/**
* Returns the token types that this sniff is interested in.
*
* @return int[]
* @return array<int|string>
*/
public function register()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ClosureLinterSniff implements Sniff
/**
* Returns the token types that this sniff is interested in.
*
* @return int[]
* @return array<int|string>
*/
public function register()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Standards/Generic/Sniffs/Debug/ESLintSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ESLintSniff implements Sniff
/**
* Returns the token types that this sniff is interested in.
*
* @return int[]
* @return array<int|string>
*/
public function register()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Standards/Generic/Sniffs/Debug/JSHintSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class JSHintSniff implements Sniff
/**
* Returns the token types that this sniff is interested in.
*
* @return int[]
* @return array<int|string>
*/
public function register()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ByteOrderMarkSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
public function register()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class EndFileNewlineSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class EndFileNoNewlineSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
public function register()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Standards/Generic/Sniffs/Files/ExecutableFileSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ExecutableFileSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
public function register()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class InlineHTMLSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
public function register()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class LineEndingsSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
public function register()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Standards/Generic/Sniffs/Files/LineLengthSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class LineLengthSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class LowercasedFilenameSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class OneClassPerFileSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class OneInterfacePerFileSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class OneObjectStructurePerFileSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class OneTraitPerFileSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DisallowMultipleStatementsSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class MultipleStatementAlignmentSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class NoSpaceAfterCastSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SpaceAfterCastSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
public function register()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SpaceAfterNotSniff implements Sniff
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
* @return array<int|string>
*/
public function register()
{
Expand Down
Loading

0 comments on commit d56f5d3

Please sign in to comment.