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 197756 - Useless PHP syntax checking
Summary: Useless PHP syntax checking
Status: RESOLVED DUPLICATE of bug 211165
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P3 normal with 2 votes (vote)
Assignee: Ondrej Brejla
URL: http://stackoverflow.com/q/5636592/19...
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-14 17:25 UTC by JohnnyWalker2001
Modified: 2012-04-13 14:18 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 JohnnyWalker2001 2011-04-14 17:25:25 UTC
I've tested the same file with several different IDEs and NetBeans is the only one (so far) that is unable to locate the source of the issue and point the user to the correct line of code.

I didn't think it was a bug at first, but given how every other PHP IDE (Eclipse, etc.) handles the problem correctly, I've begun to suspect that it is.

Please look at the supplied link for specifics on the problem.

Thanks.
Comment 1 OndrejBrejla 2011-04-15 08:34:53 UTC
Maybe it's somehow connected with http://netbeans.org/bugzilla/show_bug.cgi?id=168350 ?
Comment 2 paolosca 2011-04-16 15:02:25 UTC
(In reply to comment #1)
> Maybe it's somehow connected with
> http://netbeans.org/bugzilla/show_bug.cgi?id=168350 ?

Yes, I think it may be related. Fixing this would make a very good enhancement.


A few tests I made:

1 - In this case the line marked is the correct one one:

<?php
class TEST {
	private function testfnc($xml) {
		private $test = "";    // <---- Error
	}
}
?>

2 - If there are more lines after the error the marked line is the wrong
one:

<?php
class TEST {
	private function testfnc($xml) {
		private $test = "";
	}

	private function testfnc2($xml) {
		$test = "";
	}    // <---- Error
}
?>

My guess is that the syntax checker doesn't stop at the first error, it attempts to keep parsing the whole code and only the last line that returns error is marked.

This makes it very hard to locate the error line in long code.


Moreover, the error returned by the syntax checker is rather generic:

Syntax error:
Unexpected: if, identifier, variable, echo, do, while, [...]


While parsing the file with php -l the error is reported is much more precise:

PHP Parse error:  syntax error, unexpected T_PRIVATE in test.php on line 12


Several other IDEs rely on the php executable to check the code while I assume Netbeans relies on an internal syntax checker.

Perhaps netbeans should use both methods and the internal syntax checker could be used in case php is not installed in the system.
Comment 3 Petr Pisl 2011-09-29 10:59:14 UTC
The error handling is the first version from 6.5. Needs to be improved.
Comment 4 Ondrej Brejla 2012-04-13 14:18:24 UTC

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