1 | <?php |
||
16 | class EqualOperatorSniff extends AbstractSniff |
||
17 | { |
||
18 | /** |
||
19 | * Code when an equal operator was found. |
||
20 | * |
||
21 | * @var CODE_EQUAL_OPERATOR_FOUND string |
||
22 | */ |
||
23 | public const CODE_EQUAL_OPERATOR_FOUND = 'EqualOperatorFound'; |
||
24 | |||
25 | /** |
||
26 | * Warning when an equal operator was found. |
||
27 | * |
||
28 | * @var WARNING_EQUAL_OPERATOR_FOUND string |
||
29 | */ |
||
30 | public const WARNING_EQUAL_OPERATOR_FOUND = ' |
||
31 | An "Equal"-operator (==) was found. You should use the "Identical"-operator (===). |
||
32 | '; |
||
33 | |||
34 | /** |
||
35 | * Find the T_IS_EQUAL token and add a warning. |
||
36 | * |
||
37 | * @param File $phpcsFile |
||
38 | * @param int $stackPtr |
||
39 | * |
||
40 | * @return void |
||
41 | */ |
||
42 | private function findToken(File $phpcsFile, int $stackPtr): void |
||
58 | |||
59 | /** |
||
60 | * Processes the token. |
||
61 | * |
||
62 | * @param File $phpcsFile |
||
|
|||
63 | * @param int $stackPtr |
||
64 | * |
||
65 | * @return void |
||
66 | */ |
||
67 | protected function processToken(): void |
||
71 | |||
72 | /** |
||
73 | * Registers the tokens that this sniff wants to listen for. |
||
74 | * |
||
75 | * An example return value for a sniff that wants to listen for whitespace |
||
76 | * and any comments would be: |
||
77 | * |
||
78 | * <code> |
||
79 | * return array( |
||
80 | * T_WHITESPACE, |
||
81 | * T_DOC_COMMENT, |
||
82 | * T_COMMENT, |
||
83 | * ); |
||
84 | * </code> |
||
85 | * |
||
86 | * @return int[] |
||
87 | * @see Tokens.php |
||
88 | */ |
||
89 | public function register(): array |
||
93 | |||
94 | /** |
||
95 | * Replace token with the T_IS_IDENTIAL token. |
||
96 | * |
||
97 | * @param File $phpcsFile |
||
98 | * @param int $stackPtr |
||
99 | * |
||
100 | * @return void |
||
101 | */ |
||
102 | private function replaceToken(File $phpcsFile, int $stackPtr): void |
||
108 | } |
||
109 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.