@@ -195,14 +195,11 @@ protected function isGetDefinedVars(File $phpcsFile, $stackPtr) {
195195 }
196196
197197 /**
198- * @param int|bool $currScope
198+ * @param int $currScope
199199 *
200200 * @return string
201201 */
202202 protected function getScopeKey ($ currScope ) {
203- if ($ currScope === false ) {
204- $ currScope = 'file ' ;
205- }
206203 return ($ this ->currentFile ? $ this ->currentFile ->getFilename () : 'unknown file ' ) . ': ' . $ currScope ;
207204 }
208205
@@ -442,7 +439,7 @@ protected function markVariableReadAndWarnIfUndefined($phpcsFile, $varName, $sta
442439 */
443440 protected function markAllVariablesRead (File $ phpcsFile , $ stackPtr ) {
444441 $ currScope = Helpers::findVariableScope ($ phpcsFile , $ stackPtr );
445- if (! $ currScope ) {
442+ if ($ currScope === null ) {
446443 return ;
447444 }
448445 $ scopeInfo = $ this ->getOrCreateScopeInfo ($ currScope );
@@ -469,7 +466,7 @@ protected function checkForFunctionPrototype(File $phpcsFile, $stackPtr, $varNam
469466 // T_FUNCTION, but AbstractVariableSniff and AbstractScopeSniff define everything
470467 // we need to do that as private or final, so we have to do it this hackish way.
471468 $ openPtr = Helpers::findContainingOpeningBracket ($ phpcsFile , $ stackPtr );
472- if (is_bool ($ openPtr )) {
469+ if (! is_int ($ openPtr )) {
473470 return false ;
474471 }
475472
@@ -487,7 +484,7 @@ protected function checkForFunctionPrototype(File $phpcsFile, $stackPtr, $varNam
487484 $ varInfo ->passByReference = true ;
488485 }
489486 // Are we optional with a default?
490- if (Helpers::isNextThingAnAssign ($ phpcsFile , $ stackPtr ) !== false ) {
487+ if (Helpers::getNextAssignPointer ($ phpcsFile , $ stackPtr ) !== null ) {
491488 $ this ->markVariableAssignment ($ varName , $ stackPtr , $ functionPtr );
492489 }
493490 return true ;
@@ -574,7 +571,7 @@ protected function checkForCatchBlock(File $phpcsFile, $stackPtr, $varName, $cur
574571
575572 // Are we a catch block parameter?
576573 $ openPtr = Helpers::findContainingOpeningBracket ($ phpcsFile , $ stackPtr );
577- if ($ openPtr === false ) {
574+ if ($ openPtr === null ) {
578575 return false ;
579576 }
580577
@@ -736,7 +733,7 @@ protected function checkForStaticOutsideClass(File $phpcsFile, $stackPtr, $varNa
736733 */
737734 protected function checkForAssignment (File $ phpcsFile , $ stackPtr , $ varName , $ currScope ) {
738735 // Is the next non-whitespace an assignment?
739- $ assignPtr = Helpers::isNextThingAnAssign ($ phpcsFile , $ stackPtr );
736+ $ assignPtr = Helpers::getNextAssignPointer ($ phpcsFile , $ stackPtr );
740737 if (! is_int ($ assignPtr )) {
741738 return false ;
742739 }
@@ -787,7 +784,7 @@ protected function checkForVariableVariable(File $phpcsFile, $stackPtr, $varName
787784 protected function checkForListShorthandAssignment (File $ phpcsFile , $ stackPtr , $ varName , $ currScope ) {
788785 // OK, are we within a [ ... ] construct?
789786 $ openPtr = Helpers::findContainingOpeningSquareBracket ($ phpcsFile , $ stackPtr );
790- if ($ openPtr === false ) {
787+ if (! is_int ( $ openPtr) ) {
791788 return false ;
792789 }
793790
@@ -796,7 +793,7 @@ protected function checkForListShorthandAssignment(File $phpcsFile, $stackPtr, $
796793 if (! is_int ($ closePtr )) {
797794 return false ;
798795 }
799- $ assignPtr = Helpers::isNextThingAnAssign ($ phpcsFile , $ closePtr );
796+ $ assignPtr = Helpers::getNextAssignPointer ($ phpcsFile , $ closePtr );
800797 if (! is_int ($ assignPtr )) {
801798 return false ;
802799 }
@@ -820,7 +817,7 @@ protected function checkForListAssignment(File $phpcsFile, $stackPtr, $varName,
820817
821818 // OK, are we within a list (...) construct?
822819 $ openPtr = Helpers::findContainingOpeningBracket ($ phpcsFile , $ stackPtr );
823- if ($ openPtr === false ) {
820+ if ($ openPtr === null ) {
824821 return false ;
825822 }
826823
@@ -831,7 +828,7 @@ protected function checkForListAssignment(File $phpcsFile, $stackPtr, $varName,
831828
832829 // OK, we're a list (...) construct... are we being assigned to?
833830 $ closePtr = $ tokens [$ openPtr ]['parenthesis_closer ' ];
834- $ assignPtr = Helpers::isNextThingAnAssign ($ phpcsFile , $ closePtr );
831+ $ assignPtr = Helpers::getNextAssignPointer ($ phpcsFile , $ closePtr );
835832 if (! is_int ($ assignPtr )) {
836833 return false ;
837834 }
@@ -927,7 +924,7 @@ protected function checkForStaticDeclaration(File $phpcsFile, $stackPtr, $varNam
927924
928925 // It's a static declaration.
929926 $ this ->markVariableDeclaration ($ varName , 'static ' , null , $ stackPtr , $ currScope );
930- if (Helpers::isNextThingAnAssign ($ phpcsFile , $ stackPtr ) !== false ) {
927+ if (Helpers::getNextAssignPointer ($ phpcsFile , $ stackPtr ) !== null ) {
931928 $ this ->markVariableAssignment ($ varName , $ stackPtr , $ currScope );
932929 }
933930 return true ;
@@ -1000,7 +997,7 @@ protected function checkForPassByReferenceFunctionCall(File $phpcsFile, $stackPt
1000997
1001998 // Are we pass-by-reference to known pass-by-reference function?
1002999 $ functionPtr = Helpers::findFunctionCall ($ phpcsFile , $ stackPtr );
1003- if ($ functionPtr === false || ! isset ($ tokens [$ functionPtr ])) {
1000+ if ($ functionPtr === null || ! isset ($ tokens [$ functionPtr ])) {
10041001 return false ;
10051002 }
10061003
@@ -1012,9 +1009,6 @@ protected function checkForPassByReferenceFunctionCall(File $phpcsFile, $stackPt
10121009 }
10131010
10141011 $ argPtrs = Helpers::findFunctionCallArguments ($ phpcsFile , $ stackPtr );
1015- if ($ argPtrs === false ) {
1016- return false ;
1017- }
10181012
10191013 // We're within a function call arguments list, find which arg we are.
10201014 $ argPos = false ;
@@ -1094,7 +1088,7 @@ protected function processVariable(File $phpcsFile, $stackPtr) {
10941088 $ varName = Helpers::normalizeVarName ($ token ['content ' ]);
10951089 Helpers::debug ('examining token ' . $ varName );
10961090 $ currScope = Helpers::findVariableScope ($ phpcsFile , $ stackPtr );
1097- if ($ currScope === false ) {
1091+ if ($ currScope === null ) {
10981092 Helpers::debug ('no scope found ' );
10991093 return ;
11001094 }
@@ -1239,7 +1233,7 @@ protected function processVariableInString(File $phpcsFile, $stackPtr) {
12391233 }
12401234
12411235 $ currScope = Helpers::findVariableScope ($ phpcsFile , $ stackPtr );
1242- if (! $ currScope ) {
1236+ if ($ currScope === null ) {
12431237 return ;
12441238 }
12451239 foreach ($ matches [1 ] as $ varName ) {
@@ -1287,9 +1281,7 @@ protected function processCompactArguments(File $phpcsFile, $stackPtr, $argument
12871281 if ($ argument_first_token ['code ' ] === T_ARRAY ) {
12881282 // It's an array argument, recurse.
12891283 $ array_arguments = Helpers::findFunctionCallArguments ($ phpcsFile , $ argumentPtrs [0 ]);
1290- if ($ array_arguments !== false ) {
1291- $ this ->processCompactArguments ($ phpcsFile , $ stackPtr , $ array_arguments , $ currScope );
1292- }
1284+ $ this ->processCompactArguments ($ phpcsFile , $ stackPtr , $ array_arguments , $ currScope );
12931285 continue ;
12941286 }
12951287 if (count ($ argumentPtrs ) > 1 ) {
@@ -1327,14 +1319,12 @@ protected function processCompactArguments(File $phpcsFile, $stackPtr, $argument
13271319 */
13281320 protected function processCompact (File $ phpcsFile , $ stackPtr ) {
13291321 $ currScope = Helpers::findVariableScope ($ phpcsFile , $ stackPtr );
1330- if (! $ currScope ) {
1322+ if ($ currScope === null ) {
13311323 return ;
13321324 }
13331325
13341326 $ arguments = Helpers::findFunctionCallArguments ($ phpcsFile , $ stackPtr );
1335- if ($ arguments !== false ) {
1336- $ this ->processCompactArguments ($ phpcsFile , $ stackPtr , $ arguments , $ currScope );
1337- }
1327+ $ this ->processCompactArguments ($ phpcsFile , $ stackPtr , $ arguments , $ currScope );
13381328 }
13391329
13401330 /**
0 commit comments