1 | <?php |
||
23 | class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff |
||
|
|||
24 | extends PHPCompatibility_AbstractRemovedFeatureSniff |
||
25 | { |
||
26 | /** |
||
27 | * A list of functions to whitelist, if any. |
||
28 | * |
||
29 | * This is intended for projects using functions which start with the same |
||
30 | * prefix as one of the removed extensions. |
||
31 | * |
||
32 | * This property can be set from the ruleset, like so: |
||
33 | * <rule ref="PHPCompatibility.PHP.RemovedExtensions"> |
||
34 | * <properties> |
||
35 | * <property name="functionWhitelist" type="array" value="mysql_to_rfc3339,mysql_another_function" /> |
||
36 | * </properties> |
||
37 | * </rule> |
||
38 | * |
||
39 | * @var array |
||
40 | */ |
||
41 | public $functionWhitelist; |
||
42 | |||
43 | /** |
||
44 | * A list of removed extensions with their alternative, if any |
||
45 | * |
||
46 | * The array lists : version number with false (deprecated) and true (removed). |
||
47 | * If's sufficient to list the first version where the extension was deprecated/removed. |
||
48 | * |
||
49 | * @var array(string|null) |
||
50 | */ |
||
51 | protected $removedExtensions = array( |
||
52 | 'activescript' => array( |
||
53 | '5.1' => true, |
||
54 | 'alternative' => 'pecl/activescript' |
||
55 | ), |
||
56 | 'cpdf' => array( |
||
57 | '5.1' => true, |
||
58 | 'alternative' => 'pecl/pdflib' |
||
59 | ), |
||
60 | 'dbase' => array( |
||
61 | '5.3' => true, |
||
62 | 'alternative' => null |
||
63 | ), |
||
64 | 'dbx' => array( |
||
65 | '5.1' => true, |
||
66 | 'alternative' => 'pecl/dbx' |
||
67 | ), |
||
68 | 'dio' => array( |
||
69 | '5.1' => true, |
||
70 | 'alternative' => 'pecl/dio' |
||
71 | ), |
||
72 | 'ereg' => array( |
||
73 | '5.3' => false, |
||
74 | '7.0' => true, |
||
75 | 'alternative' => 'pcre' |
||
76 | ), |
||
77 | 'fam' => array( |
||
78 | '5.1' => true, |
||
79 | 'alternative' => null |
||
80 | ), |
||
81 | 'fbsql' => array( |
||
82 | '5.3' => true, |
||
83 | 'alternative' => null |
||
84 | ), |
||
85 | 'fdf' => array( |
||
86 | '5.3' => true, |
||
87 | 'alternative' => 'pecl/fdf' |
||
88 | ), |
||
89 | 'filepro' => array( |
||
90 | '5.2' => true, |
||
91 | 'alternative' => null |
||
92 | ), |
||
93 | 'hw_api' => array( |
||
94 | '5.2' => true, |
||
95 | 'alternative' => null |
||
96 | ), |
||
97 | 'ingres' => array( |
||
98 | '5.1' => true, |
||
99 | 'alternative' => 'pecl/ingres' |
||
100 | ), |
||
101 | 'ircg' => array( |
||
102 | '5.1' => true, |
||
103 | 'alternative' => null |
||
104 | ), |
||
105 | 'mcrypt' => array( |
||
106 | '7.1' => false, |
||
107 | 'alternative' => 'openssl (preferred) or pecl/mcrypt once available' |
||
108 | ), |
||
109 | 'mcve' => array( |
||
110 | '5.1' => true, |
||
111 | 'alternative' => 'pecl/mvce' |
||
112 | ), |
||
113 | 'ming' => array( |
||
114 | '5.3' => true, |
||
115 | 'alternative' => 'pecl/ming' |
||
116 | ), |
||
117 | 'mnogosearch' => array( |
||
118 | '5.1' => true, |
||
119 | 'alternative' => null |
||
120 | ), |
||
121 | 'msql' => array( |
||
122 | '5.3' => true, |
||
123 | 'alternative' => null |
||
124 | ), |
||
125 | 'mssql' => array( |
||
126 | '7.0' => true, |
||
127 | 'alternative' => null |
||
128 | ), |
||
129 | 'mysql_' => array( |
||
130 | '5.5' => false, |
||
131 | '7.0' => true, |
||
132 | 'alternative' => 'mysqli', |
||
133 | ), |
||
134 | 'ncurses' => array( |
||
135 | '5.3' => true, |
||
136 | 'alternative' => 'pecl/ncurses' |
||
137 | ), |
||
138 | 'oracle' => array( |
||
139 | '5.1' => true, |
||
140 | 'alternative' => 'oci8 or pdo_oci' |
||
141 | ), |
||
142 | 'ovrimos' => array( |
||
143 | '5.1' => true, |
||
144 | 'alternative' => null |
||
145 | ), |
||
146 | 'pfpro' => array( |
||
147 | '5.3' => true, |
||
148 | 'alternative' => null |
||
149 | ), |
||
150 | 'sqlite' => array( |
||
151 | '5.4' => true, |
||
152 | 'alternative' => null |
||
153 | ), |
||
154 | // Has to be before `sybase` as otherwise it will never match. |
||
155 | 'sybase_ct' => array( |
||
156 | '7.0' => true, |
||
157 | 'alternative' => null |
||
158 | ), |
||
159 | 'sybase' => array( |
||
160 | '5.3' => true, |
||
161 | 'alternative' => 'sybase_ct' |
||
162 | ), |
||
163 | 'w32api' => array( |
||
164 | '5.1' => true, |
||
165 | 'alternative' => 'pecl/ffi' |
||
166 | ), |
||
167 | 'yp' => array( |
||
168 | '5.1' => true, |
||
169 | 'alternative' => null |
||
170 | ), |
||
171 | ); |
||
172 | |||
173 | /** |
||
174 | * Returns an array of tokens this test wants to listen for. |
||
175 | * |
||
176 | * @return array |
||
177 | */ |
||
178 | public function register() |
||
186 | |||
187 | /** |
||
188 | * Processes this test, when one of its tokens is encountered. |
||
189 | * |
||
190 | * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. |
||
191 | * @param int $stackPtr The position of the current token in the |
||
192 | * stack passed in $tokens. |
||
193 | * |
||
194 | * @return void |
||
195 | */ |
||
196 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
||
251 | |||
252 | |||
253 | /** |
||
254 | * Is the current function being checked whitelisted ? |
||
255 | * |
||
256 | * Parsing the list late as it may be provided as a property, but also inline. |
||
257 | * |
||
258 | * @param string $content Content of the current token. |
||
259 | * |
||
260 | * @return bool |
||
261 | */ |
||
262 | protected function isWhiteListed($content) { |
||
283 | |||
284 | |||
285 | /** |
||
286 | * Get the relevant sub-array for a specific item from a multi-dimensional array. |
||
287 | * |
||
288 | * @param array $itemInfo Base information about the item. |
||
289 | * |
||
290 | * @return array Version and other information about the item. |
||
291 | */ |
||
292 | public function getItemArray(array $itemInfo) |
||
296 | |||
297 | |||
298 | /** |
||
299 | * Get the error message template for this sniff. |
||
300 | * |
||
301 | * @return string |
||
302 | */ |
||
303 | protected function getErrorMsgTemplate() |
||
307 | |||
308 | |||
309 | }//end class |
||
310 |
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.