NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Code completition


Joined: 31 Jan 2008
Posts: 19
Reply with quote
Hello i'm working with build 12021. I use phped in a magento project.
I noticed that objects in a foreach loop does not resolve correctly.

Code:
/**
* @var IDPerso_Ads_Model_Mysql4_SubscriptionConfig_Collection
*/
$configs = Mage::getModel('idads/subscriptionconfig')->getCollection();
foreach($configs as $config)
{
       /**
        * @var IDPerso_Ads_Model_SubscriptionConfig
        */
        $config;

        //$config is resolved to an ArrayIterator and not to IDPerso_Ads_Model_SubscriptionConfig

}



I already refresh the includes of the project.


Thank you for helping
View user's profileFind all posts by keemanSend private message
Guru master

Joined: 24 Jul 2009
Posts: 737
Reply with quote
You probably need to declare the variable before it is assigned, which is before the for loop:

Code:
/**
* @var IDPerso_Ads_Model_Mysql4_SubscriptionConfig_Collection
*/
$configs = Mage::getModel('idads/subscriptionconfig')->getCollection();
/**
 * @var $config IDPerso_Ads_Model_SubscriptionConfig
*/
foreach($configs as $config)
{
        $config;

}


Like you, I often assign the collection to a variable (easier for debugging), but you can shorten like this if $configs is not used elsewhere:

Code:
/** @var $config IDPerso_Ads_Model_SubscriptionConfig */
foreach(Mage::getModel('idads/subscriptionconfig')->getCollection() as $config)
{
        $config;

}
View user's profileFind all posts by plugnplaySend private message


Joined: 31 Jan 2008
Posts: 19
Reply with quote
Thank you it works.

But the way i coded in my first post worked with older version of phped.
View user's profileFind all posts by keemanSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
If you provide more complete sample illustrating your case, it would be clearer what's up.
I think @var IDPerso_Ads_Model_Mysql4_SubscriptionConfig_Collection would be enough if this is a class implementing iterator with known reference type returned by current() method

As of includes in the project, you do not have to refresh them. Refresh in Code Explorer is always enough. Includes play role only and only if "limit scope to includes" is turned on and we recommend to keep it turned off (meaning do not limit scope to includes)

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Code completition
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