@@ -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