@@ -174,29 +174,34 @@ static public function checkFile($file, IssuesBank $issues, Report $report = nul
174174 $ total = count ($ tokens );
175175 $ i = array_search_column ($ tokens , T_CLASS , 0 );
176176 $ class_start = $ i ;
177- $ class_name = $ tokens [$ i +2 ][1 ];
178- $ braces = 1 ;
179- $ i += 5 ;
180- while (($ braces > 0 ) && (($ i +1 ) <= $ total )) {
181- if ($ tokens [$ i ] == '{ ' ) {
182- $ braces ++;
183- /*echo '++';*/
184- } else if ($ tokens [$ i ] == '} ' ) {
185- $ braces --;
186- /*echo '--';*/
187- } else if (is_array ($ tokens [$ i ]) && $ tokens [$ i ][0 ] == T_FUNCTION && is_array ($ tokens [$ i +2 ])) {
188- $ function_name = $ tokens [$ i +2 ][1 ];
189- foreach ($ methods_naming as $ methods_naming_checker ) {
190- $ checker = ltrim ($ methods_naming_checker [0 ], '@ ' );
191- require_once dirname (dirname (__FILE__ )).'/data/ ' .$ checker .'.php ' ;
192- $ checker = __NAMESPACE__ .'\\' .$ checker ;
193- $ result = $ checker ($ class_name , $ function_name );
194- if ($ result ) {
195- $ report ->add ($ methods_naming_checker [1 ], 'method_name ' , $ function_name .': ' .$ class_name .' ( ' .$ methods_naming_checker [0 ].') ' , null , $ file , $ tokens [$ i ][2 ]);
196- }
177+ if (!is_array ($ tokens [$ class_start -1 ]) || $ tokens [$ class_start -1 ][1 ] != ':: ' ) {
178+ $ class_name = $ tokens [$ i +2 ][1 ];
179+ $ braces = 1 ;
180+ $ i += 5 ;
181+ while (($ braces > 0 ) && (($ i +1 ) <= $ total )) {
182+ if ($ tokens [$ i ] == '{ ' ) {
183+ $ braces ++;
184+ /*echo '++';*/
185+ } else if ($ tokens [$ i ] == '} ' ) {
186+ $ braces --;
187+ /*echo '--';*/
188+ } else if (is_array ($ tokens [$ i ]) && $ tokens [$ i ][0 ] == T_FUNCTION && is_array ($ tokens [$ i +2 ])) {
189+ $ function_name = $ tokens [$ i +2 ][1 ];
190+ foreach ($ methods_naming as $ methods_naming_checker ) {
191+ $ checker = ltrim ($ methods_naming_checker [0 ], '@ ' );
192+ require_once dirname (dirname (__FILE__ )).'/data/ ' .$ checker .'.php ' ;
193+ $ checker = __NAMESPACE__ .'\\' .$ checker ;
194+ $ result = $ checker ($ class_name , $ function_name );
195+ if ($ result ) {
196+ $ report ->add ($ methods_naming_checker [1 ], 'method_name ' , $ function_name .': ' .$ class_name .' ( ' .$ methods_naming_checker [0 ].') ' , null , $ file , $ tokens [$ i ][2 ]);
197+ }
197198
199+ }
198200 }
201+ $ i ++;
199202 }
203+ } else {
204+ // ::class
200205 $ i ++;
201206 }
202207 array_splice ($ tokens , $ class_start , $ i - $ class_start );
0 commit comments