@@ -466,9 +466,12 @@ protected function markVariableReadAndWarnIfUndefined($phpcsFile, $varName, $sta
466466
467467 if ($ this ->isVariableUndefined ($ varName , $ stackPtr , $ currScope ) === true ) {
468468 // We haven't been defined by this point.
469- $ phpcsFile ->addWarning ("Variable %s is undefined. " , $ stackPtr ,
469+ $ phpcsFile ->addWarning (
470+ "Variable %s is undefined. " ,
471+ $ stackPtr ,
470472 'UndefinedVariable ' ,
471- array ("\${$ varName }" ));
473+ array ("\${$ varName }" )
474+ );
472475 }
473476 return true ;
474477 }
@@ -487,8 +490,14 @@ protected function findFunctionPrototype(
487490 // so we look backwards from the opening bracket for the first thing that
488491 // isn't a function name, reference sigil or whitespace and check if
489492 // it's a function keyword.
490- $ functionPtr = $ phpcsFile ->findPrevious (array (T_STRING , T_WHITESPACE , T_BITWISE_AND ),
491- $ openPtr - 1 , null , true , null , true );
493+ $ functionPtr = $ phpcsFile ->findPrevious (
494+ array (T_STRING , T_WHITESPACE , T_BITWISE_AND ),
495+ $ openPtr - 1 ,
496+ null ,
497+ true ,
498+ null ,
499+ true
500+ );
492501 if (($ functionPtr !== false ) &&
493502 ($ tokens [$ functionPtr ]['code ' ] === T_FUNCTION )) {
494503 return $ functionPtr ;
@@ -601,8 +610,7 @@ protected function findFunctionCall(
601610
602611 if ($ openPtr = $ this ->findContainingBrackets ($ phpcsFile , $ stackPtr )) {
603612 // First non-whitespace thing and see if it's a T_STRING function name
604- $ functionPtr = $ phpcsFile ->findPrevious (T_WHITESPACE ,
605- $ openPtr - 1 , null , true , null , true );
613+ $ functionPtr = $ phpcsFile ->findPrevious (T_WHITESPACE , $ openPtr - 1 , null , true , null , true );
606614 if ($ tokens [$ functionPtr ]['code ' ] === T_STRING ) {
607615 return $ functionPtr ;
608616 }
@@ -626,8 +634,7 @@ protected function findFunctionCallArguments(
626634 }
627635
628636 // $stackPtr is the function name, find our brackets after it
629- $ openPtr = $ phpcsFile ->findNext (T_WHITESPACE ,
630- $ stackPtr + 1 , null , true , null , true );
637+ $ openPtr = $ phpcsFile ->findNext (T_WHITESPACE , $ stackPtr + 1 , null , true , null , true );
631638 if (($ openPtr === false ) || ($ tokens [$ openPtr ]['code ' ] !== T_OPEN_PARENTHESIS )) {
632639 return false ;
633640 }
@@ -674,16 +681,14 @@ protected function checkForFunctionPrototype(
674681 // so we look backwards from the opening bracket for the first thing that
675682 // isn't a function name, reference sigil or whitespace and check if
676683 // it's a function keyword.
677- $ functionPtr = $ phpcsFile ->findPrevious (array (T_STRING , T_WHITESPACE , T_BITWISE_AND ),
678- $ openPtr - 1 , null , true , null , true );
684+ $ functionPtr = $ phpcsFile ->findPrevious (array (T_STRING , T_WHITESPACE , T_BITWISE_AND ), $ openPtr - 1 , null , true , null , true );
679685 if (($ functionPtr !== false ) &&
680686 (($ tokens [$ functionPtr ]['code ' ] === T_FUNCTION ) ||
681687 ($ tokens [$ functionPtr ]['code ' ] === T_CLOSURE ))) {
682688 // TODO: typeHint
683689 $ this ->markVariableDeclaration ($ varName , 'param ' , null , $ stackPtr , $ functionPtr );
684690 // Are we pass-by-reference?
685- $ referencePtr = $ phpcsFile ->findPrevious (T_WHITESPACE ,
686- $ stackPtr - 1 , null , true , null , true );
691+ $ referencePtr = $ phpcsFile ->findPrevious (T_WHITESPACE , $ stackPtr - 1 , null , true , null , true );
687692 if (($ referencePtr !== false ) && ($ tokens [$ referencePtr ]['code ' ] === T_BITWISE_AND )) {
688693 $ varInfo = $ this ->getVariableInfo ($ varName , $ functionPtr );
689694 $ varInfo ->passByReference = true ;
@@ -700,14 +705,11 @@ protected function checkForFunctionPrototype(
700705 $ this ->markVariableRead ($ varName , $ stackPtr , $ currScope );
701706 if ($ this ->isVariableUndefined ($ varName , $ stackPtr , $ currScope ) === true ) {
702707 // We haven't been defined by this point.
703- $ phpcsFile ->addWarning ("Variable %s is undefined. " , $ stackPtr ,
704- 'UndefinedVariable ' ,
705- array ("\${$ varName }" ));
708+ $ phpcsFile ->addWarning ("Variable %s is undefined. " , $ stackPtr , 'UndefinedVariable ' , array ("\${$ varName }" ));
706709 return true ;
707710 }
708711 // $functionPtr is at the use, we need the function keyword for start of scope.
709- $ functionPtr = $ phpcsFile ->findPrevious (T_CLOSURE ,
710- $ functionPtr - 1 , $ currScope + 1 , false , null , true );
712+ $ functionPtr = $ phpcsFile ->findPrevious (T_CLOSURE , $ functionPtr - 1 , $ currScope + 1 , false , null , true );
711713 if ($ functionPtr !== false ) {
712714 // TODO: typeHints in use?
713715 $ this ->markVariableDeclaration ($ varName , 'bound ' , null , $ stackPtr , $ functionPtr );
@@ -736,8 +738,7 @@ protected function checkForCatchBlock(
736738 // so we look backwards from the opening bracket for the first thing that
737739 // isn't a function name, reference sigil or whitespace and check if
738740 // it's a function keyword.
739- $ catchPtr = $ phpcsFile ->findPrevious (T_WHITESPACE ,
740- $ openPtr - 1 , null , true , null , true );
741+ $ catchPtr = $ phpcsFile ->findPrevious (T_WHITESPACE , $ openPtr - 1 , null , true , null , true );
741742 if (($ catchPtr !== false ) &&
742743 ($ tokens [$ catchPtr ]['code ' ] === T_CATCH )) {
743744 // Scope of the exception var is actually the function, not just the catch block.
@@ -847,19 +848,15 @@ protected function checkForStaticMember(
847848 // self within a closure is invalid
848849 // Note: have to fetch code from $tokens, T_CLOSURE isn't set for conditions codes.
849850 if ($ tokens [$ scopePtr ]['code ' ] === T_CLOSURE ) {
850- $ phpcsFile ->addError ("Use of {$ err_desc }%s inside closure. " , $ stackPtr ,
851- $ err_class ,
852- array ("\${$ varName }" ));
851+ $ phpcsFile ->addError ("Use of {$ err_desc }%s inside closure. " , $ stackPtr , $ err_class , array ("\${$ varName }" ));
853852 return true ;
854853 }
855854 if ($ scopeCode === T_CLASS ) {
856855 return true ;
857856 }
858857 }
859858 }
860- $ phpcsFile ->addError ("Use of {$ err_desc }%s outside class definition. " , $ stackPtr ,
861- $ err_class ,
862- array ("\${$ varName }" ));
859+ $ phpcsFile ->addError ("Use of {$ err_desc }%s outside class definition. " , $ stackPtr , $ err_class , array ("\${$ varName }" ));
863860 return true ;
864861 }
865862
@@ -930,9 +927,7 @@ protected function checkForGlobalDeclaration(
930927
931928 // Are we a global declaration?
932929 // Search backwards for first token that isn't whitespace, comma or variable.
933- $ globalPtr = $ phpcsFile ->findPrevious (
934- array (T_WHITESPACE , T_VARIABLE , T_COMMA ),
935- $ stackPtr - 1 , null , true , null , true );
930+ $ globalPtr = $ phpcsFile ->findPrevious (array (T_WHITESPACE , T_VARIABLE , T_COMMA ), $ stackPtr - 1 , null , true , null , true );
936931 if (($ globalPtr === false ) || ($ tokens [$ globalPtr ]['code ' ] !== T_GLOBAL )) {
937932 return false ;
938933 }
@@ -980,7 +975,12 @@ protected function checkForStaticDeclaration(
980975 T_START_HEREDOC , T_HEREDOC , T_END_HEREDOC ,
981976 T_START_NOWDOC , T_NOWDOC , T_END_NOWDOC ,
982977 ),
983- $ stackPtr - 1 , null , true , null , true );
978+ $ stackPtr - 1 ,
979+ null ,
980+ true ,
981+ null ,
982+ true
983+ );
984984 if (($ staticPtr === false ) || ($ tokens [$ staticPtr ]['code ' ] !== T_STATIC )) {
985985 //if ($varName == 'static4') {
986986 // echo "Failing token:\n" . print_r($tokens[$staticPtr], true);
@@ -1105,9 +1105,7 @@ protected function checkForSymbolicObjectProperty(
11051105
11061106 // Are we a symbolic object property/function derefeference?
11071107 // Search backwards for first token that isn't whitespace, is it a "->" operator?
1108- $ objectOperatorPtr = $ phpcsFile ->findPrevious (
1109- T_WHITESPACE ,
1110- $ stackPtr - 1 , null , true , null , true );
1108+ $ objectOperatorPtr = $ phpcsFile ->findPrevious (T_WHITESPACE , $ stackPtr - 1 , null , true , null , true );
11111109 if (($ objectOperatorPtr === false ) || ($ tokens [$ objectOperatorPtr ]['code ' ] !== T_OBJECT_OPERATOR )) {
11121110 return false ;
11131111 }
@@ -1298,10 +1296,9 @@ protected function processCompactArguments(
12981296 $ token = $ tokens [$ stackPtr ];
12991297
13001298 foreach ($ arguments as $ argumentPtrs ) {
1301- $ argumentPtrs = array_values (array_filter ($ argumentPtrs ,
1302- function ($ argumentPtr ) use ($ tokens ) {
1303- return $ tokens [$ argumentPtr ]['code ' ] !== T_WHITESPACE ;
1304- }));
1299+ $ argumentPtrs = array_values (array_filter ($ argumentPtrs , function ($ argumentPtr ) use ($ tokens ) {
1300+ return $ tokens [$ argumentPtr ]['code ' ] !== T_WHITESPACE ;
1301+ }));
13051302 if (empty ($ argumentPtrs )) {
13061303 continue ;
13071304 }
@@ -1425,6 +1422,4 @@ protected function processScopeClose(
14251422 }
14261423 }
14271424 }
1428- }//end class
1429-
1430- ?>
1425+ }
0 commit comments