1 | <?php |
||
8 | class FunctionNameContainsAndOrSniff implements PHP_CodeSniffer_Sniff |
||
9 | { |
||
10 | |||
11 | /** |
||
12 | * The forbidden strings this sniff looks for. |
||
13 | * @var array |
||
14 | */ |
||
15 | protected $keywords = ['And', '_and', 'Or', '_or']; |
||
16 | |||
17 | /** |
||
18 | * Returns the token types that this sniff is interested in. |
||
19 | * @return array |
||
20 | */ |
||
21 | public function register() |
||
25 | |||
26 | /** |
||
27 | * Processes the tokens that this sniff is interested in. |
||
28 | * |
||
29 | * @param PHP_CodeSniffer_File $phpcsFile The file where the token was found. |
||
30 | * @param integer $stackPtr The position in the stack where |
||
31 | * the token was found. |
||
32 | * @return void |
||
33 | */ |
||
34 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
||
46 | |||
47 | /** |
||
48 | * Determines if the provided $string contains any of the |
||
49 | * strings in the $this->keywords property. |
||
50 | * @param string $string The string to check. |
||
51 | * @return boolean |
||
52 | */ |
||
53 | protected function containsKeywords($string) |
||
63 | |||
64 | /** |
||
65 | * Checks if the $haystack contains the $needle. |
||
66 | * @param string $needle Needle string. |
||
67 | * @param string $haystack Haystack string. |
||
68 | * @return boolean |
||
69 | */ |
||
70 | protected function contains($needle, $haystack) |
||
74 | |||
75 | /** |
||
76 | * Gets the error message for this sniff. |
||
77 | * @return string |
||
78 | */ |
||
79 | protected function getErrorMessage() |
||
83 | } |
||
84 |