How to get PHP Eclipse to align new line with above line

Dont know how to search for this. I found some questions similar to this but it doesnt answer/resolve my issue. Basically got a new PC, installed latest version of PHP Eclipse which shows Oxygen version 3.

Basically I have this line of code:

        $results = DB::query("
            SELECT
            fld1,
            fld2
            FROM
            table1");

As you see the query text aligns beneath one another. So after I type the word SELECT then hit enter, the new line then starts where fld1 is. However under this new PHP Eclipse this happens when I go to a new line:

$results = DB::query("
            SELECT 
fld1,
            fld2
            FROM
            table1");

I have to hit tab several times to get fld1 to align back up with SELECT above it. Where in PHP Eclipse can I configure the new line to indent properly under the text that is above it. It worked with no changes on the old version of PHP Eclipse, but I cant seem to find the solution in this new version. Can anyone help? This seems to happen for regular text, works just fine while coding in PHP.

2 answers

  • answered 2018-04-17 04:12 ArtisticPhoenix

    It is actually incorrect to indent lines like you have, this may have been what previous versions did, but the extra tabs in there actually throw off the format if you were to echo that out.

    For example

    $string = "hello
               this is a
               multiline
               string";
    

    This will actually output:

    hello
               this is a
               multiline
               string
    

    This may be the format it was before, but I usually use NEWDOC for large SQL statments,

    $sql = <<<'SQL'
    SELECT
       *
    FROM
    ...
    SQL;
    

    Or I start is on a new line

    $sql = '
    SELECT
       *
    FROM
    ...
    ';
    

    So I never noticed it before. Another thing I consider wrong is to use " double quotes in SQL because it allows you to put variables in the string, which should never be done in SQL. Or at least no without the utmost care.

  • answered 2018-04-17 04:12 John

    I was not able to resolve this issue with the new Eclipse PDT Oxygen build. I was able to get it resolved by going back to the old version I was using, the Mars build. Couldnt find any other solution currently, though I did see people report something similar as a bug in the new PHP Eclipse PDT, but no resolution itself. But wanted to at least provide what I did to get it to work again.

  • WEB-INF folder inside WEB-INF/classes/

    why is a WEB-INF folder inside WEB-INF/classes/ on the .war of my maven spring web app? I generate the .war file with both maven and eclipse and is the same thing My project structure enter image description here

  • jdbc connectivity (ping failure)?

    I want to connect(jdbc connectivity) oracle 10g with eclipse software, but unfortunately i am getting ping failure message.

    enter image description here

  • Eclipse C - called object 'read' is not a function or a function pointer

    I'm receiving this message and I don't know how to solve it. I Tried to close the Eclipse, close the Ubuntu, close the computer, start a new C project, checked that is included. Nothing solved the problem.