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.
Summary: | "Unexpected '[' after identifier" when declaring a const and assigning a value from an array to it | ||
---|---|---|---|
Product: | php | Reporter: | reasv |
Component: | Editor | Assignee: | Tomas Mysik <tmysik> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | adipinto, colan, hinson0, junichi11, OskarD, Paulaner, reasv, samfelgar, tmysik, touhonoob |
Priority: | P3 | ||
Version: | 8.0.2 | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: | |
Attachments: |
A screenshot of the issue
same issue here patch Netbeans 8.2 complaining about constant array syntax |
Created attachment 152614 [details]
same issue here
Product Version: NetBeans IDE 8.0.2 (Build 201411181905)
*** Bug 251489 has been marked as a duplicate of this bug. *** *** Bug 251219 has been marked as a duplicate of this bug. *** *** Bug 254474 has been marked as a duplicate of this bug. *** The same on MAC OSX Netbeans 8.1 *** Bug 257362 has been marked as a duplicate of this bug. *** The same on Linux Netbeans 8.1 Created attachment 158989 [details]
patch
I've created a patch. I also fixed GoToDeclaration and MarkOccurrence. But the following case doesn't work yet. I'll submit it as a new issue later. $constantClass = new ConstantClass(); $constantClass::C^ONSTANT; // here : also method and field Tomas, Could you please review it when you can make time? Thanks! (In reply to junichi11 from comment #9) > Tomas, Could you please review it when you can make time? Great work, Junichi! Thanks a lot! Patch applied, thanks a lot for it, Junichi! http://hg.netbeans.org/web-main/rev/0bcf8fbd05f4 Integrated into 'main-silver', will be available in build *201603300001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/0bcf8fbd05f4 User: Tomas Mysik <tmysik@netbeans.org> Log: #250579 - "Unexpected '[' after identifier" when declaring a const and assigning a value from an array to it Patch contributed by junichi11@netbeans.org. Because this bug I have tested NetBeans IDE Build 2016046001. This bug is fixed but now I get a new syntax error: Example: <html> <head> <title>Title</title> </head> <body> <span id="<?php echo $my_var; ?>">anything other txt</span> </body> </html> For the <span ... line is the error message: Bad value " " for attribute "id" on element "span":An ID must not contain whitespace. An ID consists of at least one character but must not contain any whitespace. (In reply to photonensammler from comment #13) > Because this bug I have tested NetBeans IDE Build 2016046001. > This bug is fixed but now I get a new syntax error: > > Example: > > <html> > <head> > <title>Title</title> > </head> > <body> > <span id="<?php echo $my_var; ?>">anything other txt</span> > </body> > </html> > > For the <span ... line is the error message: > > Bad value " " for attribute "id" on element "span":An ID must not contain > whitespace. > An ID consists of at least one character but must not contain any whitespace. Please don't change status. If you find some problems, please submit them as new issues. BTW, I cannot reproduce it in a php file. So, I guess that you are using an html file. Thanks. Why is this issue is closed? This problem is still persist in 8.1 (In reply to lolka_bolka from comment #15) > Why is this issue is closed? Because it was already fixed and it is available in the dev build[1]. So, please try testing it if you are interested in it. Then, if you find some problems, please report them as new issues. > This problem is still persist in 8.1 Perhaps, it will be available in 8.2(not 8.1). Basically, fixed issues will be available in the next NetBeans version. [1] http://bits.netbeans.org/download/trunk/nightly/latest/ Thanks. Created attachment 162647 [details]
Netbeans 8.2 complaining about constant array syntax
Just installed 8.2, this issue is still present.
The issue was supposed to be fixed in 8.2. I have fresh installation of NB 8.2 and it still does not respect the right of PHP's constant array for life. :-) (In reply to Jack_Brody from comment #18) > The issue was supposed to be fixed in 8.2. > > I have fresh installation of NB 8.2 and it still does not respect the right > of PHP's constant array for life. :-) Could you submit it as a new issue? Thanks. If any of you have posted a follow-up issue, please post a link here so that the rest of us can track it. Thanks! |
Created attachment 152116 [details] A screenshot of the issue I defined a const TABLES with const TABLES = array('users', 'admins'); And then I defined another const, which should contain the first element of TABLES, USERS: const USERS = TABLES[0]; But this line is highlighted as an error by NetBeans, with the following explanation: " Syntax error unexpected: [ after: Identifier 'TABLES' expected: variable, instanceof, as, implements [ETC, list goes on] " Note that the project is set as PHP 5.6, and my server running 5.6 does NOT give me errors or notices when I try to run this code, in fact the value of USERS is as expected. Of course, all errors and notices are enabled on my test server, since it's running XAMPP.