NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
db_dataobject factory code insight


Joined: 19 Jul 2006
Posts: 1
Reply with quote
Hi, I am demo'ing your product right now and came across something that I would really like to have, if it is not already possible....

I use the Pear DB_DataObject library quite a bit. That library uses a ::factory('CLASSNAME') method to create new instances of the DataObject class. The class name passed to it loads a seperate class file that inherits from DB_DataObject. The problem is, as far as I can tell, that using this method, the code insight tool doesnt know what the return value is, cause it dynamically instantiated.

I already read this FAQ posting and it did not seem to answer the question, since the return class type will be different every time.
http://forum.nusphere.com/tip-type-hints-t1563.html

So is this possible with NuSphere? Or could it be implemented down the road? If it does have it I will buy it today! I work with a lot of DataObject classes, and having the code insight work for those would be awesome.

Thanks,
Mike
View user's profileFind all posts by megaladonSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
there are two possible ways and both are covered there:
code-insite-with-methods-having-mixed-return-values-t2249.html

In short, either add /** return DataObject */ phpdoc before the factory's method,
or /** @var <real object class> */ before the assignment, like below:

/** @var SomeClass */
$my=factory::createInstance('SomeClass');
$my->| // code completion will work for $my
View user's profileFind all posts by dmitriSend private messageVisit poster's website
db_dataobject factory code insight
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