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 267895 - XML declaration error hint in PHP files in Dev 201609050002
Summary: XML declaration error hint in PHP files in Dev 201609050002
Status: NEW
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.2
Hardware: PC Linux
: P4 normal (vote)
Assignee: Tomas Mysik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-06 08:44 UTC by sviatopolk
Modified: 2016-09-06 08:44 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
"Test case" (PHP+XML) from Propel2 ORM (627 bytes, application/x-php)
2016-09-06 08:44 UTC, sviatopolk
Details

Note You need to log in before you can comment on or make changes to this bug.
Description sviatopolk 2016-09-06 08:44:26 UTC
Created attachment 161919 [details]
"Test case" (PHP+XML) from Propel2 ORM

If a PHP file starts with XML declaration, an error hint is shown.

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
      ^-- Syntax error: Unexpected identifier: "version", expected "instanceof", "OR", "&&", ..... after identifier "xml"

Please fix this, as in fact no standards mandate it should not contain XML, even so, well formed XHTML may in fact be expected to start with an XML declaration, and some systems even use XML/XSLT for presentation.

As I see it, it is a "bug" in the PHP parser, it presumably sees "<?" as a "short open tag", and "xml" as a PHP identifier.

As the documentation states

http://php.net/manual/en/ini.core.php#ini.short-open-tag

you should disable short open tag in order to use XML declaration mixed with PHP.

But given that PSR-1 from PHP-FIG recommends that

"Files MUST use only <?php and <?= tags."
http://www.php-fig.org/psr/psr-1/

, more and more projects are relying on this option, and seeing a "file contains errors" notice can become quite annoying.

The file attached is from Propel2 ORM.

Given all the above, and that it is 2016, yet you might not want to break total compatibility with "legacy" code, a possible compromise could be that a checkbox be added to somewhere in the options that "mimics" the PHP "short_open_tag" INI directive, so that when it is turned off, short tags are not allowed and XML declaration is.

All that said, I've set it as P4 should you have other, more important things to fix. :)