1 | <?php |
||
23 | class PHPCompatibility_Sniffs_PHP_NewAnonymousClassesSniff extends PHPCompatibility_Sniff |
||
|
|||
24 | { |
||
25 | |||
26 | /** |
||
27 | * Tokens which in various PHP versions indicate the `class` keyword. |
||
28 | * |
||
29 | * The dedicated anonymous class token is added from the `register()` |
||
30 | * method if the token is available. |
||
31 | * |
||
32 | * @var array |
||
33 | */ |
||
34 | private $indicators = array( |
||
35 | T_CLASS => T_CLASS, |
||
36 | ); |
||
37 | |||
38 | /** |
||
39 | * Returns an array of tokens this test wants to listen for. |
||
40 | * |
||
41 | * @return array |
||
42 | */ |
||
43 | 3 | public function register() |
|
44 | { |
||
45 | 3 | if (defined('T_ANON_CLASS')) { |
|
46 | 3 | $this->indicators[T_ANON_CLASS] = T_ANON_CLASS; |
|
47 | 3 | } |
|
48 | |||
49 | 3 | return array(T_NEW); |
|
50 | }//end register() |
||
51 | |||
52 | |||
53 | /** |
||
54 | * Processes this test, when one of its tokens is encountered. |
||
55 | * |
||
56 | * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. |
||
57 | * @param int $stackPtr The position of the current token in the |
||
58 | * stack passed in $tokens. |
||
59 | * |
||
60 | * @return void |
||
61 | */ |
||
62 | 2 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
|
82 | |||
83 | |||
84 | }//end class |
||
85 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.