@@ -750,8 +750,10 @@ protected function processVariable(File $phpcsFile, $stackPtr) {
750
750
$ token = $ tokens [$ stackPtr ];
751
751
752
752
$ varName = Helpers::normalizeVarName ($ token ['content ' ]);
753
+ Helpers::debug ('examining token ' . $ varName );
753
754
$ currScope = Helpers::findVariableScope ($ phpcsFile , $ stackPtr );
754
755
if ($ currScope === false ) {
756
+ Helpers::debug ('no scope found ' );
755
757
return ;
756
758
}
757
759
@@ -777,80 +779,96 @@ protected function processVariable(File $phpcsFile, $stackPtr) {
777
779
778
780
// Are we a $object->$property type symbolic reference?
779
781
if ($ this ->checkForSymbolicObjectProperty ($ phpcsFile , $ stackPtr , $ varName , $ currScope )) {
782
+ Helpers::debug ('found symbolic object property ' );
780
783
return ;
781
784
}
782
785
783
786
// Are we a function or closure parameter?
784
787
if ($ this ->checkForFunctionPrototype ($ phpcsFile , $ stackPtr , $ varName , $ currScope )) {
788
+ Helpers::debug ('found function prototype ' );
785
789
return ;
786
790
}
787
791
788
792
// Are we a catch parameter?
789
793
if ($ this ->checkForCatchBlock ($ phpcsFile , $ stackPtr , $ varName , $ currScope )) {
794
+ Helpers::debug ('found catch block ' );
790
795
return ;
791
796
}
792
797
793
798
// Are we $this within a class?
794
799
if ($ this ->checkForThisWithinClass ($ phpcsFile , $ stackPtr , $ varName , $ currScope )) {
800
+ Helpers::debug ('found this usage within a class ' );
795
801
return ;
796
802
}
797
803
798
804
// Are we a $GLOBALS, $_REQUEST, etc superglobal?
799
805
if ($ this ->checkForSuperGlobal ($ phpcsFile , $ stackPtr , $ varName , $ currScope )) {
806
+ Helpers::debug ('found superglobal ' );
800
807
return ;
801
808
}
802
809
803
810
// Check for static members used outside a class
804
811
if ($ this ->checkForStaticOutsideClass ($ phpcsFile , $ stackPtr , $ varName , $ currScope )) {
812
+ Helpers::debug ('found static usage outside of class ' );
805
813
return ;
806
814
}
807
815
808
816
// $var part of class::$var static member
809
817
if ($ this ->checkForStaticMember ($ phpcsFile , $ stackPtr , $ varName , $ currScope )) {
818
+ Helpers::debug ('found static member ' );
810
819
return ;
811
820
}
812
821
813
822
// Is the next non-whitespace an assignment?
814
823
if ($ this ->checkForAssignment ($ phpcsFile , $ stackPtr , $ varName , $ currScope )) {
824
+ Helpers::debug ('found assignment ' );
815
825
return ;
816
826
}
817
827
818
828
// OK, are we within a list (...) = construct?
819
829
if ($ this ->checkForListAssignment ($ phpcsFile , $ stackPtr , $ varName , $ currScope )) {
830
+ Helpers::debug ('found list assignment ' );
820
831
return ;
821
832
}
822
833
823
834
// OK, are we within a [...] = construct?
824
835
if ($ this ->checkForListShorthandAssignment ($ phpcsFile , $ stackPtr , $ varName , $ currScope )) {
836
+ Helpers::debug ('found list shorthand assignment ' );
825
837
return ;
826
838
}
827
839
828
840
// Are we a global declaration?
829
841
if ($ this ->checkForGlobalDeclaration ($ phpcsFile , $ stackPtr , $ varName , $ currScope )) {
842
+ Helpers::debug ('found global declaration ' );
830
843
return ;
831
844
}
832
845
833
846
// Are we a static declaration?
834
847
if ($ this ->checkForStaticDeclaration ($ phpcsFile , $ stackPtr , $ varName , $ currScope )) {
848
+ Helpers::debug ('found static declaration ' );
835
849
return ;
836
850
}
837
851
838
852
// Are we a foreach loopvar?
839
853
if ($ this ->checkForForeachLoopVar ($ phpcsFile , $ stackPtr , $ varName , $ currScope )) {
854
+ Helpers::debug ('found foreach loop variable ' );
840
855
return ;
841
856
}
842
857
843
858
// Are we pass-by-reference to known pass-by-reference function?
844
859
if ($ this ->checkForPassByReferenceFunctionCall ($ phpcsFile , $ stackPtr , $ varName , $ currScope )) {
860
+ Helpers::debug ('found pass by reference ' );
845
861
return ;
846
862
}
847
863
848
864
// Are we a numeric variable used for constructs like preg_replace?
849
865
if ($ this ->checkForNumericVariable ($ varName )) {
866
+ Helpers::debug ('found numeric variable ' );
850
867
return ;
851
868
}
852
869
853
870
// OK, we don't appear to be a write to the var, assume we're a read.
871
+ Helpers::debug ('looks like a variable read ' );
854
872
$ this ->markVariableReadAndWarnIfUndefined ($ phpcsFile , $ varName , $ stackPtr , $ currScope );
855
873
}
856
874
0 commit comments