NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Code completion for arrays...
Veteran

Joined: 22 Feb 2006
Posts: 106
Reply with quote
Hi,

I've just a quick question (maybe a newbie one), but how can I use the code completion on an object that is stored in a session or in an array.

For example, with the following code :

$obj =new MyClass();
$ar[0] = $obj;
foreach($ar as $id=>$obj)
{
echo $obj->getId();
}


In this case, $obj is not recognized as an object of MyClass class.

Do you have any advice ? Should I cast the variable to get it worked ?

Thanks in advance for the answer ! I would help me a lot.
View user's profileFind all posts by medifirstSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8340
Reply with quote
I'd recommend you to use type hints, like suggested there http://forum.nusphere.com/tip-type-hints-t1563.html

Code:
$obj =new MyClass();
$ar[0] = $obj;
foreach($ar as $id=>$obj)
{
  /**
  * @var MyClass
  */
  echo $obj->getId();
}


View user's profileFind all posts by dmitriSend private messageVisit poster's website
Veteran

Joined: 22 Feb 2006
Posts: 106
Reply with quote
Thanks SO MUCH for this quick answer !!

I can't tell how I love phpEd (my girldfriend will soon be jalous !) and how I appreciate coming everyday on this forum to see the new Q/A.

Thanks to your reactivity, it helps a lot to get answers to their problems so fast !

I'll recommand more than ever to everyone I know this almost-perfect IDE and the Nusphere support, which should be a model for all other software sellers !
View user's profileFind all posts by medifirstSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8340
Reply with quote
BTW, did you try version 4.5?
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Veteran

Joined: 22 Feb 2006
Posts: 106
Reply with quote
I just got it installed... I'll tell you as soon as I'll try it !
View user's profileFind all posts by medifirstSend private message
Code completion for arrays...
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