Skip to content

Commit c57a6c6

Browse files
Copilotswissspidy
andcommitted
Remove redundant @var annotations and use explicit type casting
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent db8bebf commit c57a6c6

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/DB_Users_Command.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ public function create( $args, $assoc_args ) {
6464
$grant_privileges = Utils\get_flag_value( $assoc_args, 'grant-privileges', false );
6565

6666
// Escape identifiers for SQL
67-
$username_escaped = self::esc_sql_ident( $username );
68-
$host_escaped = self::esc_sql_ident( $host );
69-
/** @var string $username_escaped */
70-
/** @var string $host_escaped */
71-
$user_identifier = "{$username_escaped}@{$host_escaped}";
67+
// @phpstan-ignore cast.string (PHPStan doesn't infer conditional return type from parent method)
68+
$username_escaped = (string) self::esc_sql_ident( $username );
69+
// @phpstan-ignore cast.string (PHPStan doesn't infer conditional return type from parent method)
70+
$host_escaped = (string) self::esc_sql_ident( $host );
71+
$user_identifier = $username_escaped . '@' . $host_escaped;
7272

7373
// Create user
7474
$create_query = "CREATE USER {$user_identifier}";
@@ -83,9 +83,8 @@ public function create( $args, $assoc_args ) {
8383
// Grant privileges if requested
8484
if ( $grant_privileges ) {
8585
$database = DB_NAME;
86-
$database_escaped = self::esc_sql_ident( $database );
87-
/** @var string $database_escaped */
88-
$grant_query = "GRANT ALL PRIVILEGES ON {$database_escaped}.* TO {$user_identifier};";
86+
$database_escaped = (string) self::esc_sql_ident( $database );
87+
$grant_query = 'GRANT ALL PRIVILEGES ON ' . $database_escaped . '.* TO ' . $user_identifier . ';';
8988
parent::run_query( $grant_query, $assoc_args );
9089

9190
// Flush privileges

0 commit comments

Comments
 (0)