|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* \PHPCompatibility\Sniffs\FunctionParameters\IconvEncodingSniff. |
|
4
|
|
|
* |
|
5
|
|
|
* PHP version 5.6 |
|
6
|
|
|
* |
|
7
|
|
|
* @category PHP |
|
8
|
|
|
* @package PHPCompatibility |
|
9
|
|
|
* @author Juliette Reinders Folmer <[email protected]> |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace PHPCompatibility\Sniffs\FunctionParameters; |
|
13
|
|
|
|
|
14
|
|
|
use PHPCompatibility\AbstractFunctionCallParameterSniff; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* \PHPCompatibility\Sniffs\FunctionParameters\IconvEncodingSniff. |
|
18
|
|
|
* |
|
19
|
|
|
* Detect: "The iconv and mbstring configuration options related to encoding |
|
20
|
|
|
* have been deprecated in favour of default_charset." |
|
21
|
|
|
* |
|
22
|
|
|
* {@internal It is unclear which mbstring functions should be targetted, so for now, |
|
23
|
|
|
* only the iconv function is handled.}} |
|
24
|
|
|
* |
|
25
|
|
|
* PHP version 5.6 |
|
26
|
|
|
* |
|
27
|
|
|
* @category PHP |
|
28
|
|
|
* @package PHPCompatibility |
|
29
|
|
|
* @author Juliette Reinders Folmer <[email protected]> |
|
30
|
|
|
*/ |
|
31
|
|
|
class IconvEncodingSniff extends AbstractFunctionCallParameterSniff |
|
32
|
|
|
{ |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Functions to check for. |
|
36
|
|
|
* |
|
37
|
|
|
* @var array |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $targetFunctions = array( |
|
40
|
|
|
'iconv_set_encoding' => true, |
|
41
|
|
|
); |
|
42
|
|
|
|
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Do a version check to determine if this sniff needs to run at all. |
|
46
|
|
|
* |
|
47
|
|
|
* @return bool |
|
48
|
|
|
*/ |
|
49
|
|
|
protected function bowOutEarly() |
|
50
|
|
|
{ |
|
51
|
|
|
return ($this->supportsAbove('5.6') === false); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Process the parameters of a matched function. |
|
57
|
|
|
* |
|
58
|
|
|
* @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
|
59
|
|
|
* @param int $stackPtr The position of the current token in the stack. |
|
60
|
|
|
* @param string $functionName The token content (function name) which was matched. |
|
61
|
|
|
* @param array $parameters Array with information about the parameters. |
|
62
|
|
|
* |
|
63
|
|
|
* @return int|void Integer stack pointer to skip forward or void to continue |
|
64
|
|
|
* normal file processing. |
|
65
|
|
|
*/ |
|
66
|
|
|
public function processParameters(\PHP_CodeSniffer_File $phpcsFile, $stackPtr, $functionName, $parameters) |
|
67
|
|
|
{ |
|
68
|
|
|
if (isset($parameters[1]) === false) { |
|
69
|
|
|
return; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
$phpcsFile->addWarning( |
|
73
|
|
|
'All previously accepted values for the $type parameter of iconv_set_encoding() have been deprecated since PHP 5.6. Found %s', |
|
74
|
|
|
$parameters[1]['start'], |
|
75
|
|
|
'DeprecatedValueFound', |
|
76
|
|
|
$parameters[1]['raw'] |
|
77
|
|
|
); |
|
78
|
|
|
} |
|
79
|
|
|
}//end class |
|
80
|
|
|
|