@@ -165,6 +165,7 @@ public function register() {
165165 return array (
166166 \T_VARIABLE ,
167167 \T_STRING ,
168+ \T_NAME_FULLY_QUALIFIED ,
168169 );
169170 }
170171
@@ -224,9 +225,16 @@ public function process_token( $stackPtr ) {
224225 }
225226
226227 // Detect a specific pattern for variable replacements in combination with `IN`.
227- if ( \T_STRING === $ this ->tokens [ $ i ]['code ' ] ) {
228+ if ( \T_STRING === $ this ->tokens [ $ i ]['code ' ]
229+ || \T_NAME_FULLY_QUALIFIED === $ this ->tokens [ $ i ]['code ' ]
230+ ) {
231+ $ content_lowercase = \strtolower ( $ this ->tokens [ $ i ]['content ' ] );
228232
229- if ( 'sprintf ' === strtolower ( $ this ->tokens [ $ i ]['content ' ] ) ) {
233+ if ( \T_NAME_FULLY_QUALIFIED === $ this ->tokens [ $ i ]['code ' ] ) {
234+ $ content_lowercase = \ltrim ( $ content_lowercase , '\\' );
235+ }
236+
237+ if ( 'sprintf ' === $ content_lowercase ) {
230238 $ sprintf_parameters = PassedParameters::getParameters ( $ this ->phpcsFile , $ i );
231239
232240 if ( ! empty ( $ sprintf_parameters ) ) {
@@ -265,7 +273,7 @@ public function process_token( $stackPtr ) {
265273 }
266274 unset( $ sprintf_parameters , $ valid_sprintf , $ last_param );
267275
268- } elseif ( 'implode ' === strtolower ( $ this -> tokens [ $ i ][ ' content ' ] ) ) {
276+ } elseif ( 'implode ' === $ content_lowercase ) {
269277 $ ignore_tokens = Tokens::$ emptyTokens + array (
270278 \T_STRING_CONCAT => \T_STRING_CONCAT ,
271279 \T_NS_SEPARATOR => \T_NS_SEPARATOR ,
@@ -679,10 +687,17 @@ protected function analyse_sprintf( $sprintf_params ) {
679687 $ sprintf_param ['end ' ],
680688 true
681689 );
690+
682691 if ( \T_STRING === $ this ->tokens [ $ implode ]['code ' ]
683- && ' implode ' === strtolower ( $ this ->tokens [ $ implode ]['content ' ] )
692+ || \ T_NAME_FULLY_QUALIFIED === $ this ->tokens [ $ implode ]['code ' ]
684693 ) {
685- if ( $ this ->analyse_implode ( $ implode ) === true ) {
694+ $ content_lowercase = \strtolower ( $ this ->tokens [ $ implode ]['content ' ] );
695+
696+ if ( \T_NAME_FULLY_QUALIFIED === $ this ->tokens [ $ implode ]['code ' ] ) {
697+ $ content_lowercase = \ltrim ( $ content_lowercase , '\\' );
698+ }
699+
700+ if ( 'implode ' === $ content_lowercase && $ this ->analyse_implode ( $ implode ) === true ) {
686701 ++$ found ;
687702 }
688703 }
@@ -738,11 +753,21 @@ protected function analyse_implode( $implode_token ) {
738753 );
739754
740755 if ( \T_STRING !== $ this ->tokens [ $ array_fill ]['code ' ]
741- || ' array_fill ' !== strtolower ( $ this ->tokens [ $ array_fill ]['content ' ] )
756+ && \ T_NAME_FULLY_QUALIFIED !== $ this ->tokens [ $ array_fill ]['code ' ]
742757 ) {
743758 return false ;
744759 }
745760
761+ $ content_lowercase = strtolower ( $ this ->tokens [ $ array_fill ]['content ' ] );
762+
763+ if ( \T_NAME_FULLY_QUALIFIED === $ this ->tokens [ $ array_fill ]['code ' ] ) {
764+ $ content_lowercase = \ltrim ( $ content_lowercase , '\\' );
765+ }
766+
767+ if ( 'array_fill ' !== $ content_lowercase ) {
768+ return false ;
769+ }
770+
746771 $ array_fill_value_param = PassedParameters::getParameter ( $ this ->phpcsFile , $ array_fill , 3 , 'value ' );
747772 if ( false === $ array_fill_value_param ) {
748773 return false ;
0 commit comments