Skip to content

Commit c759e9a

Browse files
committed
DB/PreparedSQL: update for PHPCS 4.0
The tokenization of (namespaced) "names" has changed in PHP 8.0, and this new tokenization will come into effect for PHP_CodeSniffer as of version 4.0.0. This commit adds handling for the new tokenization of fully qualified function calls and static method calls to this sniff.
1 parent bde1c28 commit c759e9a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

WordPress/Sniffs/DB/PreparedSQLSniff.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ public function register() {
145145
return array(
146146
\T_VARIABLE,
147147
\T_STRING,
148+
\T_NAME_FULLY_QUALIFIED,
148149
);
149150
}
150151

@@ -206,9 +207,15 @@ static function ( $symbol ) {
206207
}
207208
}
208209

209-
if ( \T_STRING === $this->tokens[ $this->i ]['code'] ) {
210+
if ( \T_STRING === $this->tokens[ $this->i ]['code']
211+
|| \T_NAME_FULLY_QUALIFIED === $this->tokens[ $this->i ]['code']
212+
) {
210213
$content_lowercase = strtolower( $this->tokens[ $this->i ]['content'] );
211214

215+
if ( \T_NAME_FULLY_QUALIFIED === $this->tokens[ $this->i ]['code'] ) {
216+
$content_lowercase = \ltrim( $content_lowercase, '\\' );
217+
}
218+
212219
if (
213220
isset( $this->SQLEscapingFunctions[ $content_lowercase ] )
214221
|| isset( $this->SQLAutoEscapedFunctions[ $content_lowercase ] )
@@ -225,7 +232,7 @@ static function ( $symbol ) {
225232
$this->i = $this->tokens[ $opening_paren ]['parenthesis_closer'];
226233
continue;
227234
}
228-
} elseif ( FormattingFunctionsHelper::is_formatting_function( $this->tokens[ $this->i ]['content'] ) ) {
235+
} elseif ( FormattingFunctionsHelper::is_formatting_function( $content_lowercase ) ) {
229236
continue;
230237
}
231238
}

0 commit comments

Comments
 (0)