Skip to content

Commit dc7c3f4

Browse files
committed
Fixed code by recommendation, added constants
1 parent c895716 commit dc7c3f4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Magento2/Sniffs/Functions/FunctionsDeprecatedWithoutArgumentSniff.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@ class FunctionsDeprecatedWithoutArgumentSniff implements Sniff
2020
*
2121
* @var string
2222
*/
23-
private $warningMessage = 'Calling function %s() without argument is deprecated in PHP 8.1. '
23+
private const WARNING_MESSAGE = 'Calling function %s() without argument is deprecated in PHP 8.1. '
2424
. 'Please pass the input to validate as the first argument of the function.';
2525

2626
/**
2727
* Warning violation code.
2828
*
2929
* @var string
3030
*/
31-
private $warningCode = 'FunctionsDeprecatedWithoutArgument';
31+
private const WARNING_CODE = 'FunctionsDeprecatedWithoutArgument';
3232

3333
/**
3434
* Deprecated functions without argument.
3535
*
3636
* @var array
3737
*/
38-
private $deprecatedFunctions = [
38+
private const FUNCTIONS_LIST = [
3939
'mb_check_encoding',
4040
'get_class',
4141
'get_parent_class',
@@ -66,8 +66,8 @@ public function process(File $phpcsFile, $stackPtr): void
6666

6767
$functionName = $phpcsFile->getTokensAsString($phpcsFile->findPrevious(T_STRING, $stackPtr), 1);
6868

69-
if (in_array($functionName, $this->deprecatedFunctions)) {
70-
$phpcsFile->addWarning(sprintf($this->warningMessage, $functionName), $stackPtr, $this->warningCode);
69+
if (in_array($functionName, self::FUNCTIONS_LIST)) {
70+
$phpcsFile->addWarning(sprintf(self::WARNING_MESSAGE, $functionName), $stackPtr, self::WARNING_CODE);
7171
}
7272
}
7373
}

0 commit comments

Comments
 (0)