@@ -36,7 +36,7 @@ class FunctionsDeprecatedWithoutArgumentSniff implements Sniff
3636 * @var array
3737 */
3838 private const DEPRECATED_FUNCTIONS_AND_FIXES = [
39- 'mb_check_encoding ' => ' STDIN ' ,
39+ 'mb_check_encoding ' => false ,
4040 'get_class ' => '$this ' ,
4141 'get_parent_class ' => '$this '
4242 ];
@@ -65,17 +65,27 @@ public function process(File $phpcsFile, $stackPtr): void
6565
6666 $ functionName = $ phpcsFile ->getTokensAsString ($ phpcsFile ->findPrevious (T_STRING , $ stackPtr ), 1 );
6767
68- if (in_array ($ functionName , array_keys (self ::DEPRECATED_FUNCTIONS_AND_FIXES ))) {
69- if ($ phpcsFile ->addFixableWarning (
68+ if (!isset (self ::DEPRECATED_FUNCTIONS_AND_FIXES [$ functionName ])) {
69+ return ;
70+ }
71+
72+ if (self ::DEPRECATED_FUNCTIONS_AND_FIXES [$ functionName ] === false ) {
73+ $ phpcsFile ->addWarning (
74+ sprintf (self ::WARNING_MESSAGE , $ functionName ),
75+ $ stackPtr ,
76+ self ::WARNING_CODE
77+ );
78+ }
79+
80+ if ($ phpcsFile ->addFixableWarning (
7081 sprintf (self ::WARNING_MESSAGE , $ functionName ),
7182 $ stackPtr ,
7283 self ::WARNING_CODE
7384 ) === true ) {
74- $ content = self ::DEPRECATED_FUNCTIONS_AND_FIXES [$ functionName ];
75- $ phpcsFile ->fixer ->beginChangeset ();
76- $ phpcsFile ->fixer ->addContentBefore ($ phpcsFile ->findNext (T_CLOSE_PARENTHESIS , $ stackPtr ), $ content );
77- $ phpcsFile ->fixer ->endChangeset ();
78- }
85+ $ content = self ::DEPRECATED_FUNCTIONS_AND_FIXES [$ functionName ];
86+ $ phpcsFile ->fixer ->beginChangeset ();
87+ $ phpcsFile ->fixer ->addContentBefore ($ phpcsFile ->findNext (T_CLOSE_PARENTHESIS , $ stackPtr ), $ content );
88+ $ phpcsFile ->fixer ->endChangeset ();
7989 }
8090 }
8191}
0 commit comments