1 | <?php |
||
21 | class OptionalRequiredFunctionParametersSniff extends RequiredOptionalFunctionParametersSniff |
||
22 | { |
||
23 | |||
24 | /** |
||
25 | * A list of function parameters, which were optional in older versions and became required later on. |
||
26 | * |
||
27 | * The array lists : version number with true (required) and false (optional use deprecated). |
||
28 | * |
||
29 | * The index is the location of the parameter in the parameter list, starting at 0 ! |
||
30 | * If's sufficient to list the last version in which the parameter was not yet required. |
||
31 | * |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $functionParameters = array( |
||
35 | // Special case, the optional nature is not deprecated, but usage is recommended |
||
36 | // and leaving the parameter out will throw an E_NOTICE. |
||
37 | 'crypt' => array( |
||
38 | 1 => array( |
||
39 | 'name' => 'salt', |
||
40 | '5.6' => 'recommended', |
||
41 | ), |
||
42 | ), |
||
43 | 'parse_str' => array( |
||
44 | 1 => array( |
||
45 | 'name' => 'result', |
||
46 | '7.2' => false, |
||
47 | ), |
||
48 | ), |
||
49 | ); |
||
50 | |||
51 | |||
52 | /** |
||
53 | * Determine whether an error/warning should be thrown for an item based on collected information. |
||
54 | * |
||
55 | * @param array $errorInfo Detail information about an item. |
||
56 | * |
||
57 | * @return bool |
||
58 | */ |
||
59 | protected function shouldThrowError(array $errorInfo) |
||
65 | |||
66 | |||
67 | /** |
||
68 | * Retrieve the relevant detail (version) information for use in an error message. |
||
69 | * |
||
70 | * @param array $itemArray Version and other information about the item. |
||
71 | * @param array $itemInfo Base information about the item. |
||
72 | * |
||
73 | * @return array |
||
74 | */ |
||
75 | public function getErrorInfo(array $itemArray, array $itemInfo) |
||
107 | |||
108 | |||
109 | /** |
||
110 | * Generates the error or warning for this item. |
||
111 | * |
||
112 | * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. |
||
113 | * @param int $stackPtr The position of the relevant token in |
||
114 | * the stack. |
||
115 | * @param array $itemInfo Base information about the item. |
||
116 | * @param array $errorInfo Array with detail (version) information |
||
117 | * relevant to the item. |
||
118 | * |
||
119 | * @return void |
||
120 | */ |
||
121 | public function addError(\PHP_CodeSniffer_File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo) |
||
160 | |||
161 | |||
162 | }//end class |
||
163 |