Skip to content

Commit 84acf4e

Browse files
committed
Docs: improve type declarations
This commit addresses the `@return` tag for all sniff `register()` methods. Future commits may follow for other parts of the codebase. 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.
1 parent 5b9078f commit 84acf4e

File tree

205 files changed

+213
-213
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

205 files changed

+213
-213
lines changed

src/Sniffs/AbstractArraySniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ abstract class AbstractArraySniff implements Sniff
1919
/**
2020
* Returns an array of tokens this test wants to listen for.
2121
*
22-
* @return array
22+
* @return array<int|string>
2323
*/
2424
final public function register()
2525
{

src/Sniffs/AbstractPatternSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function __construct($ignoreComments=null)
7878
* Classes extending <i>AbstractPatternTest</i> should implement the
7979
* <i>getPatterns()</i> method to register the patterns they wish to test.
8080
*
81-
* @return int[]
81+
* @return array<int|string>
8282
* @see process()
8383
*/
8484
final public function register()

src/Sniffs/AbstractScopeSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function __construct(
104104
* DO NOT OVERRIDE THIS METHOD. Use the constructor of this class to register
105105
* for the desired tokens and scope.
106106
*
107-
* @return int[]
107+
* @return array<int|string>
108108
* @see __constructor()
109109
*/
110110
final public function register()

src/Sniffs/Sniff.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ interface Sniff
2828
*
2929
* <code>
3030
* return array(
31-
* T_WHITESPACE,
32-
* T_DOC_COMMENT,
33-
* T_COMMENT,
34-
* );
31+
* T_WHITESPACE,
32+
* T_DOC_COMMENT,
33+
* T_COMMENT,
34+
* );
3535
* </code>
3636
*
37-
* @return mixed[]
37+
* @return array<int|string>
3838
* @see Tokens.php
3939
*/
4040
public function register();

src/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class DisallowLongArraySyntaxSniff implements Sniff
1919
/**
2020
* Registers the tokens that this sniff wants to listen for.
2121
*
22-
* @return int[]
22+
* @return array<int|string>
2323
*/
2424
public function register()
2525
{

src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class DuplicateClassNameSniff implements Sniff
2626
/**
2727
* Registers the tokens that this sniff wants to listen for.
2828
*
29-
* @return int[]
29+
* @return array<int|string>
3030
*/
3131
public function register()
3232
{

src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class OpeningBraceSameLineSniff implements Sniff
1919
/**
2020
* Returns an array of tokens this test wants to listen for.
2121
*
22-
* @return array
22+
* @return array<int|string>
2323
*/
2424
public function register()
2525
{

src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class AssignmentInConditionSniff implements Sniff
4040
/**
4141
* Registers the tokens that this sniff wants to listen for.
4242
*
43-
* @return int[]
43+
* @return array<int|string>
4444
*/
4545
public function register()
4646
{

src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class EmptyPHPStatementSniff implements Sniff
2323
/**
2424
* Returns an array of tokens this test wants to listen for.
2525
*
26-
* @return int[]
26+
* @return array<int|string>
2727
*/
2828
public function register()
2929
{

src/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class EmptyStatementSniff implements Sniff
3434
/**
3535
* Registers the tokens that this sniff wants to listen for.
3636
*
37-
* @return int[]
37+
* @return array<int|string>
3838
*/
3939
public function register()
4040
{

src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ForLoopShouldBeWhileLoopSniff implements Sniff
3333
/**
3434
* Registers the tokens that this sniff wants to listen for.
3535
*
36-
* @return int[]
36+
* @return array<int|string>
3737
*/
3838
public function register()
3939
{

src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ForLoopWithTestFunctionCallSniff implements Sniff
3737
/**
3838
* Registers the tokens that this sniff wants to listen for.
3939
*
40-
* @return int[]
40+
* @return array<int|string>
4141
*/
4242
public function register()
4343
{

src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class JumbledIncrementerSniff implements Sniff
3939
/**
4040
* Registers the tokens that this sniff wants to listen for.
4141
*
42-
* @return int[]
42+
* @return array<int|string>
4343
*/
4444
public function register()
4545
{

src/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class UnconditionalIfStatementSniff implements Sniff
3737
/**
3838
* Registers the tokens that this sniff wants to listen for.
3939
*
40-
* @return int[]
40+
* @return array<int|string>
4141
*/
4242
public function register()
4343
{

src/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class UnnecessaryFinalModifierSniff implements Sniff
3232
/**
3333
* Registers the tokens that this sniff wants to listen for.
3434
*
35-
* @return int[]
35+
* @return array<int|string>
3636
*/
3737
public function register()
3838
{

src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class UnusedFunctionParameterSniff implements Sniff
6060
/**
6161
* Returns an array of tokens this test wants to listen for.
6262
*
63-
* @return array
63+
* @return array<int|string>
6464
*/
6565
public function register()
6666
{

src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class UselessOverridingMethodSniff implements Sniff
3232
/**
3333
* Registers the tokens that this sniff wants to listen for.
3434
*
35-
* @return int[]
35+
* @return array<int|string>
3636
*/
3737
public function register()
3838
{

src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class DocCommentSniff implements Sniff
3030
/**
3131
* Returns an array of tokens this test wants to listen for.
3232
*
33-
* @return array
33+
* @return array<int|string>
3434
*/
3535
public function register()
3636
{

src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class FixmeSniff implements Sniff
3131
/**
3232
* Returns an array of tokens this test wants to listen for.
3333
*
34-
* @return array
34+
* @return array<int|string>
3535
*/
3636
public function register()
3737
{

src/Standards/Generic/Sniffs/Commenting/TodoSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class TodoSniff implements Sniff
3030
/**
3131
* Returns an array of tokens this test wants to listen for.
3232
*
33-
* @return array
33+
* @return array<int|string>
3434
*/
3535
public function register()
3636
{

src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class DisallowYodaConditionsSniff implements Sniff
2121
/**
2222
* Returns an array of tokens this test wants to listen for.
2323
*
24-
* @return array
24+
* @return array<int|string>
2525
*/
2626
public function register()
2727
{

src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class InlineControlStructureSniff implements Sniff
3737
/**
3838
* Returns an array of tokens this test wants to listen for.
3939
*
40-
* @return array
40+
* @return array<int|string>
4141
*/
4242
public function register()
4343
{

src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class CSSLintSniff implements Sniff
2828
/**
2929
* Returns the token types that this sniff is interested in.
3030
*
31-
* @return int[]
31+
* @return array<int|string>
3232
*/
3333
public function register()
3434
{

src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ClosureLinterSniff implements Sniff
4444
/**
4545
* Returns the token types that this sniff is interested in.
4646
*
47-
* @return int[]
47+
* @return array<int|string>
4848
*/
4949
public function register()
5050
{

src/Standards/Generic/Sniffs/Debug/ESLintSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ESLintSniff implements Sniff
3535
/**
3636
* Returns the token types that this sniff is interested in.
3737
*
38-
* @return int[]
38+
* @return array<int|string>
3939
*/
4040
public function register()
4141
{

src/Standards/Generic/Sniffs/Debug/JSHintSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class JSHintSniff implements Sniff
2929
/**
3030
* Returns the token types that this sniff is interested in.
3131
*
32-
* @return int[]
32+
* @return array<int|string>
3333
*/
3434
public function register()
3535
{

src/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ByteOrderMarkSniff implements Sniff
3333
/**
3434
* Returns an array of tokens this test wants to listen for.
3535
*
36-
* @return array
36+
* @return array<int|string>
3737
*/
3838
public function register()
3939
{

src/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class EndFileNewlineSniff implements Sniff
3030
/**
3131
* Returns an array of tokens this test wants to listen for.
3232
*
33-
* @return array
33+
* @return array<int|string>
3434
*/
3535
public function register()
3636
{

src/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class EndFileNoNewlineSniff implements Sniff
3030
/**
3131
* Returns an array of tokens this test wants to listen for.
3232
*
33-
* @return array
33+
* @return array<int|string>
3434
*/
3535
public function register()
3636
{

src/Standards/Generic/Sniffs/Files/ExecutableFileSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ExecutableFileSniff implements Sniff
1919
/**
2020
* Returns an array of tokens this test wants to listen for.
2121
*
22-
* @return array
22+
* @return array<int|string>
2323
*/
2424
public function register()
2525
{

src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class InlineHTMLSniff implements Sniff
3232
/**
3333
* Returns an array of tokens this test wants to listen for.
3434
*
35-
* @return array
35+
* @return array<int|string>
3636
*/
3737
public function register()
3838
{

src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class LineEndingsSniff implements Sniff
3737
/**
3838
* Returns an array of tokens this test wants to listen for.
3939
*
40-
* @return array
40+
* @return array<int|string>
4141
*/
4242
public function register()
4343
{

src/Standards/Generic/Sniffs/Files/LineLengthSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class LineLengthSniff implements Sniff
5050
/**
5151
* Returns an array of tokens this test wants to listen for.
5252
*
53-
* @return array
53+
* @return array<int|string>
5454
*/
5555
public function register()
5656
{

src/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class LowercasedFilenameSniff implements Sniff
1919
/**
2020
* Returns an array of tokens this test wants to listen for.
2121
*
22-
* @return array
22+
* @return array<int|string>
2323
*/
2424
public function register()
2525
{

src/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class OneClassPerFileSniff implements Sniff
1919
/**
2020
* Returns an array of tokens this test wants to listen for.
2121
*
22-
* @return array
22+
* @return array<int|string>
2323
*/
2424
public function register()
2525
{

src/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class OneInterfacePerFileSniff implements Sniff
1919
/**
2020
* Returns an array of tokens this test wants to listen for.
2121
*
22-
* @return array
22+
* @return array<int|string>
2323
*/
2424
public function register()
2525
{

src/Standards/Generic/Sniffs/Files/OneObjectStructurePerFileSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class OneObjectStructurePerFileSniff implements Sniff
1919
/**
2020
* Returns an array of tokens this test wants to listen for.
2121
*
22-
* @return array
22+
* @return array<int|string>
2323
*/
2424
public function register()
2525
{

src/Standards/Generic/Sniffs/Files/OneTraitPerFileSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class OneTraitPerFileSniff implements Sniff
1919
/**
2020
* Returns an array of tokens this test wants to listen for.
2121
*
22-
* @return array
22+
* @return array<int|string>
2323
*/
2424
public function register()
2525
{

src/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class DisallowMultipleStatementsSniff implements Sniff
1919
/**
2020
* Returns an array of tokens this test wants to listen for.
2121
*
22-
* @return array
22+
* @return array<int|string>
2323
*/
2424
public function register()
2525
{

src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class MultipleStatementAlignmentSniff implements Sniff
5858
/**
5959
* Returns an array of tokens this test wants to listen for.
6060
*
61-
* @return array
61+
* @return array<int|string>
6262
*/
6363
public function register()
6464
{

src/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class NoSpaceAfterCastSniff implements Sniff
2323
/**
2424
* Returns an array of tokens this test wants to listen for.
2525
*
26-
* @return array
26+
* @return array<int|string>
2727
*/
2828
public function register()
2929
{

src/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class SpaceAfterCastSniff implements Sniff
3434
/**
3535
* Returns an array of tokens this test wants to listen for.
3636
*
37-
* @return array
37+
* @return array<int|string>
3838
*/
3939
public function register()
4040
{

src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class SpaceAfterNotSniff implements Sniff
4444
/**
4545
* Returns an array of tokens this test wants to listen for.
4646
*
47-
* @return array
47+
* @return array<int|string>
4848
*/
4949
public function register()
5050
{

0 commit comments

Comments
 (0)