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 211129 - Wrong formatting of NOWDOC
Summary: Wrong formatting of NOWDOC
Status: NEW
Alias: None
Product: php
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 7.2
Hardware: All All
: P3 normal with 2 votes (vote)
Assignee: Tomas Mysik
URL:
Keywords:
: 255592 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-04-13 07:18 UTC by Ondrej Brejla
Modified: 2016-08-17 11:33 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ondrej Brejla 2012-04-13 07:18:05 UTC
<?php

class foo {

    public $bar = <<<'EOT'
bar
EOT;
}

?>

<?php

class foo {

    const ABC = <<<'EOT'
bar
EOT;
}

?>

Try to format these snippets.

Result:

<?php

class foo {

    public $bar = <<<'EOT'
bar


    EOT;
}

?>
Comment 1 Tomas Mysik 2016-08-12 10:48:29 UTC
*** Bug 255592 has been marked as a duplicate of this bug. ***
Comment 2 Tomas Mysik 2016-08-17 11:33:52 UTC
This seems to be quite complicated and too risky for NB 8.2.

The problem seems to be (at least to me) that PHP_HEREDOC_TAG_END contains properly only the label (the closing identifier) whereas PHP_NOWDOC_TAG_END contains also ";" and possible new line. This 2 characters cause that condition [1] in TokenFormatter.scan(ASTNode) is not met (or perhaps the node.getEndOffset() is incorrect, I am not sure).

Thanks.
[1] ts.offset() + ts.token().length()) <= node.getEndOffset()