NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Code completion bug


Joined: 21 Jan 2008
Posts: 19
Reply with quote
Hello.

This is just a little bug.
Code:
function change_status($old, $new)
{
   echo "status change: {$old}->{$new}\n";
}


If I try to code complete $new variable error shows up: Code completion is not available due to the following error(s): Failed to identify type of "$new" local variable.


Last edited by wenihal on Tue Mar 11, 2008 4:34 am; edited 1 time in total
View user's profileFind all posts by wenihalSend private message
Guru master

Joined: 05 Jul 2004
Posts: 659
Location: Belgium
Reply with quote
That is not a bug. How do you expect PHPEd to know the type of the $new variable?
Just add a phpdoc statement before the function to help:
Code:
/**
* @param DataTypeOld [$old] [description]
* @param DataTypeNew [$new] [description]
*/
function change_status($old, $new)
{
   echo "status change: {$old}->{$new}\n";
}
View user's profileFind all posts by BlizzSend private messageVisit poster's website


Joined: 21 Jan 2008
Posts: 19
Reply with quote
Blizz,

How about now:

Code:
function change_status($old, $new)
{
   echo "status change: {$old}->{$ne}\n";
}


Cursor is after "$ne" and if I press ctrl+space I have this error, but should code complete into $new (with $old works).
View user's profileFind all posts by wenihalSend private message
Guru master

Joined: 05 Jul 2004
Posts: 659
Location: Belgium
Reply with quote
Well -> is an operator, so I assume PHPEd attempts to locate a member in the $old variable. Just add spaces between them and try again:
Code:
echo "status change: {$old} -> {$ne}\n";
View user's profileFind all posts by BlizzSend private messageVisit poster's website


Joined: 21 Jan 2008
Posts: 19
Reply with quote
Blizz,

I know that I can add spaces, but I don't want spaces there and it is legal PHP code. It is a bug.

PS. Why somebody changed topic? Is this wrong place to submit bug reports?
View user's profileFind all posts by wenihalSend private message
Guru master

Joined: 05 Jul 2004
Posts: 659
Location: Belgium
Reply with quote
I'm trying to explain to you that it isn't a bug.
PHPEd interprets your code as $old->$ne| (| is the cursor).
So it tries to locate a member in the "object" $old.
You can have it complete the $new by adding spaces in between as I suggested (or by using => instead of -> for example) so that it isn't interpreted as an object anymore.
PS: My reference to "valid code" was meant for the {$old}->{$new} part, as this can be interpreted as a member of an object by php (I think it could even give you problems when you use it like that, since the php interpretor will probably do the same)
View user's profileFind all posts by BlizzSend private messageVisit poster's website


Joined: 21 Jan 2008
Posts: 19
Reply with quote
Blizz,

I understand you, but I'm trying to explain you, that PHPED shouldn't interpret this like $old->$new because of {}. It's just small bug, I can live with that, it's not big deal. Just wanted to report a bug.

Regards
View user's profileFind all posts by wenihalSend private message
Guru master

Joined: 05 Jul 2004
Posts: 659
Location: Belgium
Reply with quote
Just tested it in PHP and it seems that you are right, it does output correctly. My apologies, I thought it would be interpreted differently.
It is a bug then.
View user's profileFind all posts by BlizzSend private messageVisit poster's website
Code completion bug
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