@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | public function register() |
51 | 51 | { |
52 | 52 | // Enrich the scopes list. |
53 | - if (\defined('T_ANON_CLASS')) { |
|
54 | - $this->scopes[] = \T_ANON_CLASS; |
|
53 | + if ( \defined( 'T_ANON_CLASS' ) ) { |
|
54 | + $this->scopes[ ] = \T_ANON_CLASS; |
|
55 | 55 | } |
56 | 56 | |
57 | - return array(\T_FUNCTION); |
|
57 | + return array( \T_FUNCTION ); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -66,27 +66,27 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return void |
68 | 68 | */ |
69 | - public function process(File $phpcsFile, $stackPtr) |
|
69 | + public function process( File $phpcsFile, $stackPtr ) |
|
70 | 70 | { |
71 | - if ($this->supportsAbove('7.3') === false) { |
|
71 | + if ( $this->supportsAbove( '7.3' ) === false ) { |
|
72 | 72 | return; |
73 | 73 | } |
74 | 74 | |
75 | - $funcName = $phpcsFile->getDeclarationName($stackPtr); |
|
75 | + $funcName = $phpcsFile->getDeclarationName( $stackPtr ); |
|
76 | 76 | |
77 | - if (strtolower($funcName) !== 'assert') { |
|
77 | + if ( strtolower( $funcName ) !== 'assert' ) { |
|
78 | 78 | return; |
79 | 79 | } |
80 | 80 | |
81 | - if ($phpcsFile->hasCondition($stackPtr, $this->scopes) === true) { |
|
81 | + if ( $phpcsFile->hasCondition( $stackPtr, $this->scopes ) === true ) { |
|
82 | 82 | return; |
83 | 83 | } |
84 | 84 | |
85 | - if ($this->determineNamespace($phpcsFile, $stackPtr) === '') { |
|
85 | + if ( $this->determineNamespace( $phpcsFile, $stackPtr ) === '' ) { |
|
86 | 86 | // Not a namespaced function declaration. Parse error, but not our concern. |
87 | 87 | return; |
88 | 88 | } |
89 | 89 | |
90 | - $phpcsFile->addWarning('Declaring a free-standing function called assert() is deprecated since PHP 7.3.', $stackPtr, 'Found'); |
|
90 | + $phpcsFile->addWarning( 'Declaring a free-standing function called assert() is deprecated since PHP 7.3.', $stackPtr, 'Found' ); |
|
91 | 91 | } |
92 | 92 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function register() |
85 | 85 | { |
86 | - return array(\T_FUNCTION); |
|
86 | + return array( \T_FUNCTION ); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | |
@@ -96,16 +96,16 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @return void |
98 | 98 | */ |
99 | - public function process(File $phpcsFile, $stackPtr) |
|
99 | + public function process( File $phpcsFile, $stackPtr ) |
|
100 | 100 | { |
101 | - $functionName = $phpcsFile->getDeclarationName($stackPtr); |
|
102 | - $functionNameLc = strtolower($functionName); |
|
101 | + $functionName = $phpcsFile->getDeclarationName( $stackPtr ); |
|
102 | + $functionNameLc = strtolower( $functionName ); |
|
103 | 103 | |
104 | - if (isset($this->newMagicMethods[$functionNameLc]) === false) { |
|
104 | + if ( isset( $this->newMagicMethods[ $functionNameLc ] ) === false ) { |
|
105 | 105 | return; |
106 | 106 | } |
107 | 107 | |
108 | - if ($this->inClassScope($phpcsFile, $stackPtr, false) === false) { |
|
108 | + if ( $this->inClassScope( $phpcsFile, $stackPtr, false ) === false ) { |
|
109 | 109 | return; |
110 | 110 | } |
111 | 111 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | 'name' => $functionName, |
114 | 114 | 'nameLc' => $functionNameLc, |
115 | 115 | ); |
116 | - $this->handleFeature($phpcsFile, $stackPtr, $itemInfo); |
|
116 | + $this->handleFeature( $phpcsFile, $stackPtr, $itemInfo ); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return array Version and other information about the item. |
126 | 126 | */ |
127 | - public function getItemArray(array $itemInfo) |
|
127 | + public function getItemArray( array $itemInfo ) |
|
128 | 128 | { |
129 | - return $this->newMagicMethods[$itemInfo['nameLc']]; |
|
129 | + return $this->newMagicMethods[ $itemInfo[ 'nameLc' ] ]; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | */ |
138 | 138 | protected function getNonVersionArrayKeys() |
139 | 139 | { |
140 | - return array('message'); |
|
140 | + return array( 'message' ); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -149,14 +149,14 @@ discard block |
||
149 | 149 | * |
150 | 150 | * @return array |
151 | 151 | */ |
152 | - public function getErrorInfo(array $itemArray, array $itemInfo) |
|
152 | + public function getErrorInfo( array $itemArray, array $itemInfo ) |
|
153 | 153 | { |
154 | - $errorInfo = parent::getErrorInfo($itemArray, $itemInfo); |
|
155 | - $errorInfo['error'] = false; // Warning, not error. |
|
156 | - $errorInfo['message'] = ''; |
|
154 | + $errorInfo = parent::getErrorInfo( $itemArray, $itemInfo ); |
|
155 | + $errorInfo[ 'error' ] = false; // Warning, not error. |
|
156 | + $errorInfo[ 'message' ] = ''; |
|
157 | 157 | |
158 | - if (empty($itemArray['message']) === false) { |
|
159 | - $errorInfo['message'] = $itemArray['message']; |
|
158 | + if ( empty( $itemArray[ 'message' ] ) === false ) { |
|
159 | + $errorInfo[ 'message' ] = $itemArray[ 'message' ]; |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | return $errorInfo; |
@@ -183,10 +183,10 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @return string |
185 | 185 | */ |
186 | - protected function filterErrorMsg($error, array $itemInfo, array $errorInfo) |
|
186 | + protected function filterErrorMsg( $error, array $itemInfo, array $errorInfo ) |
|
187 | 187 | { |
188 | - if ($errorInfo['message'] !== '') { |
|
189 | - $error = $errorInfo['message']; |
|
188 | + if ( $errorInfo[ 'message' ] !== '' ) { |
|
189 | + $error = $errorInfo[ 'message' ]; |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | return $error; |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @return void |
51 | 51 | */ |
52 | - public function process(File $phpcsFile, $stackPtr) |
|
52 | + public function process( File $phpcsFile, $stackPtr ) |
|
53 | 53 | { |
54 | - if ($this->supportsAbove('7.0') === false) { |
|
54 | + if ( $this->supportsAbove( '7.0' ) === false ) { |
|
55 | 55 | return; |
56 | 56 | } |
57 | 57 | |
58 | - if ($this->determineNamespace($phpcsFile, $stackPtr) !== '') { |
|
58 | + if ( $this->determineNamespace( $phpcsFile, $stackPtr ) !== '' ) { |
|
59 | 59 | /* |
60 | 60 | * Namespaced methods with the same name as the class are treated as |
61 | 61 | * regular methods, so we can bow out if we're in a namespace. |
@@ -68,63 +68,63 @@ discard block |
||
68 | 68 | |
69 | 69 | $tokens = $phpcsFile->getTokens(); |
70 | 70 | |
71 | - $class = $tokens[$stackPtr]; |
|
71 | + $class = $tokens[ $stackPtr ]; |
|
72 | 72 | |
73 | - if (isset($class['scope_closer']) === false) { |
|
73 | + if ( isset( $class[ 'scope_closer' ] ) === false ) { |
|
74 | 74 | return; |
75 | 75 | } |
76 | 76 | |
77 | - $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); |
|
78 | - if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== \T_STRING) { |
|
77 | + $nextNonEmpty = $phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true ); |
|
78 | + if ( $nextNonEmpty === false || $tokens[ $nextNonEmpty ][ 'code' ] !== \T_STRING ) { |
|
79 | 79 | // Anonymous class in combination with PHPCS 2.3.x. |
80 | 80 | return; |
81 | 81 | } |
82 | 82 | |
83 | - $scopeCloser = $class['scope_closer']; |
|
84 | - $className = $tokens[$nextNonEmpty]['content']; |
|
83 | + $scopeCloser = $class[ 'scope_closer' ]; |
|
84 | + $className = $tokens[ $nextNonEmpty ][ 'content' ]; |
|
85 | 85 | |
86 | - if (empty($className) || \is_string($className) === false) { |
|
86 | + if ( empty( $className ) || \is_string( $className ) === false ) { |
|
87 | 87 | return; |
88 | 88 | } |
89 | 89 | |
90 | 90 | $nextFunc = $stackPtr; |
91 | - $classNameLc = strtolower($className); |
|
91 | + $classNameLc = strtolower( $className ); |
|
92 | 92 | $newConstructorFound = false; |
93 | 93 | $oldConstructorFound = false; |
94 | 94 | $oldConstructorPos = -1; |
95 | - while (($nextFunc = $phpcsFile->findNext(\T_FUNCTION, ($nextFunc + 1), $scopeCloser)) !== false) { |
|
95 | + while ( ( $nextFunc = $phpcsFile->findNext( \T_FUNCTION, ( $nextFunc + 1 ), $scopeCloser ) ) !== false ) { |
|
96 | 96 | $functionScopeCloser = $nextFunc; |
97 | - if (isset($tokens[$nextFunc]['scope_closer'])) { |
|
97 | + if ( isset( $tokens[ $nextFunc ][ 'scope_closer' ] ) ) { |
|
98 | 98 | // Normal (non-interface, non-abstract) method. |
99 | - $functionScopeCloser = $tokens[$nextFunc]['scope_closer']; |
|
99 | + $functionScopeCloser = $tokens[ $nextFunc ][ 'scope_closer' ]; |
|
100 | 100 | } |
101 | 101 | |
102 | - $funcName = $phpcsFile->getDeclarationName($nextFunc); |
|
103 | - if (empty($funcName) || \is_string($funcName) === false) { |
|
102 | + $funcName = $phpcsFile->getDeclarationName( $nextFunc ); |
|
103 | + if ( empty( $funcName ) || \is_string( $funcName ) === false ) { |
|
104 | 104 | $nextFunc = $functionScopeCloser; |
105 | 105 | continue; |
106 | 106 | } |
107 | 107 | |
108 | - $funcNameLc = strtolower($funcName); |
|
108 | + $funcNameLc = strtolower( $funcName ); |
|
109 | 109 | |
110 | - if ($funcNameLc === '__construct') { |
|
110 | + if ( $funcNameLc === '__construct' ) { |
|
111 | 111 | $newConstructorFound = true; |
112 | 112 | } |
113 | 113 | |
114 | - if ($funcNameLc === $classNameLc) { |
|
114 | + if ( $funcNameLc === $classNameLc ) { |
|
115 | 115 | $oldConstructorFound = true; |
116 | 116 | $oldConstructorPos = $nextFunc; |
117 | 117 | } |
118 | 118 | |
119 | 119 | // If both have been found, no need to continue looping through the functions. |
120 | - if ($newConstructorFound === true && $oldConstructorFound === true) { |
|
120 | + if ( $newConstructorFound === true && $oldConstructorFound === true ) { |
|
121 | 121 | break; |
122 | 122 | } |
123 | 123 | |
124 | 124 | $nextFunc = $functionScopeCloser; |
125 | 125 | } |
126 | 126 | |
127 | - if ($newConstructorFound === false && $oldConstructorFound === true) { |
|
127 | + if ( $newConstructorFound === false && $oldConstructorFound === true ) { |
|
128 | 128 | $phpcsFile->addWarning( |
129 | 129 | 'Use of deprecated PHP4 style class constructor is not supported since PHP 7.', |
130 | 130 | $oldConstructorPos, |
@@ -42,16 +42,16 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function __construct() |
44 | 44 | { |
45 | - $scopeTokens = array(\T_CLASS, \T_INTERFACE, \T_TRAIT); |
|
46 | - if (\defined('T_ANON_CLASS')) { |
|
47 | - $scopeTokens[] = \T_ANON_CLASS; |
|
45 | + $scopeTokens = array( \T_CLASS, \T_INTERFACE, \T_TRAIT ); |
|
46 | + if ( \defined( 'T_ANON_CLASS' ) ) { |
|
47 | + $scopeTokens[ ] = \T_ANON_CLASS; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | // Call the grand-parent constructor directly. |
51 | - PHPCS_AbstractScopeSniff::__construct($scopeTokens, array(\T_FUNCTION), true); |
|
51 | + PHPCS_AbstractScopeSniff::__construct( $scopeTokens, array( \T_FUNCTION ), true ); |
|
52 | 52 | |
53 | 53 | // Make sure debuginfo is included in the array. Upstream only includes it since 2.5.1. |
54 | - $this->magicMethods['debuginfo'] = true; |
|
54 | + $this->magicMethods[ 'debuginfo' ] = true; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return void |
67 | 67 | */ |
68 | - protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope) |
|
68 | + protected function processTokenWithinScope( File $phpcsFile, $stackPtr, $currScope ) |
|
69 | 69 | { |
70 | 70 | $tokens = $phpcsFile->getTokens(); |
71 | 71 | |
@@ -75,36 +75,36 @@ discard block |
||
75 | 75 | * so for nested classes, we need to make sure we only examine the token for |
76 | 76 | * the lowest level valid scope. |
77 | 77 | */ |
78 | - $conditions = $tokens[$stackPtr]['conditions']; |
|
79 | - end($conditions); |
|
80 | - $deepestScope = key($conditions); |
|
81 | - if ($deepestScope !== $currScope) { |
|
78 | + $conditions = $tokens[ $stackPtr ][ 'conditions' ]; |
|
79 | + end( $conditions ); |
|
80 | + $deepestScope = key( $conditions ); |
|
81 | + if ( $deepestScope !== $currScope ) { |
|
82 | 82 | return; |
83 | 83 | } |
84 | 84 | |
85 | - $methodName = $phpcsFile->getDeclarationName($stackPtr); |
|
86 | - if ($methodName === null) { |
|
85 | + $methodName = $phpcsFile->getDeclarationName( $stackPtr ); |
|
86 | + if ( $methodName === null ) { |
|
87 | 87 | // Ignore closures. |
88 | 88 | return; |
89 | 89 | } |
90 | 90 | |
91 | 91 | // Is this a magic method. i.e., is prefixed with "__" ? |
92 | - if (preg_match('|^__[^_]|', $methodName) > 0) { |
|
93 | - $magicPart = strtolower(substr($methodName, 2)); |
|
94 | - if (isset($this->magicMethods[$magicPart]) === false |
|
95 | - && isset($this->methodsDoubleUnderscore[$magicPart]) === false |
|
92 | + if ( preg_match( '|^__[^_]|', $methodName ) > 0 ) { |
|
93 | + $magicPart = strtolower( substr( $methodName, 2 ) ); |
|
94 | + if ( isset( $this->magicMethods[ $magicPart ] ) === false |
|
95 | + && isset( $this->methodsDoubleUnderscore[ $magicPart ] ) === false |
|
96 | 96 | ) { |
97 | 97 | $className = '[anonymous class]'; |
98 | - $scopeNextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($currScope + 1), null, true); |
|
99 | - if ($scopeNextNonEmpty !== false && $tokens[$scopeNextNonEmpty]['code'] === \T_STRING) { |
|
100 | - $className = $tokens[$scopeNextNonEmpty]['content']; |
|
98 | + $scopeNextNonEmpty = $phpcsFile->findNext( Tokens::$emptyTokens, ( $currScope + 1 ), null, true ); |
|
99 | + if ( $scopeNextNonEmpty !== false && $tokens[ $scopeNextNonEmpty ][ 'code' ] === \T_STRING ) { |
|
100 | + $className = $tokens[ $scopeNextNonEmpty ][ 'content' ]; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | $phpcsFile->addWarning( |
104 | 104 | 'Method name "%s" is discouraged; PHP has reserved all method names with a double underscore prefix for future use.', |
105 | 105 | $stackPtr, |
106 | 106 | 'MethodDoubleUnderscore', |
107 | - array($className . '::' . $methodName) |
|
107 | + array( $className . '::' . $methodName ) |
|
108 | 108 | ); |
109 | 109 | } |
110 | 110 | } |
@@ -120,23 +120,23 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return void |
122 | 122 | */ |
123 | - protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) |
|
123 | + protected function processTokenOutsideScope( File $phpcsFile, $stackPtr ) |
|
124 | 124 | { |
125 | - $functionName = $phpcsFile->getDeclarationName($stackPtr); |
|
126 | - if ($functionName === null) { |
|
125 | + $functionName = $phpcsFile->getDeclarationName( $stackPtr ); |
|
126 | + if ( $functionName === null ) { |
|
127 | 127 | // Ignore closures. |
128 | 128 | return; |
129 | 129 | } |
130 | 130 | |
131 | 131 | // Is this a magic function. i.e., it is prefixed with "__". |
132 | - if (preg_match('|^__[^_]|', $functionName) > 0) { |
|
133 | - $magicPart = strtolower(substr($functionName, 2)); |
|
134 | - if (isset($this->magicFunctions[$magicPart]) === false) { |
|
132 | + if ( preg_match( '|^__[^_]|', $functionName ) > 0 ) { |
|
133 | + $magicPart = strtolower( substr( $functionName, 2 ) ); |
|
134 | + if ( isset( $this->magicFunctions[ $magicPart ] ) === false ) { |
|
135 | 135 | $phpcsFile->addWarning( |
136 | 136 | 'Function name "%s" is discouraged; PHP has reserved all method names with a double underscore prefix for future use.', |
137 | 137 | $stackPtr, |
138 | 138 | 'FunctionDoubleUnderscore', |
139 | - array($functionName) |
|
139 | + array( $functionName ) |
|
140 | 140 | ); |
141 | 141 | } |
142 | 142 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | protected function bowOutEarly() |
85 | 85 | { |
86 | - return ($this->supportsBelow('7.0') === false); |
|
86 | + return ( $this->supportsBelow( '7.0' ) === false ); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -97,28 +97,28 @@ discard block |
||
97 | 97 | * @return int|void Integer stack pointer to skip forward or void to continue |
98 | 98 | * normal file processing. |
99 | 99 | */ |
100 | - public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters) |
|
100 | + public function processParameters( File $phpcsFile, $stackPtr, $functionName, $parameters ) |
|
101 | 101 | { |
102 | - $functionLC = strtolower($functionName); |
|
103 | - foreach ($this->targetFunctions[$functionLC] as $pos => $name) { |
|
104 | - if (isset($parameters[$pos]) === false) { |
|
102 | + $functionLC = strtolower( $functionName ); |
|
103 | + foreach ( $this->targetFunctions[ $functionLC ] as $pos => $name ) { |
|
104 | + if ( isset( $parameters[ $pos ] ) === false ) { |
|
105 | 105 | continue; |
106 | 106 | } |
107 | 107 | |
108 | - $targetParam = $parameters[$pos]; |
|
108 | + $targetParam = $parameters[ $pos ]; |
|
109 | 109 | |
110 | - if ($this->isNegativeNumber($phpcsFile, $targetParam['start'], $targetParam['end']) === false) { |
|
110 | + if ( $this->isNegativeNumber( $phpcsFile, $targetParam[ 'start' ], $targetParam[ 'end' ] ) === false ) { |
|
111 | 111 | continue; |
112 | 112 | } |
113 | 113 | |
114 | 114 | $phpcsFile->addError( |
115 | 115 | 'Negative string offsets were not supported for the $%s parameter in %s() in PHP 7.0 or lower. Found %s', |
116 | - $targetParam['start'], |
|
116 | + $targetParam[ 'start' ], |
|
117 | 117 | 'Found', |
118 | 118 | array( |
119 | 119 | $name, |
120 | 120 | $functionName, |
121 | - $targetParam['raw'], |
|
121 | + $targetParam[ 'raw' ], |
|
122 | 122 | ) |
123 | 123 | ); |
124 | 124 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | { |
67 | 67 | // Version used here should be the highest version from the `$newModifiers` array, |
68 | 68 | // i.e. the last PHP version in which a new modifier was introduced. |
69 | - return ($this->supportsBelow('7.2') === false); |
|
69 | + return ( $this->supportsBelow( '7.2' ) === false ); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | |
@@ -81,25 +81,25 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return void |
83 | 83 | */ |
84 | - protected function examineModifiers(File $phpcsFile, $stackPtr, $functionName, $modifiers) |
|
84 | + protected function examineModifiers( File $phpcsFile, $stackPtr, $functionName, $modifiers ) |
|
85 | 85 | { |
86 | 86 | $error = 'The PCRE regex modifier "%s" is not present in PHP version %s or earlier'; |
87 | 87 | |
88 | - foreach ($this->newModifiers as $modifier => $versionArray) { |
|
89 | - if (strpos($modifiers, $modifier) === false) { |
|
88 | + foreach ( $this->newModifiers as $modifier => $versionArray ) { |
|
89 | + if ( strpos( $modifiers, $modifier ) === false ) { |
|
90 | 90 | continue; |
91 | 91 | } |
92 | 92 | |
93 | 93 | $notInVersion = ''; |
94 | - foreach ($versionArray as $version => $present) { |
|
95 | - if ($notInVersion === '' && $present === false |
|
96 | - && $this->supportsBelow($version) === true |
|
94 | + foreach ( $versionArray as $version => $present ) { |
|
95 | + if ( $notInVersion === '' && $present === false |
|
96 | + && $this->supportsBelow( $version ) === true |
|
97 | 97 | ) { |
98 | 98 | $notInVersion = $version; |
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | - if ($notInVersion === '') { |
|
102 | + if ( $notInVersion === '' ) { |
|
103 | 103 | continue; |
104 | 104 | } |
105 | 105 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | $notInVersion, |
110 | 110 | ); |
111 | 111 | |
112 | - $phpcsFile->addError($error, $stackPtr, $errorCode, $data); |
|
112 | + $phpcsFile->addError( $error, $stackPtr, $errorCode, $data ); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | protected function bowOutEarly() |
67 | 67 | { |
68 | - return ($this->supportsAbove('7.2') === false); |
|
68 | + return ( $this->supportsAbove( '7.2' ) === false ); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
@@ -80,22 +80,22 @@ discard block |
||
80 | 80 | * @return int|void Integer stack pointer to skip forward or void to continue |
81 | 81 | * normal file processing. |
82 | 82 | */ |
83 | - public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters) |
|
83 | + public function processParameters( File $phpcsFile, $stackPtr, $functionName, $parameters ) |
|
84 | 84 | { |
85 | - if (isset($parameters[1]) === false) { |
|
85 | + if ( isset( $parameters[ 1 ] ) === false ) { |
|
86 | 86 | return; |
87 | 87 | } |
88 | 88 | |
89 | - $targetParam = $parameters[1]; |
|
89 | + $targetParam = $parameters[ 1 ]; |
|
90 | 90 | |
91 | - if (isset($this->disabledCryptos[$this->stripQuotes($targetParam['raw'])]) === false) { |
|
91 | + if ( isset( $this->disabledCryptos[ $this->stripQuotes( $targetParam[ 'raw' ] ) ] ) === false ) { |
|
92 | 92 | return; |
93 | 93 | } |
94 | 94 | |
95 | - if (strtolower($functionName) === 'hash_init' |
|
96 | - && (isset($parameters[2]) === false |
|
97 | - || ($parameters[2]['raw'] !== 'HASH_HMAC' |
|
98 | - && $parameters[2]['raw'] !== (string) \HASH_HMAC)) |
|
95 | + if ( strtolower( $functionName ) === 'hash_init' |
|
96 | + && ( isset( $parameters[ 2 ] ) === false |
|
97 | + || ( $parameters[ 2 ][ 'raw' ] !== 'HASH_HMAC' |
|
98 | + && $parameters[ 2 ][ 'raw' ] !== (string)\HASH_HMAC ) ) |
|
99 | 99 | ) { |
100 | 100 | // For hash_init(), these hashes are only disabled with HASH_HMAC set. |
101 | 101 | return; |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | |
104 | 104 | $phpcsFile->addError( |
105 | 105 | 'Non-cryptographic hashes are no longer accepted by function %s() since PHP 7.2. Found: %s', |
106 | - $targetParam['start'], |
|
107 | - $this->stringToErrorCode($functionName), |
|
106 | + $targetParam[ 'start' ], |
|
107 | + $this->stringToErrorCode( $functionName ), |
|
108 | 108 | array( |
109 | 109 | $functionName, |
110 | - $targetParam['raw'], |
|
110 | + $targetParam[ 'raw' ], |
|
111 | 111 | ) |
112 | 112 | ); |
113 | 113 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function register() |
56 | 56 | { |
57 | - return array(\T_STRING); |
|
57 | + return array( \T_STRING ); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -67,22 +67,22 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return void |
69 | 69 | */ |
70 | - public function process(File $phpcsFile, $stackPtr) |
|
70 | + public function process( File $phpcsFile, $stackPtr ) |
|
71 | 71 | { |
72 | - $algo = $this->getHashAlgorithmParameter($phpcsFile, $stackPtr); |
|
73 | - if (empty($algo) || \is_string($algo) === false) { |
|
72 | + $algo = $this->getHashAlgorithmParameter( $phpcsFile, $stackPtr ); |
|
73 | + if ( empty( $algo ) || \is_string( $algo ) === false ) { |
|
74 | 74 | return; |
75 | 75 | } |
76 | 76 | |
77 | 77 | // Bow out if not one of the algorithms we're targetting. |
78 | - if (isset($this->removedAlgorithms[$algo]) === false) { |
|
78 | + if ( isset( $this->removedAlgorithms[ $algo ] ) === false ) { |
|
79 | 79 | return; |
80 | 80 | } |
81 | 81 | |
82 | 82 | $itemInfo = array( |
83 | 83 | 'name' => $algo, |
84 | 84 | ); |
85 | - $this->handleFeature($phpcsFile, $stackPtr, $itemInfo); |
|
85 | + $this->handleFeature( $phpcsFile, $stackPtr, $itemInfo ); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @return array Version and other information about the item. |
95 | 95 | */ |
96 | - public function getItemArray(array $itemInfo) |
|
96 | + public function getItemArray( array $itemInfo ) |
|
97 | 97 | { |
98 | - return $this->removedAlgorithms[$itemInfo['name']]; |
|
98 | + return $this->removedAlgorithms[ $itemInfo[ 'name' ] ]; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | protected function bowOutEarly() |
58 | 58 | { |
59 | - return ($this->supportsBelow('5.2') === false); |
|
59 | + return ( $this->supportsBelow( '5.2' ) === false ); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
@@ -71,35 +71,35 @@ discard block |
||
71 | 71 | * @return int|void Integer stack pointer to skip forward or void to continue |
72 | 72 | * normal file processing. |
73 | 73 | */ |
74 | - public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters) |
|
74 | + public function processParameters( File $phpcsFile, $stackPtr, $functionName, $parameters ) |
|
75 | 75 | { |
76 | - if (isset($parameters[3]) === false) { |
|
76 | + if ( isset( $parameters[ 3 ] ) === false ) { |
|
77 | 77 | return; |
78 | 78 | } |
79 | 79 | |
80 | - $targetParam = $parameters[3]; |
|
81 | - if ($this->isNumber($phpcsFile, $targetParam['start'], $targetParam['end'], true) !== false) { |
|
80 | + $targetParam = $parameters[ 3 ]; |
|
81 | + if ( $this->isNumber( $phpcsFile, $targetParam[ 'start' ], $targetParam[ 'end' ], true ) !== false ) { |
|
82 | 82 | return; |
83 | 83 | } |
84 | 84 | |
85 | - if ($this->isNumericCalculation($phpcsFile, $targetParam['start'], $targetParam['end']) === true) { |
|
85 | + if ( $this->isNumericCalculation( $phpcsFile, $targetParam[ 'start' ], $targetParam[ 'end' ] ) === true ) { |
|
86 | 86 | return; |
87 | 87 | } |
88 | 88 | |
89 | 89 | $error = 'Passing a non-integer as the value for $initial to array_reduce() is not supported in PHP 5.2 or lower.'; |
90 | - if ($phpcsFile->findNext($this->variableValueTokens, $targetParam['start'], ($targetParam['end'] + 1)) === false) { |
|
90 | + if ( $phpcsFile->findNext( $this->variableValueTokens, $targetParam[ 'start' ], ( $targetParam[ 'end' ] + 1 ) ) === false ) { |
|
91 | 91 | $phpcsFile->addError( |
92 | 92 | $error . ' Found %s', |
93 | - $targetParam['start'], |
|
93 | + $targetParam[ 'start' ], |
|
94 | 94 | 'InvalidTypeFound', |
95 | - array($targetParam['raw']) |
|
95 | + array( $targetParam[ 'raw' ] ) |
|
96 | 96 | ); |
97 | 97 | } else { |
98 | 98 | $phpcsFile->addWarning( |
99 | 99 | $error . ' Variable value found. Found %s', |
100 | - $targetParam['start'], |
|
100 | + $targetParam[ 'start' ], |
|
101 | 101 | 'VariableFound', |
102 | - array($targetParam['raw']) |
|
102 | + array( $targetParam[ 'raw' ] ) |
|
103 | 103 | ); |
104 | 104 | } |
105 | 105 | } |