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.
Created attachment 96096 [details] example of the problem See attached picture. The auto-complete parser currently treats class/namespace constants the same as named constants in namespace context when infact named constants ignores namespaces.
Product Version: NetBeans IDE Dev (Build 100418-38937479e21f) Java: 1.6.0_16; Java HotSpot(TM) 64-Bit Server VM 14.2-b01 reproduced P2 because this code completion error leads to PHP Fatal error: Undefined constant I used example in reporters screenshot. code: <?php namespace foo; const bar = "bar_value"; define("BAZ", "baz_value"); namespace foo2; $bar = \foo\bar; $baz = | 1. invoke code completion where carret is. 2. you have more choices at the moment. One of the is BAZ that is from namespace foo. Using cc you will get $baz = \foo\BAZ; that's incorrect, as reporter stated. According to http://us.php.net/manual/en/function.define.php you can specify namespace constant explicitly in define function's arguments. In our case you have two possibilities. 1. define in global namespace <?php namespace foo; define("BAZ", "baz_value"); \\ correct define("\BAZ", "baz_value"); \\ incorrect namespace foo2; $baz = \BAZ; \\correct $baz = BAZ; \\correct $baz = \foo\BAZ; \\incorrect ?> 2. define in namespace (not global) <?php namespace foo; define("foo\BAZ", "baz_value"); namespace foo2; $baz = \foo\BAZ; \\correct $baz = BAZ; \\incorrect $baz = \BAZ; \\incorrect ?>
Ah. And since define is a function and not a language construct, it couldn't possible know what namespace it was called in, which is why you have to state the namespace explicitly. Thanks for fixing!
http://hg.netbeans.org/web-main/rev/132476c39cfc Please test and verify
Integrated into 'main-golden', will be available in build *201004210200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/132476c39cfc User: Radek Matous <rmatous@netbeans.org> Log: #183012 - Auto-complete parser treats constants in namespaces incorrectly
cannot verify because of BUG 184602
http://hg.netbeans.org/web-main/rev/9dc7bb1f8f00