Community
Participate
Working Groups
Build ID: M20080911-1700 Steps To Reproduce: <?php define('AGlobalConst', 1); class AClass { const AClassConst = 1; } class Test { protected $var = A|; // <- cursor } ?> Expect to have code assist suggest: 'AClass' 'AGlobalConst' Actual: 'No completions available' error in status bar. More information:
Created attachment 157051 [details] pathc
The patch will cause testClassStatement1.pdtt and testClassStatement2.pdtt fail.
Created attachment 171820 [details] Code assist bug when assigning class properties to constants
Hi Ronen Thanks for your patch! It seems that your patch is the same as mine,there was unit test failure ,but now it disappears:) Contributed by Ronen!
The patch could be improved so constants are not suggested in the following case: class A { | } but only in a right-hand side of an assignment expression: class A { something = | }
Hi Michael Thanks for your suggestion. And we can have: class A { echo CONSTANT; } So do you mean CONSTANT should not be the first word?
Still reproducible for PDT-2.2.0.v20100616 The same behavior is looking at this PDT build No completion available Reopen this issue If will have the fix for next build please resolved for them Reopened by Teodor Kirkov teodor.k@zend.com
works now
Tested on 2.2.1.v20100829 Using the example in the bug description: AGlobalConst is suggested but AClass is NOT.
I have a question,if class AClass does not contain any constant do we need to show 'AClass'? and further,we have the following content: <?php define('AGlobalConst', 1); class AClass { const AClassConst = 1; public static $field; } class Test { protected $var = AAClass::|; // <- cursor } ?> do we need we only to show 'AClassConst'?
for performance reasons I would not show only the classes that have const but all classes.
Created attachment 178582 [details] patch
Still issues of namespace 1. The namespace AA is listed and the generated code is broke. <?php namespace AA; define('AGlobalConst', 1); class AClass { const AClassConst = 1; } class Test { AA\:: } ?> 2. Select the class AClass, the generated code is broke. <?php use AA\AClass; namespace AA; define('AGlobalConst', 1); class AClass { const AClassConst = 1; } class Test { AClass:: } ?>
Hi QS for 1st case,it is not special for this bug,and I have committed code that fixes it. for 2nd case,I could not reproduce it,I updated to the latest code(head).
I'm using the latest code from 7.3 and haven't tried the head code. I assume that you plan to port the patch back to 7.3, otherwise no review needed at all. The original code is as below. <?php namespace AA; define('AGlobalConst', 1); class AClass { const AClassConst = 1; } class Test { AClas | // CA here. } ?>
(In reply to comment #15) > I'm using the latest code from 7.3 and haven't tried the head code. > I assume that you plan to port the patch back to 7.3, otherwise no review > needed at all. > > The original code is as below. > > <?php > namespace AA; > > > define('AGlobalConst', 1); > class AClass > { > const AClassConst = 1; > } > class Test > { > AClas | // CA here. > } > ?> instead insert "use AA\AClass;",I got an exception,and I think the problem is we should not propose anything at '|' as Michael said.I will think about this later:)
Created attachment 181466 [details] patch (In reply to comment #13) > 2. Select the class AClass, the generated code is broke. > > <?php > use AA\AClass; > namespace AA; > > > define('AGlobalConst', 1); > class AClass > { > const AClassConst = 1; > } > class Test > { > AClass:: > } > ?> There is no need to insert the use statement, this patch can fix the issue
The patch looks all right. Can you please add unit test for it?
(In reply to comment #15) > I'm using the latest code from 7.3 and haven't tried the head code. > I assume that you plan to port the patch back to 7.3, otherwise no review needed > at all. > > The original code is as below. > > <?php > namespace AA; > > > define('AGlobalConst', 1); > class AClass > { > const AClassConst = 1; > } > class Test > { > AClas | // CA here. > } > ?> The problem is we should not show any proposal at the above location.I have reverted my patch and my patch will cause tests failing. Xu's patch is based on my wrong patch,sorry for this.