netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

Syntax error Match class

Open cuescore opened this issue 3 years ago • 2 comments

Apache NetBeans version

Apache NetBeans 14

What happened

I want to use Netbeans > 11.3, but I work on PHP code for PHP7.4 and have a class Match, and "match" is a reserved keyword in PHP8. In Netbeans > 11.3 (I've tested 12/13/14) I can set the project properties to use PHP7.4, but it will still give me a syntax error for using the Match class: "Syntax error, unexpected :: after match, expected ("

I expected the syntax error to not be a syntax error for PHP7.4 projects, but I can't seem to shake it. Is this a bug, or is there something I can do about this?

How to reproduce

Create a class Match and try to use a constant in it f.ex. Will yield a syntax error even though the project is for PHP7.4.

Did this work correctly in an earlier version?

Apache NetBeans 12.3 or earlier

Operating System

Fedora Linux

JDK

java-1.8.0-openjdk.x86_64

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

No response

Are you willing to submit a pull request?

No

Code of Conduct

Yes

cuescore avatar Sep 13 '22 20:09 cuescore

Switching the PHP version will not fix/change errors of current PHP version. This was intented to be. I also don't know why we should change the PHP version if this is not changing the errors. This feature was somehow implemented into JS. If the parser found for example "async" and we are still on an older version of JS, it shows that async is a feature of a newer version, would you like to switch? So yes, me as a user also expect that switching the PHP version will change to that version and checks PHP for exact this version but it isnt for now.

Chris2011 avatar Sep 13 '22 21:09 Chris2011

Well, we support only the syntax of the latest version. We would like to avoid adding parsers for each PHP version. If we add them, we must add all unit tests for each parser. (we have so many unit tests.) We don't want to do that.

Sooner or later, you have to change the class name in the future...

junichi11 avatar Oct 03 '22 05:10 junichi11