@@ -110,14 +110,14 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop
110
110
// Is this a magic method. i.e., is prefixed with "__" ?
111
111
if (preg_match ('|^__[^_]| ' , $ methodName ) !== 0 ) {
112
112
$ magicPart = strtolower (substr ($ methodName , 2 ));
113
- if (isset ($ this ->magicMethods [$ magicPart ]) === false
114
- && isset ($ this ->methodsDoubleUnderscore [$ magicPart ]) === false
113
+ if (isset ($ this ->magicMethods [$ magicPart ]) === true
114
+ || isset ($ this ->methodsDoubleUnderscore [$ magicPart ]) === true
115
115
) {
116
- $ error = 'Method name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore ' ;
117
- $ phpcsFile ->addError ($ error , $ stackPtr , 'MethodDoubleUnderscore ' , $ errorData );
116
+ return ;
118
117
}
119
118
120
- return ;
119
+ $ error = 'Method name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore ' ;
120
+ $ phpcsFile ->addError ($ error , $ stackPtr , 'MethodDoubleUnderscore ' , $ errorData );
121
121
}
122
122
123
123
// PHP4 constructors are allowed to break our rules.
@@ -178,12 +178,12 @@ protected function processTokenOutsideScope(File $phpcsFile, $stackPtr)
178
178
// Is this a magic function. i.e., it is prefixed with "__".
179
179
if (preg_match ('|^__[^_]| ' , $ functionName ) !== 0 ) {
180
180
$ magicPart = strtolower (substr ($ functionName , 2 ));
181
- if (isset ($ this ->magicFunctions [$ magicPart ]) === false ) {
182
- $ error = 'Function name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore ' ;
183
- $ phpcsFile ->addError ($ error , $ stackPtr , 'FunctionDoubleUnderscore ' , $ errorData );
181
+ if (isset ($ this ->magicFunctions [$ magicPart ]) === true ) {
182
+ return ;
184
183
}
185
184
186
- return ;
185
+ $ error = 'Function name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore ' ;
186
+ $ phpcsFile ->addError ($ error , $ stackPtr , 'FunctionDoubleUnderscore ' , $ errorData );
187
187
}
188
188
189
189
// Ignore first underscore in functions prefixed with "_".
0 commit comments