Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 318133 - Constants defined in A.php file are not present in code assist in file B.php
Summary: Constants defined in A.php file are not present in code assist in file B.php
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: PDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P1 normal (vote)
Target Milestone: ---   Edit
Assignee: PHP UI CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-27 15:15 EDT by Vitaly CLA
Modified: 2020-05-14 11:08 EDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vitaly CLA 2010-06-27 15:15:07 EDT
Build Identifier: 20100617-1415

File A.php

define ('LW_DB_PASSWORD', '');
define ('LW_DB_SERVER', 'localhost');

File B.php

class Test{
   private $var = LW | code assist doesn't shows defined constants 
}

Reproducible: Always
Comment 1 Roy Ganor CLA 2010-06-27 15:29:06 EDT
did you include file A.php in file B.php, if not - do you think we should list all constants in all files?

(potential performance issue?)
Comment 2 Vitaly CLA 2010-06-27 15:41:30 EDT
(In reply to comment #1)
> did you include file A.php in file B.php, if not - do you think we should list
> all constants in all files?
> 
> (potential performance issue?)

If file A.php is included, the problem is also reproducible. 

In Eclipse Galileo PDT everything is working fine (constants were shown)
Comment 3 Zhongwei Zhao CLA 2010-06-30 08:03:35 EDT
I have a question:
File A.php

$aa="";

File B.php

class Test{
private $var = $a| //code assist doesn't shows $aa
}


Is this a bug too?And there are many other cases(global classes...) like this.
Comment 4 Jacek Pospychala CLA 2010-06-30 09:59:24 EDT
(In reply to comment #3)
> Is this a bug too?And there are many other cases(global classes...) like this.

for me it looks so. That's the point of global stuff - it should be visible everywhere :-(
However, different cases may be fixed as separate bugs..
Comment 5 Zhongwei Zhao CLA 2010-06-30 11:54:33 EDT
fixed in head
Comment 6 Roy Ganor CLA 2010-07-04 02:27:37 EDT
(In reply to comment #4)
> (In reply to comment #3)
> > Is this a bug too?And there are many other cases(global classes...) like this.
> 
> for me it looks so. That's the point of global stuff - it should be visible
> everywhere :-(
> However, different cases may be fixed as separate bugs..

but this is not a (syntax) valid php execution:

<?php 

$aa = 5;
class A {
	private $v = $aa;
}

$a = new A();
echo $a->v;



so why should we provide it?
Comment 7 Zhongwei Zhao CLA 2010-07-04 07:08:48 EDT
(In reply to comment #6)
> (In reply to comment #4)
> > (In reply to comment #3)
> > > Is this a bug too?And there are many other cases(global classes...) like this.
> > 
> > for me it looks so. That's the point of global stuff - it should be visible
> > everywhere :-(
> > However, different cases may be fixed as separate bugs..
> 
> but this is not a (syntax) valid php execution:
> 
> <?php 
> 
> $aa = 5;
> class A {
>     private $v = $aa;
> }
> 
> $a = new A();
> echo $a->v;
> 
> 
> 
> so why should we provide it?

Hi Roy

Yes,I just knew it is not valid.Sorry for this.
But I did not provide for global variables.
I just fix the global constant issue.
So,can we mark this bug as fixed again?
Comment 8 Q.S. Wang CLA 2010-07-07 04:03:56 EDT
I think there's more issue of the CA for constant.

1. create a class with a method
2. try CA for DIR| -> constants are not proposed
3. try outside the class - works as expected 

I think the fixing in GlobalConstantsStrategy.java for 300530 caused this issue and going to do more changes in the GlobalConstantsStrategy.java.
Comment 9 Zhongwei Zhao CLA 2010-07-07 04:37:21 EDT
(In reply to comment #8)
> I think there's more issue of the CA for constant.
> 
> 1. create a class with a method
> 2. try CA for DIR| -> constants are not proposed
> 3. try outside the class - works as expected 
> 
> I think the fixing in GlobalConstantsStrategy.java for 300530 caused this issue
> and going to do more changes in the GlobalConstantsStrategy.java.

<?php
define("DIR", "");

class class_name {
	function function_name() {
		DI| // DIR proposed as expected in my devenv
	}
}
?>
Comment 10 Zhongwei Zhao CLA 2010-07-07 04:42:19 EDT
Oh,sorry

My fixing code is just workaround:)
Comment 11 Q.S. Wang CLA 2010-07-07 04:44:22 EDT
I'm talking about the DIRECTORY_SEPARATOR from the standard.php.
Comment 12 Zhongwei Zhao CLA 2010-07-07 04:49:28 EDT
DIRECTORY_SEPARATOR is proposed too,but do not mention it,go ahead!
Comment 13 Q.S. Wang CLA 2010-07-07 04:55:30 EDT
Well not sure if you're using the latest code. Did you change anything in the GlobalConstantsStrategy.java?
Comment 14 Pavel Galaton CLA 2010-07-16 02:39:02 EDT
Hi,
I also have some problems with AC constants.
Example:
created file test.php
<?php
define('TEST_CONST', 'test_value');
when typing here `echo TES` nothing appears (in CA window were only standard php constants), ctrl+space don't help also.
but if I type `echo` press ctrl+space and then type TEST it shows me TEST_CONST in CA window as expected.

Build id: 20100617-1415
with installed pdt-Update-N201007152113
PHP version for project containing file test.php : PHP 5.1/5.2
Comment 15 Pavel Galaton CLA 2010-07-16 02:47:20 EDT
(In reply to comment #14)
> Hi,
> I also have some problems with AC constants.
> Example:
> created file test.php
> <?php
> define('TEST_CONST', 'test_value');
> when typing here `echo TES` nothing appears (in CA window were only standard
> php constants), ctrl+space don't help also.
> but if I type `echo` press ctrl+space and then type TEST it shows me TEST_CONST
> in CA window as expected.
> 
> Build id: 20100617-1415
> with installed pdt-Update-N201007152113
> PHP version for project containing file test.php : PHP 5.1/5.2

same problem with PHP 5.3 
<?php
const TEST_CONST = 12;
start typing `TEST_` nothing shows, 
ctrl+space and then type `TEST_` works.

really annoying, hope soon will be fixed
Comment 16 Zhongwei Zhao CLA 2010-07-16 04:05:05 EDT
(In reply to comment #15)
> (In reply to comment #14)
> > Hi,
> > I also have some problems with AC constants.
> > Example:
> > created file test.php
> > <?php
> > define('TEST_CONST', 'test_value');
> > when typing here `echo TES` nothing appears (in CA window were only standard
> > php constants), ctrl+space don't help also.
> > but if I type `echo` press ctrl+space and then type TEST it shows me
> TEST_CONST
> > in CA window as expected.
> >
> > Build id: 20100617-1415
> > with installed pdt-Update-N201007152113
> > PHP version for project containing file test.php : PHP 5.1/5.2
> 
> same problem with PHP 5.3
> <?php
> const TEST_CONST = 12;
> start typing `TEST_` nothing shows,
> ctrl+space and then type `TEST_` works.
> 
> really annoying, hope soon will be fixed
Ah...it seems that I could not reproduce this:(
Comment 17 Pavel Galaton CLA 2010-07-16 05:28:45 EDT
Ooops sorry, my bad, file test.php i created was outside of buid path, thats why it wasnt working.

By the way shouldn't it show me global constants in this file, even if it is outside build path?

steps to reproduce:
1) create project
2) go to properties of project -> PHP Build Path -> Select project folder and Remove it -> OK
3) create new file `test.php` in root of project with source:
<?php
define('TEST_VAR', 'test');

4) start writing TEST_VAR and you will see that no AC,

Same thing with variables,

Thing that i note is when you first press ctrl+space you can find your TEST_VAR in list, but it is marked with green bullet and little "F" on this bullet, instead of normal triangle that marks constants

screen showing this : http://j.imagehost.org/0952/screen.png
Comment 18 Zhongwei Zhao CLA 2010-08-04 02:56:41 EDT
Hi Pavel

the original bug has been fixed,and about you last comment we have not supported it.If you would like please open another bug for it marking as enhancement,thanks!
Comment 19 Petyo Tanchev CLA 2010-09-01 07:10:46 EDT
Tested on 2.2.1.v20100829
Fixed