This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 167791

Summary: php autoformat "echo <<<EOT " should not indent
Product: php Reporter: roger_roger <roger_roger>
Component: Formatting & IndentationAssignee: Tomasz Slota <tslota>
Status: REOPENED ---    
Severity: blocker    
Priority: P2    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:

Description roger_roger 2009-06-29 12:04:08 UTC
when using chevrons to mark a text area,
it should not be indented by the source-format option,
because it breaks the code and stops the the colour highlighting from working as well.

e.g. consider this unformatted code

<body>

<?php

echo <<<EOT

<h1>
some header
</h1>

EOT;

when correctly formated should be

<body>

  <?php

echo <<<EOT

    <h1>
      some header
    </h1>

EOT;

so that the text boudary markers stay at the left hand side.

at the moment the auto format gives the following:

<body>

  <?php

    echo <<<EOT

    <h1>
      some header
    </h1>

    EOT;

the indent means the compiler cannot recognise the text boundary markers.
Comment 1 Petr Pisl 2009-11-10 08:31:40 UTC
The heredoc and nowdoc (PHP 5.3) shouldn't be formatted by php code. The biggest problem as is mentioned that the end of heredoc or nowdoc doesn't have to be recognized and all file then is thread as a string. 

Example of nowdoc:

<?php
$str = <<<'EOD'
Example of string
spanning multiple lines
using nowdoc syntax.
EOD;

/* More complex example, with variables. */
class foo {
    public $foo;
    public $bar;

    function foo()
    {
        $this->foo = 'Foo';
        $this->bar = array('Bar1', 'Bar2', 'Bar3');
    }
}

$foo = new foo();
$name = 'MyName';

echo <<<'EOT'
My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should not print a capital 'A': \x41
EOT;
?>
Comment 2 Tomasz Slota 2009-11-10 10:46:03 UTC
fixed & unit tested:
http://hg.netbeans.org/web-main/rev/4c1e01e54386
Comment 3 Filip Zamboj 2009-11-19 17:34:27 UTC
verified 
Product Version: NetBeans IDE Dev (Build 091119-840bbe3ddcb3)
Java: 1.5.0_17-ea; Java HotSpot(TM) 64-Bit Server VM 1.5.0_17-ea-b01
Comment 4 kripper 2018-01-05 16:15:04 UTC
When selecting text containing a complete HEREDOC block and pressing TAB or Shift + TAB, the HEREDOC block (the content) shouldn't be indented because it will break the code.

When selecting only the HEREDOC content (without the start and end tags), it's ok to indent the content.

Tested in v8.1