@@ -50,375 +50,375 @@ |
||
50 | 50 | class ForbiddenThisUseContextsSniff extends Sniff |
51 | 51 | { |
52 | 52 | |
53 | - /** |
|
54 | - * OO scope tokens. |
|
55 | - * |
|
56 | - * Duplicate of Tokens::$ooScopeTokens array in PHPCS which was added in 3.1.0. |
|
57 | - * |
|
58 | - * @since 9.1.0 |
|
59 | - * |
|
60 | - * @var array |
|
61 | - */ |
|
62 | - private $ooScopeTokens = array( |
|
63 | - 'T_CLASS' => \T_CLASS, |
|
64 | - 'T_INTERFACE' => \T_INTERFACE, |
|
65 | - 'T_TRAIT' => \T_TRAIT, |
|
66 | - ); |
|
67 | - |
|
68 | - /** |
|
69 | - * Scopes to skip over when examining the contents of functions. |
|
70 | - * |
|
71 | - * @since 9.1.0 |
|
72 | - * |
|
73 | - * @var array |
|
74 | - */ |
|
75 | - private $skipOverScopes = array( |
|
76 | - 'T_FUNCTION' => true, |
|
77 | - 'T_CLOSURE' => true, |
|
78 | - ); |
|
79 | - |
|
80 | - /** |
|
81 | - * Valid uses of $this in plain functions or methods outside object context. |
|
82 | - * |
|
83 | - * @since 9.1.0 |
|
84 | - * |
|
85 | - * @var array |
|
86 | - */ |
|
87 | - private $validUseOutsideObject = array( |
|
88 | - \T_ISSET => true, |
|
89 | - \T_EMPTY => true, |
|
90 | - ); |
|
91 | - |
|
92 | - /** |
|
93 | - * Returns an array of tokens this test wants to listen for. |
|
94 | - * |
|
95 | - * @since 9.1.0 |
|
96 | - * |
|
97 | - * @return array |
|
98 | - */ |
|
99 | - public function register() |
|
100 | - { |
|
101 | - if (\defined('T_ANON_CLASS')) { |
|
102 | - $this->ooScopeTokens['T_ANON_CLASS'] = \T_ANON_CLASS; |
|
103 | - } |
|
104 | - |
|
105 | - $this->skipOverScopes += $this->ooScopeTokens; |
|
106 | - |
|
107 | - return array( |
|
108 | - \T_FUNCTION, |
|
109 | - \T_CLOSURE, |
|
110 | - \T_GLOBAL, |
|
111 | - \T_CATCH, |
|
112 | - \T_FOREACH, |
|
113 | - \T_UNSET, |
|
114 | - ); |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * Processes this test, when one of its tokens is encountered. |
|
119 | - * |
|
120 | - * @since 9.1.0 |
|
121 | - * |
|
122 | - * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
123 | - * @param int $stackPtr The position of the current token in |
|
124 | - * the stack passed in $tokens. |
|
125 | - * |
|
126 | - * @return void |
|
127 | - */ |
|
128 | - public function process(File $phpcsFile, $stackPtr) |
|
129 | - { |
|
130 | - if ($this->supportsAbove('7.1') === false) { |
|
131 | - return; |
|
132 | - } |
|
133 | - |
|
134 | - $tokens = $phpcsFile->getTokens(); |
|
135 | - |
|
136 | - switch ($tokens[$stackPtr]['code']) { |
|
137 | - case \T_FUNCTION: |
|
138 | - $this->isThisUsedAsParameter($phpcsFile, $stackPtr); |
|
139 | - $this->isThisUsedOutsideObjectContext($phpcsFile, $stackPtr); |
|
140 | - break; |
|
141 | - |
|
142 | - case \T_CLOSURE: |
|
143 | - $this->isThisUsedAsParameter($phpcsFile, $stackPtr); |
|
144 | - break; |
|
145 | - |
|
146 | - case \T_GLOBAL: |
|
147 | - /* |
|
53 | + /** |
|
54 | + * OO scope tokens. |
|
55 | + * |
|
56 | + * Duplicate of Tokens::$ooScopeTokens array in PHPCS which was added in 3.1.0. |
|
57 | + * |
|
58 | + * @since 9.1.0 |
|
59 | + * |
|
60 | + * @var array |
|
61 | + */ |
|
62 | + private $ooScopeTokens = array( |
|
63 | + 'T_CLASS' => \T_CLASS, |
|
64 | + 'T_INTERFACE' => \T_INTERFACE, |
|
65 | + 'T_TRAIT' => \T_TRAIT, |
|
66 | + ); |
|
67 | + |
|
68 | + /** |
|
69 | + * Scopes to skip over when examining the contents of functions. |
|
70 | + * |
|
71 | + * @since 9.1.0 |
|
72 | + * |
|
73 | + * @var array |
|
74 | + */ |
|
75 | + private $skipOverScopes = array( |
|
76 | + 'T_FUNCTION' => true, |
|
77 | + 'T_CLOSURE' => true, |
|
78 | + ); |
|
79 | + |
|
80 | + /** |
|
81 | + * Valid uses of $this in plain functions or methods outside object context. |
|
82 | + * |
|
83 | + * @since 9.1.0 |
|
84 | + * |
|
85 | + * @var array |
|
86 | + */ |
|
87 | + private $validUseOutsideObject = array( |
|
88 | + \T_ISSET => true, |
|
89 | + \T_EMPTY => true, |
|
90 | + ); |
|
91 | + |
|
92 | + /** |
|
93 | + * Returns an array of tokens this test wants to listen for. |
|
94 | + * |
|
95 | + * @since 9.1.0 |
|
96 | + * |
|
97 | + * @return array |
|
98 | + */ |
|
99 | + public function register() |
|
100 | + { |
|
101 | + if (\defined('T_ANON_CLASS')) { |
|
102 | + $this->ooScopeTokens['T_ANON_CLASS'] = \T_ANON_CLASS; |
|
103 | + } |
|
104 | + |
|
105 | + $this->skipOverScopes += $this->ooScopeTokens; |
|
106 | + |
|
107 | + return array( |
|
108 | + \T_FUNCTION, |
|
109 | + \T_CLOSURE, |
|
110 | + \T_GLOBAL, |
|
111 | + \T_CATCH, |
|
112 | + \T_FOREACH, |
|
113 | + \T_UNSET, |
|
114 | + ); |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * Processes this test, when one of its tokens is encountered. |
|
119 | + * |
|
120 | + * @since 9.1.0 |
|
121 | + * |
|
122 | + * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
123 | + * @param int $stackPtr The position of the current token in |
|
124 | + * the stack passed in $tokens. |
|
125 | + * |
|
126 | + * @return void |
|
127 | + */ |
|
128 | + public function process(File $phpcsFile, $stackPtr) |
|
129 | + { |
|
130 | + if ($this->supportsAbove('7.1') === false) { |
|
131 | + return; |
|
132 | + } |
|
133 | + |
|
134 | + $tokens = $phpcsFile->getTokens(); |
|
135 | + |
|
136 | + switch ($tokens[$stackPtr]['code']) { |
|
137 | + case \T_FUNCTION: |
|
138 | + $this->isThisUsedAsParameter($phpcsFile, $stackPtr); |
|
139 | + $this->isThisUsedOutsideObjectContext($phpcsFile, $stackPtr); |
|
140 | + break; |
|
141 | + |
|
142 | + case \T_CLOSURE: |
|
143 | + $this->isThisUsedAsParameter($phpcsFile, $stackPtr); |
|
144 | + break; |
|
145 | + |
|
146 | + case \T_GLOBAL: |
|
147 | + /* |
|
148 | 148 | * $this can no longer be imported using the `global` keyword. |
149 | 149 | * This worked in PHP 7.0, though in PHP 5.x, it would throw a |
150 | 150 | * fatal "Cannot re-assign $this" error. |
151 | 151 | */ |
152 | - $endOfStatement = $phpcsFile->findNext(array(\T_SEMICOLON, \T_CLOSE_TAG), ($stackPtr + 1)); |
|
153 | - if ($endOfStatement === false) { |
|
154 | - // No semi-colon - live coding. |
|
155 | - return; |
|
156 | - } |
|
157 | - |
|
158 | - for ($i = ($stackPtr + 1); $i < $endOfStatement; $i++) { |
|
159 | - if ($tokens[$i]['code'] !== \T_VARIABLE || $tokens[$i]['content'] !== '$this') { |
|
160 | - continue; |
|
161 | - } |
|
162 | - |
|
163 | - $phpcsFile->addError( |
|
164 | - '"$this" can no longer be used with the "global" keyword since PHP 7.1.', |
|
165 | - $i, |
|
166 | - 'Global' |
|
167 | - ); |
|
168 | - } |
|
169 | - |
|
170 | - break; |
|
171 | - |
|
172 | - case \T_CATCH: |
|
173 | - /* |
|
152 | + $endOfStatement = $phpcsFile->findNext(array(\T_SEMICOLON, \T_CLOSE_TAG), ($stackPtr + 1)); |
|
153 | + if ($endOfStatement === false) { |
|
154 | + // No semi-colon - live coding. |
|
155 | + return; |
|
156 | + } |
|
157 | + |
|
158 | + for ($i = ($stackPtr + 1); $i < $endOfStatement; $i++) { |
|
159 | + if ($tokens[$i]['code'] !== \T_VARIABLE || $tokens[$i]['content'] !== '$this') { |
|
160 | + continue; |
|
161 | + } |
|
162 | + |
|
163 | + $phpcsFile->addError( |
|
164 | + '"$this" can no longer be used with the "global" keyword since PHP 7.1.', |
|
165 | + $i, |
|
166 | + 'Global' |
|
167 | + ); |
|
168 | + } |
|
169 | + |
|
170 | + break; |
|
171 | + |
|
172 | + case \T_CATCH: |
|
173 | + /* |
|
174 | 174 | * $this can no longer be used as a catch variable. |
175 | 175 | */ |
176 | - if (isset($tokens[$stackPtr]['parenthesis_opener'], $tokens[$stackPtr]['parenthesis_closer']) === false) { |
|
177 | - return; |
|
178 | - } |
|
179 | - |
|
180 | - $varPtr = $phpcsFile->findNext( |
|
181 | - \T_VARIABLE, |
|
182 | - ($tokens[$stackPtr]['parenthesis_opener'] + 1), |
|
183 | - $tokens[$stackPtr]['parenthesis_closer'] |
|
184 | - ); |
|
185 | - |
|
186 | - if ($varPtr === false || $tokens[$varPtr]['content'] !== '$this') { |
|
187 | - return; |
|
188 | - } |
|
189 | - |
|
190 | - $phpcsFile->addError( |
|
191 | - '"$this" can no longer be used as a catch variable since PHP 7.1.', |
|
192 | - $varPtr, |
|
193 | - 'Catch' |
|
194 | - ); |
|
195 | - |
|
196 | - break; |
|
197 | - |
|
198 | - case \T_FOREACH: |
|
199 | - /* |
|
176 | + if (isset($tokens[$stackPtr]['parenthesis_opener'], $tokens[$stackPtr]['parenthesis_closer']) === false) { |
|
177 | + return; |
|
178 | + } |
|
179 | + |
|
180 | + $varPtr = $phpcsFile->findNext( |
|
181 | + \T_VARIABLE, |
|
182 | + ($tokens[$stackPtr]['parenthesis_opener'] + 1), |
|
183 | + $tokens[$stackPtr]['parenthesis_closer'] |
|
184 | + ); |
|
185 | + |
|
186 | + if ($varPtr === false || $tokens[$varPtr]['content'] !== '$this') { |
|
187 | + return; |
|
188 | + } |
|
189 | + |
|
190 | + $phpcsFile->addError( |
|
191 | + '"$this" can no longer be used as a catch variable since PHP 7.1.', |
|
192 | + $varPtr, |
|
193 | + 'Catch' |
|
194 | + ); |
|
195 | + |
|
196 | + break; |
|
197 | + |
|
198 | + case \T_FOREACH: |
|
199 | + /* |
|
200 | 200 | * $this can no longer be used as a foreach *value* variable. |
201 | 201 | * This worked in PHP 7.0, though in PHP 5.x, it would throw a |
202 | 202 | * fatal "Cannot re-assign $this" error. |
203 | 203 | */ |
204 | - if (isset($tokens[$stackPtr]['parenthesis_opener'], $tokens[$stackPtr]['parenthesis_closer']) === false) { |
|
205 | - return; |
|
206 | - } |
|
207 | - |
|
208 | - $stopPtr = $phpcsFile->findPrevious( |
|
209 | - array(\T_AS, \T_DOUBLE_ARROW), |
|
210 | - ($tokens[$stackPtr]['parenthesis_closer'] - 1), |
|
211 | - $tokens[$stackPtr]['parenthesis_opener'] |
|
212 | - ); |
|
213 | - if ($stopPtr === false) { |
|
214 | - return; |
|
215 | - } |
|
216 | - |
|
217 | - $valueVarPtr = $phpcsFile->findNext( |
|
218 | - \T_VARIABLE, |
|
219 | - ($stopPtr + 1), |
|
220 | - $tokens[$stackPtr]['parenthesis_closer'] |
|
221 | - ); |
|
222 | - if ($valueVarPtr === false || $tokens[$valueVarPtr]['content'] !== '$this') { |
|
223 | - return; |
|
224 | - } |
|
225 | - |
|
226 | - $afterThis = $phpcsFile->findNext( |
|
227 | - Tokens::$emptyTokens, |
|
228 | - ($valueVarPtr + 1), |
|
229 | - $tokens[$stackPtr]['parenthesis_closer'], |
|
230 | - true |
|
231 | - ); |
|
232 | - |
|
233 | - if ($afterThis !== false |
|
234 | - && ($tokens[$afterThis]['code'] === \T_OBJECT_OPERATOR |
|
235 | - || $tokens[$afterThis]['code'] === \T_DOUBLE_COLON) |
|
236 | - ) { |
|
237 | - return; |
|
238 | - } |
|
239 | - |
|
240 | - $phpcsFile->addError( |
|
241 | - '"$this" can no longer be used as value variable in a foreach control structure since PHP 7.1.', |
|
242 | - $valueVarPtr, |
|
243 | - 'ForeachValueVar' |
|
244 | - ); |
|
245 | - |
|
246 | - break; |
|
247 | - |
|
248 | - case \T_UNSET: |
|
249 | - /* |
|
204 | + if (isset($tokens[$stackPtr]['parenthesis_opener'], $tokens[$stackPtr]['parenthesis_closer']) === false) { |
|
205 | + return; |
|
206 | + } |
|
207 | + |
|
208 | + $stopPtr = $phpcsFile->findPrevious( |
|
209 | + array(\T_AS, \T_DOUBLE_ARROW), |
|
210 | + ($tokens[$stackPtr]['parenthesis_closer'] - 1), |
|
211 | + $tokens[$stackPtr]['parenthesis_opener'] |
|
212 | + ); |
|
213 | + if ($stopPtr === false) { |
|
214 | + return; |
|
215 | + } |
|
216 | + |
|
217 | + $valueVarPtr = $phpcsFile->findNext( |
|
218 | + \T_VARIABLE, |
|
219 | + ($stopPtr + 1), |
|
220 | + $tokens[$stackPtr]['parenthesis_closer'] |
|
221 | + ); |
|
222 | + if ($valueVarPtr === false || $tokens[$valueVarPtr]['content'] !== '$this') { |
|
223 | + return; |
|
224 | + } |
|
225 | + |
|
226 | + $afterThis = $phpcsFile->findNext( |
|
227 | + Tokens::$emptyTokens, |
|
228 | + ($valueVarPtr + 1), |
|
229 | + $tokens[$stackPtr]['parenthesis_closer'], |
|
230 | + true |
|
231 | + ); |
|
232 | + |
|
233 | + if ($afterThis !== false |
|
234 | + && ($tokens[$afterThis]['code'] === \T_OBJECT_OPERATOR |
|
235 | + || $tokens[$afterThis]['code'] === \T_DOUBLE_COLON) |
|
236 | + ) { |
|
237 | + return; |
|
238 | + } |
|
239 | + |
|
240 | + $phpcsFile->addError( |
|
241 | + '"$this" can no longer be used as value variable in a foreach control structure since PHP 7.1.', |
|
242 | + $valueVarPtr, |
|
243 | + 'ForeachValueVar' |
|
244 | + ); |
|
245 | + |
|
246 | + break; |
|
247 | + |
|
248 | + case \T_UNSET: |
|
249 | + /* |
|
250 | 250 | * $this can no longer be unset. |
251 | 251 | */ |
252 | - $openParenthesis = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); |
|
253 | - if ($openParenthesis === false |
|
254 | - || $tokens[$openParenthesis]['code'] !== \T_OPEN_PARENTHESIS |
|
255 | - || isset($tokens[$openParenthesis]['parenthesis_closer']) === false |
|
256 | - ) { |
|
257 | - return; |
|
258 | - } |
|
259 | - |
|
260 | - for ($i = ($openParenthesis + 1); $i < $tokens[$openParenthesis]['parenthesis_closer']; $i++) { |
|
261 | - if ($tokens[$i]['code'] !== \T_VARIABLE || $tokens[$i]['content'] !== '$this') { |
|
262 | - continue; |
|
263 | - } |
|
264 | - |
|
265 | - $afterThis = $phpcsFile->findNext( |
|
266 | - Tokens::$emptyTokens, |
|
267 | - ($i + 1), |
|
268 | - $tokens[$openParenthesis]['parenthesis_closer'], |
|
269 | - true |
|
270 | - ); |
|
271 | - |
|
272 | - if ($afterThis !== false |
|
273 | - && ($tokens[$afterThis]['code'] === \T_OBJECT_OPERATOR |
|
274 | - || $tokens[$afterThis]['code'] === \T_DOUBLE_COLON |
|
275 | - || $tokens[$afterThis]['code'] === \T_OPEN_SQUARE_BRACKET) |
|
276 | - ) { |
|
277 | - $i = $afterThis; |
|
278 | - continue; |
|
279 | - } |
|
280 | - |
|
281 | - $phpcsFile->addError( |
|
282 | - '"$this" can no longer be unset since PHP 7.1.', |
|
283 | - $i, |
|
284 | - 'Unset' |
|
285 | - ); |
|
286 | - } |
|
287 | - |
|
288 | - break; |
|
289 | - } |
|
290 | - } |
|
291 | - |
|
292 | - /** |
|
293 | - * Check if $this is used as a parameter in a function declaration. |
|
294 | - * |
|
295 | - * $this can no longer be used as a parameter in a *global* function. |
|
296 | - * Use as a parameter in a method was already an error prior to PHP 7.1. |
|
297 | - * |
|
298 | - * @since 9.1.0 |
|
299 | - * |
|
300 | - * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
301 | - * @param int $stackPtr The position of the current token in |
|
302 | - * the stack passed in $tokens. |
|
303 | - * |
|
304 | - * @return void |
|
305 | - */ |
|
306 | - protected function isThisUsedAsParameter(File $phpcsFile, $stackPtr) |
|
307 | - { |
|
308 | - if ($this->validDirectScope($phpcsFile, $stackPtr, $this->ooScopeTokens) !== false) { |
|
309 | - return; |
|
310 | - } |
|
311 | - |
|
312 | - $params = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr); |
|
313 | - if (empty($params)) { |
|
314 | - return; |
|
315 | - } |
|
316 | - |
|
317 | - $tokens = $phpcsFile->getTokens(); |
|
318 | - |
|
319 | - foreach ($params as $param) { |
|
320 | - if ($param['name'] !== '$this') { |
|
321 | - continue; |
|
322 | - } |
|
323 | - |
|
324 | - if ($tokens[$stackPtr]['code'] === \T_FUNCTION) { |
|
325 | - $phpcsFile->addError( |
|
326 | - '"$this" can no longer be used as a parameter since PHP 7.1.', |
|
327 | - $param['token'], |
|
328 | - 'FunctionParam' |
|
329 | - ); |
|
330 | - } else { |
|
331 | - $phpcsFile->addError( |
|
332 | - '"$this" can no longer be used as a closure parameter since PHP 7.0.7.', |
|
333 | - $param['token'], |
|
334 | - 'ClosureParam' |
|
335 | - ); |
|
336 | - } |
|
337 | - } |
|
338 | - } |
|
339 | - |
|
340 | - /** |
|
341 | - * Check if $this is used in a plain function or method. |
|
342 | - * |
|
343 | - * Prior to PHP 7.1, this would result in an "undefined variable" notice |
|
344 | - * and execution would continue with $this regarded as `null`. |
|
345 | - * As of PHP 7.1, this throws an exception. |
|
346 | - * |
|
347 | - * Note: use within isset() and empty() to check object context is still allowed. |
|
348 | - * Note: $this can still be used within a closure. |
|
349 | - * |
|
350 | - * @since 9.1.0 |
|
351 | - * |
|
352 | - * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
353 | - * @param int $stackPtr The position of the current token in |
|
354 | - * the stack passed in $tokens. |
|
355 | - * |
|
356 | - * @return void |
|
357 | - */ |
|
358 | - protected function isThisUsedOutsideObjectContext(File $phpcsFile, $stackPtr) |
|
359 | - { |
|
360 | - $tokens = $phpcsFile->getTokens(); |
|
361 | - |
|
362 | - if (isset($tokens[$stackPtr]['scope_opener'], $tokens[$stackPtr]['scope_closer']) === false) { |
|
363 | - return; |
|
364 | - } |
|
365 | - |
|
366 | - if ($this->validDirectScope($phpcsFile, $stackPtr, $this->ooScopeTokens) !== false) { |
|
367 | - $methodProps = $phpcsFile->getMethodProperties($stackPtr); |
|
368 | - if ($methodProps['is_static'] === false) { |
|
369 | - return; |
|
370 | - } else { |
|
371 | - $methodName = $phpcsFile->getDeclarationName($stackPtr); |
|
372 | - if ($methodName === '__call') { |
|
373 | - /* |
|
252 | + $openParenthesis = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); |
|
253 | + if ($openParenthesis === false |
|
254 | + || $tokens[$openParenthesis]['code'] !== \T_OPEN_PARENTHESIS |
|
255 | + || isset($tokens[$openParenthesis]['parenthesis_closer']) === false |
|
256 | + ) { |
|
257 | + return; |
|
258 | + } |
|
259 | + |
|
260 | + for ($i = ($openParenthesis + 1); $i < $tokens[$openParenthesis]['parenthesis_closer']; $i++) { |
|
261 | + if ($tokens[$i]['code'] !== \T_VARIABLE || $tokens[$i]['content'] !== '$this') { |
|
262 | + continue; |
|
263 | + } |
|
264 | + |
|
265 | + $afterThis = $phpcsFile->findNext( |
|
266 | + Tokens::$emptyTokens, |
|
267 | + ($i + 1), |
|
268 | + $tokens[$openParenthesis]['parenthesis_closer'], |
|
269 | + true |
|
270 | + ); |
|
271 | + |
|
272 | + if ($afterThis !== false |
|
273 | + && ($tokens[$afterThis]['code'] === \T_OBJECT_OPERATOR |
|
274 | + || $tokens[$afterThis]['code'] === \T_DOUBLE_COLON |
|
275 | + || $tokens[$afterThis]['code'] === \T_OPEN_SQUARE_BRACKET) |
|
276 | + ) { |
|
277 | + $i = $afterThis; |
|
278 | + continue; |
|
279 | + } |
|
280 | + |
|
281 | + $phpcsFile->addError( |
|
282 | + '"$this" can no longer be unset since PHP 7.1.', |
|
283 | + $i, |
|
284 | + 'Unset' |
|
285 | + ); |
|
286 | + } |
|
287 | + |
|
288 | + break; |
|
289 | + } |
|
290 | + } |
|
291 | + |
|
292 | + /** |
|
293 | + * Check if $this is used as a parameter in a function declaration. |
|
294 | + * |
|
295 | + * $this can no longer be used as a parameter in a *global* function. |
|
296 | + * Use as a parameter in a method was already an error prior to PHP 7.1. |
|
297 | + * |
|
298 | + * @since 9.1.0 |
|
299 | + * |
|
300 | + * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
301 | + * @param int $stackPtr The position of the current token in |
|
302 | + * the stack passed in $tokens. |
|
303 | + * |
|
304 | + * @return void |
|
305 | + */ |
|
306 | + protected function isThisUsedAsParameter(File $phpcsFile, $stackPtr) |
|
307 | + { |
|
308 | + if ($this->validDirectScope($phpcsFile, $stackPtr, $this->ooScopeTokens) !== false) { |
|
309 | + return; |
|
310 | + } |
|
311 | + |
|
312 | + $params = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr); |
|
313 | + if (empty($params)) { |
|
314 | + return; |
|
315 | + } |
|
316 | + |
|
317 | + $tokens = $phpcsFile->getTokens(); |
|
318 | + |
|
319 | + foreach ($params as $param) { |
|
320 | + if ($param['name'] !== '$this') { |
|
321 | + continue; |
|
322 | + } |
|
323 | + |
|
324 | + if ($tokens[$stackPtr]['code'] === \T_FUNCTION) { |
|
325 | + $phpcsFile->addError( |
|
326 | + '"$this" can no longer be used as a parameter since PHP 7.1.', |
|
327 | + $param['token'], |
|
328 | + 'FunctionParam' |
|
329 | + ); |
|
330 | + } else { |
|
331 | + $phpcsFile->addError( |
|
332 | + '"$this" can no longer be used as a closure parameter since PHP 7.0.7.', |
|
333 | + $param['token'], |
|
334 | + 'ClosureParam' |
|
335 | + ); |
|
336 | + } |
|
337 | + } |
|
338 | + } |
|
339 | + |
|
340 | + /** |
|
341 | + * Check if $this is used in a plain function or method. |
|
342 | + * |
|
343 | + * Prior to PHP 7.1, this would result in an "undefined variable" notice |
|
344 | + * and execution would continue with $this regarded as `null`. |
|
345 | + * As of PHP 7.1, this throws an exception. |
|
346 | + * |
|
347 | + * Note: use within isset() and empty() to check object context is still allowed. |
|
348 | + * Note: $this can still be used within a closure. |
|
349 | + * |
|
350 | + * @since 9.1.0 |
|
351 | + * |
|
352 | + * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
353 | + * @param int $stackPtr The position of the current token in |
|
354 | + * the stack passed in $tokens. |
|
355 | + * |
|
356 | + * @return void |
|
357 | + */ |
|
358 | + protected function isThisUsedOutsideObjectContext(File $phpcsFile, $stackPtr) |
|
359 | + { |
|
360 | + $tokens = $phpcsFile->getTokens(); |
|
361 | + |
|
362 | + if (isset($tokens[$stackPtr]['scope_opener'], $tokens[$stackPtr]['scope_closer']) === false) { |
|
363 | + return; |
|
364 | + } |
|
365 | + |
|
366 | + if ($this->validDirectScope($phpcsFile, $stackPtr, $this->ooScopeTokens) !== false) { |
|
367 | + $methodProps = $phpcsFile->getMethodProperties($stackPtr); |
|
368 | + if ($methodProps['is_static'] === false) { |
|
369 | + return; |
|
370 | + } else { |
|
371 | + $methodName = $phpcsFile->getDeclarationName($stackPtr); |
|
372 | + if ($methodName === '__call') { |
|
373 | + /* |
|
374 | 374 | * This is an exception. |
375 | 375 | * @link https://wiki.php.net/rfc/this_var#always_show_true_this_value_in_magic_method_call |
376 | 376 | */ |
377 | - return; |
|
378 | - } |
|
379 | - } |
|
380 | - } |
|
381 | - |
|
382 | - for ($i = ($tokens[$stackPtr]['scope_opener'] + 1); $i < $tokens[$stackPtr]['scope_closer']; $i++) { |
|
383 | - if (isset($this->skipOverScopes[$tokens[$i]['type']])) { |
|
384 | - if (isset($tokens[$i]['scope_closer']) === false) { |
|
385 | - // Live coding or parse error, will only lead to inaccurate results. |
|
386 | - return; |
|
387 | - } |
|
388 | - |
|
389 | - // Skip over nested structures. |
|
390 | - $i = $tokens[$i]['scope_closer']; |
|
391 | - continue; |
|
392 | - } |
|
393 | - |
|
394 | - if ($tokens[$i]['code'] !== \T_VARIABLE || $tokens[$i]['content'] !== '$this') { |
|
395 | - continue; |
|
396 | - } |
|
397 | - |
|
398 | - if (isset($tokens[$i]['nested_parenthesis']) === true) { |
|
399 | - $nestedParenthesis = $tokens[$i]['nested_parenthesis']; |
|
400 | - $nestedOpenParenthesis = array_keys($nestedParenthesis); |
|
401 | - $lastOpenParenthesis = array_pop($nestedOpenParenthesis); |
|
402 | - |
|
403 | - $previousNonEmpty = $phpcsFile->findPrevious( |
|
404 | - Tokens::$emptyTokens, |
|
405 | - ($lastOpenParenthesis - 1), |
|
406 | - null, |
|
407 | - true, |
|
408 | - null, |
|
409 | - true |
|
410 | - ); |
|
411 | - |
|
412 | - if (isset($this->validUseOutsideObject[$tokens[$previousNonEmpty]['code']])) { |
|
413 | - continue; |
|
414 | - } |
|
415 | - } |
|
416 | - |
|
417 | - $phpcsFile->addError( |
|
418 | - '"$this" can no longer be used in a plain function or method since PHP 7.1.', |
|
419 | - $i, |
|
420 | - 'OutsideObjectContext' |
|
421 | - ); |
|
422 | - } |
|
423 | - } |
|
377 | + return; |
|
378 | + } |
|
379 | + } |
|
380 | + } |
|
381 | + |
|
382 | + for ($i = ($tokens[$stackPtr]['scope_opener'] + 1); $i < $tokens[$stackPtr]['scope_closer']; $i++) { |
|
383 | + if (isset($this->skipOverScopes[$tokens[$i]['type']])) { |
|
384 | + if (isset($tokens[$i]['scope_closer']) === false) { |
|
385 | + // Live coding or parse error, will only lead to inaccurate results. |
|
386 | + return; |
|
387 | + } |
|
388 | + |
|
389 | + // Skip over nested structures. |
|
390 | + $i = $tokens[$i]['scope_closer']; |
|
391 | + continue; |
|
392 | + } |
|
393 | + |
|
394 | + if ($tokens[$i]['code'] !== \T_VARIABLE || $tokens[$i]['content'] !== '$this') { |
|
395 | + continue; |
|
396 | + } |
|
397 | + |
|
398 | + if (isset($tokens[$i]['nested_parenthesis']) === true) { |
|
399 | + $nestedParenthesis = $tokens[$i]['nested_parenthesis']; |
|
400 | + $nestedOpenParenthesis = array_keys($nestedParenthesis); |
|
401 | + $lastOpenParenthesis = array_pop($nestedOpenParenthesis); |
|
402 | + |
|
403 | + $previousNonEmpty = $phpcsFile->findPrevious( |
|
404 | + Tokens::$emptyTokens, |
|
405 | + ($lastOpenParenthesis - 1), |
|
406 | + null, |
|
407 | + true, |
|
408 | + null, |
|
409 | + true |
|
410 | + ); |
|
411 | + |
|
412 | + if (isset($this->validUseOutsideObject[$tokens[$previousNonEmpty]['code']])) { |
|
413 | + continue; |
|
414 | + } |
|
415 | + } |
|
416 | + |
|
417 | + $phpcsFile->addError( |
|
418 | + '"$this" can no longer be used in a plain function or method since PHP 7.1.', |
|
419 | + $i, |
|
420 | + 'OutsideObjectContext' |
|
421 | + ); |
|
422 | + } |
|
423 | + } |
|
424 | 424 | } |
@@ -28,84 +28,84 @@ |
||
28 | 28 | */ |
29 | 29 | class NewUniformVariableSyntaxSniff extends Sniff |
30 | 30 | { |
31 | - /** |
|
32 | - * Returns an array of tokens this test wants to listen for. |
|
33 | - * |
|
34 | - * @return array |
|
35 | - */ |
|
36 | - public function register() |
|
37 | - { |
|
38 | - return array(\T_VARIABLE); |
|
39 | - } |
|
31 | + /** |
|
32 | + * Returns an array of tokens this test wants to listen for. |
|
33 | + * |
|
34 | + * @return array |
|
35 | + */ |
|
36 | + public function register() |
|
37 | + { |
|
38 | + return array(\T_VARIABLE); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Processes this test, when one of its tokens is encountered. |
|
43 | - * |
|
44 | - * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
45 | - * @param int $stackPtr The position of the current token |
|
46 | - * in the stack passed in $tokens. |
|
47 | - * |
|
48 | - * @return void |
|
49 | - */ |
|
50 | - public function process(File $phpcsFile, $stackPtr) |
|
51 | - { |
|
52 | - if ($this->supportsAbove('7.0') === false) { |
|
53 | - return; |
|
54 | - } |
|
41 | + /** |
|
42 | + * Processes this test, when one of its tokens is encountered. |
|
43 | + * |
|
44 | + * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
45 | + * @param int $stackPtr The position of the current token |
|
46 | + * in the stack passed in $tokens. |
|
47 | + * |
|
48 | + * @return void |
|
49 | + */ |
|
50 | + public function process(File $phpcsFile, $stackPtr) |
|
51 | + { |
|
52 | + if ($this->supportsAbove('7.0') === false) { |
|
53 | + return; |
|
54 | + } |
|
55 | 55 | |
56 | - $tokens = $phpcsFile->getTokens(); |
|
56 | + $tokens = $phpcsFile->getTokens(); |
|
57 | 57 | |
58 | - // Verify that the next token is a square open bracket. If not, bow out. |
|
59 | - $nextToken = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true); |
|
58 | + // Verify that the next token is a square open bracket. If not, bow out. |
|
59 | + $nextToken = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true); |
|
60 | 60 | |
61 | - if ($nextToken === false || $tokens[$nextToken]['code'] !== \T_OPEN_SQUARE_BRACKET || isset($tokens[$nextToken]['bracket_closer']) === false) { |
|
62 | - return; |
|
63 | - } |
|
61 | + if ($nextToken === false || $tokens[$nextToken]['code'] !== \T_OPEN_SQUARE_BRACKET || isset($tokens[$nextToken]['bracket_closer']) === false) { |
|
62 | + return; |
|
63 | + } |
|
64 | 64 | |
65 | - // The previous non-empty token has to be a $, -> or ::. |
|
66 | - $prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true); |
|
67 | - if ($prevToken === false || \in_array($tokens[$prevToken]['code'], array(\T_DOLLAR, \T_OBJECT_OPERATOR, \T_DOUBLE_COLON), true) === false) { |
|
68 | - return; |
|
69 | - } |
|
65 | + // The previous non-empty token has to be a $, -> or ::. |
|
66 | + $prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true); |
|
67 | + if ($prevToken === false || \in_array($tokens[$prevToken]['code'], array(\T_DOLLAR, \T_OBJECT_OPERATOR, \T_DOUBLE_COLON), true) === false) { |
|
68 | + return; |
|
69 | + } |
|
70 | 70 | |
71 | - // For static object calls, it only applies when this is a function call. |
|
72 | - if ($tokens[$prevToken]['code'] === \T_DOUBLE_COLON) { |
|
73 | - $hasBrackets = $tokens[$nextToken]['bracket_closer']; |
|
74 | - while (($hasBrackets = $phpcsFile->findNext(Tokens::$emptyTokens, ($hasBrackets + 1), null, true, null, true)) !== false) { |
|
75 | - if ($tokens[$hasBrackets]['code'] === \T_OPEN_SQUARE_BRACKET) { |
|
76 | - if (isset($tokens[$hasBrackets]['bracket_closer'])) { |
|
77 | - $hasBrackets = $tokens[$hasBrackets]['bracket_closer']; |
|
78 | - continue; |
|
79 | - } else { |
|
80 | - // Live coding. |
|
81 | - return; |
|
82 | - } |
|
71 | + // For static object calls, it only applies when this is a function call. |
|
72 | + if ($tokens[$prevToken]['code'] === \T_DOUBLE_COLON) { |
|
73 | + $hasBrackets = $tokens[$nextToken]['bracket_closer']; |
|
74 | + while (($hasBrackets = $phpcsFile->findNext(Tokens::$emptyTokens, ($hasBrackets + 1), null, true, null, true)) !== false) { |
|
75 | + if ($tokens[$hasBrackets]['code'] === \T_OPEN_SQUARE_BRACKET) { |
|
76 | + if (isset($tokens[$hasBrackets]['bracket_closer'])) { |
|
77 | + $hasBrackets = $tokens[$hasBrackets]['bracket_closer']; |
|
78 | + continue; |
|
79 | + } else { |
|
80 | + // Live coding. |
|
81 | + return; |
|
82 | + } |
|
83 | 83 | |
84 | - } elseif ($tokens[$hasBrackets]['code'] === \T_OPEN_PARENTHESIS) { |
|
85 | - // Caught! |
|
86 | - break; |
|
84 | + } elseif ($tokens[$hasBrackets]['code'] === \T_OPEN_PARENTHESIS) { |
|
85 | + // Caught! |
|
86 | + break; |
|
87 | 87 | |
88 | - } else { |
|
89 | - // Not a function call, so bow out. |
|
90 | - return; |
|
91 | - } |
|
92 | - } |
|
88 | + } else { |
|
89 | + // Not a function call, so bow out. |
|
90 | + return; |
|
91 | + } |
|
92 | + } |
|
93 | 93 | |
94 | - // Now let's also prevent false positives when used with self and static which still work fine. |
|
95 | - $classToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prevToken - 1), null, true, null, true); |
|
96 | - if ($classToken !== false) { |
|
97 | - if ($tokens[$classToken]['code'] === \T_STATIC || $tokens[$classToken]['code'] === \T_SELF) { |
|
98 | - return; |
|
99 | - } elseif ($tokens[$classToken]['code'] === \T_STRING && $tokens[$classToken]['content'] === 'self') { |
|
100 | - return; |
|
101 | - } |
|
102 | - } |
|
103 | - } |
|
94 | + // Now let's also prevent false positives when used with self and static which still work fine. |
|
95 | + $classToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prevToken - 1), null, true, null, true); |
|
96 | + if ($classToken !== false) { |
|
97 | + if ($tokens[$classToken]['code'] === \T_STATIC || $tokens[$classToken]['code'] === \T_SELF) { |
|
98 | + return; |
|
99 | + } elseif ($tokens[$classToken]['code'] === \T_STRING && $tokens[$classToken]['content'] === 'self') { |
|
100 | + return; |
|
101 | + } |
|
102 | + } |
|
103 | + } |
|
104 | 104 | |
105 | - $phpcsFile->addError( |
|
106 | - 'Indirect access to variables, properties and methods will be evaluated strictly in left-to-right order since PHP 7.0. Use curly braces to remove ambiguity.', |
|
107 | - $stackPtr, |
|
108 | - 'Found' |
|
109 | - ); |
|
110 | - } |
|
105 | + $phpcsFile->addError( |
|
106 | + 'Indirect access to variables, properties and methods will be evaluated strictly in left-to-right order since PHP 7.0. Use curly braces to remove ambiguity.', |
|
107 | + $stackPtr, |
|
108 | + 'Found' |
|
109 | + ); |
|
110 | + } |
|
111 | 111 | } |
@@ -29,96 +29,96 @@ |
||
29 | 29 | class ForbiddenGlobalVariableVariableSniff extends Sniff |
30 | 30 | { |
31 | 31 | |
32 | - /** |
|
33 | - * Returns an array of tokens this test wants to listen for. |
|
34 | - * |
|
35 | - * @return array |
|
36 | - */ |
|
37 | - public function register() |
|
38 | - { |
|
39 | - return array(\T_GLOBAL); |
|
40 | - } |
|
32 | + /** |
|
33 | + * Returns an array of tokens this test wants to listen for. |
|
34 | + * |
|
35 | + * @return array |
|
36 | + */ |
|
37 | + public function register() |
|
38 | + { |
|
39 | + return array(\T_GLOBAL); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Processes this test, when one of its tokens is encountered. |
|
44 | - * |
|
45 | - * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
46 | - * @param int $stackPtr The position of the current token in the |
|
47 | - * stack passed in $tokens. |
|
48 | - * |
|
49 | - * @return void |
|
50 | - */ |
|
51 | - public function process(File $phpcsFile, $stackPtr) |
|
52 | - { |
|
53 | - if ($this->supportsAbove('7.0') === false) { |
|
54 | - return; |
|
55 | - } |
|
42 | + /** |
|
43 | + * Processes this test, when one of its tokens is encountered. |
|
44 | + * |
|
45 | + * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
46 | + * @param int $stackPtr The position of the current token in the |
|
47 | + * stack passed in $tokens. |
|
48 | + * |
|
49 | + * @return void |
|
50 | + */ |
|
51 | + public function process(File $phpcsFile, $stackPtr) |
|
52 | + { |
|
53 | + if ($this->supportsAbove('7.0') === false) { |
|
54 | + return; |
|
55 | + } |
|
56 | 56 | |
57 | - $tokens = $phpcsFile->getTokens(); |
|
58 | - $endOfStatement = $phpcsFile->findNext(array(\T_SEMICOLON, \T_CLOSE_TAG), ($stackPtr + 1)); |
|
59 | - if ($endOfStatement === false) { |
|
60 | - // No semi-colon - live coding. |
|
61 | - return; |
|
62 | - } |
|
57 | + $tokens = $phpcsFile->getTokens(); |
|
58 | + $endOfStatement = $phpcsFile->findNext(array(\T_SEMICOLON, \T_CLOSE_TAG), ($stackPtr + 1)); |
|
59 | + if ($endOfStatement === false) { |
|
60 | + // No semi-colon - live coding. |
|
61 | + return; |
|
62 | + } |
|
63 | 63 | |
64 | - for ($ptr = ($stackPtr + 1); $ptr <= $endOfStatement; $ptr++) { |
|
65 | - $errorThrown = false; |
|
66 | - $nextComma = $phpcsFile->findNext(\T_COMMA, $ptr, $endOfStatement, false, null, true); |
|
67 | - $varEnd = ($nextComma === false) ? $endOfStatement : $nextComma; |
|
68 | - $variable = $phpcsFile->findNext(\T_VARIABLE, $ptr, $varEnd); |
|
69 | - $varString = trim($phpcsFile->getTokensAsString($ptr, ($varEnd - $ptr))); |
|
70 | - $data = array($varString); |
|
64 | + for ($ptr = ($stackPtr + 1); $ptr <= $endOfStatement; $ptr++) { |
|
65 | + $errorThrown = false; |
|
66 | + $nextComma = $phpcsFile->findNext(\T_COMMA, $ptr, $endOfStatement, false, null, true); |
|
67 | + $varEnd = ($nextComma === false) ? $endOfStatement : $nextComma; |
|
68 | + $variable = $phpcsFile->findNext(\T_VARIABLE, $ptr, $varEnd); |
|
69 | + $varString = trim($phpcsFile->getTokensAsString($ptr, ($varEnd - $ptr))); |
|
70 | + $data = array($varString); |
|
71 | 71 | |
72 | - if ($variable !== false) { |
|
72 | + if ($variable !== false) { |
|
73 | 73 | |
74 | - $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($variable - 1), $ptr, true); |
|
74 | + $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($variable - 1), $ptr, true); |
|
75 | 75 | |
76 | - if ($prev !== false && $tokens[$prev]['type'] === 'T_DOLLAR') { |
|
76 | + if ($prev !== false && $tokens[$prev]['type'] === 'T_DOLLAR') { |
|
77 | 77 | |
78 | - $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($variable + 1), $varEnd, true); |
|
78 | + $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($variable + 1), $varEnd, true); |
|
79 | 79 | |
80 | - if ($next !== false |
|
81 | - && \in_array($tokens[$next]['code'], array(\T_OPEN_SQUARE_BRACKET, \T_OBJECT_OPERATOR, \T_DOUBLE_COLON), true) === true |
|
82 | - ) { |
|
83 | - $phpcsFile->addError( |
|
84 | - 'Global with variable variables is not allowed since PHP 7.0. Found %s', |
|
85 | - $variable, |
|
86 | - 'Found', |
|
87 | - $data |
|
88 | - ); |
|
89 | - $errorThrown = true; |
|
90 | - } else { |
|
91 | - $phpcsFile->addWarning( |
|
92 | - 'Global with anything other than bare variables is discouraged since PHP 7.0. Found %s', |
|
93 | - $variable, |
|
94 | - 'NonBareVariableFound', |
|
95 | - $data |
|
96 | - ); |
|
97 | - $errorThrown = true; |
|
98 | - } |
|
99 | - } |
|
100 | - } |
|
80 | + if ($next !== false |
|
81 | + && \in_array($tokens[$next]['code'], array(\T_OPEN_SQUARE_BRACKET, \T_OBJECT_OPERATOR, \T_DOUBLE_COLON), true) === true |
|
82 | + ) { |
|
83 | + $phpcsFile->addError( |
|
84 | + 'Global with variable variables is not allowed since PHP 7.0. Found %s', |
|
85 | + $variable, |
|
86 | + 'Found', |
|
87 | + $data |
|
88 | + ); |
|
89 | + $errorThrown = true; |
|
90 | + } else { |
|
91 | + $phpcsFile->addWarning( |
|
92 | + 'Global with anything other than bare variables is discouraged since PHP 7.0. Found %s', |
|
93 | + $variable, |
|
94 | + 'NonBareVariableFound', |
|
95 | + $data |
|
96 | + ); |
|
97 | + $errorThrown = true; |
|
98 | + } |
|
99 | + } |
|
100 | + } |
|
101 | 101 | |
102 | - if ($errorThrown === false) { |
|
103 | - $dollar = $phpcsFile->findNext(\T_DOLLAR, $ptr, $varEnd); |
|
104 | - if ($dollar !== false) { |
|
105 | - $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($dollar + 1), $varEnd, true); |
|
106 | - if ($tokens[$next]['code'] === \T_OPEN_CURLY_BRACKET) { |
|
107 | - $phpcsFile->addWarning( |
|
108 | - 'Global with anything other than bare variables is discouraged since PHP 7.0. Found %s', |
|
109 | - $dollar, |
|
110 | - 'NonBareVariableFound', |
|
111 | - $data |
|
112 | - ); |
|
113 | - } |
|
114 | - } |
|
115 | - } |
|
102 | + if ($errorThrown === false) { |
|
103 | + $dollar = $phpcsFile->findNext(\T_DOLLAR, $ptr, $varEnd); |
|
104 | + if ($dollar !== false) { |
|
105 | + $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($dollar + 1), $varEnd, true); |
|
106 | + if ($tokens[$next]['code'] === \T_OPEN_CURLY_BRACKET) { |
|
107 | + $phpcsFile->addWarning( |
|
108 | + 'Global with anything other than bare variables is discouraged since PHP 7.0. Found %s', |
|
109 | + $dollar, |
|
110 | + 'NonBareVariableFound', |
|
111 | + $data |
|
112 | + ); |
|
113 | + } |
|
114 | + } |
|
115 | + } |
|
116 | 116 | |
117 | - // Move the stack pointer forward to the next variable for multi-variable statements. |
|
118 | - if ($nextComma === false) { |
|
119 | - break; |
|
120 | - } |
|
121 | - $ptr = $nextComma; |
|
122 | - } |
|
123 | - } |
|
117 | + // Move the stack pointer forward to the next variable for multi-variable statements. |
|
118 | + if ($nextComma === false) { |
|
119 | + break; |
|
120 | + } |
|
121 | + $ptr = $nextComma; |
|
122 | + } |
|
123 | + } |
|
124 | 124 | } |
@@ -26,268 +26,268 @@ |
||
26 | 26 | class RemovedPredefinedGlobalVariablesSniff extends AbstractRemovedFeatureSniff |
27 | 27 | { |
28 | 28 | |
29 | - /** |
|
30 | - * A list of removed global variables with their alternative, if any. |
|
31 | - * |
|
32 | - * The array lists : version number with false (deprecated) and true (removed). |
|
33 | - * If's sufficient to list the first version where the variable was deprecated/removed. |
|
34 | - * |
|
35 | - * @var array(string|null) |
|
36 | - */ |
|
37 | - protected $removedGlobalVariables = array( |
|
38 | - 'HTTP_POST_VARS' => array( |
|
39 | - '5.3' => false, |
|
40 | - '5.4' => true, |
|
41 | - 'alternative' => '$_POST', |
|
42 | - ), |
|
43 | - 'HTTP_GET_VARS' => array( |
|
44 | - '5.3' => false, |
|
45 | - '5.4' => true, |
|
46 | - 'alternative' => '$_GET', |
|
47 | - ), |
|
48 | - 'HTTP_ENV_VARS' => array( |
|
49 | - '5.3' => false, |
|
50 | - '5.4' => true, |
|
51 | - 'alternative' => '$_ENV', |
|
52 | - ), |
|
53 | - 'HTTP_SERVER_VARS' => array( |
|
54 | - '5.3' => false, |
|
55 | - '5.4' => true, |
|
56 | - 'alternative' => '$_SERVER', |
|
57 | - ), |
|
58 | - 'HTTP_COOKIE_VARS' => array( |
|
59 | - '5.3' => false, |
|
60 | - '5.4' => true, |
|
61 | - 'alternative' => '$_COOKIE', |
|
62 | - ), |
|
63 | - 'HTTP_SESSION_VARS' => array( |
|
64 | - '5.3' => false, |
|
65 | - '5.4' => true, |
|
66 | - 'alternative' => '$_SESSION', |
|
67 | - ), |
|
68 | - 'HTTP_POST_FILES' => array( |
|
69 | - '5.3' => false, |
|
70 | - '5.4' => true, |
|
71 | - 'alternative' => '$_FILES', |
|
72 | - ), |
|
73 | - |
|
74 | - 'HTTP_RAW_POST_DATA' => array( |
|
75 | - '5.6' => false, |
|
76 | - '7.0' => true, |
|
77 | - 'alternative' => 'php://input', |
|
78 | - ), |
|
79 | - |
|
80 | - 'php_errormsg' => array( |
|
81 | - '7.2' => false, |
|
82 | - 'alternative' => 'error_get_last()', |
|
83 | - ), |
|
84 | - ); |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * Returns an array of tokens this test wants to listen for. |
|
89 | - * |
|
90 | - * @return array |
|
91 | - */ |
|
92 | - public function register() |
|
93 | - { |
|
94 | - return array(\T_VARIABLE); |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * Processes this test, when one of its tokens is encountered. |
|
100 | - * |
|
101 | - * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
102 | - * @param int $stackPtr The position of the current token in the |
|
103 | - * stack passed in $tokens. |
|
104 | - * |
|
105 | - * @return void |
|
106 | - */ |
|
107 | - public function process(File $phpcsFile, $stackPtr) |
|
108 | - { |
|
109 | - if ($this->supportsAbove('5.3') === false) { |
|
110 | - return; |
|
111 | - } |
|
112 | - |
|
113 | - $tokens = $phpcsFile->getTokens(); |
|
114 | - $varName = substr($tokens[$stackPtr]['content'], 1); |
|
115 | - |
|
116 | - if (isset($this->removedGlobalVariables[$varName]) === false) { |
|
117 | - return; |
|
118 | - } |
|
119 | - |
|
120 | - if ($this->isClassProperty($phpcsFile, $stackPtr) === true) { |
|
121 | - // Ok, so this was a class property declaration, not our concern. |
|
122 | - return; |
|
123 | - } |
|
124 | - |
|
125 | - // Check for static usage of class properties shadowing the removed global variables. |
|
126 | - if ($this->inClassScope($phpcsFile, $stackPtr, false) === true) { |
|
127 | - $prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true); |
|
128 | - if ($prevToken !== false && $tokens[$prevToken]['code'] === \T_DOUBLE_COLON) { |
|
129 | - return; |
|
130 | - } |
|
131 | - } |
|
132 | - |
|
133 | - // Do some additional checks for the $php_errormsg variable. |
|
134 | - if ($varName === 'php_errormsg' |
|
135 | - && $this->isTargetPHPErrormsgVar($phpcsFile, $stackPtr, $tokens) === false |
|
136 | - ) { |
|
137 | - return; |
|
138 | - } |
|
139 | - |
|
140 | - // Still here, so throw an error/warning. |
|
141 | - $itemInfo = array( |
|
142 | - 'name' => $varName, |
|
143 | - ); |
|
144 | - $this->handleFeature($phpcsFile, $stackPtr, $itemInfo); |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * Get the relevant sub-array for a specific item from a multi-dimensional array. |
|
150 | - * |
|
151 | - * @param array $itemInfo Base information about the item. |
|
152 | - * |
|
153 | - * @return array Version and other information about the item. |
|
154 | - */ |
|
155 | - public function getItemArray(array $itemInfo) |
|
156 | - { |
|
157 | - return $this->removedGlobalVariables[$itemInfo['name']]; |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * Get the error message template for this sniff. |
|
163 | - * |
|
164 | - * @return string |
|
165 | - */ |
|
166 | - protected function getErrorMsgTemplate() |
|
167 | - { |
|
168 | - return "Global variable '\$%s' is "; |
|
169 | - } |
|
170 | - |
|
171 | - |
|
172 | - /** |
|
173 | - * Filter the error message before it's passed to PHPCS. |
|
174 | - * |
|
175 | - * @param string $error The error message which was created. |
|
176 | - * @param array $itemInfo Base information about the item this error message applies to. |
|
177 | - * @param array $errorInfo Detail information about an item this error message applies to. |
|
178 | - * |
|
179 | - * @return string |
|
180 | - */ |
|
181 | - protected function filterErrorMsg($error, array $itemInfo, array $errorInfo) |
|
182 | - { |
|
183 | - if ($itemInfo['name'] === 'php_errormsg') { |
|
184 | - $error = str_replace('Global', 'The', $error); |
|
185 | - } |
|
186 | - return $error; |
|
187 | - } |
|
188 | - |
|
189 | - /** |
|
190 | - * Run some additional checks for the `$php_errormsg` variable. |
|
191 | - * |
|
192 | - * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
193 | - * @param int $stackPtr The position of the current token in the |
|
194 | - * stack passed in $tokens. |
|
195 | - * @param array $tokens Token array of the current file. |
|
196 | - * |
|
197 | - * @return bool |
|
198 | - */ |
|
199 | - private function isTargetPHPErrormsgVar(File $phpcsFile, $stackPtr, array $tokens) |
|
200 | - { |
|
201 | - $scopeStart = 0; |
|
202 | - |
|
203 | - /* |
|
29 | + /** |
|
30 | + * A list of removed global variables with their alternative, if any. |
|
31 | + * |
|
32 | + * The array lists : version number with false (deprecated) and true (removed). |
|
33 | + * If's sufficient to list the first version where the variable was deprecated/removed. |
|
34 | + * |
|
35 | + * @var array(string|null) |
|
36 | + */ |
|
37 | + protected $removedGlobalVariables = array( |
|
38 | + 'HTTP_POST_VARS' => array( |
|
39 | + '5.3' => false, |
|
40 | + '5.4' => true, |
|
41 | + 'alternative' => '$_POST', |
|
42 | + ), |
|
43 | + 'HTTP_GET_VARS' => array( |
|
44 | + '5.3' => false, |
|
45 | + '5.4' => true, |
|
46 | + 'alternative' => '$_GET', |
|
47 | + ), |
|
48 | + 'HTTP_ENV_VARS' => array( |
|
49 | + '5.3' => false, |
|
50 | + '5.4' => true, |
|
51 | + 'alternative' => '$_ENV', |
|
52 | + ), |
|
53 | + 'HTTP_SERVER_VARS' => array( |
|
54 | + '5.3' => false, |
|
55 | + '5.4' => true, |
|
56 | + 'alternative' => '$_SERVER', |
|
57 | + ), |
|
58 | + 'HTTP_COOKIE_VARS' => array( |
|
59 | + '5.3' => false, |
|
60 | + '5.4' => true, |
|
61 | + 'alternative' => '$_COOKIE', |
|
62 | + ), |
|
63 | + 'HTTP_SESSION_VARS' => array( |
|
64 | + '5.3' => false, |
|
65 | + '5.4' => true, |
|
66 | + 'alternative' => '$_SESSION', |
|
67 | + ), |
|
68 | + 'HTTP_POST_FILES' => array( |
|
69 | + '5.3' => false, |
|
70 | + '5.4' => true, |
|
71 | + 'alternative' => '$_FILES', |
|
72 | + ), |
|
73 | + |
|
74 | + 'HTTP_RAW_POST_DATA' => array( |
|
75 | + '5.6' => false, |
|
76 | + '7.0' => true, |
|
77 | + 'alternative' => 'php://input', |
|
78 | + ), |
|
79 | + |
|
80 | + 'php_errormsg' => array( |
|
81 | + '7.2' => false, |
|
82 | + 'alternative' => 'error_get_last()', |
|
83 | + ), |
|
84 | + ); |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * Returns an array of tokens this test wants to listen for. |
|
89 | + * |
|
90 | + * @return array |
|
91 | + */ |
|
92 | + public function register() |
|
93 | + { |
|
94 | + return array(\T_VARIABLE); |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * Processes this test, when one of its tokens is encountered. |
|
100 | + * |
|
101 | + * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
102 | + * @param int $stackPtr The position of the current token in the |
|
103 | + * stack passed in $tokens. |
|
104 | + * |
|
105 | + * @return void |
|
106 | + */ |
|
107 | + public function process(File $phpcsFile, $stackPtr) |
|
108 | + { |
|
109 | + if ($this->supportsAbove('5.3') === false) { |
|
110 | + return; |
|
111 | + } |
|
112 | + |
|
113 | + $tokens = $phpcsFile->getTokens(); |
|
114 | + $varName = substr($tokens[$stackPtr]['content'], 1); |
|
115 | + |
|
116 | + if (isset($this->removedGlobalVariables[$varName]) === false) { |
|
117 | + return; |
|
118 | + } |
|
119 | + |
|
120 | + if ($this->isClassProperty($phpcsFile, $stackPtr) === true) { |
|
121 | + // Ok, so this was a class property declaration, not our concern. |
|
122 | + return; |
|
123 | + } |
|
124 | + |
|
125 | + // Check for static usage of class properties shadowing the removed global variables. |
|
126 | + if ($this->inClassScope($phpcsFile, $stackPtr, false) === true) { |
|
127 | + $prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true); |
|
128 | + if ($prevToken !== false && $tokens[$prevToken]['code'] === \T_DOUBLE_COLON) { |
|
129 | + return; |
|
130 | + } |
|
131 | + } |
|
132 | + |
|
133 | + // Do some additional checks for the $php_errormsg variable. |
|
134 | + if ($varName === 'php_errormsg' |
|
135 | + && $this->isTargetPHPErrormsgVar($phpcsFile, $stackPtr, $tokens) === false |
|
136 | + ) { |
|
137 | + return; |
|
138 | + } |
|
139 | + |
|
140 | + // Still here, so throw an error/warning. |
|
141 | + $itemInfo = array( |
|
142 | + 'name' => $varName, |
|
143 | + ); |
|
144 | + $this->handleFeature($phpcsFile, $stackPtr, $itemInfo); |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * Get the relevant sub-array for a specific item from a multi-dimensional array. |
|
150 | + * |
|
151 | + * @param array $itemInfo Base information about the item. |
|
152 | + * |
|
153 | + * @return array Version and other information about the item. |
|
154 | + */ |
|
155 | + public function getItemArray(array $itemInfo) |
|
156 | + { |
|
157 | + return $this->removedGlobalVariables[$itemInfo['name']]; |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * Get the error message template for this sniff. |
|
163 | + * |
|
164 | + * @return string |
|
165 | + */ |
|
166 | + protected function getErrorMsgTemplate() |
|
167 | + { |
|
168 | + return "Global variable '\$%s' is "; |
|
169 | + } |
|
170 | + |
|
171 | + |
|
172 | + /** |
|
173 | + * Filter the error message before it's passed to PHPCS. |
|
174 | + * |
|
175 | + * @param string $error The error message which was created. |
|
176 | + * @param array $itemInfo Base information about the item this error message applies to. |
|
177 | + * @param array $errorInfo Detail information about an item this error message applies to. |
|
178 | + * |
|
179 | + * @return string |
|
180 | + */ |
|
181 | + protected function filterErrorMsg($error, array $itemInfo, array $errorInfo) |
|
182 | + { |
|
183 | + if ($itemInfo['name'] === 'php_errormsg') { |
|
184 | + $error = str_replace('Global', 'The', $error); |
|
185 | + } |
|
186 | + return $error; |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * Run some additional checks for the `$php_errormsg` variable. |
|
191 | + * |
|
192 | + * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
193 | + * @param int $stackPtr The position of the current token in the |
|
194 | + * stack passed in $tokens. |
|
195 | + * @param array $tokens Token array of the current file. |
|
196 | + * |
|
197 | + * @return bool |
|
198 | + */ |
|
199 | + private function isTargetPHPErrormsgVar(File $phpcsFile, $stackPtr, array $tokens) |
|
200 | + { |
|
201 | + $scopeStart = 0; |
|
202 | + |
|
203 | + /* |
|
204 | 204 | * If the variable is detected within the scope of a function/closure, limit the checking. |
205 | 205 | */ |
206 | - $function = $phpcsFile->getCondition($stackPtr, \T_CLOSURE); |
|
207 | - if ($function === false) { |
|
208 | - $function = $phpcsFile->getCondition($stackPtr, \T_FUNCTION); |
|
209 | - } |
|
210 | - |
|
211 | - // It could also be a function param, which is not in the function scope. |
|
212 | - if ($function === false && isset($tokens[$stackPtr]['nested_parenthesis']) === true) { |
|
213 | - $nestedParentheses = $tokens[$stackPtr]['nested_parenthesis']; |
|
214 | - $parenthesisCloser = end($nestedParentheses); |
|
215 | - if (isset($tokens[$parenthesisCloser]['parenthesis_owner']) |
|
216 | - && ($tokens[$tokens[$parenthesisCloser]['parenthesis_owner']]['code'] === \T_FUNCTION |
|
217 | - || $tokens[$tokens[$parenthesisCloser]['parenthesis_owner']]['code'] === \T_CLOSURE) |
|
218 | - ) { |
|
219 | - $function = $tokens[$parenthesisCloser]['parenthesis_owner']; |
|
220 | - } |
|
221 | - } |
|
222 | - |
|
223 | - if ($function !== false) { |
|
224 | - $scopeStart = $tokens[$function]['scope_opener']; |
|
225 | - } |
|
226 | - |
|
227 | - /* |
|
206 | + $function = $phpcsFile->getCondition($stackPtr, \T_CLOSURE); |
|
207 | + if ($function === false) { |
|
208 | + $function = $phpcsFile->getCondition($stackPtr, \T_FUNCTION); |
|
209 | + } |
|
210 | + |
|
211 | + // It could also be a function param, which is not in the function scope. |
|
212 | + if ($function === false && isset($tokens[$stackPtr]['nested_parenthesis']) === true) { |
|
213 | + $nestedParentheses = $tokens[$stackPtr]['nested_parenthesis']; |
|
214 | + $parenthesisCloser = end($nestedParentheses); |
|
215 | + if (isset($tokens[$parenthesisCloser]['parenthesis_owner']) |
|
216 | + && ($tokens[$tokens[$parenthesisCloser]['parenthesis_owner']]['code'] === \T_FUNCTION |
|
217 | + || $tokens[$tokens[$parenthesisCloser]['parenthesis_owner']]['code'] === \T_CLOSURE) |
|
218 | + ) { |
|
219 | + $function = $tokens[$parenthesisCloser]['parenthesis_owner']; |
|
220 | + } |
|
221 | + } |
|
222 | + |
|
223 | + if ($function !== false) { |
|
224 | + $scopeStart = $tokens[$function]['scope_opener']; |
|
225 | + } |
|
226 | + |
|
227 | + /* |
|
228 | 228 | * Now, let's do some additional checks. |
229 | 229 | */ |
230 | - $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); |
|
231 | - |
|
232 | - // Is the variable being used as an array ? |
|
233 | - if ($nextNonEmpty !== false && $tokens[$nextNonEmpty]['code'] === \T_OPEN_SQUARE_BRACKET) { |
|
234 | - // The PHP native variable is a string, so this is probably not it |
|
235 | - // (except for array access to string, but why would you in this case ?). |
|
236 | - return false; |
|
237 | - } |
|
238 | - |
|
239 | - // Is this a variable assignment ? |
|
240 | - if ($nextNonEmpty !== false |
|
241 | - && isset(Tokens::$assignmentTokens[$tokens[$nextNonEmpty]['code']]) === true |
|
242 | - ) { |
|
243 | - return false; |
|
244 | - } |
|
245 | - |
|
246 | - // Is this a function param shadowing the PHP native one ? |
|
247 | - if ($function !== false) { |
|
248 | - $parameters = PHPCSHelper::getMethodParameters($phpcsFile, $function); |
|
249 | - if (\is_array($parameters) === true && empty($parameters) === false) { |
|
250 | - foreach ($parameters as $param) { |
|
251 | - if ($param['name'] === '$php_errormsg') { |
|
252 | - return false; |
|
253 | - } |
|
254 | - } |
|
255 | - } |
|
256 | - } |
|
257 | - |
|
258 | - $skipPast = array( |
|
259 | - 'T_CLASS' => true, |
|
260 | - 'T_ANON_CLASS' => true, |
|
261 | - 'T_INTERFACE' => true, |
|
262 | - 'T_TRAIT' => true, |
|
263 | - 'T_FUNCTION' => true, |
|
264 | - 'T_CLOSURE' => true, |
|
265 | - ); |
|
266 | - |
|
267 | - // Walk back and see if there is an assignment to the variable within the same scope. |
|
268 | - for ($i = ($stackPtr - 1); $i >= $scopeStart; $i--) { |
|
269 | - if ($tokens[$i]['code'] === \T_CLOSE_CURLY_BRACKET |
|
270 | - && isset($tokens[$i]['scope_condition']) |
|
271 | - && isset($skipPast[$tokens[$tokens[$i]['scope_condition']]['type']]) |
|
272 | - ) { |
|
273 | - // Skip past functions, classes etc. |
|
274 | - $i = $tokens[$i]['scope_condition']; |
|
275 | - continue; |
|
276 | - } |
|
277 | - |
|
278 | - if ($tokens[$i]['code'] !== \T_VARIABLE || $tokens[$i]['content'] !== '$php_errormsg') { |
|
279 | - continue; |
|
280 | - } |
|
281 | - |
|
282 | - $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true); |
|
283 | - |
|
284 | - if ($nextNonEmpty !== false |
|
285 | - && isset(Tokens::$assignmentTokens[$tokens[$nextNonEmpty]['code']]) === true |
|
286 | - ) { |
|
287 | - return false; |
|
288 | - } |
|
289 | - } |
|
290 | - |
|
291 | - return true; |
|
292 | - } |
|
230 | + $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); |
|
231 | + |
|
232 | + // Is the variable being used as an array ? |
|
233 | + if ($nextNonEmpty !== false && $tokens[$nextNonEmpty]['code'] === \T_OPEN_SQUARE_BRACKET) { |
|
234 | + // The PHP native variable is a string, so this is probably not it |
|
235 | + // (except for array access to string, but why would you in this case ?). |
|
236 | + return false; |
|
237 | + } |
|
238 | + |
|
239 | + // Is this a variable assignment ? |
|
240 | + if ($nextNonEmpty !== false |
|
241 | + && isset(Tokens::$assignmentTokens[$tokens[$nextNonEmpty]['code']]) === true |
|
242 | + ) { |
|
243 | + return false; |
|
244 | + } |
|
245 | + |
|
246 | + // Is this a function param shadowing the PHP native one ? |
|
247 | + if ($function !== false) { |
|
248 | + $parameters = PHPCSHelper::getMethodParameters($phpcsFile, $function); |
|
249 | + if (\is_array($parameters) === true && empty($parameters) === false) { |
|
250 | + foreach ($parameters as $param) { |
|
251 | + if ($param['name'] === '$php_errormsg') { |
|
252 | + return false; |
|
253 | + } |
|
254 | + } |
|
255 | + } |
|
256 | + } |
|
257 | + |
|
258 | + $skipPast = array( |
|
259 | + 'T_CLASS' => true, |
|
260 | + 'T_ANON_CLASS' => true, |
|
261 | + 'T_INTERFACE' => true, |
|
262 | + 'T_TRAIT' => true, |
|
263 | + 'T_FUNCTION' => true, |
|
264 | + 'T_CLOSURE' => true, |
|
265 | + ); |
|
266 | + |
|
267 | + // Walk back and see if there is an assignment to the variable within the same scope. |
|
268 | + for ($i = ($stackPtr - 1); $i >= $scopeStart; $i--) { |
|
269 | + if ($tokens[$i]['code'] === \T_CLOSE_CURLY_BRACKET |
|
270 | + && isset($tokens[$i]['scope_condition']) |
|
271 | + && isset($skipPast[$tokens[$tokens[$i]['scope_condition']]['type']]) |
|
272 | + ) { |
|
273 | + // Skip past functions, classes etc. |
|
274 | + $i = $tokens[$i]['scope_condition']; |
|
275 | + continue; |
|
276 | + } |
|
277 | + |
|
278 | + if ($tokens[$i]['code'] !== \T_VARIABLE || $tokens[$i]['content'] !== '$php_errormsg') { |
|
279 | + continue; |
|
280 | + } |
|
281 | + |
|
282 | + $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true); |
|
283 | + |
|
284 | + if ($nextNonEmpty !== false |
|
285 | + && isset(Tokens::$assignmentTokens[$tokens[$nextNonEmpty]['code']]) === true |
|
286 | + ) { |
|
287 | + return false; |
|
288 | + } |
|
289 | + } |
|
290 | + |
|
291 | + return true; |
|
292 | + } |
|
293 | 293 | } |
@@ -30,191 +30,191 @@ discard block |
||
30 | 30 | class ArgumentFunctionsReportCurrentValueSniff extends Sniff |
31 | 31 | { |
32 | 32 | |
33 | - /** |
|
34 | - * A list of functions that, when called, can behave differently in PHP 7 |
|
35 | - * when dealing with parameters of the function they're called in. |
|
36 | - * |
|
37 | - * @var array |
|
38 | - */ |
|
39 | - protected $changedFunctions = array( |
|
40 | - 'func_get_arg' => true, |
|
41 | - 'func_get_args' => true, |
|
42 | - 'debug_backtrace' => true, |
|
43 | - 'debug_print_backtrace' => true, |
|
44 | - ); |
|
45 | - |
|
46 | - /** |
|
47 | - * Tokens to look out for to allow us to skip past nested scoped structures. |
|
48 | - * |
|
49 | - * @var array |
|
50 | - */ |
|
51 | - private $skipPastNested = array( |
|
52 | - 'T_CLASS' => true, |
|
53 | - 'T_ANON_CLASS' => true, |
|
54 | - 'T_INTERFACE' => true, |
|
55 | - 'T_TRAIT' => true, |
|
56 | - 'T_FUNCTION' => true, |
|
57 | - 'T_CLOSURE' => true, |
|
58 | - ); |
|
59 | - |
|
60 | - /** |
|
61 | - * List of tokens which when they preceed a T_STRING *within a function* indicate |
|
62 | - * this is not a call to a PHP native function. |
|
63 | - * |
|
64 | - * This list already takes into account that nested scoped structures are being |
|
65 | - * skipped over, so doesn't check for those again. |
|
66 | - * Similarly, as constants won't have parentheses, those don't need to be checked |
|
67 | - * for either. |
|
68 | - * |
|
69 | - * @var array |
|
70 | - */ |
|
71 | - private $noneFunctionCallIndicators = array( |
|
72 | - \T_DOUBLE_COLON => true, |
|
73 | - \T_OBJECT_OPERATOR => true, |
|
74 | - ); |
|
75 | - |
|
76 | - /** |
|
77 | - * The tokens for variable incrementing/decrementing. |
|
78 | - * |
|
79 | - * @var array |
|
80 | - */ |
|
81 | - private $plusPlusMinusMinus = array( |
|
82 | - \T_DEC => true, |
|
83 | - \T_INC => true, |
|
84 | - ); |
|
85 | - |
|
86 | - /** |
|
87 | - * Tokens to ignore when determining the start of a statement. |
|
88 | - * |
|
89 | - * @var array |
|
90 | - */ |
|
91 | - private $ignoreForStartOfStatement = array( |
|
92 | - \T_COMMA, |
|
93 | - \T_DOUBLE_ARROW, |
|
94 | - \T_OPEN_SQUARE_BRACKET, |
|
95 | - \T_OPEN_PARENTHESIS, |
|
96 | - ); |
|
97 | - |
|
98 | - /** |
|
99 | - * Returns an array of tokens this test wants to listen for. |
|
100 | - * |
|
101 | - * @return array |
|
102 | - */ |
|
103 | - public function register() |
|
104 | - { |
|
105 | - return array( |
|
106 | - \T_FUNCTION, |
|
107 | - \T_CLOSURE, |
|
108 | - ); |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Processes this test, when one of its tokens is encountered. |
|
113 | - * |
|
114 | - * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
115 | - * @param int $stackPtr The position of the current token |
|
116 | - * in the stack passed in $tokens. |
|
117 | - * |
|
118 | - * @return void |
|
119 | - */ |
|
120 | - public function process(File $phpcsFile, $stackPtr) |
|
121 | - { |
|
122 | - if ($this->supportsAbove('7.0') === false) { |
|
123 | - return; |
|
124 | - } |
|
125 | - |
|
126 | - $tokens = $phpcsFile->getTokens(); |
|
127 | - |
|
128 | - if (isset($tokens[$stackPtr]['scope_opener'], $tokens[$stackPtr]['scope_closer']) === false) { |
|
129 | - // Abstract function, interface function, live coding or parse error. |
|
130 | - return; |
|
131 | - } |
|
132 | - |
|
133 | - $scopeOpener = $tokens[$stackPtr]['scope_opener']; |
|
134 | - $scopeCloser = $tokens[$stackPtr]['scope_closer']; |
|
135 | - |
|
136 | - // Does the function declaration have parameters ? |
|
137 | - $params = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr); |
|
138 | - if (empty($params)) { |
|
139 | - // No named arguments found, so no risk of them being changed. |
|
140 | - return; |
|
141 | - } |
|
142 | - |
|
143 | - $paramNames = array(); |
|
144 | - foreach ($params as $param) { |
|
145 | - $paramNames[] = $param['name']; |
|
146 | - } |
|
147 | - |
|
148 | - for ($i = ($scopeOpener + 1); $i < $scopeCloser; $i++) { |
|
149 | - if (isset($this->skipPastNested[$tokens[$i]['type']]) && isset($tokens[$i]['scope_closer'])) { |
|
150 | - // Skip past nested structures. |
|
151 | - $i = $tokens[$i]['scope_closer']; |
|
152 | - continue; |
|
153 | - } |
|
154 | - |
|
155 | - if ($tokens[$i]['code'] !== \T_STRING) { |
|
156 | - continue; |
|
157 | - } |
|
158 | - |
|
159 | - $foundFunctionName = strtolower($tokens[$i]['content']); |
|
160 | - |
|
161 | - if (isset($this->changedFunctions[$foundFunctionName]) === false) { |
|
162 | - // Not one of the target functions. |
|
163 | - continue; |
|
164 | - } |
|
165 | - |
|
166 | - /* |
|
33 | + /** |
|
34 | + * A list of functions that, when called, can behave differently in PHP 7 |
|
35 | + * when dealing with parameters of the function they're called in. |
|
36 | + * |
|
37 | + * @var array |
|
38 | + */ |
|
39 | + protected $changedFunctions = array( |
|
40 | + 'func_get_arg' => true, |
|
41 | + 'func_get_args' => true, |
|
42 | + 'debug_backtrace' => true, |
|
43 | + 'debug_print_backtrace' => true, |
|
44 | + ); |
|
45 | + |
|
46 | + /** |
|
47 | + * Tokens to look out for to allow us to skip past nested scoped structures. |
|
48 | + * |
|
49 | + * @var array |
|
50 | + */ |
|
51 | + private $skipPastNested = array( |
|
52 | + 'T_CLASS' => true, |
|
53 | + 'T_ANON_CLASS' => true, |
|
54 | + 'T_INTERFACE' => true, |
|
55 | + 'T_TRAIT' => true, |
|
56 | + 'T_FUNCTION' => true, |
|
57 | + 'T_CLOSURE' => true, |
|
58 | + ); |
|
59 | + |
|
60 | + /** |
|
61 | + * List of tokens which when they preceed a T_STRING *within a function* indicate |
|
62 | + * this is not a call to a PHP native function. |
|
63 | + * |
|
64 | + * This list already takes into account that nested scoped structures are being |
|
65 | + * skipped over, so doesn't check for those again. |
|
66 | + * Similarly, as constants won't have parentheses, those don't need to be checked |
|
67 | + * for either. |
|
68 | + * |
|
69 | + * @var array |
|
70 | + */ |
|
71 | + private $noneFunctionCallIndicators = array( |
|
72 | + \T_DOUBLE_COLON => true, |
|
73 | + \T_OBJECT_OPERATOR => true, |
|
74 | + ); |
|
75 | + |
|
76 | + /** |
|
77 | + * The tokens for variable incrementing/decrementing. |
|
78 | + * |
|
79 | + * @var array |
|
80 | + */ |
|
81 | + private $plusPlusMinusMinus = array( |
|
82 | + \T_DEC => true, |
|
83 | + \T_INC => true, |
|
84 | + ); |
|
85 | + |
|
86 | + /** |
|
87 | + * Tokens to ignore when determining the start of a statement. |
|
88 | + * |
|
89 | + * @var array |
|
90 | + */ |
|
91 | + private $ignoreForStartOfStatement = array( |
|
92 | + \T_COMMA, |
|
93 | + \T_DOUBLE_ARROW, |
|
94 | + \T_OPEN_SQUARE_BRACKET, |
|
95 | + \T_OPEN_PARENTHESIS, |
|
96 | + ); |
|
97 | + |
|
98 | + /** |
|
99 | + * Returns an array of tokens this test wants to listen for. |
|
100 | + * |
|
101 | + * @return array |
|
102 | + */ |
|
103 | + public function register() |
|
104 | + { |
|
105 | + return array( |
|
106 | + \T_FUNCTION, |
|
107 | + \T_CLOSURE, |
|
108 | + ); |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Processes this test, when one of its tokens is encountered. |
|
113 | + * |
|
114 | + * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
115 | + * @param int $stackPtr The position of the current token |
|
116 | + * in the stack passed in $tokens. |
|
117 | + * |
|
118 | + * @return void |
|
119 | + */ |
|
120 | + public function process(File $phpcsFile, $stackPtr) |
|
121 | + { |
|
122 | + if ($this->supportsAbove('7.0') === false) { |
|
123 | + return; |
|
124 | + } |
|
125 | + |
|
126 | + $tokens = $phpcsFile->getTokens(); |
|
127 | + |
|
128 | + if (isset($tokens[$stackPtr]['scope_opener'], $tokens[$stackPtr]['scope_closer']) === false) { |
|
129 | + // Abstract function, interface function, live coding or parse error. |
|
130 | + return; |
|
131 | + } |
|
132 | + |
|
133 | + $scopeOpener = $tokens[$stackPtr]['scope_opener']; |
|
134 | + $scopeCloser = $tokens[$stackPtr]['scope_closer']; |
|
135 | + |
|
136 | + // Does the function declaration have parameters ? |
|
137 | + $params = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr); |
|
138 | + if (empty($params)) { |
|
139 | + // No named arguments found, so no risk of them being changed. |
|
140 | + return; |
|
141 | + } |
|
142 | + |
|
143 | + $paramNames = array(); |
|
144 | + foreach ($params as $param) { |
|
145 | + $paramNames[] = $param['name']; |
|
146 | + } |
|
147 | + |
|
148 | + for ($i = ($scopeOpener + 1); $i < $scopeCloser; $i++) { |
|
149 | + if (isset($this->skipPastNested[$tokens[$i]['type']]) && isset($tokens[$i]['scope_closer'])) { |
|
150 | + // Skip past nested structures. |
|
151 | + $i = $tokens[$i]['scope_closer']; |
|
152 | + continue; |
|
153 | + } |
|
154 | + |
|
155 | + if ($tokens[$i]['code'] !== \T_STRING) { |
|
156 | + continue; |
|
157 | + } |
|
158 | + |
|
159 | + $foundFunctionName = strtolower($tokens[$i]['content']); |
|
160 | + |
|
161 | + if (isset($this->changedFunctions[$foundFunctionName]) === false) { |
|
162 | + // Not one of the target functions. |
|
163 | + continue; |
|
164 | + } |
|
165 | + |
|
166 | + /* |
|
167 | 167 | * Ok, so is this really a function call to one of the PHP native functions ? |
168 | 168 | */ |
169 | - $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true); |
|
170 | - if ($next === false || $tokens[$next]['code'] !== \T_OPEN_PARENTHESIS) { |
|
171 | - // Live coding, parse error or not a function call. |
|
172 | - continue; |
|
173 | - } |
|
174 | - |
|
175 | - $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($i - 1), null, true); |
|
176 | - if ($prev !== false) { |
|
177 | - if (isset($this->noneFunctionCallIndicators[$tokens[$prev]['code']])) { |
|
178 | - continue; |
|
179 | - } |
|
180 | - |
|
181 | - // Check for namespaced functions, ie: \foo\bar() not \bar(). |
|
182 | - if ($tokens[ $prev ]['code'] === \T_NS_SEPARATOR) { |
|
183 | - $pprev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prev - 1), null, true); |
|
184 | - if ($pprev !== false && $tokens[ $pprev ]['code'] === \T_STRING) { |
|
185 | - continue; |
|
186 | - } |
|
187 | - } |
|
188 | - } |
|
189 | - |
|
190 | - /* |
|
169 | + $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true); |
|
170 | + if ($next === false || $tokens[$next]['code'] !== \T_OPEN_PARENTHESIS) { |
|
171 | + // Live coding, parse error or not a function call. |
|
172 | + continue; |
|
173 | + } |
|
174 | + |
|
175 | + $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($i - 1), null, true); |
|
176 | + if ($prev !== false) { |
|
177 | + if (isset($this->noneFunctionCallIndicators[$tokens[$prev]['code']])) { |
|
178 | + continue; |
|
179 | + } |
|
180 | + |
|
181 | + // Check for namespaced functions, ie: \foo\bar() not \bar(). |
|
182 | + if ($tokens[ $prev ]['code'] === \T_NS_SEPARATOR) { |
|
183 | + $pprev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prev - 1), null, true); |
|
184 | + if ($pprev !== false && $tokens[ $pprev ]['code'] === \T_STRING) { |
|
185 | + continue; |
|
186 | + } |
|
187 | + } |
|
188 | + } |
|
189 | + |
|
190 | + /* |
|
191 | 191 | * Address some special cases. |
192 | 192 | */ |
193 | - if ($foundFunctionName !== 'func_get_args') { |
|
194 | - $paramOne = $this->getFunctionCallParameter($phpcsFile, $i, 1); |
|
195 | - if ($paramOne !== false) { |
|
196 | - switch ($foundFunctionName) { |
|
197 | - /* |
|
193 | + if ($foundFunctionName !== 'func_get_args') { |
|
194 | + $paramOne = $this->getFunctionCallParameter($phpcsFile, $i, 1); |
|
195 | + if ($paramOne !== false) { |
|
196 | + switch ($foundFunctionName) { |
|
197 | + /* |
|
198 | 198 | * Check if `debug_(print_)backtrace()` is called with the |
199 | 199 | * `DEBUG_BACKTRACE_IGNORE_ARGS` option. |
200 | 200 | */ |
201 | - case 'debug_backtrace': |
|
202 | - case 'debug_print_backtrace': |
|
203 | - $hasIgnoreArgs = $phpcsFile->findNext( |
|
204 | - \T_STRING, |
|
205 | - $paramOne['start'], |
|
206 | - ($paramOne['end'] + 1), |
|
207 | - false, |
|
208 | - 'DEBUG_BACKTRACE_IGNORE_ARGS' |
|
209 | - ); |
|
210 | - |
|
211 | - if ($hasIgnoreArgs !== false) { |
|
212 | - // Debug_backtrace() called with ignore args option. |
|
213 | - continue 2; |
|
214 | - } |
|
215 | - break; |
|
216 | - |
|
217 | - /* |
|
201 | + case 'debug_backtrace': |
|
202 | + case 'debug_print_backtrace': |
|
203 | + $hasIgnoreArgs = $phpcsFile->findNext( |
|
204 | + \T_STRING, |
|
205 | + $paramOne['start'], |
|
206 | + ($paramOne['end'] + 1), |
|
207 | + false, |
|
208 | + 'DEBUG_BACKTRACE_IGNORE_ARGS' |
|
209 | + ); |
|
210 | + |
|
211 | + if ($hasIgnoreArgs !== false) { |
|
212 | + // Debug_backtrace() called with ignore args option. |
|
213 | + continue 2; |
|
214 | + } |
|
215 | + break; |
|
216 | + |
|
217 | + /* |
|
218 | 218 | * Collect the necessary information to only throw a notice if the argument |
219 | 219 | * touched/changed is in line with the passed $arg_num. |
220 | 220 | * |
@@ -224,21 +224,21 @@ discard block |
||
224 | 224 | * {@internal Note: This does not take calculations into account! |
225 | 225 | * Should be exceptionally rare and can - if needs be - be addressed at a later stage.}} |
226 | 226 | */ |
227 | - case 'func_get_arg': |
|
228 | - $number = $phpcsFile->findNext(\T_LNUMBER, $paramOne['start'], ($paramOne['end'] + 1)); |
|
229 | - if ($number !== false) { |
|
230 | - $argNumber = $tokens[$number]['content']; |
|
231 | - |
|
232 | - if (isset($paramNames[$argNumber]) === false) { |
|
233 | - // Requesting a non-named additional parameter. Ignore. |
|
234 | - continue 2; |
|
235 | - } |
|
236 | - } |
|
237 | - break; |
|
238 | - } |
|
239 | - } |
|
240 | - } else { |
|
241 | - /* |
|
227 | + case 'func_get_arg': |
|
228 | + $number = $phpcsFile->findNext(\T_LNUMBER, $paramOne['start'], ($paramOne['end'] + 1)); |
|
229 | + if ($number !== false) { |
|
230 | + $argNumber = $tokens[$number]['content']; |
|
231 | + |
|
232 | + if (isset($paramNames[$argNumber]) === false) { |
|
233 | + // Requesting a non-named additional parameter. Ignore. |
|
234 | + continue 2; |
|
235 | + } |
|
236 | + } |
|
237 | + break; |
|
238 | + } |
|
239 | + } |
|
240 | + } else { |
|
241 | + /* |
|
242 | 242 | * Check if the call to func_get_args() happens to be in an array_slice() or |
243 | 243 | * array_splice() with an $offset higher than the number of named parameters. |
244 | 244 | * In that case, we can ignore it. |
@@ -246,33 +246,33 @@ discard block |
||
246 | 246 | * {@internal Note: This does not take offset calculations into account! |
247 | 247 | * Should be exceptionally rare and can - if needs be - be addressed at a later stage.}} |
248 | 248 | */ |
249 | - if ($prev !== false && $tokens[$prev]['code'] === \T_OPEN_PARENTHESIS) { |
|
250 | - |
|
251 | - $maybeFunctionCall = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prev - 1), null, true); |
|
252 | - if ($maybeFunctionCall !== false |
|
253 | - && $tokens[$maybeFunctionCall]['code'] === \T_STRING |
|
254 | - && ($tokens[$maybeFunctionCall]['content'] === 'array_slice' |
|
255 | - || $tokens[$maybeFunctionCall]['content'] === 'array_splice') |
|
256 | - ) { |
|
257 | - $parentFuncParamTwo = $this->getFunctionCallParameter($phpcsFile, $maybeFunctionCall, 2); |
|
258 | - $number = $phpcsFile->findNext( |
|
259 | - \T_LNUMBER, |
|
260 | - $parentFuncParamTwo['start'], |
|
261 | - ($parentFuncParamTwo['end'] + 1) |
|
262 | - ); |
|
263 | - |
|
264 | - if ($number !== false && isset($paramNames[$tokens[$number]['content']]) === false) { |
|
265 | - // Requesting non-named additional parameters. Ignore. |
|
266 | - continue ; |
|
267 | - } |
|
268 | - |
|
269 | - // Slice starts at a named argument, but we know which params are being accessed. |
|
270 | - $paramNamesSubset = \array_slice($paramNames, $tokens[$number]['content']); |
|
271 | - } |
|
272 | - } |
|
273 | - } |
|
274 | - |
|
275 | - /* |
|
249 | + if ($prev !== false && $tokens[$prev]['code'] === \T_OPEN_PARENTHESIS) { |
|
250 | + |
|
251 | + $maybeFunctionCall = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prev - 1), null, true); |
|
252 | + if ($maybeFunctionCall !== false |
|
253 | + && $tokens[$maybeFunctionCall]['code'] === \T_STRING |
|
254 | + && ($tokens[$maybeFunctionCall]['content'] === 'array_slice' |
|
255 | + || $tokens[$maybeFunctionCall]['content'] === 'array_splice') |
|
256 | + ) { |
|
257 | + $parentFuncParamTwo = $this->getFunctionCallParameter($phpcsFile, $maybeFunctionCall, 2); |
|
258 | + $number = $phpcsFile->findNext( |
|
259 | + \T_LNUMBER, |
|
260 | + $parentFuncParamTwo['start'], |
|
261 | + ($parentFuncParamTwo['end'] + 1) |
|
262 | + ); |
|
263 | + |
|
264 | + if ($number !== false && isset($paramNames[$tokens[$number]['content']]) === false) { |
|
265 | + // Requesting non-named additional parameters. Ignore. |
|
266 | + continue ; |
|
267 | + } |
|
268 | + |
|
269 | + // Slice starts at a named argument, but we know which params are being accessed. |
|
270 | + $paramNamesSubset = \array_slice($paramNames, $tokens[$number]['content']); |
|
271 | + } |
|
272 | + } |
|
273 | + } |
|
274 | + |
|
275 | + /* |
|
276 | 276 | * For debug_backtrace(), check if the result is being dereferenced and if so, |
277 | 277 | * whether the `args` index is used. |
278 | 278 | * I.e. whether `$index` in `debug_backtrace()[$stackFrame][$index]` is a string |
@@ -280,160 +280,160 @@ discard block |
||
280 | 280 | * |
281 | 281 | * Note: We already know that $next is the open parenthesis of the function call. |
282 | 282 | */ |
283 | - if ($foundFunctionName === 'debug_backtrace' && isset($tokens[$next]['parenthesis_closer'])) { |
|
284 | - $afterParenthesis = $phpcsFile->findNext( |
|
285 | - Tokens::$emptyTokens, |
|
286 | - ($tokens[$next]['parenthesis_closer'] + 1), |
|
287 | - null, |
|
288 | - true |
|
289 | - ); |
|
290 | - |
|
291 | - if ($tokens[$afterParenthesis]['code'] === \T_OPEN_SQUARE_BRACKET |
|
292 | - && isset($tokens[$afterParenthesis]['bracket_closer']) |
|
293 | - ) { |
|
294 | - $afterStackFrame = $phpcsFile->findNext( |
|
295 | - Tokens::$emptyTokens, |
|
296 | - ($tokens[$afterParenthesis]['bracket_closer'] + 1), |
|
297 | - null, |
|
298 | - true |
|
299 | - ); |
|
300 | - |
|
301 | - if ($tokens[$afterStackFrame]['code'] === \T_OPEN_SQUARE_BRACKET |
|
302 | - && isset($tokens[$afterStackFrame]['bracket_closer']) |
|
303 | - ) { |
|
304 | - $arrayIndex = $phpcsFile->findNext( |
|
305 | - \T_CONSTANT_ENCAPSED_STRING, |
|
306 | - ($afterStackFrame + 1), |
|
307 | - $tokens[$afterStackFrame]['bracket_closer'] |
|
308 | - ); |
|
309 | - |
|
310 | - if ($arrayIndex !== false && $this->stripQuotes($tokens[$arrayIndex]['content']) !== 'args') { |
|
311 | - continue; |
|
312 | - } |
|
313 | - } |
|
314 | - } |
|
315 | - } |
|
316 | - |
|
317 | - /* |
|
283 | + if ($foundFunctionName === 'debug_backtrace' && isset($tokens[$next]['parenthesis_closer'])) { |
|
284 | + $afterParenthesis = $phpcsFile->findNext( |
|
285 | + Tokens::$emptyTokens, |
|
286 | + ($tokens[$next]['parenthesis_closer'] + 1), |
|
287 | + null, |
|
288 | + true |
|
289 | + ); |
|
290 | + |
|
291 | + if ($tokens[$afterParenthesis]['code'] === \T_OPEN_SQUARE_BRACKET |
|
292 | + && isset($tokens[$afterParenthesis]['bracket_closer']) |
|
293 | + ) { |
|
294 | + $afterStackFrame = $phpcsFile->findNext( |
|
295 | + Tokens::$emptyTokens, |
|
296 | + ($tokens[$afterParenthesis]['bracket_closer'] + 1), |
|
297 | + null, |
|
298 | + true |
|
299 | + ); |
|
300 | + |
|
301 | + if ($tokens[$afterStackFrame]['code'] === \T_OPEN_SQUARE_BRACKET |
|
302 | + && isset($tokens[$afterStackFrame]['bracket_closer']) |
|
303 | + ) { |
|
304 | + $arrayIndex = $phpcsFile->findNext( |
|
305 | + \T_CONSTANT_ENCAPSED_STRING, |
|
306 | + ($afterStackFrame + 1), |
|
307 | + $tokens[$afterStackFrame]['bracket_closer'] |
|
308 | + ); |
|
309 | + |
|
310 | + if ($arrayIndex !== false && $this->stripQuotes($tokens[$arrayIndex]['content']) !== 'args') { |
|
311 | + continue; |
|
312 | + } |
|
313 | + } |
|
314 | + } |
|
315 | + } |
|
316 | + |
|
317 | + /* |
|
318 | 318 | * Only check for variables before the start of the statement to |
319 | 319 | * prevent false positives on the return value of the function call |
320 | 320 | * being assigned to one of the parameters, i.e.: |
321 | 321 | * `$param = func_get_args();`. |
322 | 322 | */ |
323 | - $startOfStatement = PHPCSHelper::findStartOfStatement($phpcsFile, $i, $this->ignoreForStartOfStatement); |
|
323 | + $startOfStatement = PHPCSHelper::findStartOfStatement($phpcsFile, $i, $this->ignoreForStartOfStatement); |
|
324 | 324 | |
325 | - /* |
|
325 | + /* |
|
326 | 326 | * Ok, so we've found one of the target functions in the right scope. |
327 | 327 | * Now, let's check if any of the passed parameters were touched. |
328 | 328 | */ |
329 | - $scanResult = 'clean'; |
|
330 | - for ($j = ($scopeOpener + 1); $j < $startOfStatement; $j++) { |
|
331 | - if (isset($this->skipPastNested[$tokens[$j]['type']]) |
|
332 | - && isset($tokens[$j]['scope_closer']) |
|
333 | - ) { |
|
334 | - // Skip past nested structures. |
|
335 | - $j = $tokens[$j]['scope_closer']; |
|
336 | - continue; |
|
337 | - } |
|
338 | - |
|
339 | - if ($tokens[$j]['code'] !== \T_VARIABLE) { |
|
340 | - continue; |
|
341 | - } |
|
342 | - |
|
343 | - if ($foundFunctionName === 'func_get_arg' && isset($argNumber)) { |
|
344 | - if (isset($paramNames[$argNumber]) |
|
345 | - && $tokens[$j]['content'] !== $paramNames[$argNumber] |
|
346 | - ) { |
|
347 | - // Different param than the one requested by func_get_arg(). |
|
348 | - continue; |
|
349 | - } |
|
350 | - } elseif ($foundFunctionName === 'func_get_args' && isset($paramNamesSubset)) { |
|
351 | - if (\in_array($tokens[$j]['content'], $paramNamesSubset, true) === false) { |
|
352 | - // Different param than the ones requested by func_get_args(). |
|
353 | - continue; |
|
354 | - } |
|
355 | - } elseif (\in_array($tokens[$j]['content'], $paramNames, true) === false) { |
|
356 | - // Variable is not one of the function parameters. |
|
357 | - continue; |
|
358 | - } |
|
359 | - |
|
360 | - /* |
|
329 | + $scanResult = 'clean'; |
|
330 | + for ($j = ($scopeOpener + 1); $j < $startOfStatement; $j++) { |
|
331 | + if (isset($this->skipPastNested[$tokens[$j]['type']]) |
|
332 | + && isset($tokens[$j]['scope_closer']) |
|
333 | + ) { |
|
334 | + // Skip past nested structures. |
|
335 | + $j = $tokens[$j]['scope_closer']; |
|
336 | + continue; |
|
337 | + } |
|
338 | + |
|
339 | + if ($tokens[$j]['code'] !== \T_VARIABLE) { |
|
340 | + continue; |
|
341 | + } |
|
342 | + |
|
343 | + if ($foundFunctionName === 'func_get_arg' && isset($argNumber)) { |
|
344 | + if (isset($paramNames[$argNumber]) |
|
345 | + && $tokens[$j]['content'] !== $paramNames[$argNumber] |
|
346 | + ) { |
|
347 | + // Different param than the one requested by func_get_arg(). |
|
348 | + continue; |
|
349 | + } |
|
350 | + } elseif ($foundFunctionName === 'func_get_args' && isset($paramNamesSubset)) { |
|
351 | + if (\in_array($tokens[$j]['content'], $paramNamesSubset, true) === false) { |
|
352 | + // Different param than the ones requested by func_get_args(). |
|
353 | + continue; |
|
354 | + } |
|
355 | + } elseif (\in_array($tokens[$j]['content'], $paramNames, true) === false) { |
|
356 | + // Variable is not one of the function parameters. |
|
357 | + continue; |
|
358 | + } |
|
359 | + |
|
360 | + /* |
|
361 | 361 | * Ok, so we've found a variable which was passed as one of the parameters. |
362 | 362 | * Now, is this variable being changed, i.e. incremented, decremented or |
363 | 363 | * assigned something ? |
364 | 364 | */ |
365 | - $scanResult = 'warning'; |
|
366 | - if (isset($variableToken) === false) { |
|
367 | - $variableToken = $j; |
|
368 | - } |
|
369 | - |
|
370 | - $beforeVar = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($j - 1), null, true); |
|
371 | - if ($beforeVar !== false && isset($this->plusPlusMinusMinus[$tokens[$beforeVar]['code']])) { |
|
372 | - // Variable is being (pre-)incremented/decremented. |
|
373 | - $scanResult = 'error'; |
|
374 | - $variableToken = $j; |
|
375 | - break; |
|
376 | - } |
|
377 | - |
|
378 | - $afterVar = $phpcsFile->findNext(Tokens::$emptyTokens, ($j + 1), null, true); |
|
379 | - if ($afterVar === false) { |
|
380 | - // Shouldn't be possible, but just in case. |
|
381 | - continue; |
|
382 | - } |
|
383 | - |
|
384 | - if (isset($this->plusPlusMinusMinus[$tokens[$afterVar]['code']])) { |
|
385 | - // Variable is being (post-)incremented/decremented. |
|
386 | - $scanResult = 'error'; |
|
387 | - $variableToken = $j; |
|
388 | - break; |
|
389 | - } |
|
390 | - |
|
391 | - if ($tokens[$afterVar]['code'] === \T_OPEN_SQUARE_BRACKET |
|
392 | - && isset($tokens[$afterVar]['bracket_closer']) |
|
393 | - ) { |
|
394 | - // Skip past array access on the variable. |
|
395 | - while (($afterVar = $phpcsFile->findNext(Tokens::$emptyTokens, ($tokens[$afterVar]['bracket_closer'] + 1), null, true)) !== false) { |
|
396 | - if ($tokens[$afterVar]['code'] !== \T_OPEN_SQUARE_BRACKET |
|
397 | - || isset($tokens[$afterVar]['bracket_closer']) === false |
|
398 | - ) { |
|
399 | - break; |
|
400 | - } |
|
401 | - } |
|
402 | - } |
|
403 | - |
|
404 | - if ($afterVar !== false |
|
405 | - && isset(Tokens::$assignmentTokens[$tokens[$afterVar]['code']]) |
|
406 | - ) { |
|
407 | - // Variable is being assigned something. |
|
408 | - $scanResult = 'error'; |
|
409 | - $variableToken = $j; |
|
410 | - break; |
|
411 | - } |
|
412 | - } |
|
413 | - |
|
414 | - unset($argNumber, $paramNamesSubset); |
|
415 | - |
|
416 | - if ($scanResult === 'clean') { |
|
417 | - continue; |
|
418 | - } |
|
419 | - |
|
420 | - $error = 'Since PHP 7.0, functions inspecting arguments, like %1$s(), no longer report the original value as passed to a parameter, but will instead provide the current value. The parameter "%2$s" was %4$s on line %3$s.'; |
|
421 | - $data = array( |
|
422 | - $foundFunctionName, |
|
423 | - $tokens[$variableToken]['content'], |
|
424 | - $tokens[$variableToken]['line'], |
|
425 | - ); |
|
426 | - |
|
427 | - if ($scanResult === 'error') { |
|
428 | - $data[] = 'changed'; |
|
429 | - $phpcsFile->addError($error, $i, 'Changed', $data); |
|
430 | - |
|
431 | - } elseif ($scanResult === 'warning') { |
|
432 | - $data[] = 'used, and possibly changed (by reference),'; |
|
433 | - $phpcsFile->addWarning($error, $i, 'NeedsInspection', $data); |
|
434 | - } |
|
435 | - |
|
436 | - unset($variableToken); |
|
437 | - } |
|
438 | - } |
|
365 | + $scanResult = 'warning'; |
|
366 | + if (isset($variableToken) === false) { |
|
367 | + $variableToken = $j; |
|
368 | + } |
|
369 | + |
|
370 | + $beforeVar = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($j - 1), null, true); |
|
371 | + if ($beforeVar !== false && isset($this->plusPlusMinusMinus[$tokens[$beforeVar]['code']])) { |
|
372 | + // Variable is being (pre-)incremented/decremented. |
|
373 | + $scanResult = 'error'; |
|
374 | + $variableToken = $j; |
|
375 | + break; |
|
376 | + } |
|
377 | + |
|
378 | + $afterVar = $phpcsFile->findNext(Tokens::$emptyTokens, ($j + 1), null, true); |
|
379 | + if ($afterVar === false) { |
|
380 | + // Shouldn't be possible, but just in case. |
|
381 | + continue; |
|
382 | + } |
|
383 | + |
|
384 | + if (isset($this->plusPlusMinusMinus[$tokens[$afterVar]['code']])) { |
|
385 | + // Variable is being (post-)incremented/decremented. |
|
386 | + $scanResult = 'error'; |
|
387 | + $variableToken = $j; |
|
388 | + break; |
|
389 | + } |
|
390 | + |
|
391 | + if ($tokens[$afterVar]['code'] === \T_OPEN_SQUARE_BRACKET |
|
392 | + && isset($tokens[$afterVar]['bracket_closer']) |
|
393 | + ) { |
|
394 | + // Skip past array access on the variable. |
|
395 | + while (($afterVar = $phpcsFile->findNext(Tokens::$emptyTokens, ($tokens[$afterVar]['bracket_closer'] + 1), null, true)) !== false) { |
|
396 | + if ($tokens[$afterVar]['code'] !== \T_OPEN_SQUARE_BRACKET |
|
397 | + || isset($tokens[$afterVar]['bracket_closer']) === false |
|
398 | + ) { |
|
399 | + break; |
|
400 | + } |
|
401 | + } |
|
402 | + } |
|
403 | + |
|
404 | + if ($afterVar !== false |
|
405 | + && isset(Tokens::$assignmentTokens[$tokens[$afterVar]['code']]) |
|
406 | + ) { |
|
407 | + // Variable is being assigned something. |
|
408 | + $scanResult = 'error'; |
|
409 | + $variableToken = $j; |
|
410 | + break; |
|
411 | + } |
|
412 | + } |
|
413 | + |
|
414 | + unset($argNumber, $paramNamesSubset); |
|
415 | + |
|
416 | + if ($scanResult === 'clean') { |
|
417 | + continue; |
|
418 | + } |
|
419 | + |
|
420 | + $error = 'Since PHP 7.0, functions inspecting arguments, like %1$s(), no longer report the original value as passed to a parameter, but will instead provide the current value. The parameter "%2$s" was %4$s on line %3$s.'; |
|
421 | + $data = array( |
|
422 | + $foundFunctionName, |
|
423 | + $tokens[$variableToken]['content'], |
|
424 | + $tokens[$variableToken]['line'], |
|
425 | + ); |
|
426 | + |
|
427 | + if ($scanResult === 'error') { |
|
428 | + $data[] = 'changed'; |
|
429 | + $phpcsFile->addError($error, $i, 'Changed', $data); |
|
430 | + |
|
431 | + } elseif ($scanResult === 'warning') { |
|
432 | + $data[] = 'used, and possibly changed (by reference),'; |
|
433 | + $phpcsFile->addWarning($error, $i, 'NeedsInspection', $data); |
|
434 | + } |
|
435 | + |
|
436 | + unset($variableToken); |
|
437 | + } |
|
438 | + } |
|
439 | 439 | } |
@@ -23,302 +23,302 @@ |
||
23 | 23 | class RequiredToOptionalFunctionParametersSniff extends AbstractComplexVersionSniff |
24 | 24 | { |
25 | 25 | |
26 | - /** |
|
27 | - * A list of function parameters, which were required in older versions and became optional later on. |
|
28 | - * |
|
29 | - * The array lists : version number with true (required) and false (optional). |
|
30 | - * |
|
31 | - * The index is the location of the parameter in the parameter list, starting at 0 ! |
|
32 | - * If's sufficient to list the last version in which the parameter was still required. |
|
33 | - * |
|
34 | - * @var array |
|
35 | - */ |
|
36 | - protected $functionParameters = array( |
|
37 | - 'array_merge' => array( |
|
38 | - 0 => array( |
|
39 | - 'name' => 'array(s) to merge', |
|
40 | - '7.3' => true, |
|
41 | - '7.4' => false, |
|
42 | - ), |
|
43 | - ), |
|
44 | - 'array_merge_recursive' => array( |
|
45 | - 0 => array( |
|
46 | - 'name' => 'array(s) to merge', |
|
47 | - '7.3' => true, |
|
48 | - '7.4' => false, |
|
49 | - ), |
|
50 | - ), |
|
51 | - 'array_push' => array( |
|
52 | - 1 => array( |
|
53 | - 'name' => 'element to push', |
|
54 | - '7.2' => true, |
|
55 | - '7.3' => false, |
|
56 | - ), |
|
57 | - ), |
|
58 | - 'array_unshift' => array( |
|
59 | - 1 => array( |
|
60 | - 'name' => 'element to prepend', |
|
61 | - '7.2' => true, |
|
62 | - '7.3' => false, |
|
63 | - ), |
|
64 | - ), |
|
65 | - 'bcscale' => array( |
|
66 | - 0 => array( |
|
67 | - 'name' => 'scale', |
|
68 | - '7.2' => true, |
|
69 | - '7.3' => false, |
|
70 | - ), |
|
71 | - ), |
|
72 | - 'ftp_fget' => array( |
|
73 | - 3 => array( |
|
74 | - 'name' => 'mode', |
|
75 | - '7.2' => true, |
|
76 | - '7.3' => false, |
|
77 | - ), |
|
78 | - ), |
|
79 | - 'ftp_fput' => array( |
|
80 | - 3 => array( |
|
81 | - 'name' => 'mode', |
|
82 | - '7.2' => true, |
|
83 | - '7.3' => false, |
|
84 | - ), |
|
85 | - ), |
|
86 | - 'ftp_get' => array( |
|
87 | - 3 => array( |
|
88 | - 'name' => 'mode', |
|
89 | - '7.2' => true, |
|
90 | - '7.3' => false, |
|
91 | - ), |
|
92 | - ), |
|
93 | - 'ftp_nb_fget' => array( |
|
94 | - 3 => array( |
|
95 | - 'name' => 'mode', |
|
96 | - '7.2' => true, |
|
97 | - '7.3' => false, |
|
98 | - ), |
|
99 | - ), |
|
100 | - 'ftp_nb_fput' => array( |
|
101 | - 3 => array( |
|
102 | - 'name' => 'mode', |
|
103 | - '7.2' => true, |
|
104 | - '7.3' => false, |
|
105 | - ), |
|
106 | - ), |
|
107 | - 'ftp_nb_get' => array( |
|
108 | - 3 => array( |
|
109 | - 'name' => 'mode', |
|
110 | - '7.2' => true, |
|
111 | - '7.3' => false, |
|
112 | - ), |
|
113 | - ), |
|
114 | - 'ftp_nb_put' => array( |
|
115 | - 3 => array( |
|
116 | - 'name' => 'mode', |
|
117 | - '7.2' => true, |
|
118 | - '7.3' => false, |
|
119 | - ), |
|
120 | - ), |
|
121 | - 'ftp_put' => array( |
|
122 | - 3 => array( |
|
123 | - 'name' => 'mode', |
|
124 | - '7.2' => true, |
|
125 | - '7.3' => false, |
|
126 | - ), |
|
127 | - ), |
|
128 | - 'getenv' => array( |
|
129 | - 0 => array( |
|
130 | - 'name' => 'varname', |
|
131 | - '7.0' => true, |
|
132 | - '7.1' => false, |
|
133 | - ), |
|
134 | - ), |
|
135 | - 'preg_match_all' => array( |
|
136 | - 2 => array( |
|
137 | - 'name' => 'matches', |
|
138 | - '5.3' => true, |
|
139 | - '5.4' => false, |
|
140 | - ), |
|
141 | - ), |
|
142 | - 'stream_socket_enable_crypto' => array( |
|
143 | - 2 => array( |
|
144 | - 'name' => 'crypto_type', |
|
145 | - '5.5' => true, |
|
146 | - '5.6' => false, |
|
147 | - ), |
|
148 | - ), |
|
149 | - ); |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * Returns an array of tokens this test wants to listen for. |
|
154 | - * |
|
155 | - * @return array |
|
156 | - */ |
|
157 | - public function register() |
|
158 | - { |
|
159 | - // Handle case-insensitivity of function names. |
|
160 | - $this->functionParameters = $this->arrayKeysToLowercase($this->functionParameters); |
|
161 | - |
|
162 | - return array(\T_STRING); |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * Processes this test, when one of its tokens is encountered. |
|
167 | - * |
|
168 | - * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
169 | - * @param int $stackPtr The position of the current token in |
|
170 | - * the stack passed in $tokens. |
|
171 | - * |
|
172 | - * @return void |
|
173 | - */ |
|
174 | - public function process(File $phpcsFile, $stackPtr) |
|
175 | - { |
|
176 | - $tokens = $phpcsFile->getTokens(); |
|
177 | - |
|
178 | - $ignore = array( |
|
179 | - \T_DOUBLE_COLON => true, |
|
180 | - \T_OBJECT_OPERATOR => true, |
|
181 | - \T_FUNCTION => true, |
|
182 | - \T_CONST => true, |
|
183 | - ); |
|
184 | - |
|
185 | - $prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true); |
|
186 | - if (isset($ignore[$tokens[$prevToken]['code']]) === true) { |
|
187 | - // Not a call to a PHP function. |
|
188 | - return; |
|
189 | - } |
|
190 | - |
|
191 | - $function = $tokens[$stackPtr]['content']; |
|
192 | - $functionLc = strtolower($function); |
|
193 | - |
|
194 | - if (isset($this->functionParameters[$functionLc]) === false) { |
|
195 | - return; |
|
196 | - } |
|
197 | - |
|
198 | - $parameterCount = $this->getFunctionCallParameterCount($phpcsFile, $stackPtr); |
|
199 | - $openParenthesis = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true); |
|
200 | - |
|
201 | - // If the parameter count returned > 0, we know there will be valid open parenthesis. |
|
202 | - if ($parameterCount === 0 && $tokens[$openParenthesis]['code'] !== \T_OPEN_PARENTHESIS) { |
|
203 | - return; |
|
204 | - } |
|
205 | - |
|
206 | - $parameterOffsetFound = $parameterCount - 1; |
|
207 | - |
|
208 | - foreach ($this->functionParameters[$functionLc] as $offset => $parameterDetails) { |
|
209 | - if ($offset > $parameterOffsetFound) { |
|
210 | - $itemInfo = array( |
|
211 | - 'name' => $function, |
|
212 | - 'nameLc' => $functionLc, |
|
213 | - 'offset' => $offset, |
|
214 | - ); |
|
215 | - $this->handleFeature($phpcsFile, $openParenthesis, $itemInfo); |
|
216 | - } |
|
217 | - } |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - /** |
|
222 | - * Determine whether an error/warning should be thrown for an item based on collected information. |
|
223 | - * |
|
224 | - * @param array $errorInfo Detail information about an item. |
|
225 | - * |
|
226 | - * @return bool |
|
227 | - */ |
|
228 | - protected function shouldThrowError(array $errorInfo) |
|
229 | - { |
|
230 | - return ($errorInfo['requiredVersion'] !== ''); |
|
231 | - } |
|
232 | - |
|
233 | - |
|
234 | - /** |
|
235 | - * Get the relevant sub-array for a specific item from a multi-dimensional array. |
|
236 | - * |
|
237 | - * @param array $itemInfo Base information about the item. |
|
238 | - * |
|
239 | - * @return array Version and other information about the item. |
|
240 | - */ |
|
241 | - public function getItemArray(array $itemInfo) |
|
242 | - { |
|
243 | - return $this->functionParameters[$itemInfo['nameLc']][$itemInfo['offset']]; |
|
244 | - } |
|
245 | - |
|
246 | - |
|
247 | - /** |
|
248 | - * Get an array of the non-PHP-version array keys used in a sub-array. |
|
249 | - * |
|
250 | - * @return array |
|
251 | - */ |
|
252 | - protected function getNonVersionArrayKeys() |
|
253 | - { |
|
254 | - return array('name'); |
|
255 | - } |
|
256 | - |
|
257 | - |
|
258 | - /** |
|
259 | - * Retrieve the relevant detail (version) information for use in an error message. |
|
260 | - * |
|
261 | - * @param array $itemArray Version and other information about the item. |
|
262 | - * @param array $itemInfo Base information about the item. |
|
263 | - * |
|
264 | - * @return array |
|
265 | - */ |
|
266 | - public function getErrorInfo(array $itemArray, array $itemInfo) |
|
267 | - { |
|
268 | - $errorInfo = array( |
|
269 | - 'paramName' => '', |
|
270 | - 'requiredVersion' => '', |
|
271 | - ); |
|
272 | - |
|
273 | - $versionArray = $this->getVersionArray($itemArray); |
|
274 | - |
|
275 | - if (empty($versionArray) === false) { |
|
276 | - foreach ($versionArray as $version => $required) { |
|
277 | - if ($required === true && $this->supportsBelow($version) === true) { |
|
278 | - $errorInfo['requiredVersion'] = $version; |
|
279 | - } |
|
280 | - } |
|
281 | - } |
|
282 | - |
|
283 | - $errorInfo['paramName'] = $itemArray['name']; |
|
284 | - |
|
285 | - return $errorInfo; |
|
286 | - } |
|
287 | - |
|
288 | - |
|
289 | - /** |
|
290 | - * Get the error message template for this sniff. |
|
291 | - * |
|
292 | - * @return string |
|
293 | - */ |
|
294 | - protected function getErrorMsgTemplate() |
|
295 | - { |
|
296 | - return 'The "%s" parameter for function %s() is missing, but was required for PHP version %s and lower'; |
|
297 | - } |
|
298 | - |
|
299 | - |
|
300 | - /** |
|
301 | - * Generates the error or warning for this item. |
|
302 | - * |
|
303 | - * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
304 | - * @param int $stackPtr The position of the relevant token in |
|
305 | - * the stack. |
|
306 | - * @param array $itemInfo Base information about the item. |
|
307 | - * @param array $errorInfo Array with detail (version) information |
|
308 | - * relevant to the item. |
|
309 | - * |
|
310 | - * @return void |
|
311 | - */ |
|
312 | - public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo) |
|
313 | - { |
|
314 | - $error = $this->getErrorMsgTemplate(); |
|
315 | - $errorCode = $this->stringToErrorCode($itemInfo['name'] . '_' . $errorInfo['paramName']) . 'Missing'; |
|
316 | - $data = array( |
|
317 | - $errorInfo['paramName'], |
|
318 | - $itemInfo['name'], |
|
319 | - $errorInfo['requiredVersion'], |
|
320 | - ); |
|
321 | - |
|
322 | - $phpcsFile->addError($error, $stackPtr, $errorCode, $data); |
|
323 | - } |
|
26 | + /** |
|
27 | + * A list of function parameters, which were required in older versions and became optional later on. |
|
28 | + * |
|
29 | + * The array lists : version number with true (required) and false (optional). |
|
30 | + * |
|
31 | + * The index is the location of the parameter in the parameter list, starting at 0 ! |
|
32 | + * If's sufficient to list the last version in which the parameter was still required. |
|
33 | + * |
|
34 | + * @var array |
|
35 | + */ |
|
36 | + protected $functionParameters = array( |
|
37 | + 'array_merge' => array( |
|
38 | + 0 => array( |
|
39 | + 'name' => 'array(s) to merge', |
|
40 | + '7.3' => true, |
|
41 | + '7.4' => false, |
|
42 | + ), |
|
43 | + ), |
|
44 | + 'array_merge_recursive' => array( |
|
45 | + 0 => array( |
|
46 | + 'name' => 'array(s) to merge', |
|
47 | + '7.3' => true, |
|
48 | + '7.4' => false, |
|
49 | + ), |
|
50 | + ), |
|
51 | + 'array_push' => array( |
|
52 | + 1 => array( |
|
53 | + 'name' => 'element to push', |
|
54 | + '7.2' => true, |
|
55 | + '7.3' => false, |
|
56 | + ), |
|
57 | + ), |
|
58 | + 'array_unshift' => array( |
|
59 | + 1 => array( |
|
60 | + 'name' => 'element to prepend', |
|
61 | + '7.2' => true, |
|
62 | + '7.3' => false, |
|
63 | + ), |
|
64 | + ), |
|
65 | + 'bcscale' => array( |
|
66 | + 0 => array( |
|
67 | + 'name' => 'scale', |
|
68 | + '7.2' => true, |
|
69 | + '7.3' => false, |
|
70 | + ), |
|
71 | + ), |
|
72 | + 'ftp_fget' => array( |
|
73 | + 3 => array( |
|
74 | + 'name' => 'mode', |
|
75 | + '7.2' => true, |
|
76 | + '7.3' => false, |
|
77 | + ), |
|
78 | + ), |
|
79 | + 'ftp_fput' => array( |
|
80 | + 3 => array( |
|
81 | + 'name' => 'mode', |
|
82 | + '7.2' => true, |
|
83 | + '7.3' => false, |
|
84 | + ), |
|
85 | + ), |
|
86 | + 'ftp_get' => array( |
|
87 | + 3 => array( |
|
88 | + 'name' => 'mode', |
|
89 | + '7.2' => true, |
|
90 | + '7.3' => false, |
|
91 | + ), |
|
92 | + ), |
|
93 | + 'ftp_nb_fget' => array( |
|
94 | + 3 => array( |
|
95 | + 'name' => 'mode', |
|
96 | + '7.2' => true, |
|
97 | + '7.3' => false, |
|
98 | + ), |
|
99 | + ), |
|
100 | + 'ftp_nb_fput' => array( |
|
101 | + 3 => array( |
|
102 | + 'name' => 'mode', |
|
103 | + '7.2' => true, |
|
104 | + '7.3' => false, |
|
105 | + ), |
|
106 | + ), |
|
107 | + 'ftp_nb_get' => array( |
|
108 | + 3 => array( |
|
109 | + 'name' => 'mode', |
|
110 | + '7.2' => true, |
|
111 | + '7.3' => false, |
|
112 | + ), |
|
113 | + ), |
|
114 | + 'ftp_nb_put' => array( |
|
115 | + 3 => array( |
|
116 | + 'name' => 'mode', |
|
117 | + '7.2' => true, |
|
118 | + '7.3' => false, |
|
119 | + ), |
|
120 | + ), |
|
121 | + 'ftp_put' => array( |
|
122 | + 3 => array( |
|
123 | + 'name' => 'mode', |
|
124 | + '7.2' => true, |
|
125 | + '7.3' => false, |
|
126 | + ), |
|
127 | + ), |
|
128 | + 'getenv' => array( |
|
129 | + 0 => array( |
|
130 | + 'name' => 'varname', |
|
131 | + '7.0' => true, |
|
132 | + '7.1' => false, |
|
133 | + ), |
|
134 | + ), |
|
135 | + 'preg_match_all' => array( |
|
136 | + 2 => array( |
|
137 | + 'name' => 'matches', |
|
138 | + '5.3' => true, |
|
139 | + '5.4' => false, |
|
140 | + ), |
|
141 | + ), |
|
142 | + 'stream_socket_enable_crypto' => array( |
|
143 | + 2 => array( |
|
144 | + 'name' => 'crypto_type', |
|
145 | + '5.5' => true, |
|
146 | + '5.6' => false, |
|
147 | + ), |
|
148 | + ), |
|
149 | + ); |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * Returns an array of tokens this test wants to listen for. |
|
154 | + * |
|
155 | + * @return array |
|
156 | + */ |
|
157 | + public function register() |
|
158 | + { |
|
159 | + // Handle case-insensitivity of function names. |
|
160 | + $this->functionParameters = $this->arrayKeysToLowercase($this->functionParameters); |
|
161 | + |
|
162 | + return array(\T_STRING); |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * Processes this test, when one of its tokens is encountered. |
|
167 | + * |
|
168 | + * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
169 | + * @param int $stackPtr The position of the current token in |
|
170 | + * the stack passed in $tokens. |
|
171 | + * |
|
172 | + * @return void |
|
173 | + */ |
|
174 | + public function process(File $phpcsFile, $stackPtr) |
|
175 | + { |
|
176 | + $tokens = $phpcsFile->getTokens(); |
|
177 | + |
|
178 | + $ignore = array( |
|
179 | + \T_DOUBLE_COLON => true, |
|
180 | + \T_OBJECT_OPERATOR => true, |
|
181 | + \T_FUNCTION => true, |
|
182 | + \T_CONST => true, |
|
183 | + ); |
|
184 | + |
|
185 | + $prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true); |
|
186 | + if (isset($ignore[$tokens[$prevToken]['code']]) === true) { |
|
187 | + // Not a call to a PHP function. |
|
188 | + return; |
|
189 | + } |
|
190 | + |
|
191 | + $function = $tokens[$stackPtr]['content']; |
|
192 | + $functionLc = strtolower($function); |
|
193 | + |
|
194 | + if (isset($this->functionParameters[$functionLc]) === false) { |
|
195 | + return; |
|
196 | + } |
|
197 | + |
|
198 | + $parameterCount = $this->getFunctionCallParameterCount($phpcsFile, $stackPtr); |
|
199 | + $openParenthesis = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true); |
|
200 | + |
|
201 | + // If the parameter count returned > 0, we know there will be valid open parenthesis. |
|
202 | + if ($parameterCount === 0 && $tokens[$openParenthesis]['code'] !== \T_OPEN_PARENTHESIS) { |
|
203 | + return; |
|
204 | + } |
|
205 | + |
|
206 | + $parameterOffsetFound = $parameterCount - 1; |
|
207 | + |
|
208 | + foreach ($this->functionParameters[$functionLc] as $offset => $parameterDetails) { |
|
209 | + if ($offset > $parameterOffsetFound) { |
|
210 | + $itemInfo = array( |
|
211 | + 'name' => $function, |
|
212 | + 'nameLc' => $functionLc, |
|
213 | + 'offset' => $offset, |
|
214 | + ); |
|
215 | + $this->handleFeature($phpcsFile, $openParenthesis, $itemInfo); |
|
216 | + } |
|
217 | + } |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + /** |
|
222 | + * Determine whether an error/warning should be thrown for an item based on collected information. |
|
223 | + * |
|
224 | + * @param array $errorInfo Detail information about an item. |
|
225 | + * |
|
226 | + * @return bool |
|
227 | + */ |
|
228 | + protected function shouldThrowError(array $errorInfo) |
|
229 | + { |
|
230 | + return ($errorInfo['requiredVersion'] !== ''); |
|
231 | + } |
|
232 | + |
|
233 | + |
|
234 | + /** |
|
235 | + * Get the relevant sub-array for a specific item from a multi-dimensional array. |
|
236 | + * |
|
237 | + * @param array $itemInfo Base information about the item. |
|
238 | + * |
|
239 | + * @return array Version and other information about the item. |
|
240 | + */ |
|
241 | + public function getItemArray(array $itemInfo) |
|
242 | + { |
|
243 | + return $this->functionParameters[$itemInfo['nameLc']][$itemInfo['offset']]; |
|
244 | + } |
|
245 | + |
|
246 | + |
|
247 | + /** |
|
248 | + * Get an array of the non-PHP-version array keys used in a sub-array. |
|
249 | + * |
|
250 | + * @return array |
|
251 | + */ |
|
252 | + protected function getNonVersionArrayKeys() |
|
253 | + { |
|
254 | + return array('name'); |
|
255 | + } |
|
256 | + |
|
257 | + |
|
258 | + /** |
|
259 | + * Retrieve the relevant detail (version) information for use in an error message. |
|
260 | + * |
|
261 | + * @param array $itemArray Version and other information about the item. |
|
262 | + * @param array $itemInfo Base information about the item. |
|
263 | + * |
|
264 | + * @return array |
|
265 | + */ |
|
266 | + public function getErrorInfo(array $itemArray, array $itemInfo) |
|
267 | + { |
|
268 | + $errorInfo = array( |
|
269 | + 'paramName' => '', |
|
270 | + 'requiredVersion' => '', |
|
271 | + ); |
|
272 | + |
|
273 | + $versionArray = $this->getVersionArray($itemArray); |
|
274 | + |
|
275 | + if (empty($versionArray) === false) { |
|
276 | + foreach ($versionArray as $version => $required) { |
|
277 | + if ($required === true && $this->supportsBelow($version) === true) { |
|
278 | + $errorInfo['requiredVersion'] = $version; |
|
279 | + } |
|
280 | + } |
|
281 | + } |
|
282 | + |
|
283 | + $errorInfo['paramName'] = $itemArray['name']; |
|
284 | + |
|
285 | + return $errorInfo; |
|
286 | + } |
|
287 | + |
|
288 | + |
|
289 | + /** |
|
290 | + * Get the error message template for this sniff. |
|
291 | + * |
|
292 | + * @return string |
|
293 | + */ |
|
294 | + protected function getErrorMsgTemplate() |
|
295 | + { |
|
296 | + return 'The "%s" parameter for function %s() is missing, but was required for PHP version %s and lower'; |
|
297 | + } |
|
298 | + |
|
299 | + |
|
300 | + /** |
|
301 | + * Generates the error or warning for this item. |
|
302 | + * |
|
303 | + * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
304 | + * @param int $stackPtr The position of the relevant token in |
|
305 | + * the stack. |
|
306 | + * @param array $itemInfo Base information about the item. |
|
307 | + * @param array $errorInfo Array with detail (version) information |
|
308 | + * relevant to the item. |
|
309 | + * |
|
310 | + * @return void |
|
311 | + */ |
|
312 | + public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo) |
|
313 | + { |
|
314 | + $error = $this->getErrorMsgTemplate(); |
|
315 | + $errorCode = $this->stringToErrorCode($itemInfo['name'] . '_' . $errorInfo['paramName']) . 'Missing'; |
|
316 | + $data = array( |
|
317 | + $errorInfo['paramName'], |
|
318 | + $itemInfo['name'], |
|
319 | + $errorInfo['requiredVersion'], |
|
320 | + ); |
|
321 | + |
|
322 | + $phpcsFile->addError($error, $stackPtr, $errorCode, $data); |
|
323 | + } |
|
324 | 324 | } |
@@ -35,130 +35,130 @@ |
||
35 | 35 | class ArgumentFunctionsUsageSniff extends Sniff |
36 | 36 | { |
37 | 37 | |
38 | - /** |
|
39 | - * The target functions for this sniff. |
|
40 | - * |
|
41 | - * @var array |
|
42 | - */ |
|
43 | - protected $targetFunctions = array( |
|
44 | - 'func_get_args' => true, |
|
45 | - 'func_get_arg' => true, |
|
46 | - 'func_num_args' => true, |
|
47 | - ); |
|
48 | - |
|
49 | - |
|
50 | - /** |
|
51 | - * Returns an array of tokens this test wants to listen for. |
|
52 | - * |
|
53 | - * @return array |
|
54 | - */ |
|
55 | - public function register() |
|
56 | - { |
|
57 | - return array(\T_STRING); |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * Processes this test, when one of its tokens is encountered. |
|
63 | - * |
|
64 | - * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
65 | - * @param int $stackPtr The position of the current token in the |
|
66 | - * stack passed in $tokens. |
|
67 | - * |
|
68 | - * @return void |
|
69 | - */ |
|
70 | - public function process(File $phpcsFile, $stackPtr) |
|
71 | - { |
|
72 | - $tokens = $phpcsFile->getTokens(); |
|
73 | - $functionLc = strtolower($tokens[$stackPtr]['content']); |
|
74 | - if (isset($this->targetFunctions[$functionLc]) === false) { |
|
75 | - return; |
|
76 | - } |
|
77 | - |
|
78 | - // Next non-empty token should be the open parenthesis. |
|
79 | - $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true); |
|
80 | - if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_OPEN_PARENTHESIS) { |
|
81 | - return; |
|
82 | - } |
|
83 | - |
|
84 | - $ignore = array( |
|
85 | - \T_DOUBLE_COLON => true, |
|
86 | - \T_OBJECT_OPERATOR => true, |
|
87 | - \T_FUNCTION => true, |
|
88 | - \T_NEW => true, |
|
89 | - ); |
|
90 | - |
|
91 | - $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); |
|
92 | - if (isset($ignore[$tokens[$prevNonEmpty]['code']]) === true) { |
|
93 | - // Not a call to a PHP function. |
|
94 | - return; |
|
95 | - } elseif ($tokens[$prevNonEmpty]['code'] === \T_NS_SEPARATOR && $tokens[$prevNonEmpty - 1]['code'] === \T_STRING) { |
|
96 | - // Namespaced function. |
|
97 | - return; |
|
98 | - } |
|
99 | - |
|
100 | - $data = $tokens[$stackPtr]['content']; |
|
101 | - |
|
102 | - /* |
|
38 | + /** |
|
39 | + * The target functions for this sniff. |
|
40 | + * |
|
41 | + * @var array |
|
42 | + */ |
|
43 | + protected $targetFunctions = array( |
|
44 | + 'func_get_args' => true, |
|
45 | + 'func_get_arg' => true, |
|
46 | + 'func_num_args' => true, |
|
47 | + ); |
|
48 | + |
|
49 | + |
|
50 | + /** |
|
51 | + * Returns an array of tokens this test wants to listen for. |
|
52 | + * |
|
53 | + * @return array |
|
54 | + */ |
|
55 | + public function register() |
|
56 | + { |
|
57 | + return array(\T_STRING); |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * Processes this test, when one of its tokens is encountered. |
|
63 | + * |
|
64 | + * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
65 | + * @param int $stackPtr The position of the current token in the |
|
66 | + * stack passed in $tokens. |
|
67 | + * |
|
68 | + * @return void |
|
69 | + */ |
|
70 | + public function process(File $phpcsFile, $stackPtr) |
|
71 | + { |
|
72 | + $tokens = $phpcsFile->getTokens(); |
|
73 | + $functionLc = strtolower($tokens[$stackPtr]['content']); |
|
74 | + if (isset($this->targetFunctions[$functionLc]) === false) { |
|
75 | + return; |
|
76 | + } |
|
77 | + |
|
78 | + // Next non-empty token should be the open parenthesis. |
|
79 | + $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true); |
|
80 | + if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_OPEN_PARENTHESIS) { |
|
81 | + return; |
|
82 | + } |
|
83 | + |
|
84 | + $ignore = array( |
|
85 | + \T_DOUBLE_COLON => true, |
|
86 | + \T_OBJECT_OPERATOR => true, |
|
87 | + \T_FUNCTION => true, |
|
88 | + \T_NEW => true, |
|
89 | + ); |
|
90 | + |
|
91 | + $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); |
|
92 | + if (isset($ignore[$tokens[$prevNonEmpty]['code']]) === true) { |
|
93 | + // Not a call to a PHP function. |
|
94 | + return; |
|
95 | + } elseif ($tokens[$prevNonEmpty]['code'] === \T_NS_SEPARATOR && $tokens[$prevNonEmpty - 1]['code'] === \T_STRING) { |
|
96 | + // Namespaced function. |
|
97 | + return; |
|
98 | + } |
|
99 | + |
|
100 | + $data = $tokens[$stackPtr]['content']; |
|
101 | + |
|
102 | + /* |
|
103 | 103 | * Check for usage of the functions in the global scope. |
104 | 104 | * |
105 | 105 | * As PHPCS can not determine whether a file is included from within a function in |
106 | 106 | * another file, so always throw a warning/error. |
107 | 107 | */ |
108 | - if ($phpcsFile->hasCondition($stackPtr, array(\T_FUNCTION, \T_CLOSURE)) === false) { |
|
109 | - $isError = false; |
|
110 | - $message = 'Use of %s() outside of a user-defined function is only supported if the file is included from within a user-defined function in another file prior to PHP 5.3.'; |
|
108 | + if ($phpcsFile->hasCondition($stackPtr, array(\T_FUNCTION, \T_CLOSURE)) === false) { |
|
109 | + $isError = false; |
|
110 | + $message = 'Use of %s() outside of a user-defined function is only supported if the file is included from within a user-defined function in another file prior to PHP 5.3.'; |
|
111 | 111 | |
112 | - if ($this->supportsAbove('5.3') === true) { |
|
113 | - $isError = true; |
|
114 | - $message .= ' As of PHP 5.3, it is no longer supported at all.'; |
|
115 | - } |
|
112 | + if ($this->supportsAbove('5.3') === true) { |
|
113 | + $isError = true; |
|
114 | + $message .= ' As of PHP 5.3, it is no longer supported at all.'; |
|
115 | + } |
|
116 | 116 | |
117 | - $this->addMessage($phpcsFile, $message, $stackPtr, $isError, 'OutsideFunctionScope', $data); |
|
118 | - } |
|
117 | + $this->addMessage($phpcsFile, $message, $stackPtr, $isError, 'OutsideFunctionScope', $data); |
|
118 | + } |
|
119 | 119 | |
120 | - /* |
|
120 | + /* |
|
121 | 121 | * Check for usage of the functions as a parameter in a function call. |
122 | 122 | */ |
123 | - if ($this->supportsBelow('5.2') === false) { |
|
124 | - return; |
|
125 | - } |
|
126 | - |
|
127 | - if (isset($tokens[$stackPtr]['nested_parenthesis']) === false) { |
|
128 | - return; |
|
129 | - } |
|
130 | - |
|
131 | - $throwError = false; |
|
132 | - |
|
133 | - $closer = end($tokens[$stackPtr]['nested_parenthesis']); |
|
134 | - if (isset($tokens[$closer]['parenthesis_owner']) |
|
135 | - && $tokens[$tokens[$closer]['parenthesis_owner']]['type'] === 'T_CLOSURE' |
|
136 | - ) { |
|
137 | - $throwError = true; |
|
138 | - } else { |
|
139 | - $opener = key($tokens[$stackPtr]['nested_parenthesis']); |
|
140 | - $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($opener - 1), null, true); |
|
141 | - if ($tokens[$prevNonEmpty]['code'] !== \T_STRING) { |
|
142 | - return; |
|
143 | - } |
|
144 | - |
|
145 | - $prevPrevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prevNonEmpty - 1), null, true); |
|
146 | - if ($tokens[$prevPrevNonEmpty]['code'] === \T_FUNCTION) { |
|
147 | - return; |
|
148 | - } |
|
149 | - |
|
150 | - $throwError = true; |
|
151 | - } |
|
152 | - |
|
153 | - if ($throwError === false) { |
|
154 | - return; |
|
155 | - } |
|
156 | - |
|
157 | - $phpcsFile->addError( |
|
158 | - '%s() could not be used in parameter lists prior to PHP 5.3.', |
|
159 | - $stackPtr, |
|
160 | - 'InParameterList', |
|
161 | - $data |
|
162 | - ); |
|
163 | - } |
|
123 | + if ($this->supportsBelow('5.2') === false) { |
|
124 | + return; |
|
125 | + } |
|
126 | + |
|
127 | + if (isset($tokens[$stackPtr]['nested_parenthesis']) === false) { |
|
128 | + return; |
|
129 | + } |
|
130 | + |
|
131 | + $throwError = false; |
|
132 | + |
|
133 | + $closer = end($tokens[$stackPtr]['nested_parenthesis']); |
|
134 | + if (isset($tokens[$closer]['parenthesis_owner']) |
|
135 | + && $tokens[$tokens[$closer]['parenthesis_owner']]['type'] === 'T_CLOSURE' |
|
136 | + ) { |
|
137 | + $throwError = true; |
|
138 | + } else { |
|
139 | + $opener = key($tokens[$stackPtr]['nested_parenthesis']); |
|
140 | + $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($opener - 1), null, true); |
|
141 | + if ($tokens[$prevNonEmpty]['code'] !== \T_STRING) { |
|
142 | + return; |
|
143 | + } |
|
144 | + |
|
145 | + $prevPrevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prevNonEmpty - 1), null, true); |
|
146 | + if ($tokens[$prevPrevNonEmpty]['code'] === \T_FUNCTION) { |
|
147 | + return; |
|
148 | + } |
|
149 | + |
|
150 | + $throwError = true; |
|
151 | + } |
|
152 | + |
|
153 | + if ($throwError === false) { |
|
154 | + return; |
|
155 | + } |
|
156 | + |
|
157 | + $phpcsFile->addError( |
|
158 | + '%s() could not be used in parameter lists prior to PHP 5.3.', |
|
159 | + $stackPtr, |
|
160 | + 'InParameterList', |
|
161 | + $data |
|
162 | + ); |
|
163 | + } |
|
164 | 164 | } |
@@ -21,1018 +21,1018 @@ |
||
21 | 21 | */ |
22 | 22 | class RemovedFunctionsSniff extends AbstractRemovedFeatureSniff |
23 | 23 | { |
24 | - /** |
|
25 | - * A list of deprecated and removed functions with their alternatives. |
|
26 | - * |
|
27 | - * The array lists : version number with false (deprecated) or true (removed) and an alternative function. |
|
28 | - * If no alternative exists, it is NULL, i.e, the function should just not be used. |
|
29 | - * |
|
30 | - * @var array(string => array(string => bool|string|null)) |
|
31 | - */ |
|
32 | - protected $removedFunctions = array( |
|
33 | - 'php_check_syntax' => array( |
|
34 | - '5.0.5' => true, |
|
35 | - 'alternative' => null, |
|
36 | - ), |
|
24 | + /** |
|
25 | + * A list of deprecated and removed functions with their alternatives. |
|
26 | + * |
|
27 | + * The array lists : version number with false (deprecated) or true (removed) and an alternative function. |
|
28 | + * If no alternative exists, it is NULL, i.e, the function should just not be used. |
|
29 | + * |
|
30 | + * @var array(string => array(string => bool|string|null)) |
|
31 | + */ |
|
32 | + protected $removedFunctions = array( |
|
33 | + 'php_check_syntax' => array( |
|
34 | + '5.0.5' => true, |
|
35 | + 'alternative' => null, |
|
36 | + ), |
|
37 | 37 | |
38 | - 'pfpro_cleanup' => array( |
|
39 | - '5.1' => true, |
|
40 | - 'alternative' => null, |
|
41 | - ), |
|
42 | - 'pfpro_init' => array( |
|
43 | - '5.1' => true, |
|
44 | - 'alternative' => null, |
|
45 | - ), |
|
46 | - 'pfpro_process_raw' => array( |
|
47 | - '5.1' => true, |
|
48 | - 'alternative' => null, |
|
49 | - ), |
|
50 | - 'pfpro_process' => array( |
|
51 | - '5.1' => true, |
|
52 | - 'alternative' => null, |
|
53 | - ), |
|
54 | - 'pfpro_version' => array( |
|
55 | - '5.1' => true, |
|
56 | - 'alternative' => null, |
|
57 | - ), |
|
38 | + 'pfpro_cleanup' => array( |
|
39 | + '5.1' => true, |
|
40 | + 'alternative' => null, |
|
41 | + ), |
|
42 | + 'pfpro_init' => array( |
|
43 | + '5.1' => true, |
|
44 | + 'alternative' => null, |
|
45 | + ), |
|
46 | + 'pfpro_process_raw' => array( |
|
47 | + '5.1' => true, |
|
48 | + 'alternative' => null, |
|
49 | + ), |
|
50 | + 'pfpro_process' => array( |
|
51 | + '5.1' => true, |
|
52 | + 'alternative' => null, |
|
53 | + ), |
|
54 | + 'pfpro_version' => array( |
|
55 | + '5.1' => true, |
|
56 | + 'alternative' => null, |
|
57 | + ), |
|
58 | 58 | |
59 | - 'call_user_method' => array( |
|
60 | - '5.3' => false, |
|
61 | - '7.0' => true, |
|
62 | - 'alternative' => 'call_user_func()', |
|
63 | - ), |
|
64 | - 'call_user_method_array' => array( |
|
65 | - '5.3' => false, |
|
66 | - '7.0' => true, |
|
67 | - 'alternative' => 'call_user_func_array()', |
|
68 | - ), |
|
69 | - 'define_syslog_variables' => array( |
|
70 | - '5.3' => false, |
|
71 | - '5.4' => true, |
|
72 | - 'alternative' => null, |
|
73 | - ), |
|
74 | - 'dl' => array( |
|
75 | - '5.3' => false, |
|
76 | - 'alternative' => null, |
|
77 | - ), |
|
78 | - 'ereg' => array( |
|
79 | - '5.3' => false, |
|
80 | - '7.0' => true, |
|
81 | - 'alternative' => 'preg_match()', |
|
82 | - ), |
|
83 | - 'ereg_replace' => array( |
|
84 | - '5.3' => false, |
|
85 | - '7.0' => true, |
|
86 | - 'alternative' => 'preg_replace()', |
|
87 | - ), |
|
88 | - 'eregi' => array( |
|
89 | - '5.3' => false, |
|
90 | - '7.0' => true, |
|
91 | - 'alternative' => 'preg_match()', |
|
92 | - ), |
|
93 | - 'eregi_replace' => array( |
|
94 | - '5.3' => false, |
|
95 | - '7.0' => true, |
|
96 | - 'alternative' => 'preg_replace()', |
|
97 | - ), |
|
98 | - 'imagepsbbox' => array( |
|
99 | - '7.0' => true, |
|
100 | - 'alternative' => null, |
|
101 | - ), |
|
102 | - 'imagepsencodefont' => array( |
|
103 | - '7.0' => true, |
|
104 | - 'alternative' => null, |
|
105 | - ), |
|
106 | - 'imagepsextendfont' => array( |
|
107 | - '7.0' => true, |
|
108 | - 'alternative' => null, |
|
109 | - ), |
|
110 | - 'imagepsfreefont' => array( |
|
111 | - '7.0' => true, |
|
112 | - 'alternative' => null, |
|
113 | - ), |
|
114 | - 'imagepsloadfont' => array( |
|
115 | - '7.0' => true, |
|
116 | - 'alternative' => null, |
|
117 | - ), |
|
118 | - 'imagepsslantfont' => array( |
|
119 | - '7.0' => true, |
|
120 | - 'alternative' => null, |
|
121 | - ), |
|
122 | - 'imagepstext' => array( |
|
123 | - '7.0' => true, |
|
124 | - 'alternative' => null, |
|
125 | - ), |
|
126 | - 'import_request_variables' => array( |
|
127 | - '5.3' => false, |
|
128 | - '5.4' => true, |
|
129 | - 'alternative' => null, |
|
130 | - ), |
|
131 | - 'ldap_sort' => array( |
|
132 | - '7.0' => false, |
|
133 | - 'alternative' => null, |
|
134 | - ), |
|
135 | - 'mcrypt_generic_end' => array( |
|
136 | - '5.3' => false, |
|
137 | - '7.0' => true, |
|
138 | - 'alternative' => 'mcrypt_generic_deinit()', |
|
139 | - ), |
|
140 | - 'mysql_db_query' => array( |
|
141 | - '5.3' => false, |
|
142 | - '7.0' => true, |
|
143 | - 'alternative' => 'mysqli::select_db() and mysqli::query()', |
|
144 | - ), |
|
145 | - 'mysql_escape_string' => array( |
|
146 | - '5.3' => false, |
|
147 | - '7.0' => true, |
|
148 | - 'alternative' => 'mysqli::real_escape_string()', |
|
149 | - ), |
|
150 | - 'mysql_list_dbs' => array( |
|
151 | - '5.4' => false, |
|
152 | - '7.0' => true, |
|
153 | - 'alternative' => null, |
|
154 | - ), |
|
155 | - 'mysqli_bind_param' => array( |
|
156 | - '5.3' => false, |
|
157 | - '5.4' => true, |
|
158 | - 'alternative' => 'mysqli_stmt::bind_param()', |
|
159 | - ), |
|
160 | - 'mysqli_bind_result' => array( |
|
161 | - '5.3' => false, |
|
162 | - '5.4' => true, |
|
163 | - 'alternative' => 'mysqli_stmt::bind_result()', |
|
164 | - ), |
|
165 | - 'mysqli_client_encoding' => array( |
|
166 | - '5.3' => false, |
|
167 | - '5.4' => true, |
|
168 | - 'alternative' => 'mysqli::character_set_name()', |
|
169 | - ), |
|
170 | - 'mysqli_fetch' => array( |
|
171 | - '5.3' => false, |
|
172 | - '5.4' => true, |
|
173 | - 'alternative' => 'mysqli_stmt::fetch()', |
|
174 | - ), |
|
175 | - 'mysqli_param_count' => array( |
|
176 | - '5.3' => false, |
|
177 | - '5.4' => true, |
|
178 | - 'alternative' => 'mysqli_stmt_param_count()', |
|
179 | - ), |
|
180 | - 'mysqli_get_metadata' => array( |
|
181 | - '5.3' => false, |
|
182 | - '5.4' => true, |
|
183 | - 'alternative' => 'mysqli_stmt::result_metadata()', |
|
184 | - ), |
|
185 | - 'mysqli_send_long_data' => array( |
|
186 | - '5.3' => false, |
|
187 | - '5.4' => true, |
|
188 | - 'alternative' => 'mysqli_stmt::send_long_data()', |
|
189 | - ), |
|
190 | - 'magic_quotes_runtime' => array( |
|
191 | - '5.3' => false, |
|
192 | - '7.0' => true, |
|
193 | - 'alternative' => null, |
|
194 | - ), |
|
195 | - 'session_register' => array( |
|
196 | - '5.3' => false, |
|
197 | - '5.4' => true, |
|
198 | - 'alternative' => '$_SESSION', |
|
199 | - ), |
|
200 | - 'session_unregister' => array( |
|
201 | - '5.3' => false, |
|
202 | - '5.4' => true, |
|
203 | - 'alternative' => '$_SESSION', |
|
204 | - ), |
|
205 | - 'session_is_registered' => array( |
|
206 | - '5.3' => false, |
|
207 | - '5.4' => true, |
|
208 | - 'alternative' => '$_SESSION', |
|
209 | - ), |
|
210 | - 'set_magic_quotes_runtime' => array( |
|
211 | - '5.3' => false, |
|
212 | - '7.0' => true, |
|
213 | - 'alternative' => null, |
|
214 | - ), |
|
215 | - 'set_socket_blocking' => array( |
|
216 | - '5.3' => false, |
|
217 | - '7.0' => true, |
|
218 | - 'alternative' => 'stream_set_blocking()', |
|
219 | - ), |
|
220 | - 'split' => array( |
|
221 | - '5.3' => false, |
|
222 | - '7.0' => true, |
|
223 | - 'alternative' => 'preg_split()', |
|
224 | - ), |
|
225 | - 'spliti' => array( |
|
226 | - '5.3' => false, |
|
227 | - '7.0' => true, |
|
228 | - 'alternative' => 'preg_split()', |
|
229 | - ), |
|
230 | - 'sql_regcase' => array( |
|
231 | - '5.3' => false, |
|
232 | - '7.0' => true, |
|
233 | - 'alternative' => null, |
|
234 | - ), |
|
235 | - 'php_logo_guid' => array( |
|
236 | - '5.5' => true, |
|
237 | - 'alternative' => null, |
|
238 | - ), |
|
239 | - 'php_egg_logo_guid' => array( |
|
240 | - '5.5' => true, |
|
241 | - 'alternative' => null, |
|
242 | - ), |
|
243 | - 'php_real_logo_guid' => array( |
|
244 | - '5.5' => true, |
|
245 | - 'alternative' => null, |
|
246 | - ), |
|
247 | - 'zend_logo_guid' => array( |
|
248 | - '5.5' => true, |
|
249 | - 'alternative' => null, |
|
250 | - ), |
|
251 | - 'datefmt_set_timezone_id' => array( |
|
252 | - '5.5' => false, |
|
253 | - '7.0' => true, |
|
254 | - 'alternative' => 'IntlDateFormatter::setTimeZone()', |
|
255 | - ), |
|
256 | - 'mcrypt_ecb' => array( |
|
257 | - '5.5' => false, |
|
258 | - '7.0' => true, |
|
259 | - 'alternative' => null, |
|
260 | - ), |
|
261 | - 'mcrypt_cbc' => array( |
|
262 | - '5.5' => false, |
|
263 | - '7.0' => true, |
|
264 | - 'alternative' => null, |
|
265 | - ), |
|
266 | - 'mcrypt_cfb' => array( |
|
267 | - '5.5' => false, |
|
268 | - '7.0' => true, |
|
269 | - 'alternative' => null, |
|
270 | - ), |
|
271 | - 'mcrypt_ofb' => array( |
|
272 | - '5.5' => false, |
|
273 | - '7.0' => true, |
|
274 | - 'alternative' => null, |
|
275 | - ), |
|
276 | - 'ocibindbyname' => array( |
|
277 | - '5.4' => false, |
|
278 | - 'alternative' => 'oci_bind_by_name()', |
|
279 | - ), |
|
280 | - 'ocicancel' => array( |
|
281 | - '5.4' => false, |
|
282 | - 'alternative' => 'oci_cancel()', |
|
283 | - ), |
|
284 | - 'ocicloselob' => array( |
|
285 | - '5.4' => false, |
|
286 | - 'alternative' => 'OCI-Lob::close()', |
|
287 | - ), |
|
288 | - 'ocicollappend' => array( |
|
289 | - '5.4' => false, |
|
290 | - 'alternative' => 'OCI-Collection::append()', |
|
291 | - ), |
|
292 | - 'ocicollassign' => array( |
|
293 | - '5.4' => false, |
|
294 | - 'alternative' => 'OCI-Collection::assign()', |
|
295 | - ), |
|
296 | - 'ocicollassignelem' => array( |
|
297 | - '5.4' => false, |
|
298 | - 'alternative' => 'OCI-Collection::assignElem()', |
|
299 | - ), |
|
300 | - 'ocicollgetelem' => array( |
|
301 | - '5.4' => false, |
|
302 | - 'alternative' => 'OCI-Collection::getElem()', |
|
303 | - ), |
|
304 | - 'ocicollmax' => array( |
|
305 | - '5.4' => false, |
|
306 | - 'alternative' => 'OCI-Collection::max()', |
|
307 | - ), |
|
308 | - 'ocicollsize' => array( |
|
309 | - '5.4' => false, |
|
310 | - 'alternative' => 'OCI-Collection::size()', |
|
311 | - ), |
|
312 | - 'ocicolltrim' => array( |
|
313 | - '5.4' => false, |
|
314 | - 'alternative' => 'OCI-Collection::trim()', |
|
315 | - ), |
|
316 | - 'ocicolumnisnull' => array( |
|
317 | - '5.4' => false, |
|
318 | - 'alternative' => 'oci_field_is_null()', |
|
319 | - ), |
|
320 | - 'ocicolumnname' => array( |
|
321 | - '5.4' => false, |
|
322 | - 'alternative' => 'oci_field_name()', |
|
323 | - ), |
|
324 | - 'ocicolumnprecision' => array( |
|
325 | - '5.4' => false, |
|
326 | - 'alternative' => 'oci_field_precision()', |
|
327 | - ), |
|
328 | - 'ocicolumnscale' => array( |
|
329 | - '5.4' => false, |
|
330 | - 'alternative' => 'oci_field_scale()', |
|
331 | - ), |
|
332 | - 'ocicolumnsize' => array( |
|
333 | - '5.4' => false, |
|
334 | - 'alternative' => 'oci_field_size()', |
|
335 | - ), |
|
336 | - 'ocicolumntype' => array( |
|
337 | - '5.4' => false, |
|
338 | - 'alternative' => 'oci_field_type()', |
|
339 | - ), |
|
340 | - 'ocicolumntyperaw' => array( |
|
341 | - '5.4' => false, |
|
342 | - 'alternative' => 'oci_field_type_raw()', |
|
343 | - ), |
|
344 | - 'ocicommit' => array( |
|
345 | - '5.4' => false, |
|
346 | - 'alternative' => 'oci_commit()', |
|
347 | - ), |
|
348 | - 'ocidefinebyname' => array( |
|
349 | - '5.4' => false, |
|
350 | - 'alternative' => 'oci_define_by_name()', |
|
351 | - ), |
|
352 | - 'ocierror' => array( |
|
353 | - '5.4' => false, |
|
354 | - 'alternative' => 'oci_error()', |
|
355 | - ), |
|
356 | - 'ociexecute' => array( |
|
357 | - '5.4' => false, |
|
358 | - 'alternative' => 'oci_execute()', |
|
359 | - ), |
|
360 | - 'ocifetch' => array( |
|
361 | - '5.4' => false, |
|
362 | - 'alternative' => 'oci_fetch()', |
|
363 | - ), |
|
364 | - 'ocifetchinto' => array( |
|
365 | - '5.4' => false, |
|
366 | - 'alternative' => null, |
|
367 | - ), |
|
368 | - 'ocifetchstatement' => array( |
|
369 | - '5.4' => false, |
|
370 | - 'alternative' => 'oci_fetch_all()', |
|
371 | - ), |
|
372 | - 'ocifreecollection' => array( |
|
373 | - '5.4' => false, |
|
374 | - 'alternative' => 'OCI-Collection::free()', |
|
375 | - ), |
|
376 | - 'ocifreecursor' => array( |
|
377 | - '5.4' => false, |
|
378 | - 'alternative' => 'oci_free_statement()', |
|
379 | - ), |
|
380 | - 'ocifreedesc' => array( |
|
381 | - '5.4' => false, |
|
382 | - 'alternative' => 'OCI-Lob::free()', |
|
383 | - ), |
|
384 | - 'ocifreestatement' => array( |
|
385 | - '5.4' => false, |
|
386 | - 'alternative' => 'oci_free_statement()', |
|
387 | - ), |
|
388 | - 'ociinternaldebug' => array( |
|
389 | - '5.4' => false, |
|
390 | - 'alternative' => 'oci_internal_debug()', |
|
391 | - ), |
|
392 | - 'ociloadlob' => array( |
|
393 | - '5.4' => false, |
|
394 | - 'alternative' => 'OCI-Lob::load()', |
|
395 | - ), |
|
396 | - 'ocilogoff' => array( |
|
397 | - '5.4' => false, |
|
398 | - 'alternative' => 'oci_close()', |
|
399 | - ), |
|
400 | - 'ocilogon' => array( |
|
401 | - '5.4' => false, |
|
402 | - 'alternative' => 'oci_connect()', |
|
403 | - ), |
|
404 | - 'ocinewcollection' => array( |
|
405 | - '5.4' => false, |
|
406 | - 'alternative' => 'oci_new_collection()', |
|
407 | - ), |
|
408 | - 'ocinewcursor' => array( |
|
409 | - '5.4' => false, |
|
410 | - 'alternative' => 'oci_new_cursor()', |
|
411 | - ), |
|
412 | - 'ocinewdescriptor' => array( |
|
413 | - '5.4' => false, |
|
414 | - 'alternative' => 'oci_new_descriptor()', |
|
415 | - ), |
|
416 | - 'ocinlogon' => array( |
|
417 | - '5.4' => false, |
|
418 | - 'alternative' => 'oci_new_connect()', |
|
419 | - ), |
|
420 | - 'ocinumcols' => array( |
|
421 | - '5.4' => false, |
|
422 | - 'alternative' => 'oci_num_fields()', |
|
423 | - ), |
|
424 | - 'ociparse' => array( |
|
425 | - '5.4' => false, |
|
426 | - 'alternative' => 'oci_parse()', |
|
427 | - ), |
|
428 | - 'ociplogon' => array( |
|
429 | - '5.4' => false, |
|
430 | - 'alternative' => 'oci_pconnect()', |
|
431 | - ), |
|
432 | - 'ociresult' => array( |
|
433 | - '5.4' => false, |
|
434 | - 'alternative' => 'oci_result()', |
|
435 | - ), |
|
436 | - 'ocirollback' => array( |
|
437 | - '5.4' => false, |
|
438 | - 'alternative' => 'oci_rollback()', |
|
439 | - ), |
|
440 | - 'ocirowcount' => array( |
|
441 | - '5.4' => false, |
|
442 | - 'alternative' => 'oci_num_rows()', |
|
443 | - ), |
|
444 | - 'ocisavelob' => array( |
|
445 | - '5.4' => false, |
|
446 | - 'alternative' => 'OCI-Lob::save()', |
|
447 | - ), |
|
448 | - 'ocisavelobfile' => array( |
|
449 | - '5.4' => false, |
|
450 | - 'alternative' => 'OCI-Lob::import()', |
|
451 | - ), |
|
452 | - 'ociserverversion' => array( |
|
453 | - '5.4' => false, |
|
454 | - 'alternative' => 'oci_server_version()', |
|
455 | - ), |
|
456 | - 'ocisetprefetch' => array( |
|
457 | - '5.4' => false, |
|
458 | - 'alternative' => 'oci_set_prefetch()', |
|
459 | - ), |
|
460 | - 'ocistatementtype' => array( |
|
461 | - '5.4' => false, |
|
462 | - 'alternative' => 'oci_statement_type()', |
|
463 | - ), |
|
464 | - 'ociwritelobtofile' => array( |
|
465 | - '5.4' => false, |
|
466 | - 'alternative' => 'OCI-Lob::export()', |
|
467 | - ), |
|
468 | - 'ociwritetemporarylob' => array( |
|
469 | - '5.4' => false, |
|
470 | - 'alternative' => 'OCI-Lob::writeTemporary()', |
|
471 | - ), |
|
472 | - 'mysqli_get_cache_stats' => array( |
|
473 | - '5.4' => true, |
|
474 | - 'alternative' => null, |
|
475 | - ), |
|
59 | + 'call_user_method' => array( |
|
60 | + '5.3' => false, |
|
61 | + '7.0' => true, |
|
62 | + 'alternative' => 'call_user_func()', |
|
63 | + ), |
|
64 | + 'call_user_method_array' => array( |
|
65 | + '5.3' => false, |
|
66 | + '7.0' => true, |
|
67 | + 'alternative' => 'call_user_func_array()', |
|
68 | + ), |
|
69 | + 'define_syslog_variables' => array( |
|
70 | + '5.3' => false, |
|
71 | + '5.4' => true, |
|
72 | + 'alternative' => null, |
|
73 | + ), |
|
74 | + 'dl' => array( |
|
75 | + '5.3' => false, |
|
76 | + 'alternative' => null, |
|
77 | + ), |
|
78 | + 'ereg' => array( |
|
79 | + '5.3' => false, |
|
80 | + '7.0' => true, |
|
81 | + 'alternative' => 'preg_match()', |
|
82 | + ), |
|
83 | + 'ereg_replace' => array( |
|
84 | + '5.3' => false, |
|
85 | + '7.0' => true, |
|
86 | + 'alternative' => 'preg_replace()', |
|
87 | + ), |
|
88 | + 'eregi' => array( |
|
89 | + '5.3' => false, |
|
90 | + '7.0' => true, |
|
91 | + 'alternative' => 'preg_match()', |
|
92 | + ), |
|
93 | + 'eregi_replace' => array( |
|
94 | + '5.3' => false, |
|
95 | + '7.0' => true, |
|
96 | + 'alternative' => 'preg_replace()', |
|
97 | + ), |
|
98 | + 'imagepsbbox' => array( |
|
99 | + '7.0' => true, |
|
100 | + 'alternative' => null, |
|
101 | + ), |
|
102 | + 'imagepsencodefont' => array( |
|
103 | + '7.0' => true, |
|
104 | + 'alternative' => null, |
|
105 | + ), |
|
106 | + 'imagepsextendfont' => array( |
|
107 | + '7.0' => true, |
|
108 | + 'alternative' => null, |
|
109 | + ), |
|
110 | + 'imagepsfreefont' => array( |
|
111 | + '7.0' => true, |
|
112 | + 'alternative' => null, |
|
113 | + ), |
|
114 | + 'imagepsloadfont' => array( |
|
115 | + '7.0' => true, |
|
116 | + 'alternative' => null, |
|
117 | + ), |
|
118 | + 'imagepsslantfont' => array( |
|
119 | + '7.0' => true, |
|
120 | + 'alternative' => null, |
|
121 | + ), |
|
122 | + 'imagepstext' => array( |
|
123 | + '7.0' => true, |
|
124 | + 'alternative' => null, |
|
125 | + ), |
|
126 | + 'import_request_variables' => array( |
|
127 | + '5.3' => false, |
|
128 | + '5.4' => true, |
|
129 | + 'alternative' => null, |
|
130 | + ), |
|
131 | + 'ldap_sort' => array( |
|
132 | + '7.0' => false, |
|
133 | + 'alternative' => null, |
|
134 | + ), |
|
135 | + 'mcrypt_generic_end' => array( |
|
136 | + '5.3' => false, |
|
137 | + '7.0' => true, |
|
138 | + 'alternative' => 'mcrypt_generic_deinit()', |
|
139 | + ), |
|
140 | + 'mysql_db_query' => array( |
|
141 | + '5.3' => false, |
|
142 | + '7.0' => true, |
|
143 | + 'alternative' => 'mysqli::select_db() and mysqli::query()', |
|
144 | + ), |
|
145 | + 'mysql_escape_string' => array( |
|
146 | + '5.3' => false, |
|
147 | + '7.0' => true, |
|
148 | + 'alternative' => 'mysqli::real_escape_string()', |
|
149 | + ), |
|
150 | + 'mysql_list_dbs' => array( |
|
151 | + '5.4' => false, |
|
152 | + '7.0' => true, |
|
153 | + 'alternative' => null, |
|
154 | + ), |
|
155 | + 'mysqli_bind_param' => array( |
|
156 | + '5.3' => false, |
|
157 | + '5.4' => true, |
|
158 | + 'alternative' => 'mysqli_stmt::bind_param()', |
|
159 | + ), |
|
160 | + 'mysqli_bind_result' => array( |
|
161 | + '5.3' => false, |
|
162 | + '5.4' => true, |
|
163 | + 'alternative' => 'mysqli_stmt::bind_result()', |
|
164 | + ), |
|
165 | + 'mysqli_client_encoding' => array( |
|
166 | + '5.3' => false, |
|
167 | + '5.4' => true, |
|
168 | + 'alternative' => 'mysqli::character_set_name()', |
|
169 | + ), |
|
170 | + 'mysqli_fetch' => array( |
|
171 | + '5.3' => false, |
|
172 | + '5.4' => true, |
|
173 | + 'alternative' => 'mysqli_stmt::fetch()', |
|
174 | + ), |
|
175 | + 'mysqli_param_count' => array( |
|
176 | + '5.3' => false, |
|
177 | + '5.4' => true, |
|
178 | + 'alternative' => 'mysqli_stmt_param_count()', |
|
179 | + ), |
|
180 | + 'mysqli_get_metadata' => array( |
|
181 | + '5.3' => false, |
|
182 | + '5.4' => true, |
|
183 | + 'alternative' => 'mysqli_stmt::result_metadata()', |
|
184 | + ), |
|
185 | + 'mysqli_send_long_data' => array( |
|
186 | + '5.3' => false, |
|
187 | + '5.4' => true, |
|
188 | + 'alternative' => 'mysqli_stmt::send_long_data()', |
|
189 | + ), |
|
190 | + 'magic_quotes_runtime' => array( |
|
191 | + '5.3' => false, |
|
192 | + '7.0' => true, |
|
193 | + 'alternative' => null, |
|
194 | + ), |
|
195 | + 'session_register' => array( |
|
196 | + '5.3' => false, |
|
197 | + '5.4' => true, |
|
198 | + 'alternative' => '$_SESSION', |
|
199 | + ), |
|
200 | + 'session_unregister' => array( |
|
201 | + '5.3' => false, |
|
202 | + '5.4' => true, |
|
203 | + 'alternative' => '$_SESSION', |
|
204 | + ), |
|
205 | + 'session_is_registered' => array( |
|
206 | + '5.3' => false, |
|
207 | + '5.4' => true, |
|
208 | + 'alternative' => '$_SESSION', |
|
209 | + ), |
|
210 | + 'set_magic_quotes_runtime' => array( |
|
211 | + '5.3' => false, |
|
212 | + '7.0' => true, |
|
213 | + 'alternative' => null, |
|
214 | + ), |
|
215 | + 'set_socket_blocking' => array( |
|
216 | + '5.3' => false, |
|
217 | + '7.0' => true, |
|
218 | + 'alternative' => 'stream_set_blocking()', |
|
219 | + ), |
|
220 | + 'split' => array( |
|
221 | + '5.3' => false, |
|
222 | + '7.0' => true, |
|
223 | + 'alternative' => 'preg_split()', |
|
224 | + ), |
|
225 | + 'spliti' => array( |
|
226 | + '5.3' => false, |
|
227 | + '7.0' => true, |
|
228 | + 'alternative' => 'preg_split()', |
|
229 | + ), |
|
230 | + 'sql_regcase' => array( |
|
231 | + '5.3' => false, |
|
232 | + '7.0' => true, |
|
233 | + 'alternative' => null, |
|
234 | + ), |
|
235 | + 'php_logo_guid' => array( |
|
236 | + '5.5' => true, |
|
237 | + 'alternative' => null, |
|
238 | + ), |
|
239 | + 'php_egg_logo_guid' => array( |
|
240 | + '5.5' => true, |
|
241 | + 'alternative' => null, |
|
242 | + ), |
|
243 | + 'php_real_logo_guid' => array( |
|
244 | + '5.5' => true, |
|
245 | + 'alternative' => null, |
|
246 | + ), |
|
247 | + 'zend_logo_guid' => array( |
|
248 | + '5.5' => true, |
|
249 | + 'alternative' => null, |
|
250 | + ), |
|
251 | + 'datefmt_set_timezone_id' => array( |
|
252 | + '5.5' => false, |
|
253 | + '7.0' => true, |
|
254 | + 'alternative' => 'IntlDateFormatter::setTimeZone()', |
|
255 | + ), |
|
256 | + 'mcrypt_ecb' => array( |
|
257 | + '5.5' => false, |
|
258 | + '7.0' => true, |
|
259 | + 'alternative' => null, |
|
260 | + ), |
|
261 | + 'mcrypt_cbc' => array( |
|
262 | + '5.5' => false, |
|
263 | + '7.0' => true, |
|
264 | + 'alternative' => null, |
|
265 | + ), |
|
266 | + 'mcrypt_cfb' => array( |
|
267 | + '5.5' => false, |
|
268 | + '7.0' => true, |
|
269 | + 'alternative' => null, |
|
270 | + ), |
|
271 | + 'mcrypt_ofb' => array( |
|
272 | + '5.5' => false, |
|
273 | + '7.0' => true, |
|
274 | + 'alternative' => null, |
|
275 | + ), |
|
276 | + 'ocibindbyname' => array( |
|
277 | + '5.4' => false, |
|
278 | + 'alternative' => 'oci_bind_by_name()', |
|
279 | + ), |
|
280 | + 'ocicancel' => array( |
|
281 | + '5.4' => false, |
|
282 | + 'alternative' => 'oci_cancel()', |
|
283 | + ), |
|
284 | + 'ocicloselob' => array( |
|
285 | + '5.4' => false, |
|
286 | + 'alternative' => 'OCI-Lob::close()', |
|
287 | + ), |
|
288 | + 'ocicollappend' => array( |
|
289 | + '5.4' => false, |
|
290 | + 'alternative' => 'OCI-Collection::append()', |
|
291 | + ), |
|
292 | + 'ocicollassign' => array( |
|
293 | + '5.4' => false, |
|
294 | + 'alternative' => 'OCI-Collection::assign()', |
|
295 | + ), |
|
296 | + 'ocicollassignelem' => array( |
|
297 | + '5.4' => false, |
|
298 | + 'alternative' => 'OCI-Collection::assignElem()', |
|
299 | + ), |
|
300 | + 'ocicollgetelem' => array( |
|
301 | + '5.4' => false, |
|
302 | + 'alternative' => 'OCI-Collection::getElem()', |
|
303 | + ), |
|
304 | + 'ocicollmax' => array( |
|
305 | + '5.4' => false, |
|
306 | + 'alternative' => 'OCI-Collection::max()', |
|
307 | + ), |
|
308 | + 'ocicollsize' => array( |
|
309 | + '5.4' => false, |
|
310 | + 'alternative' => 'OCI-Collection::size()', |
|
311 | + ), |
|
312 | + 'ocicolltrim' => array( |
|
313 | + '5.4' => false, |
|
314 | + 'alternative' => 'OCI-Collection::trim()', |
|
315 | + ), |
|
316 | + 'ocicolumnisnull' => array( |
|
317 | + '5.4' => false, |
|
318 | + 'alternative' => 'oci_field_is_null()', |
|
319 | + ), |
|
320 | + 'ocicolumnname' => array( |
|
321 | + '5.4' => false, |
|
322 | + 'alternative' => 'oci_field_name()', |
|
323 | + ), |
|
324 | + 'ocicolumnprecision' => array( |
|
325 | + '5.4' => false, |
|
326 | + 'alternative' => 'oci_field_precision()', |
|
327 | + ), |
|
328 | + 'ocicolumnscale' => array( |
|
329 | + '5.4' => false, |
|
330 | + 'alternative' => 'oci_field_scale()', |
|
331 | + ), |
|
332 | + 'ocicolumnsize' => array( |
|
333 | + '5.4' => false, |
|
334 | + 'alternative' => 'oci_field_size()', |
|
335 | + ), |
|
336 | + 'ocicolumntype' => array( |
|
337 | + '5.4' => false, |
|
338 | + 'alternative' => 'oci_field_type()', |
|
339 | + ), |
|
340 | + 'ocicolumntyperaw' => array( |
|
341 | + '5.4' => false, |
|
342 | + 'alternative' => 'oci_field_type_raw()', |
|
343 | + ), |
|
344 | + 'ocicommit' => array( |
|
345 | + '5.4' => false, |
|
346 | + 'alternative' => 'oci_commit()', |
|
347 | + ), |
|
348 | + 'ocidefinebyname' => array( |
|
349 | + '5.4' => false, |
|
350 | + 'alternative' => 'oci_define_by_name()', |
|
351 | + ), |
|
352 | + 'ocierror' => array( |
|
353 | + '5.4' => false, |
|
354 | + 'alternative' => 'oci_error()', |
|
355 | + ), |
|
356 | + 'ociexecute' => array( |
|
357 | + '5.4' => false, |
|
358 | + 'alternative' => 'oci_execute()', |
|
359 | + ), |
|
360 | + 'ocifetch' => array( |
|
361 | + '5.4' => false, |
|
362 | + 'alternative' => 'oci_fetch()', |
|
363 | + ), |
|
364 | + 'ocifetchinto' => array( |
|
365 | + '5.4' => false, |
|
366 | + 'alternative' => null, |
|
367 | + ), |
|
368 | + 'ocifetchstatement' => array( |
|
369 | + '5.4' => false, |
|
370 | + 'alternative' => 'oci_fetch_all()', |
|
371 | + ), |
|
372 | + 'ocifreecollection' => array( |
|
373 | + '5.4' => false, |
|
374 | + 'alternative' => 'OCI-Collection::free()', |
|
375 | + ), |
|
376 | + 'ocifreecursor' => array( |
|
377 | + '5.4' => false, |
|
378 | + 'alternative' => 'oci_free_statement()', |
|
379 | + ), |
|
380 | + 'ocifreedesc' => array( |
|
381 | + '5.4' => false, |
|
382 | + 'alternative' => 'OCI-Lob::free()', |
|
383 | + ), |
|
384 | + 'ocifreestatement' => array( |
|
385 | + '5.4' => false, |
|
386 | + 'alternative' => 'oci_free_statement()', |
|
387 | + ), |
|
388 | + 'ociinternaldebug' => array( |
|
389 | + '5.4' => false, |
|
390 | + 'alternative' => 'oci_internal_debug()', |
|
391 | + ), |
|
392 | + 'ociloadlob' => array( |
|
393 | + '5.4' => false, |
|
394 | + 'alternative' => 'OCI-Lob::load()', |
|
395 | + ), |
|
396 | + 'ocilogoff' => array( |
|
397 | + '5.4' => false, |
|
398 | + 'alternative' => 'oci_close()', |
|
399 | + ), |
|
400 | + 'ocilogon' => array( |
|
401 | + '5.4' => false, |
|
402 | + 'alternative' => 'oci_connect()', |
|
403 | + ), |
|
404 | + 'ocinewcollection' => array( |
|
405 | + '5.4' => false, |
|
406 | + 'alternative' => 'oci_new_collection()', |
|
407 | + ), |
|
408 | + 'ocinewcursor' => array( |
|
409 | + '5.4' => false, |
|
410 | + 'alternative' => 'oci_new_cursor()', |
|
411 | + ), |
|
412 | + 'ocinewdescriptor' => array( |
|
413 | + '5.4' => false, |
|
414 | + 'alternative' => 'oci_new_descriptor()', |
|
415 | + ), |
|
416 | + 'ocinlogon' => array( |
|
417 | + '5.4' => false, |
|
418 | + 'alternative' => 'oci_new_connect()', |
|
419 | + ), |
|
420 | + 'ocinumcols' => array( |
|
421 | + '5.4' => false, |
|
422 | + 'alternative' => 'oci_num_fields()', |
|
423 | + ), |
|
424 | + 'ociparse' => array( |
|
425 | + '5.4' => false, |
|
426 | + 'alternative' => 'oci_parse()', |
|
427 | + ), |
|
428 | + 'ociplogon' => array( |
|
429 | + '5.4' => false, |
|
430 | + 'alternative' => 'oci_pconnect()', |
|
431 | + ), |
|
432 | + 'ociresult' => array( |
|
433 | + '5.4' => false, |
|
434 | + 'alternative' => 'oci_result()', |
|
435 | + ), |
|
436 | + 'ocirollback' => array( |
|
437 | + '5.4' => false, |
|
438 | + 'alternative' => 'oci_rollback()', |
|
439 | + ), |
|
440 | + 'ocirowcount' => array( |
|
441 | + '5.4' => false, |
|
442 | + 'alternative' => 'oci_num_rows()', |
|
443 | + ), |
|
444 | + 'ocisavelob' => array( |
|
445 | + '5.4' => false, |
|
446 | + 'alternative' => 'OCI-Lob::save()', |
|
447 | + ), |
|
448 | + 'ocisavelobfile' => array( |
|
449 | + '5.4' => false, |
|
450 | + 'alternative' => 'OCI-Lob::import()', |
|
451 | + ), |
|
452 | + 'ociserverversion' => array( |
|
453 | + '5.4' => false, |
|
454 | + 'alternative' => 'oci_server_version()', |
|
455 | + ), |
|
456 | + 'ocisetprefetch' => array( |
|
457 | + '5.4' => false, |
|
458 | + 'alternative' => 'oci_set_prefetch()', |
|
459 | + ), |
|
460 | + 'ocistatementtype' => array( |
|
461 | + '5.4' => false, |
|
462 | + 'alternative' => 'oci_statement_type()', |
|
463 | + ), |
|
464 | + 'ociwritelobtofile' => array( |
|
465 | + '5.4' => false, |
|
466 | + 'alternative' => 'OCI-Lob::export()', |
|
467 | + ), |
|
468 | + 'ociwritetemporarylob' => array( |
|
469 | + '5.4' => false, |
|
470 | + 'alternative' => 'OCI-Lob::writeTemporary()', |
|
471 | + ), |
|
472 | + 'mysqli_get_cache_stats' => array( |
|
473 | + '5.4' => true, |
|
474 | + 'alternative' => null, |
|
475 | + ), |
|
476 | 476 | |
477 | - 'mcrypt_create_iv' => array( |
|
478 | - '7.1' => false, |
|
479 | - '7.2' => true, |
|
480 | - 'alternative' => 'random_bytes() or OpenSSL', |
|
481 | - ), |
|
482 | - 'mcrypt_decrypt' => array( |
|
483 | - '7.1' => false, |
|
484 | - '7.2' => true, |
|
485 | - 'alternative' => 'OpenSSL', |
|
486 | - ), |
|
487 | - 'mcrypt_enc_get_algorithms_name' => array( |
|
488 | - '7.1' => false, |
|
489 | - '7.2' => true, |
|
490 | - 'alternative' => 'OpenSSL', |
|
491 | - ), |
|
492 | - 'mcrypt_enc_get_block_size' => array( |
|
493 | - '7.1' => false, |
|
494 | - '7.2' => true, |
|
495 | - 'alternative' => 'OpenSSL', |
|
496 | - ), |
|
497 | - 'mcrypt_enc_get_iv_size' => array( |
|
498 | - '7.1' => false, |
|
499 | - '7.2' => true, |
|
500 | - 'alternative' => 'OpenSSL', |
|
501 | - ), |
|
502 | - 'mcrypt_enc_get_key_size' => array( |
|
503 | - '7.1' => false, |
|
504 | - '7.2' => true, |
|
505 | - 'alternative' => 'OpenSSL', |
|
506 | - ), |
|
507 | - 'mcrypt_enc_get_modes_name' => array( |
|
508 | - '7.1' => false, |
|
509 | - '7.2' => true, |
|
510 | - 'alternative' => 'OpenSSL', |
|
511 | - ), |
|
512 | - 'mcrypt_enc_get_supported_key_sizes' => array( |
|
513 | - '7.1' => false, |
|
514 | - '7.2' => true, |
|
515 | - 'alternative' => 'OpenSSL', |
|
516 | - ), |
|
517 | - 'mcrypt_enc_is_block_algorithm_mode' => array( |
|
518 | - '7.1' => false, |
|
519 | - '7.2' => true, |
|
520 | - 'alternative' => 'OpenSSL', |
|
521 | - ), |
|
522 | - 'mcrypt_enc_is_block_algorithm' => array( |
|
523 | - '7.1' => false, |
|
524 | - '7.2' => true, |
|
525 | - 'alternative' => 'OpenSSL', |
|
526 | - ), |
|
527 | - 'mcrypt_enc_is_block_mode' => array( |
|
528 | - '7.1' => false, |
|
529 | - '7.2' => true, |
|
530 | - 'alternative' => 'OpenSSL', |
|
531 | - ), |
|
532 | - 'mcrypt_enc_self_test' => array( |
|
533 | - '7.1' => false, |
|
534 | - '7.2' => true, |
|
535 | - 'alternative' => 'OpenSSL', |
|
536 | - ), |
|
537 | - 'mcrypt_encrypt' => array( |
|
538 | - '7.1' => false, |
|
539 | - '7.2' => true, |
|
540 | - 'alternative' => 'OpenSSL', |
|
541 | - ), |
|
542 | - 'mcrypt_generic_deinit' => array( |
|
543 | - '7.1' => false, |
|
544 | - '7.2' => true, |
|
545 | - 'alternative' => 'OpenSSL', |
|
546 | - ), |
|
547 | - 'mcrypt_generic_init' => array( |
|
548 | - '7.1' => false, |
|
549 | - '7.2' => true, |
|
550 | - 'alternative' => 'OpenSSL', |
|
551 | - ), |
|
552 | - 'mcrypt_generic' => array( |
|
553 | - '7.1' => false, |
|
554 | - '7.2' => true, |
|
555 | - 'alternative' => 'OpenSSL', |
|
556 | - ), |
|
557 | - 'mcrypt_get_block_size' => array( |
|
558 | - '7.1' => false, |
|
559 | - '7.2' => true, |
|
560 | - 'alternative' => 'OpenSSL', |
|
561 | - ), |
|
562 | - 'mcrypt_get_cipher_name' => array( |
|
563 | - '7.1' => false, |
|
564 | - '7.2' => true, |
|
565 | - 'alternative' => 'OpenSSL', |
|
566 | - ), |
|
567 | - 'mcrypt_get_iv_size' => array( |
|
568 | - '7.1' => false, |
|
569 | - '7.2' => true, |
|
570 | - 'alternative' => 'OpenSSL', |
|
571 | - ), |
|
572 | - 'mcrypt_get_key_size' => array( |
|
573 | - '7.1' => false, |
|
574 | - '7.2' => true, |
|
575 | - 'alternative' => 'OpenSSL', |
|
576 | - ), |
|
577 | - 'mcrypt_list_algorithms' => array( |
|
578 | - '7.1' => false, |
|
579 | - '7.2' => true, |
|
580 | - 'alternative' => 'OpenSSL', |
|
581 | - ), |
|
582 | - 'mcrypt_list_modes' => array( |
|
583 | - '7.1' => false, |
|
584 | - '7.2' => true, |
|
585 | - 'alternative' => 'OpenSSL', |
|
586 | - ), |
|
587 | - 'mcrypt_module_close' => array( |
|
588 | - '7.1' => false, |
|
589 | - '7.2' => true, |
|
590 | - 'alternative' => 'OpenSSL', |
|
591 | - ), |
|
592 | - 'mcrypt_module_get_algo_block_size' => array( |
|
593 | - '7.1' => false, |
|
594 | - '7.2' => true, |
|
595 | - 'alternative' => 'OpenSSL', |
|
596 | - ), |
|
597 | - 'mcrypt_module_get_algo_key_size' => array( |
|
598 | - '7.1' => false, |
|
599 | - '7.2' => true, |
|
600 | - 'alternative' => 'OpenSSL', |
|
601 | - ), |
|
602 | - 'mcrypt_module_get_supported_key_sizes' => array( |
|
603 | - '7.1' => false, |
|
604 | - '7.2' => true, |
|
605 | - 'alternative' => 'OpenSSL', |
|
606 | - ), |
|
607 | - 'mcrypt_module_is_block_algorithm_mode' => array( |
|
608 | - '7.1' => false, |
|
609 | - '7.2' => true, |
|
610 | - 'alternative' => 'OpenSSL', |
|
611 | - ), |
|
612 | - 'mcrypt_module_is_block_algorithm' => array( |
|
613 | - '7.1' => false, |
|
614 | - '7.2' => true, |
|
615 | - 'alternative' => 'OpenSSL', |
|
616 | - ), |
|
617 | - 'mcrypt_module_is_block_mode' => array( |
|
618 | - '7.1' => false, |
|
619 | - '7.2' => true, |
|
620 | - 'alternative' => 'OpenSSL', |
|
621 | - ), |
|
622 | - 'mcrypt_module_open' => array( |
|
623 | - '7.1' => false, |
|
624 | - '7.2' => true, |
|
625 | - 'alternative' => 'OpenSSL', |
|
626 | - ), |
|
627 | - 'mcrypt_module_self_test' => array( |
|
628 | - '7.1' => false, |
|
629 | - '7.2' => true, |
|
630 | - 'alternative' => 'OpenSSL', |
|
631 | - ), |
|
632 | - 'mdecrypt_generic' => array( |
|
633 | - '7.1' => false, |
|
634 | - '7.2' => true, |
|
635 | - 'alternative' => 'OpenSSL', |
|
636 | - ), |
|
637 | - 'jpeg2wbmp' => array( |
|
638 | - '7.2' => false, |
|
639 | - 'alternative' => 'imagecreatefromjpeg() and imagewbmp()', |
|
640 | - ), |
|
641 | - 'png2wbmp' => array( |
|
642 | - '7.2' => false, |
|
643 | - 'alternative' => 'imagecreatefrompng() or imagewbmp()', |
|
644 | - ), |
|
645 | - 'create_function' => array( |
|
646 | - '7.2' => false, |
|
647 | - 'alternative' => 'an anonymous function', |
|
648 | - ), |
|
649 | - 'each' => array( |
|
650 | - '7.2' => false, |
|
651 | - 'alternative' => 'a foreach loop', |
|
652 | - ), |
|
653 | - 'gmp_random' => array( |
|
654 | - '7.2' => false, |
|
655 | - 'alternative' => 'gmp_random_bits() or gmp_random_range()', |
|
656 | - ), |
|
657 | - 'read_exif_data' => array( |
|
658 | - '7.2' => false, |
|
659 | - 'alternative' => 'exif_read_data()', |
|
660 | - ), |
|
477 | + 'mcrypt_create_iv' => array( |
|
478 | + '7.1' => false, |
|
479 | + '7.2' => true, |
|
480 | + 'alternative' => 'random_bytes() or OpenSSL', |
|
481 | + ), |
|
482 | + 'mcrypt_decrypt' => array( |
|
483 | + '7.1' => false, |
|
484 | + '7.2' => true, |
|
485 | + 'alternative' => 'OpenSSL', |
|
486 | + ), |
|
487 | + 'mcrypt_enc_get_algorithms_name' => array( |
|
488 | + '7.1' => false, |
|
489 | + '7.2' => true, |
|
490 | + 'alternative' => 'OpenSSL', |
|
491 | + ), |
|
492 | + 'mcrypt_enc_get_block_size' => array( |
|
493 | + '7.1' => false, |
|
494 | + '7.2' => true, |
|
495 | + 'alternative' => 'OpenSSL', |
|
496 | + ), |
|
497 | + 'mcrypt_enc_get_iv_size' => array( |
|
498 | + '7.1' => false, |
|
499 | + '7.2' => true, |
|
500 | + 'alternative' => 'OpenSSL', |
|
501 | + ), |
|
502 | + 'mcrypt_enc_get_key_size' => array( |
|
503 | + '7.1' => false, |
|
504 | + '7.2' => true, |
|
505 | + 'alternative' => 'OpenSSL', |
|
506 | + ), |
|
507 | + 'mcrypt_enc_get_modes_name' => array( |
|
508 | + '7.1' => false, |
|
509 | + '7.2' => true, |
|
510 | + 'alternative' => 'OpenSSL', |
|
511 | + ), |
|
512 | + 'mcrypt_enc_get_supported_key_sizes' => array( |
|
513 | + '7.1' => false, |
|
514 | + '7.2' => true, |
|
515 | + 'alternative' => 'OpenSSL', |
|
516 | + ), |
|
517 | + 'mcrypt_enc_is_block_algorithm_mode' => array( |
|
518 | + '7.1' => false, |
|
519 | + '7.2' => true, |
|
520 | + 'alternative' => 'OpenSSL', |
|
521 | + ), |
|
522 | + 'mcrypt_enc_is_block_algorithm' => array( |
|
523 | + '7.1' => false, |
|
524 | + '7.2' => true, |
|
525 | + 'alternative' => 'OpenSSL', |
|
526 | + ), |
|
527 | + 'mcrypt_enc_is_block_mode' => array( |
|
528 | + '7.1' => false, |
|
529 | + '7.2' => true, |
|
530 | + 'alternative' => 'OpenSSL', |
|
531 | + ), |
|
532 | + 'mcrypt_enc_self_test' => array( |
|
533 | + '7.1' => false, |
|
534 | + '7.2' => true, |
|
535 | + 'alternative' => 'OpenSSL', |
|
536 | + ), |
|
537 | + 'mcrypt_encrypt' => array( |
|
538 | + '7.1' => false, |
|
539 | + '7.2' => true, |
|
540 | + 'alternative' => 'OpenSSL', |
|
541 | + ), |
|
542 | + 'mcrypt_generic_deinit' => array( |
|
543 | + '7.1' => false, |
|
544 | + '7.2' => true, |
|
545 | + 'alternative' => 'OpenSSL', |
|
546 | + ), |
|
547 | + 'mcrypt_generic_init' => array( |
|
548 | + '7.1' => false, |
|
549 | + '7.2' => true, |
|
550 | + 'alternative' => 'OpenSSL', |
|
551 | + ), |
|
552 | + 'mcrypt_generic' => array( |
|
553 | + '7.1' => false, |
|
554 | + '7.2' => true, |
|
555 | + 'alternative' => 'OpenSSL', |
|
556 | + ), |
|
557 | + 'mcrypt_get_block_size' => array( |
|
558 | + '7.1' => false, |
|
559 | + '7.2' => true, |
|
560 | + 'alternative' => 'OpenSSL', |
|
561 | + ), |
|
562 | + 'mcrypt_get_cipher_name' => array( |
|
563 | + '7.1' => false, |
|
564 | + '7.2' => true, |
|
565 | + 'alternative' => 'OpenSSL', |
|
566 | + ), |
|
567 | + 'mcrypt_get_iv_size' => array( |
|
568 | + '7.1' => false, |
|
569 | + '7.2' => true, |
|
570 | + 'alternative' => 'OpenSSL', |
|
571 | + ), |
|
572 | + 'mcrypt_get_key_size' => array( |
|
573 | + '7.1' => false, |
|
574 | + '7.2' => true, |
|
575 | + 'alternative' => 'OpenSSL', |
|
576 | + ), |
|
577 | + 'mcrypt_list_algorithms' => array( |
|
578 | + '7.1' => false, |
|
579 | + '7.2' => true, |
|
580 | + 'alternative' => 'OpenSSL', |
|
581 | + ), |
|
582 | + 'mcrypt_list_modes' => array( |
|
583 | + '7.1' => false, |
|
584 | + '7.2' => true, |
|
585 | + 'alternative' => 'OpenSSL', |
|
586 | + ), |
|
587 | + 'mcrypt_module_close' => array( |
|
588 | + '7.1' => false, |
|
589 | + '7.2' => true, |
|
590 | + 'alternative' => 'OpenSSL', |
|
591 | + ), |
|
592 | + 'mcrypt_module_get_algo_block_size' => array( |
|
593 | + '7.1' => false, |
|
594 | + '7.2' => true, |
|
595 | + 'alternative' => 'OpenSSL', |
|
596 | + ), |
|
597 | + 'mcrypt_module_get_algo_key_size' => array( |
|
598 | + '7.1' => false, |
|
599 | + '7.2' => true, |
|
600 | + 'alternative' => 'OpenSSL', |
|
601 | + ), |
|
602 | + 'mcrypt_module_get_supported_key_sizes' => array( |
|
603 | + '7.1' => false, |
|
604 | + '7.2' => true, |
|
605 | + 'alternative' => 'OpenSSL', |
|
606 | + ), |
|
607 | + 'mcrypt_module_is_block_algorithm_mode' => array( |
|
608 | + '7.1' => false, |
|
609 | + '7.2' => true, |
|
610 | + 'alternative' => 'OpenSSL', |
|
611 | + ), |
|
612 | + 'mcrypt_module_is_block_algorithm' => array( |
|
613 | + '7.1' => false, |
|
614 | + '7.2' => true, |
|
615 | + 'alternative' => 'OpenSSL', |
|
616 | + ), |
|
617 | + 'mcrypt_module_is_block_mode' => array( |
|
618 | + '7.1' => false, |
|
619 | + '7.2' => true, |
|
620 | + 'alternative' => 'OpenSSL', |
|
621 | + ), |
|
622 | + 'mcrypt_module_open' => array( |
|
623 | + '7.1' => false, |
|
624 | + '7.2' => true, |
|
625 | + 'alternative' => 'OpenSSL', |
|
626 | + ), |
|
627 | + 'mcrypt_module_self_test' => array( |
|
628 | + '7.1' => false, |
|
629 | + '7.2' => true, |
|
630 | + 'alternative' => 'OpenSSL', |
|
631 | + ), |
|
632 | + 'mdecrypt_generic' => array( |
|
633 | + '7.1' => false, |
|
634 | + '7.2' => true, |
|
635 | + 'alternative' => 'OpenSSL', |
|
636 | + ), |
|
637 | + 'jpeg2wbmp' => array( |
|
638 | + '7.2' => false, |
|
639 | + 'alternative' => 'imagecreatefromjpeg() and imagewbmp()', |
|
640 | + ), |
|
641 | + 'png2wbmp' => array( |
|
642 | + '7.2' => false, |
|
643 | + 'alternative' => 'imagecreatefrompng() or imagewbmp()', |
|
644 | + ), |
|
645 | + 'create_function' => array( |
|
646 | + '7.2' => false, |
|
647 | + 'alternative' => 'an anonymous function', |
|
648 | + ), |
|
649 | + 'each' => array( |
|
650 | + '7.2' => false, |
|
651 | + 'alternative' => 'a foreach loop', |
|
652 | + ), |
|
653 | + 'gmp_random' => array( |
|
654 | + '7.2' => false, |
|
655 | + 'alternative' => 'gmp_random_bits() or gmp_random_range()', |
|
656 | + ), |
|
657 | + 'read_exif_data' => array( |
|
658 | + '7.2' => false, |
|
659 | + 'alternative' => 'exif_read_data()', |
|
660 | + ), |
|
661 | 661 | |
662 | - 'image2wbmp' => array( |
|
663 | - '7.3' => false, |
|
664 | - 'alternative' => 'imagewbmp()', |
|
665 | - ), |
|
666 | - 'mbregex_encoding' => array( |
|
667 | - '7.3' => false, |
|
668 | - 'alternative' => 'mb_regex_encoding()', |
|
669 | - ), |
|
670 | - 'mbereg' => array( |
|
671 | - '7.3' => false, |
|
672 | - 'alternative' => 'mb_ereg()', |
|
673 | - ), |
|
674 | - 'mberegi' => array( |
|
675 | - '7.3' => false, |
|
676 | - 'alternative' => 'mb_eregi()', |
|
677 | - ), |
|
678 | - 'mbereg_replace' => array( |
|
679 | - '7.3' => false, |
|
680 | - 'alternative' => 'mb_ereg_replace()', |
|
681 | - ), |
|
682 | - 'mberegi_replace' => array( |
|
683 | - '7.3' => false, |
|
684 | - 'alternative' => 'mb_eregi_replace()', |
|
685 | - ), |
|
686 | - 'mbsplit' => array( |
|
687 | - '7.3' => false, |
|
688 | - 'alternative' => 'mb_split()', |
|
689 | - ), |
|
690 | - 'mbereg_match' => array( |
|
691 | - '7.3' => false, |
|
692 | - 'alternative' => 'mb_ereg_match()', |
|
693 | - ), |
|
694 | - 'mbereg_search' => array( |
|
695 | - '7.3' => false, |
|
696 | - 'alternative' => 'mb_ereg_search()', |
|
697 | - ), |
|
698 | - 'mbereg_search_pos' => array( |
|
699 | - '7.3' => false, |
|
700 | - 'alternative' => 'mb_ereg_search_pos()', |
|
701 | - ), |
|
702 | - 'mbereg_search_regs' => array( |
|
703 | - '7.3' => false, |
|
704 | - 'alternative' => 'mb_ereg_search_regs()', |
|
705 | - ), |
|
706 | - 'mbereg_search_init' => array( |
|
707 | - '7.3' => false, |
|
708 | - 'alternative' => 'mb_ereg_search_init()', |
|
709 | - ), |
|
710 | - 'mbereg_search_getregs' => array( |
|
711 | - '7.3' => false, |
|
712 | - 'alternative' => 'mb_ereg_search_getregs()', |
|
713 | - ), |
|
714 | - 'mbereg_search_getpos' => array( |
|
715 | - '7.3' => false, |
|
716 | - 'alternative' => 'mb_ereg_search_getpos()', |
|
717 | - ), |
|
718 | - 'mbereg_search_setpos' => array( |
|
719 | - '7.3' => false, |
|
720 | - 'alternative' => 'mb_ereg_search_setpos()', |
|
721 | - ), |
|
722 | - 'fgetss' => array( |
|
723 | - '7.3' => false, |
|
724 | - 'alternative' => null, |
|
725 | - ), |
|
726 | - 'gzgetss' => array( |
|
727 | - '7.3' => false, |
|
728 | - 'alternative' => null, |
|
729 | - ), |
|
662 | + 'image2wbmp' => array( |
|
663 | + '7.3' => false, |
|
664 | + 'alternative' => 'imagewbmp()', |
|
665 | + ), |
|
666 | + 'mbregex_encoding' => array( |
|
667 | + '7.3' => false, |
|
668 | + 'alternative' => 'mb_regex_encoding()', |
|
669 | + ), |
|
670 | + 'mbereg' => array( |
|
671 | + '7.3' => false, |
|
672 | + 'alternative' => 'mb_ereg()', |
|
673 | + ), |
|
674 | + 'mberegi' => array( |
|
675 | + '7.3' => false, |
|
676 | + 'alternative' => 'mb_eregi()', |
|
677 | + ), |
|
678 | + 'mbereg_replace' => array( |
|
679 | + '7.3' => false, |
|
680 | + 'alternative' => 'mb_ereg_replace()', |
|
681 | + ), |
|
682 | + 'mberegi_replace' => array( |
|
683 | + '7.3' => false, |
|
684 | + 'alternative' => 'mb_eregi_replace()', |
|
685 | + ), |
|
686 | + 'mbsplit' => array( |
|
687 | + '7.3' => false, |
|
688 | + 'alternative' => 'mb_split()', |
|
689 | + ), |
|
690 | + 'mbereg_match' => array( |
|
691 | + '7.3' => false, |
|
692 | + 'alternative' => 'mb_ereg_match()', |
|
693 | + ), |
|
694 | + 'mbereg_search' => array( |
|
695 | + '7.3' => false, |
|
696 | + 'alternative' => 'mb_ereg_search()', |
|
697 | + ), |
|
698 | + 'mbereg_search_pos' => array( |
|
699 | + '7.3' => false, |
|
700 | + 'alternative' => 'mb_ereg_search_pos()', |
|
701 | + ), |
|
702 | + 'mbereg_search_regs' => array( |
|
703 | + '7.3' => false, |
|
704 | + 'alternative' => 'mb_ereg_search_regs()', |
|
705 | + ), |
|
706 | + 'mbereg_search_init' => array( |
|
707 | + '7.3' => false, |
|
708 | + 'alternative' => 'mb_ereg_search_init()', |
|
709 | + ), |
|
710 | + 'mbereg_search_getregs' => array( |
|
711 | + '7.3' => false, |
|
712 | + 'alternative' => 'mb_ereg_search_getregs()', |
|
713 | + ), |
|
714 | + 'mbereg_search_getpos' => array( |
|
715 | + '7.3' => false, |
|
716 | + 'alternative' => 'mb_ereg_search_getpos()', |
|
717 | + ), |
|
718 | + 'mbereg_search_setpos' => array( |
|
719 | + '7.3' => false, |
|
720 | + 'alternative' => 'mb_ereg_search_setpos()', |
|
721 | + ), |
|
722 | + 'fgetss' => array( |
|
723 | + '7.3' => false, |
|
724 | + 'alternative' => null, |
|
725 | + ), |
|
726 | + 'gzgetss' => array( |
|
727 | + '7.3' => false, |
|
728 | + 'alternative' => null, |
|
729 | + ), |
|
730 | 730 | |
731 | - 'ibase_add_user' => array( |
|
732 | - '7.4' => true, |
|
733 | - 'alternative' => null, |
|
734 | - ), |
|
735 | - 'ibase_affected_rows' => array( |
|
736 | - '7.4' => true, |
|
737 | - 'alternative' => null, |
|
738 | - ), |
|
739 | - 'ibase_backup' => array( |
|
740 | - '7.4' => true, |
|
741 | - 'alternative' => null, |
|
742 | - ), |
|
743 | - 'ibase_blob_add' => array( |
|
744 | - '7.4' => true, |
|
745 | - 'alternative' => null, |
|
746 | - ), |
|
747 | - 'ibase_blob_cancel' => array( |
|
748 | - '7.4' => true, |
|
749 | - 'alternative' => null, |
|
750 | - ), |
|
751 | - 'ibase_blob_close' => array( |
|
752 | - '7.4' => true, |
|
753 | - 'alternative' => null, |
|
754 | - ), |
|
755 | - 'ibase_blob_create' => array( |
|
756 | - '7.4' => true, |
|
757 | - 'alternative' => null, |
|
758 | - ), |
|
759 | - 'ibase_blob_echo' => array( |
|
760 | - '7.4' => true, |
|
761 | - 'alternative' => null, |
|
762 | - ), |
|
763 | - 'ibase_blob_get' => array( |
|
764 | - '7.4' => true, |
|
765 | - 'alternative' => null, |
|
766 | - ), |
|
767 | - 'ibase_blob_import' => array( |
|
768 | - '7.4' => true, |
|
769 | - 'alternative' => null, |
|
770 | - ), |
|
771 | - 'ibase_blob_info' => array( |
|
772 | - '7.4' => true, |
|
773 | - 'alternative' => null, |
|
774 | - ), |
|
775 | - 'ibase_blob_open' => array( |
|
776 | - '7.4' => true, |
|
777 | - 'alternative' => null, |
|
778 | - ), |
|
779 | - 'ibase_close' => array( |
|
780 | - '7.4' => true, |
|
781 | - 'alternative' => null, |
|
782 | - ), |
|
783 | - 'ibase_commit_ret' => array( |
|
784 | - '7.4' => true, |
|
785 | - 'alternative' => null, |
|
786 | - ), |
|
787 | - 'ibase_commit' => array( |
|
788 | - '7.4' => true, |
|
789 | - 'alternative' => null, |
|
790 | - ), |
|
791 | - 'ibase_connect' => array( |
|
792 | - '7.4' => true, |
|
793 | - 'alternative' => null, |
|
794 | - ), |
|
795 | - 'ibase_db_info' => array( |
|
796 | - '7.4' => true, |
|
797 | - 'alternative' => null, |
|
798 | - ), |
|
799 | - 'ibase_delete_user' => array( |
|
800 | - '7.4' => true, |
|
801 | - 'alternative' => null, |
|
802 | - ), |
|
803 | - 'ibase_drop_db' => array( |
|
804 | - '7.4' => true, |
|
805 | - 'alternative' => null, |
|
806 | - ), |
|
807 | - 'ibase_errcode' => array( |
|
808 | - '7.4' => true, |
|
809 | - 'alternative' => null, |
|
810 | - ), |
|
811 | - 'ibase_errmsg' => array( |
|
812 | - '7.4' => true, |
|
813 | - 'alternative' => null, |
|
814 | - ), |
|
815 | - 'ibase_execute' => array( |
|
816 | - '7.4' => true, |
|
817 | - 'alternative' => null, |
|
818 | - ), |
|
819 | - 'ibase_fetch_assoc' => array( |
|
820 | - '7.4' => true, |
|
821 | - 'alternative' => null, |
|
822 | - ), |
|
823 | - 'ibase_fetch_object' => array( |
|
824 | - '7.4' => true, |
|
825 | - 'alternative' => null, |
|
826 | - ), |
|
827 | - 'ibase_fetch_row' => array( |
|
828 | - '7.4' => true, |
|
829 | - 'alternative' => null, |
|
830 | - ), |
|
831 | - 'ibase_field_info' => array( |
|
832 | - '7.4' => true, |
|
833 | - 'alternative' => null, |
|
834 | - ), |
|
835 | - 'ibase_free_event_handler' => array( |
|
836 | - '7.4' => true, |
|
837 | - 'alternative' => null, |
|
838 | - ), |
|
839 | - 'ibase_free_query' => array( |
|
840 | - '7.4' => true, |
|
841 | - 'alternative' => null, |
|
842 | - ), |
|
843 | - 'ibase_free_result' => array( |
|
844 | - '7.4' => true, |
|
845 | - 'alternative' => null, |
|
846 | - ), |
|
847 | - 'ibase_gen_id' => array( |
|
848 | - '7.4' => true, |
|
849 | - 'alternative' => null, |
|
850 | - ), |
|
851 | - 'ibase_maintain_db' => array( |
|
852 | - '7.4' => true, |
|
853 | - 'alternative' => null, |
|
854 | - ), |
|
855 | - 'ibase_modify_user' => array( |
|
856 | - '7.4' => true, |
|
857 | - 'alternative' => null, |
|
858 | - ), |
|
859 | - 'ibase_name_result' => array( |
|
860 | - '7.4' => true, |
|
861 | - 'alternative' => null, |
|
862 | - ), |
|
863 | - 'ibase_num_fields' => array( |
|
864 | - '7.4' => true, |
|
865 | - 'alternative' => null, |
|
866 | - ), |
|
867 | - 'ibase_num_params' => array( |
|
868 | - '7.4' => true, |
|
869 | - 'alternative' => null, |
|
870 | - ), |
|
871 | - 'ibase_param_info' => array( |
|
872 | - '7.4' => true, |
|
873 | - 'alternative' => null, |
|
874 | - ), |
|
875 | - 'ibase_pconnect' => array( |
|
876 | - '7.4' => true, |
|
877 | - 'alternative' => null, |
|
878 | - ), |
|
879 | - 'ibase_prepare' => array( |
|
880 | - '7.4' => true, |
|
881 | - 'alternative' => null, |
|
882 | - ), |
|
883 | - 'ibase_query' => array( |
|
884 | - '7.4' => true, |
|
885 | - 'alternative' => null, |
|
886 | - ), |
|
887 | - 'ibase_restore' => array( |
|
888 | - '7.4' => true, |
|
889 | - 'alternative' => null, |
|
890 | - ), |
|
891 | - 'ibase_rollback_ret' => array( |
|
892 | - '7.4' => true, |
|
893 | - 'alternative' => null, |
|
894 | - ), |
|
895 | - 'ibase_rollback' => array( |
|
896 | - '7.4' => true, |
|
897 | - 'alternative' => null, |
|
898 | - ), |
|
899 | - 'ibase_server_info' => array( |
|
900 | - '7.4' => true, |
|
901 | - 'alternative' => null, |
|
902 | - ), |
|
903 | - 'ibase_service_attach' => array( |
|
904 | - '7.4' => true, |
|
905 | - 'alternative' => null, |
|
906 | - ), |
|
907 | - 'ibase_service_detach' => array( |
|
908 | - '7.4' => true, |
|
909 | - 'alternative' => null, |
|
910 | - ), |
|
911 | - 'ibase_set_event_handler' => array( |
|
912 | - '7.4' => true, |
|
913 | - 'alternative' => null, |
|
914 | - ), |
|
915 | - 'ibase_trans' => array( |
|
916 | - '7.4' => true, |
|
917 | - 'alternative' => null, |
|
918 | - ), |
|
919 | - 'ibase_wait_event' => array( |
|
920 | - '7.4' => true, |
|
921 | - 'alternative' => null, |
|
922 | - ), |
|
923 | - 'ldap_control_paged_result_response' => array( |
|
924 | - '7.4' => false, |
|
925 | - 'alternative' => 'ldap_search()', |
|
926 | - ), |
|
927 | - 'ldap_control_paged_result' => array( |
|
928 | - '7.4' => false, |
|
929 | - 'alternative' => 'ldap_search()', |
|
930 | - ), |
|
931 | - 'wddx_add_vars' => array( |
|
932 | - '7.4' => true, |
|
933 | - 'alternative' => null, |
|
934 | - ), |
|
935 | - 'wddx_deserialize' => array( |
|
936 | - '7.4' => true, |
|
937 | - 'alternative' => null, |
|
938 | - ), |
|
939 | - 'wddx_packet_end' => array( |
|
940 | - '7.4' => true, |
|
941 | - 'alternative' => null, |
|
942 | - ), |
|
943 | - 'wddx_packet_start' => array( |
|
944 | - '7.4' => true, |
|
945 | - 'alternative' => null, |
|
946 | - ), |
|
947 | - 'wddx_serialize_value' => array( |
|
948 | - '7.4' => true, |
|
949 | - 'alternative' => null, |
|
950 | - ), |
|
951 | - 'wddx_serialize_vars' => array( |
|
952 | - '7.4' => true, |
|
953 | - 'alternative' => null, |
|
954 | - ), |
|
955 | - ); |
|
731 | + 'ibase_add_user' => array( |
|
732 | + '7.4' => true, |
|
733 | + 'alternative' => null, |
|
734 | + ), |
|
735 | + 'ibase_affected_rows' => array( |
|
736 | + '7.4' => true, |
|
737 | + 'alternative' => null, |
|
738 | + ), |
|
739 | + 'ibase_backup' => array( |
|
740 | + '7.4' => true, |
|
741 | + 'alternative' => null, |
|
742 | + ), |
|
743 | + 'ibase_blob_add' => array( |
|
744 | + '7.4' => true, |
|
745 | + 'alternative' => null, |
|
746 | + ), |
|
747 | + 'ibase_blob_cancel' => array( |
|
748 | + '7.4' => true, |
|
749 | + 'alternative' => null, |
|
750 | + ), |
|
751 | + 'ibase_blob_close' => array( |
|
752 | + '7.4' => true, |
|
753 | + 'alternative' => null, |
|
754 | + ), |
|
755 | + 'ibase_blob_create' => array( |
|
756 | + '7.4' => true, |
|
757 | + 'alternative' => null, |
|
758 | + ), |
|
759 | + 'ibase_blob_echo' => array( |
|
760 | + '7.4' => true, |
|
761 | + 'alternative' => null, |
|
762 | + ), |
|
763 | + 'ibase_blob_get' => array( |
|
764 | + '7.4' => true, |
|
765 | + 'alternative' => null, |
|
766 | + ), |
|
767 | + 'ibase_blob_import' => array( |
|
768 | + '7.4' => true, |
|
769 | + 'alternative' => null, |
|
770 | + ), |
|
771 | + 'ibase_blob_info' => array( |
|
772 | + '7.4' => true, |
|
773 | + 'alternative' => null, |
|
774 | + ), |
|
775 | + 'ibase_blob_open' => array( |
|
776 | + '7.4' => true, |
|
777 | + 'alternative' => null, |
|
778 | + ), |
|
779 | + 'ibase_close' => array( |
|
780 | + '7.4' => true, |
|
781 | + 'alternative' => null, |
|
782 | + ), |
|
783 | + 'ibase_commit_ret' => array( |
|
784 | + '7.4' => true, |
|
785 | + 'alternative' => null, |
|
786 | + ), |
|
787 | + 'ibase_commit' => array( |
|
788 | + '7.4' => true, |
|
789 | + 'alternative' => null, |
|
790 | + ), |
|
791 | + 'ibase_connect' => array( |
|
792 | + '7.4' => true, |
|
793 | + 'alternative' => null, |
|
794 | + ), |
|
795 | + 'ibase_db_info' => array( |
|
796 | + '7.4' => true, |
|
797 | + 'alternative' => null, |
|
798 | + ), |
|
799 | + 'ibase_delete_user' => array( |
|
800 | + '7.4' => true, |
|
801 | + 'alternative' => null, |
|
802 | + ), |
|
803 | + 'ibase_drop_db' => array( |
|
804 | + '7.4' => true, |
|
805 | + 'alternative' => null, |
|
806 | + ), |
|
807 | + 'ibase_errcode' => array( |
|
808 | + '7.4' => true, |
|
809 | + 'alternative' => null, |
|
810 | + ), |
|
811 | + 'ibase_errmsg' => array( |
|
812 | + '7.4' => true, |
|
813 | + 'alternative' => null, |
|
814 | + ), |
|
815 | + 'ibase_execute' => array( |
|
816 | + '7.4' => true, |
|
817 | + 'alternative' => null, |
|
818 | + ), |
|
819 | + 'ibase_fetch_assoc' => array( |
|
820 | + '7.4' => true, |
|
821 | + 'alternative' => null, |
|
822 | + ), |
|
823 | + 'ibase_fetch_object' => array( |
|
824 | + '7.4' => true, |
|
825 | + 'alternative' => null, |
|
826 | + ), |
|
827 | + 'ibase_fetch_row' => array( |
|
828 | + '7.4' => true, |
|
829 | + 'alternative' => null, |
|
830 | + ), |
|
831 | + 'ibase_field_info' => array( |
|
832 | + '7.4' => true, |
|
833 | + 'alternative' => null, |
|
834 | + ), |
|
835 | + 'ibase_free_event_handler' => array( |
|
836 | + '7.4' => true, |
|
837 | + 'alternative' => null, |
|
838 | + ), |
|
839 | + 'ibase_free_query' => array( |
|
840 | + '7.4' => true, |
|
841 | + 'alternative' => null, |
|
842 | + ), |
|
843 | + 'ibase_free_result' => array( |
|
844 | + '7.4' => true, |
|
845 | + 'alternative' => null, |
|
846 | + ), |
|
847 | + 'ibase_gen_id' => array( |
|
848 | + '7.4' => true, |
|
849 | + 'alternative' => null, |
|
850 | + ), |
|
851 | + 'ibase_maintain_db' => array( |
|
852 | + '7.4' => true, |
|
853 | + 'alternative' => null, |
|
854 | + ), |
|
855 | + 'ibase_modify_user' => array( |
|
856 | + '7.4' => true, |
|
857 | + 'alternative' => null, |
|
858 | + ), |
|
859 | + 'ibase_name_result' => array( |
|
860 | + '7.4' => true, |
|
861 | + 'alternative' => null, |
|
862 | + ), |
|
863 | + 'ibase_num_fields' => array( |
|
864 | + '7.4' => true, |
|
865 | + 'alternative' => null, |
|
866 | + ), |
|
867 | + 'ibase_num_params' => array( |
|
868 | + '7.4' => true, |
|
869 | + 'alternative' => null, |
|
870 | + ), |
|
871 | + 'ibase_param_info' => array( |
|
872 | + '7.4' => true, |
|
873 | + 'alternative' => null, |
|
874 | + ), |
|
875 | + 'ibase_pconnect' => array( |
|
876 | + '7.4' => true, |
|
877 | + 'alternative' => null, |
|
878 | + ), |
|
879 | + 'ibase_prepare' => array( |
|
880 | + '7.4' => true, |
|
881 | + 'alternative' => null, |
|
882 | + ), |
|
883 | + 'ibase_query' => array( |
|
884 | + '7.4' => true, |
|
885 | + 'alternative' => null, |
|
886 | + ), |
|
887 | + 'ibase_restore' => array( |
|
888 | + '7.4' => true, |
|
889 | + 'alternative' => null, |
|
890 | + ), |
|
891 | + 'ibase_rollback_ret' => array( |
|
892 | + '7.4' => true, |
|
893 | + 'alternative' => null, |
|
894 | + ), |
|
895 | + 'ibase_rollback' => array( |
|
896 | + '7.4' => true, |
|
897 | + 'alternative' => null, |
|
898 | + ), |
|
899 | + 'ibase_server_info' => array( |
|
900 | + '7.4' => true, |
|
901 | + 'alternative' => null, |
|
902 | + ), |
|
903 | + 'ibase_service_attach' => array( |
|
904 | + '7.4' => true, |
|
905 | + 'alternative' => null, |
|
906 | + ), |
|
907 | + 'ibase_service_detach' => array( |
|
908 | + '7.4' => true, |
|
909 | + 'alternative' => null, |
|
910 | + ), |
|
911 | + 'ibase_set_event_handler' => array( |
|
912 | + '7.4' => true, |
|
913 | + 'alternative' => null, |
|
914 | + ), |
|
915 | + 'ibase_trans' => array( |
|
916 | + '7.4' => true, |
|
917 | + 'alternative' => null, |
|
918 | + ), |
|
919 | + 'ibase_wait_event' => array( |
|
920 | + '7.4' => true, |
|
921 | + 'alternative' => null, |
|
922 | + ), |
|
923 | + 'ldap_control_paged_result_response' => array( |
|
924 | + '7.4' => false, |
|
925 | + 'alternative' => 'ldap_search()', |
|
926 | + ), |
|
927 | + 'ldap_control_paged_result' => array( |
|
928 | + '7.4' => false, |
|
929 | + 'alternative' => 'ldap_search()', |
|
930 | + ), |
|
931 | + 'wddx_add_vars' => array( |
|
932 | + '7.4' => true, |
|
933 | + 'alternative' => null, |
|
934 | + ), |
|
935 | + 'wddx_deserialize' => array( |
|
936 | + '7.4' => true, |
|
937 | + 'alternative' => null, |
|
938 | + ), |
|
939 | + 'wddx_packet_end' => array( |
|
940 | + '7.4' => true, |
|
941 | + 'alternative' => null, |
|
942 | + ), |
|
943 | + 'wddx_packet_start' => array( |
|
944 | + '7.4' => true, |
|
945 | + 'alternative' => null, |
|
946 | + ), |
|
947 | + 'wddx_serialize_value' => array( |
|
948 | + '7.4' => true, |
|
949 | + 'alternative' => null, |
|
950 | + ), |
|
951 | + 'wddx_serialize_vars' => array( |
|
952 | + '7.4' => true, |
|
953 | + 'alternative' => null, |
|
954 | + ), |
|
955 | + ); |
|
956 | 956 | |
957 | 957 | |
958 | - /** |
|
959 | - * Returns an array of tokens this test wants to listen for. |
|
960 | - * |
|
961 | - * @return array |
|
962 | - */ |
|
963 | - public function register() |
|
964 | - { |
|
965 | - // Handle case-insensitivity of function names. |
|
966 | - $this->removedFunctions = $this->arrayKeysToLowercase($this->removedFunctions); |
|
958 | + /** |
|
959 | + * Returns an array of tokens this test wants to listen for. |
|
960 | + * |
|
961 | + * @return array |
|
962 | + */ |
|
963 | + public function register() |
|
964 | + { |
|
965 | + // Handle case-insensitivity of function names. |
|
966 | + $this->removedFunctions = $this->arrayKeysToLowercase($this->removedFunctions); |
|
967 | 967 | |
968 | - return array(\T_STRING); |
|
969 | - } |
|
968 | + return array(\T_STRING); |
|
969 | + } |
|
970 | 970 | |
971 | 971 | |
972 | - /** |
|
973 | - * Processes this test, when one of its tokens is encountered. |
|
974 | - * |
|
975 | - * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
976 | - * @param int $stackPtr The position of the current token in |
|
977 | - * the stack passed in $tokens. |
|
978 | - * |
|
979 | - * @return void |
|
980 | - */ |
|
981 | - public function process(File $phpcsFile, $stackPtr) |
|
982 | - { |
|
983 | - $tokens = $phpcsFile->getTokens(); |
|
972 | + /** |
|
973 | + * Processes this test, when one of its tokens is encountered. |
|
974 | + * |
|
975 | + * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
976 | + * @param int $stackPtr The position of the current token in |
|
977 | + * the stack passed in $tokens. |
|
978 | + * |
|
979 | + * @return void |
|
980 | + */ |
|
981 | + public function process(File $phpcsFile, $stackPtr) |
|
982 | + { |
|
983 | + $tokens = $phpcsFile->getTokens(); |
|
984 | 984 | |
985 | - $ignore = array( |
|
986 | - \T_DOUBLE_COLON => true, |
|
987 | - \T_OBJECT_OPERATOR => true, |
|
988 | - \T_FUNCTION => true, |
|
989 | - \T_CLASS => true, |
|
990 | - \T_CONST => true, |
|
991 | - \T_USE => true, |
|
992 | - \T_NS_SEPARATOR => true, |
|
993 | - ); |
|
985 | + $ignore = array( |
|
986 | + \T_DOUBLE_COLON => true, |
|
987 | + \T_OBJECT_OPERATOR => true, |
|
988 | + \T_FUNCTION => true, |
|
989 | + \T_CLASS => true, |
|
990 | + \T_CONST => true, |
|
991 | + \T_USE => true, |
|
992 | + \T_NS_SEPARATOR => true, |
|
993 | + ); |
|
994 | 994 | |
995 | - $prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true); |
|
996 | - if (isset($ignore[$tokens[$prevToken]['code']]) === true) { |
|
997 | - // Not a call to a PHP function. |
|
998 | - return; |
|
999 | - } |
|
995 | + $prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true); |
|
996 | + if (isset($ignore[$tokens[$prevToken]['code']]) === true) { |
|
997 | + // Not a call to a PHP function. |
|
998 | + return; |
|
999 | + } |
|
1000 | 1000 | |
1001 | - $function = $tokens[$stackPtr]['content']; |
|
1002 | - $functionLc = strtolower($function); |
|
1001 | + $function = $tokens[$stackPtr]['content']; |
|
1002 | + $functionLc = strtolower($function); |
|
1003 | 1003 | |
1004 | - if (isset($this->removedFunctions[$functionLc]) === false) { |
|
1005 | - return; |
|
1006 | - } |
|
1004 | + if (isset($this->removedFunctions[$functionLc]) === false) { |
|
1005 | + return; |
|
1006 | + } |
|
1007 | 1007 | |
1008 | - $itemInfo = array( |
|
1009 | - 'name' => $function, |
|
1010 | - 'nameLc' => $functionLc, |
|
1011 | - ); |
|
1012 | - $this->handleFeature($phpcsFile, $stackPtr, $itemInfo); |
|
1013 | - } |
|
1008 | + $itemInfo = array( |
|
1009 | + 'name' => $function, |
|
1010 | + 'nameLc' => $functionLc, |
|
1011 | + ); |
|
1012 | + $this->handleFeature($phpcsFile, $stackPtr, $itemInfo); |
|
1013 | + } |
|
1014 | 1014 | |
1015 | 1015 | |
1016 | - /** |
|
1017 | - * Get the relevant sub-array for a specific item from a multi-dimensional array. |
|
1018 | - * |
|
1019 | - * @param array $itemInfo Base information about the item. |
|
1020 | - * |
|
1021 | - * @return array Version and other information about the item. |
|
1022 | - */ |
|
1023 | - public function getItemArray(array $itemInfo) |
|
1024 | - { |
|
1025 | - return $this->removedFunctions[$itemInfo['nameLc']]; |
|
1026 | - } |
|
1016 | + /** |
|
1017 | + * Get the relevant sub-array for a specific item from a multi-dimensional array. |
|
1018 | + * |
|
1019 | + * @param array $itemInfo Base information about the item. |
|
1020 | + * |
|
1021 | + * @return array Version and other information about the item. |
|
1022 | + */ |
|
1023 | + public function getItemArray(array $itemInfo) |
|
1024 | + { |
|
1025 | + return $this->removedFunctions[$itemInfo['nameLc']]; |
|
1026 | + } |
|
1027 | 1027 | |
1028 | 1028 | |
1029 | - /** |
|
1030 | - * Get the error message template for this sniff. |
|
1031 | - * |
|
1032 | - * @return string |
|
1033 | - */ |
|
1034 | - protected function getErrorMsgTemplate() |
|
1035 | - { |
|
1036 | - return 'Function %s() is '; |
|
1037 | - } |
|
1029 | + /** |
|
1030 | + * Get the error message template for this sniff. |
|
1031 | + * |
|
1032 | + * @return string |
|
1033 | + */ |
|
1034 | + protected function getErrorMsgTemplate() |
|
1035 | + { |
|
1036 | + return 'Function %s() is '; |
|
1037 | + } |
|
1038 | 1038 | } |
@@ -22,198 +22,198 @@ |
||
22 | 22 | */ |
23 | 23 | class RemovedFunctionParametersSniff extends AbstractRemovedFeatureSniff |
24 | 24 | { |
25 | - /** |
|
26 | - * A list of removed function parameters, which were present in older versions. |
|
27 | - * |
|
28 | - * The array lists : version number with false (deprecated) and true (removed). |
|
29 | - * The index is the location of the parameter in the parameter list, starting at 0 ! |
|
30 | - * If's sufficient to list the first version where the function parameter was deprecated/removed. |
|
31 | - * |
|
32 | - * @var array |
|
33 | - */ |
|
34 | - protected $removedFunctionParameters = array( |
|
35 | - 'define' => array( |
|
36 | - 2 => array( |
|
37 | - 'name' => 'case_insensitive', |
|
38 | - '7.3' => false, // Slated for removal in PHP 8.0.0. |
|
39 | - ), |
|
40 | - ), |
|
41 | - 'gmmktime' => array( |
|
42 | - 6 => array( |
|
43 | - 'name' => 'is_dst', |
|
44 | - '5.1' => false, |
|
45 | - '7.0' => true, |
|
46 | - ), |
|
47 | - ), |
|
48 | - 'ldap_first_attribute' => array( |
|
49 | - 2 => array( |
|
50 | - 'name' => 'ber_identifier', |
|
51 | - '5.2.4' => true, |
|
52 | - ), |
|
53 | - ), |
|
54 | - 'ldap_next_attribute' => array( |
|
55 | - 2 => array( |
|
56 | - 'name' => 'ber_identifier', |
|
57 | - '5.2.4' => true, |
|
58 | - ), |
|
59 | - ), |
|
60 | - 'mktime' => array( |
|
61 | - 6 => array( |
|
62 | - 'name' => 'is_dst', |
|
63 | - '5.1' => false, |
|
64 | - '7.0' => true, |
|
65 | - ), |
|
66 | - ), |
|
67 | - ); |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * Returns an array of tokens this test wants to listen for. |
|
72 | - * |
|
73 | - * @return array |
|
74 | - */ |
|
75 | - public function register() |
|
76 | - { |
|
77 | - // Handle case-insensitivity of function names. |
|
78 | - $this->removedFunctionParameters = $this->arrayKeysToLowercase($this->removedFunctionParameters); |
|
79 | - |
|
80 | - return array(\T_STRING); |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * Processes this test, when one of its tokens is encountered. |
|
85 | - * |
|
86 | - * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
87 | - * @param int $stackPtr The position of the current token in |
|
88 | - * the stack passed in $tokens. |
|
89 | - * |
|
90 | - * @return void |
|
91 | - */ |
|
92 | - public function process(File $phpcsFile, $stackPtr) |
|
93 | - { |
|
94 | - $tokens = $phpcsFile->getTokens(); |
|
95 | - |
|
96 | - $ignore = array( |
|
97 | - \T_DOUBLE_COLON => true, |
|
98 | - \T_OBJECT_OPERATOR => true, |
|
99 | - \T_FUNCTION => true, |
|
100 | - \T_CONST => true, |
|
101 | - ); |
|
102 | - |
|
103 | - $prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true); |
|
104 | - if (isset($ignore[$tokens[$prevToken]['code']]) === true) { |
|
105 | - // Not a call to a PHP function. |
|
106 | - return; |
|
107 | - } |
|
108 | - |
|
109 | - $function = $tokens[$stackPtr]['content']; |
|
110 | - $functionLc = strtolower($function); |
|
111 | - |
|
112 | - if (isset($this->removedFunctionParameters[$functionLc]) === false) { |
|
113 | - return; |
|
114 | - } |
|
115 | - |
|
116 | - $parameterCount = $this->getFunctionCallParameterCount($phpcsFile, $stackPtr); |
|
117 | - if ($parameterCount === 0) { |
|
118 | - return; |
|
119 | - } |
|
120 | - |
|
121 | - // If the parameter count returned > 0, we know there will be valid open parenthesis. |
|
122 | - $openParenthesis = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true); |
|
123 | - $parameterOffsetFound = $parameterCount - 1; |
|
124 | - |
|
125 | - foreach ($this->removedFunctionParameters[$functionLc] as $offset => $parameterDetails) { |
|
126 | - if ($offset <= $parameterOffsetFound) { |
|
127 | - $itemInfo = array( |
|
128 | - 'name' => $function, |
|
129 | - 'nameLc' => $functionLc, |
|
130 | - 'offset' => $offset, |
|
131 | - ); |
|
132 | - $this->handleFeature($phpcsFile, $openParenthesis, $itemInfo); |
|
133 | - } |
|
134 | - } |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - /** |
|
139 | - * Get the relevant sub-array for a specific item from a multi-dimensional array. |
|
140 | - * |
|
141 | - * @param array $itemInfo Base information about the item. |
|
142 | - * |
|
143 | - * @return array Version and other information about the item. |
|
144 | - */ |
|
145 | - public function getItemArray(array $itemInfo) |
|
146 | - { |
|
147 | - return $this->removedFunctionParameters[$itemInfo['nameLc']][$itemInfo['offset']]; |
|
148 | - } |
|
149 | - |
|
150 | - |
|
151 | - /** |
|
152 | - * Get an array of the non-PHP-version array keys used in a sub-array. |
|
153 | - * |
|
154 | - * @return array |
|
155 | - */ |
|
156 | - protected function getNonVersionArrayKeys() |
|
157 | - { |
|
158 | - return array('name'); |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * Retrieve the relevant detail (version) information for use in an error message. |
|
164 | - * |
|
165 | - * @param array $itemArray Version and other information about the item. |
|
166 | - * @param array $itemInfo Base information about the item. |
|
167 | - * |
|
168 | - * @return array |
|
169 | - */ |
|
170 | - public function getErrorInfo(array $itemArray, array $itemInfo) |
|
171 | - { |
|
172 | - $errorInfo = parent::getErrorInfo($itemArray, $itemInfo); |
|
173 | - $errorInfo['paramName'] = $itemArray['name']; |
|
174 | - |
|
175 | - return $errorInfo; |
|
176 | - } |
|
177 | - |
|
178 | - |
|
179 | - /** |
|
180 | - * Get the item name to be used for the creation of the error code. |
|
181 | - * |
|
182 | - * @param array $itemInfo Base information about the item. |
|
183 | - * @param array $errorInfo Detail information about an item. |
|
184 | - * |
|
185 | - * @return string |
|
186 | - */ |
|
187 | - protected function getItemName(array $itemInfo, array $errorInfo) |
|
188 | - { |
|
189 | - return $itemInfo['name'] . '_' . $errorInfo['paramName']; |
|
190 | - } |
|
191 | - |
|
192 | - |
|
193 | - /** |
|
194 | - * Get the error message template for this sniff. |
|
195 | - * |
|
196 | - * @return string |
|
197 | - */ |
|
198 | - protected function getErrorMsgTemplate() |
|
199 | - { |
|
200 | - return 'The "%s" parameter for function %s() is '; |
|
201 | - } |
|
202 | - |
|
203 | - |
|
204 | - /** |
|
205 | - * Filter the error data before it's passed to PHPCS. |
|
206 | - * |
|
207 | - * @param array $data The error data array which was created. |
|
208 | - * @param array $itemInfo Base information about the item this error message applies to. |
|
209 | - * @param array $errorInfo Detail information about an item this error message applies to. |
|
210 | - * |
|
211 | - * @return array |
|
212 | - */ |
|
213 | - protected function filterErrorData(array $data, array $itemInfo, array $errorInfo) |
|
214 | - { |
|
215 | - array_shift($data); |
|
216 | - array_unshift($data, $errorInfo['paramName'], $itemInfo['name']); |
|
217 | - return $data; |
|
218 | - } |
|
25 | + /** |
|
26 | + * A list of removed function parameters, which were present in older versions. |
|
27 | + * |
|
28 | + * The array lists : version number with false (deprecated) and true (removed). |
|
29 | + * The index is the location of the parameter in the parameter list, starting at 0 ! |
|
30 | + * If's sufficient to list the first version where the function parameter was deprecated/removed. |
|
31 | + * |
|
32 | + * @var array |
|
33 | + */ |
|
34 | + protected $removedFunctionParameters = array( |
|
35 | + 'define' => array( |
|
36 | + 2 => array( |
|
37 | + 'name' => 'case_insensitive', |
|
38 | + '7.3' => false, // Slated for removal in PHP 8.0.0. |
|
39 | + ), |
|
40 | + ), |
|
41 | + 'gmmktime' => array( |
|
42 | + 6 => array( |
|
43 | + 'name' => 'is_dst', |
|
44 | + '5.1' => false, |
|
45 | + '7.0' => true, |
|
46 | + ), |
|
47 | + ), |
|
48 | + 'ldap_first_attribute' => array( |
|
49 | + 2 => array( |
|
50 | + 'name' => 'ber_identifier', |
|
51 | + '5.2.4' => true, |
|
52 | + ), |
|
53 | + ), |
|
54 | + 'ldap_next_attribute' => array( |
|
55 | + 2 => array( |
|
56 | + 'name' => 'ber_identifier', |
|
57 | + '5.2.4' => true, |
|
58 | + ), |
|
59 | + ), |
|
60 | + 'mktime' => array( |
|
61 | + 6 => array( |
|
62 | + 'name' => 'is_dst', |
|
63 | + '5.1' => false, |
|
64 | + '7.0' => true, |
|
65 | + ), |
|
66 | + ), |
|
67 | + ); |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * Returns an array of tokens this test wants to listen for. |
|
72 | + * |
|
73 | + * @return array |
|
74 | + */ |
|
75 | + public function register() |
|
76 | + { |
|
77 | + // Handle case-insensitivity of function names. |
|
78 | + $this->removedFunctionParameters = $this->arrayKeysToLowercase($this->removedFunctionParameters); |
|
79 | + |
|
80 | + return array(\T_STRING); |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * Processes this test, when one of its tokens is encountered. |
|
85 | + * |
|
86 | + * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
87 | + * @param int $stackPtr The position of the current token in |
|
88 | + * the stack passed in $tokens. |
|
89 | + * |
|
90 | + * @return void |
|
91 | + */ |
|
92 | + public function process(File $phpcsFile, $stackPtr) |
|
93 | + { |
|
94 | + $tokens = $phpcsFile->getTokens(); |
|
95 | + |
|
96 | + $ignore = array( |
|
97 | + \T_DOUBLE_COLON => true, |
|
98 | + \T_OBJECT_OPERATOR => true, |
|
99 | + \T_FUNCTION => true, |
|
100 | + \T_CONST => true, |
|
101 | + ); |
|
102 | + |
|
103 | + $prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true); |
|
104 | + if (isset($ignore[$tokens[$prevToken]['code']]) === true) { |
|
105 | + // Not a call to a PHP function. |
|
106 | + return; |
|
107 | + } |
|
108 | + |
|
109 | + $function = $tokens[$stackPtr]['content']; |
|
110 | + $functionLc = strtolower($function); |
|
111 | + |
|
112 | + if (isset($this->removedFunctionParameters[$functionLc]) === false) { |
|
113 | + return; |
|
114 | + } |
|
115 | + |
|
116 | + $parameterCount = $this->getFunctionCallParameterCount($phpcsFile, $stackPtr); |
|
117 | + if ($parameterCount === 0) { |
|
118 | + return; |
|
119 | + } |
|
120 | + |
|
121 | + // If the parameter count returned > 0, we know there will be valid open parenthesis. |
|
122 | + $openParenthesis = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true); |
|
123 | + $parameterOffsetFound = $parameterCount - 1; |
|
124 | + |
|
125 | + foreach ($this->removedFunctionParameters[$functionLc] as $offset => $parameterDetails) { |
|
126 | + if ($offset <= $parameterOffsetFound) { |
|
127 | + $itemInfo = array( |
|
128 | + 'name' => $function, |
|
129 | + 'nameLc' => $functionLc, |
|
130 | + 'offset' => $offset, |
|
131 | + ); |
|
132 | + $this->handleFeature($phpcsFile, $openParenthesis, $itemInfo); |
|
133 | + } |
|
134 | + } |
|
135 | + } |
|
136 | + |
|
137 | + |
|
138 | + /** |
|
139 | + * Get the relevant sub-array for a specific item from a multi-dimensional array. |
|
140 | + * |
|
141 | + * @param array $itemInfo Base information about the item. |
|
142 | + * |
|
143 | + * @return array Version and other information about the item. |
|
144 | + */ |
|
145 | + public function getItemArray(array $itemInfo) |
|
146 | + { |
|
147 | + return $this->removedFunctionParameters[$itemInfo['nameLc']][$itemInfo['offset']]; |
|
148 | + } |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * Get an array of the non-PHP-version array keys used in a sub-array. |
|
153 | + * |
|
154 | + * @return array |
|
155 | + */ |
|
156 | + protected function getNonVersionArrayKeys() |
|
157 | + { |
|
158 | + return array('name'); |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * Retrieve the relevant detail (version) information for use in an error message. |
|
164 | + * |
|
165 | + * @param array $itemArray Version and other information about the item. |
|
166 | + * @param array $itemInfo Base information about the item. |
|
167 | + * |
|
168 | + * @return array |
|
169 | + */ |
|
170 | + public function getErrorInfo(array $itemArray, array $itemInfo) |
|
171 | + { |
|
172 | + $errorInfo = parent::getErrorInfo($itemArray, $itemInfo); |
|
173 | + $errorInfo['paramName'] = $itemArray['name']; |
|
174 | + |
|
175 | + return $errorInfo; |
|
176 | + } |
|
177 | + |
|
178 | + |
|
179 | + /** |
|
180 | + * Get the item name to be used for the creation of the error code. |
|
181 | + * |
|
182 | + * @param array $itemInfo Base information about the item. |
|
183 | + * @param array $errorInfo Detail information about an item. |
|
184 | + * |
|
185 | + * @return string |
|
186 | + */ |
|
187 | + protected function getItemName(array $itemInfo, array $errorInfo) |
|
188 | + { |
|
189 | + return $itemInfo['name'] . '_' . $errorInfo['paramName']; |
|
190 | + } |
|
191 | + |
|
192 | + |
|
193 | + /** |
|
194 | + * Get the error message template for this sniff. |
|
195 | + * |
|
196 | + * @return string |
|
197 | + */ |
|
198 | + protected function getErrorMsgTemplate() |
|
199 | + { |
|
200 | + return 'The "%s" parameter for function %s() is '; |
|
201 | + } |
|
202 | + |
|
203 | + |
|
204 | + /** |
|
205 | + * Filter the error data before it's passed to PHPCS. |
|
206 | + * |
|
207 | + * @param array $data The error data array which was created. |
|
208 | + * @param array $itemInfo Base information about the item this error message applies to. |
|
209 | + * @param array $errorInfo Detail information about an item this error message applies to. |
|
210 | + * |
|
211 | + * @return array |
|
212 | + */ |
|
213 | + protected function filterErrorData(array $data, array $itemInfo, array $errorInfo) |
|
214 | + { |
|
215 | + array_shift($data); |
|
216 | + array_unshift($data, $errorInfo['paramName'], $itemInfo['name']); |
|
217 | + return $data; |
|
218 | + } |
|
219 | 219 | } |