1 | <?php |
||
19 | class PHPCompatibility_Sniffs_PHP_NewMagicMethodsSniff extends PHPCompatibility_Sniff |
||
|
|||
20 | { |
||
21 | |||
22 | /** |
||
23 | * A list of new magic methods, not considered magic in older versions. |
||
24 | * |
||
25 | * Method names in the array should be all *lowercase*. |
||
26 | * The array lists : version number with false (not magic) or true (magic). |
||
27 | * If's sufficient to list the first version where the method became magic. |
||
28 | * |
||
29 | * @var array(string => array(string => int|string|null)) |
||
30 | */ |
||
31 | protected $newMagicMethods = array( |
||
32 | '__get' => array( // verified |
||
33 | '4.4' => false, |
||
34 | '5.0' => true, |
||
35 | ), |
||
36 | |||
37 | '__isset' => array( // verified |
||
38 | '5.0' => false, |
||
39 | '5.1' => true, |
||
40 | ), |
||
41 | '__unset' => array( // verified |
||
42 | '5.0' => false, |
||
43 | '5.1' => true, |
||
44 | ), |
||
45 | '__set_state' => array( // verified |
||
46 | '5.0' => false, |
||
47 | '5.1' => true, |
||
48 | ), |
||
49 | |||
50 | '__callstatic' => array( // verified |
||
51 | '5.2' => false, |
||
52 | '5.3' => true, |
||
53 | ), |
||
54 | '__invoke' => array( // verified |
||
55 | '5.2' => false, |
||
56 | '5.3' => true, |
||
57 | ), |
||
58 | |||
59 | '__debuginfo' => array( // verified |
||
60 | '5.5' => false, |
||
61 | '5.6' => true, |
||
62 | ), |
||
63 | |||
64 | // Special case - only became properly magical in 5.2.0, |
||
65 | // before that it was only called for echo and print. |
||
66 | '__tostring' => array( |
||
67 | '5.1' => false, |
||
68 | '5.2' => true, |
||
69 | 'message' => 'The method %s() was not truly magical in PHP version %s and earlier. The associated magic functionality will only be called when directly combined with echo or print.', |
||
70 | ), |
||
71 | ); |
||
72 | |||
73 | |||
74 | /** |
||
75 | * Returns an array of tokens this test wants to listen for. |
||
76 | * |
||
77 | * @return array |
||
78 | */ |
||
79 | public function register() |
||
84 | |||
85 | |||
86 | /** |
||
87 | * Processes this test, when one of its tokens is encountered. |
||
88 | * |
||
89 | * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. |
||
90 | * @param int $stackPtr The position of the current token in the |
||
91 | * stack passed in $tokens. |
||
92 | * |
||
93 | * @return void |
||
94 | */ |
||
95 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
||
130 | |||
131 | }//end class |
||
132 |
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.