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 163619 - [verification] warn against using array in class constant
Summary: [verification] warn against using array in class constant
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-24 16:39 UTC by txigreman
Modified: 2013-04-04 12:49 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description txigreman 2009-04-24 16:39:24 UTC
Hi,

class constants can't be arrays. The IDE con't check it.


Example code:

class A {
	const $a = array('hello' => 'world');
}


Error message:

Fatal error:  Arrays are not allowed in class constants in ... on line ...
Comment 1 Tomasz Slota 2009-05-06 15:24:57 UTC
The $ character is not allowed in class constant names. The following code is handled without problems:

class A {
	const a = array('hello' => 'world');
}

The error message on your original code does not say that "arrays are not allowed in class constants", at least not when using the current dev build. The 
message only says there is a syntax error.
Comment 2 txigreman 2009-05-06 18:42:40 UTC
Example code was wrong, sorry. Just remove $

class A {
	const a = array('hello' => 'world');
}
Comment 3 Tomasz Slota 2009-05-07 12:21:39 UTC
The latter example works fine for me, what version of NetBeans are you using?
Comment 4 txigreman 2009-05-07 15:28:03 UTC
I've tested it on 6.5 and on 6.7beta. The IDE doesn't show any error messsage, but php 5.2.9-2 (windows) shows this
error when you execute it:

Fatal error: Arrays are not allowed in class constants in D:\temp\test.php on line 3
Comment 5 Tomasz Slota 2009-05-07 15:45:53 UTC
OK, I understand it now
Comment 6 txigreman 2009-05-07 18:48:07 UTC
Sorry for my english xD
Comment 7 Tomasz Slota 2010-02-10 08:46:20 UTC
reassigning to default owner
Comment 8 Filip Zamboj 2010-09-15 12:28:50 UTC
batch reassigning
Comment 9 Ondrej Brejla 2013-04-04 12:49:42 UTC
Fixed in web-main #16b2f57ba42b