1 | <?php |
||
16 | class MultipleReturnSniff extends AbstractScopeSniff |
||
17 | { |
||
18 | /** |
||
19 | * Code for multiple returns. |
||
20 | * |
||
21 | * @var string CODE_MULTIPLE_RETURNS_FOUND |
||
22 | */ |
||
23 | public const CODE_MULTIPLE_RETURNS_FOUND = 'MultipleReturnsFound'; |
||
24 | |||
25 | /** |
||
26 | * Error message for multiple returns. |
||
27 | * |
||
28 | * @var string WARNING_MULTIPLE_RETURNS_FOUND |
||
29 | */ |
||
30 | private const WARNING_MULTIPLE_RETURNS_FOUND = 'Multiple returns detected. Did you refactor your class?'; |
||
31 | |||
32 | /** |
||
33 | * MultipleReturnSniff constructor. |
||
34 | */ |
||
35 | public function __construct() |
||
39 | |||
40 | /** |
||
41 | * Processes the tokens that this test is listening for. |
||
42 | * |
||
43 | * @param File $phpcsFile |
||
44 | * @param int $returnPos |
||
45 | * @param int $functionPos |
||
46 | * |
||
47 | * @return void |
||
48 | */ |
||
49 | protected function processTokenWithinScope(File $phpcsFile, $returnPos, $functionPos): void |
||
62 | |||
63 | /** |
||
64 | * Processes a token that is found outside the scope that this test is listening to. |
||
65 | * |
||
66 | * @param File $phpcsFile The file where this token was found. |
||
67 | * @param int $stackPtr The position in the stack where this token was found. |
||
68 | * |
||
69 | * @return void|int Optionally returns a stack pointer. The sniff will not be |
||
70 | * called again on the current file until the returned stack |
||
71 | * pointer is reached. Return (count($tokens) + 1) to skip |
||
72 | * the rest of the file. |
||
73 | */ |
||
74 | protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) |
||
79 | } |
||
80 |