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 201961 - Problem with indentions when using mix of HTML and PHP code
Summary: Problem with indentions when using mix of HTML and PHP code
Status: RESOLVED DUPLICATE of bug 257574
Alias: None
Product: php
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 7.0.1
Hardware: All All
: P4 normal (vote)
Assignee: Tomas Mysik
URL:
Keywords:
: 190652 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-09-11 23:50 UTC by TrebleSnake
Modified: 2016-08-12 10:10 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Example code (432 bytes, text/plain)
2011-09-11 23:50 UTC, TrebleSnake
Details
Example 2 (653 bytes, text/plain)
2011-09-13 19:56 UTC, TrebleSnake
Details

Note You need to log in before you can comment on or make changes to this bug.
Description TrebleSnake 2011-09-11 23:50:45 UTC
Created attachment 110630 [details]
Example code

Well, there is a problem with indentions when using mix of HTML and PHP code.

The example code, formatted by NetBeans, is in attachment.

So, some description: we have class MyClass with methods Foo1, Foo2 and Foo3.
Foo1 contains html and php, but formatter is OK with it.
Foo2 also contains html and php, and here is the bug.

You can see extra indents before Foo2's closing brace and also before each row down below. Notice, that sometimes formatter does not add extra braces on first C-S-F pressing, only after second one. But I couldn't precisely reproduce it.

Maybe, in this simple example you can hack the bug by inserting some new lines here and there. But I can assure you, it will not work with more complex source codes (to say nothing of some cases, when new lines are unsuitable, e.g. for inline elements).

As I can see, the logic of this bug is rather esoteric :). E.g., wrap the body of the Foo2() into another pair of braces and - bang - it will be satisfactory formatted. Or delete one of the <div> elements - the same thing.
Comment 1 Petr Pisl 2011-09-13 14:46:57 UTC
Reproducible. The main problem I see in the formating of Foo3 from the example.
Comment 2 TrebleSnake 2011-09-13 19:55:21 UTC
(In reply to comment #1)
> Reproducible. The main problem I see in the formating of Foo3 from the example.

Yes, and don't forget the closing brace of Foo2 and the closing brace of the MyClass class itself, please.

Thus, every line after Foo2 will have extra indents. And closing PHP tag (correctly formatted in the Example) may also be wrongly moved to the right (see Example 2. Main differences are on 19th and 20th lines).
Comment 3 TrebleSnake 2011-09-13 19:56:39 UTC
Created attachment 110723 [details]
Example 2
Comment 4 Ondrej Brejla 2013-06-04 13:37:23 UTC
*** Bug 190652 has been marked as a duplicate of this bug. ***
Comment 5 Tomas Mysik 2016-08-12 10:09:20 UTC
Sorry but this is - IMHO - very unusual use (misuse? ;) of PHP and HTML. I mean to end PHP block inside of a declaration (of a method or a function). IMHO you should really prefer to use variables and "echo" function, e.g.:

function header($title) {
    echo '<h1>' . $title . '</h1>';
}

Thanks for reporting.
Comment 6 Tomas Mysik 2016-08-12 10:10:30 UTC

*** This bug has been marked as a duplicate of bug 257574 ***