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 183012 - Auto-complete parser treats constants in namespaces incorrectly
Summary: Auto-complete parser treats constants in namespaces incorrectly
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: PC Windows 7 x64
: P2 normal (vote)
Assignee: rmatous
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-28 12:13 UTC by coops
Modified: 2010-04-21 16:43 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
example of the problem (22.57 KB, image/png)
2010-03-28 12:13 UTC, coops
Details

Note You need to log in before you can comment on or make changes to this bug.
Description coops 2010-03-28 12:13:04 UTC
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.
Comment 1 Filip Zamboj 2010-04-19 13:29:04 UTC
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
?>
Comment 2 coops 2010-04-19 21:54:13 UTC
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!
Comment 3 rmatous 2010-04-20 14:41:35 UTC
http://hg.netbeans.org/web-main/rev/132476c39cfc

Please test and verify
Comment 4 Quality Engineering 2010-04-21 04:37:38 UTC
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
Comment 5 Filip Zamboj 2010-04-21 11:58:15 UTC
cannot verify because of BUG 184602