1 | <?php |
||
15 | class MultipleReturnSniff extends AbstractScopeSniff |
||
16 | { |
||
17 | /** |
||
18 | * Code for multiple returns. |
||
19 | * |
||
20 | * @var string CODE_MULTIPLE_RETURNS_FOUND |
||
21 | */ |
||
22 | public const CODE_MULTIPLE_RETURNS_FOUND = 'MultipleReturnsFound'; |
||
23 | |||
24 | /** |
||
25 | * Error message for multiple returns. |
||
26 | * |
||
27 | * @var string WARNING_MULTIPLE_RETURNS_FOUND |
||
28 | */ |
||
29 | public const WARNING_MULTIPLE_RETURNS_FOUND = 'Multiple returns detected. Did you refactor your class?'; |
||
30 | |||
31 | /** |
||
32 | * MultipleReturnSniff constructor. |
||
33 | */ |
||
34 | public function __construct() |
||
38 | |||
39 | /** |
||
40 | * Processes the tokens that this test is listening for. |
||
41 | * |
||
42 | * @param File $phpcsFile |
||
43 | * @param $functionPos |
||
44 | * @param $classPos |
||
45 | * |
||
46 | * @return void |
||
47 | */ |
||
48 | protected function processTokenWithinScope(File $phpcsFile, $functionPos, $classPos): void |
||
56 | |||
57 | /** |
||
58 | * Throws a warning. |
||
59 | * |
||
60 | * @param File $phpcsFile The file to test. |
||
61 | * @param int $stackPtr Position where to throw the warning. |
||
62 | * |
||
63 | * @return void |
||
64 | */ |
||
65 | private static function throwWarning(File $phpcsFile, $stackPtr): void |
||
74 | |||
75 | /** |
||
76 | * Processes a token that is found outside the scope that this test is listening to. |
||
77 | * |
||
78 | * @param File $phpcsFile The file where this token was found. |
||
79 | * @param int $stackPtr The position in the stack where this token was found. |
||
80 | * |
||
81 | * @return void|int Optionally returns a stack pointer. The sniff will not be |
||
82 | * called again on the current file until the returned stack |
||
83 | * pointer is reached. Return (count($tokens) + 1) to skip |
||
84 | * the rest of the file. |
||
85 | */ |
||
86 | protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) |
||
89 | } |
||
90 |