1 | <?php |
||
16 | class SingleObjectOperatorSniff implements Sniff |
||
17 | { |
||
18 | /** |
||
19 | * Error message when found more then one object operator per line. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | const ERROR_NOT_SINGLE_OBJECT_OPERATOR_STATEMENT = 'Only one object operator per line allowed'; |
||
24 | |||
25 | /** |
||
26 | * Code when found more then one object operator per line. |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | const CODE_NOT_SINGLE_OBJECT_OPERATOR_STATEMENT = 'NotSingleObjectOperatorStatement'; |
||
31 | |||
32 | /** |
||
33 | * Registers the tokens that this sniff wants to listen for. |
||
34 | * |
||
35 | * @return int[] List of tokens to listen for |
||
36 | */ |
||
37 | public function register(): array |
||
43 | |||
44 | /** |
||
45 | * Called when one of the token types that this sniff is listening for is found. |
||
46 | * |
||
47 | * @param File $phpcsFile The PHP_CodeSniffer file where the token was found. |
||
48 | * @param int $stackPtr The position in the PHP_CodeSniffer file's token stack where the token was found. |
||
49 | * |
||
50 | * @return void|int Optionally returns a stack pointer. |
||
51 | */ |
||
52 | public function process(File $phpcsFile, $stackPtr) |
||
70 | |||
71 | /** |
||
72 | * Check if given position of object operator is valid |
||
73 | * |
||
74 | * @param array $tokens |
||
75 | * @param int $stackPtr |
||
76 | * |
||
77 | * @return bool |
||
78 | */ |
||
79 | private function isValidOperator($tokens, $stackPtr) |
||
104 | } |
||
105 |