NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Auto Completion Issue


Joined: 16 Jun 2011
Posts: 31
Reply with quote
Hi all,

recently i've upgraded to PHPEd 15.
Now experiencing a weird issue. I don't know if this was already so before but it annoys me now.

Auto completion get a little bit weird when you do the following:

Code:
<?php
class MyClassOne{
    public function updateAll(){}
}
class MyClassTwo{
    public function cancelAll(){}
}

$obj = new MyClassOne();
$obj = new MyClassTwo();

$obj->


When you auto complete for $obj-> at the end the both functions "updateAll" and "cancelAll" will be listed.
Expected result ist only "cancelAll".

Is this a bug or a expected behaviour? For me it's annoying because i unintentionally sometimes auto complete with the wrong methods when re-using variable names.
I'm pretty sure that this wasn't like so before v15.
View user's profileFind all posts by brainSend private message


Joined: 22 Apr 2014
Posts: 22
Reply with quote
I see the same behavior in 14043, I copied your code and paste it in a new file and the auto completion suggest both method.
View user's profileFind all posts by infcSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8342
Reply with quote
This is not a bug, but rather an intended behaviour.
Your example is too simple and wouln't appear anywhere in real life.
Consider the following case. I think it makes it clear why IDE works this way:

Code:

<?php
 
class MyClassOne{
    public function updateAll(){}
}
class MyClassTwo{
    public function cancelAll(){}
}

switch ($someflag) {
case 0:
  $obj = new MyClassOne();
  break;
case 1:
  $obj = new MyClassTwo();
  break;
}

$obj->


there could also be loops, branches and other things that would make it impossible to guess what class instance is assigned to $obj without knowing all values at run-time.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 16 Jun 2011
Posts: 31
Reply with quote
Well, i understand that behaviour right now.
But saying that "wouln't appear anywhere in real life" is a little bit naive, isn't it?

Just a quick example how you maybe come in this situation.
It's simple right now but when you have many of those calls with special fields, that uses a lot of parent classes, where you don't know the exact dependencies, than it will be a bit tricky and you may expect (as i) that auto-completion show exactly that things that are available at the moment, like when php executes the code for you.

Nevermind, i totally understand the design decision, i just don't like your answer because it's not true saying "wouln't appear anywhere in real life" Smile

Code:
...
$field = new Form_Field_Hidden($name);
$field->setDefaultValue(1);
$form->addField($field);

// select field is the only class the have the method ->addOption
$field = new Form_Field_Select($name);
$field->setDefaultValue(1);
$field->addOption("key", "value");
$form->addField($field);

$field = new Form_Field_Checkbox($name);
$field->setDefaultValue(1);
$form->addField($field);

$field = new Form_Field_Radio($name);
$field->setDefaultValue(1);
$form->addField($field);
...
View user's profileFind all posts by brainSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8342
Reply with quote
and what you presented is not what was originally posted and what wouldn't be expected in real life.
To be specific -- you assign a variable with some class instance, then use it, then assign another class instance (seemngly related to the 1st), then use 2nd.
In the original sample -- two assignmes are made in a row. This is not that useful Wink

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 16 Jun 2011
Posts: 31
Reply with quote
You are right, my first example was just for showing up the issue.
I thought you referenced your answer to the functionality in nusphere and not explicitely to my short example.
Seems like we had a little communication mistake here.
Anyway, for me the actual PHPEd behaviour make more sense now - Listing more is better than listing to less things - Especially for your "switch" case.
It's really depending on how people do the work.
View user's profileFind all posts by brainSend private message
Auto Completion Issue
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic