NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Code Completion Insight w/ return $this


Joined: 06 Mar 2009
Posts: 5
Reply with quote
A lot of new PHP scripts are using "return $this" at the end of methods to simplify coding. It would be grand if PhpED could recognize that "return $this" returns an object of the current class (or at least a child of).

In this example, the first call to setData() shows up in auto-complete, while the second call does not:
Code:
class Lp_LpAutopromo_Model_Promo extends Mage_Core_Model_Abstract {
  ...
  public function setData($key, $data) {
    ...
    return $this;
  }
  public function loadPost(array $data) {
    $this->setData('name', $data['name'])->setData('title', $data['title']);
    return $this;
  }
}


Thanks for the great product! The co-workers love it, too (after some initial arm-twisting).
View user's profileFind all posts by niaxilinSend private message
Code Completion Insight w/ return $this
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