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 237726 - Do not flag final ?> as unnecessary when followed by any non-whitespace
Summary: Do not flag final ?> as unnecessary when followed by any non-whitespace
Status: VERIFIED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.4
Hardware: All All
: P3 normal (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-28 19:11 UTC by dharkness
Modified: 2013-11-12 13:46 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 dharkness 2013-10-28 19:11:49 UTC
When a PHP page ends with non-PHP code such as <script> or <style>, the final ?> before those tags is flagged as unnecessary, but in fact it *is* necessary. Using a <div> as the first tag following ?> removes the warning. so I assume the editor is checking for certain tags or text.

    <?php ?>    <!-- flagged -->
    <script>
        var foo = 5;
    </script>

    <?php ?>    <!-- flagged -->
    <style>
        .foo {}
    </style>

    <?php ?>    <!-- not flagged -->
    xxx
    <script>
        var foo = 5;
    </script>

    <?php ?>    <!-- not flagged -->
    <div>foo</div>

I recommend having the warning *only* when it ends the file or is followed by whitespace characters only.
Comment 1 dharkness 2013-10-28 19:41:43 UTC
Also, the description text for the hint is not quite standard English. Replace the first sentence

    It is a good practise to don't use closing PHP delimiter at the end of file.

with

    It is a good practise to omit the closing PHP delimiter at the end of the file.
Comment 2 Ondrej Brejla 2013-10-29 08:30:54 UTC
<script> will probably be considered as a JS token. I'll look at it, thanks. I'll improve message as well.
Comment 3 Ondrej Brejla 2013-10-29 10:03:40 UTC
Hmm...I copypasted your code into a PHP file and I don't see any "Unnecessary closing dellimiter" hint :/ Can you attach a sample file, where it can be reproduced? Thanks.

English fixed in web-main #1b338e761370
Comment 4 mmolda 2013-10-29 12:44:20 UTC
@obrejla: Ondreji, copy and paste just this (without comments):

<?php ?>
<script>
    var foo = 5;
</script>

or this:

<?php ?>
<style>
    .foo {}
</style>
Comment 5 Ondrej Brejla 2013-10-29 12:52:38 UTC
Yep, reproducible, thanks.
Comment 6 Ondrej Brejla 2013-10-29 13:18:54 UTC
Fixed in web-main #812c81be997b
Comment 7 mmolda 2013-11-04 17:40:16 UTC
Verified, thanks.

Product Version: NetBeans IDE Dev (Build 201311040001)
Java: 1.7.0_45; Java HotSpot(TM) Client VM 24.45-b08
Runtime: Java(TM) SE Runtime Environment 1.7.0_45-b18
System: Windows 7 version 6.1 running on x86; Cp1250; en_US (nb)
Comment 8 Ondrej Brejla 2013-11-07 14:03:44 UTC
Transplanted to release74 branch in releases repo. Please, verify, thanks.
Comment 9 mmolda 2013-11-12 13:44:14 UTC
Verified.

Product Version: NetBeans IDE 7.4 (Build 201311111738)
Java: 1.7.0_45; Java HotSpot(TM) Client VM 24.45-b08
Runtime: Java(TM) SE Runtime Environment 1.7.0_45-b18
System: Windows 7 version 6.1 running on x86; Cp1250; en_US (nb)