Format SQL strings in PHP as in Typescript

Hello, I noticed, that SQL strings in TypeScript files are formatted automatically when I use backticks.

When I enter 

let test = `select * from user where id = 1`

in a typescript file, PhpStorm reformats/reindents the SQL properly to

let test = `select * 
            from user
            where id = 1`

This is a relly great feature. But I do not get working it for PHP files

I also found a lot of posts, that I should use the “Edit SQL Fragment” feature, but this makes indention much worse.  I get this in PHP

function x() {
    $test = "select * 
from user
where id = 1";
}

Note: SQL formatting in typescript works only when using backticks as string delimiter, it does not work for single or double quotes. Maybe I am using just the wrong quotes in PHP (tried differen ones)

 

Roland

PhpStorm 2025.3
Build #PS-253.28294.345, built on December 8, 2025
 

0

Hello Pram,

Thank you for reporting. Please upvote WI-18521.

0

请先登录再写评论。