Darghon Posted February 6, 2013 Share Posted February 6, 2013 Hello all, My question isn't about php, but the php docs. I have several php classes that extend a base class. This class has a static method that returns a object based on the extending class that calls this method How can I add php docs that my editor knows that when I call this function on 1 class, that I get a object of a specific class in return? Right now I'm passing the "super" class of that object, but it would to great to be more accurate. If the above explenation isn't clear, this is a example of what I want to do php class User extends BusinessClass php class FUser extends FinderClass when I call User::Find() => autocomplete shows info of FinderClass I want it to show info of FUser. current code: /** * Static function that creates a "Find" static function to each business object, which in turn is basicly a shortkey to get The Findertype, or when an ID is passed, to get the object by that ID * @return BusinessClass|FinderClass */ final public static function & Find($id = null) { Adding the following line above my User class result in the correct object types, but the function is no longer detected as available in autocomplete /** * @method User|FUser Find(Integer $id) Find a object by ID, or return the object finder. */ Autocomplete on "User::" no longer shows Find as a available function Thx for any help Quote Link to comment https://forums.phpfreaks.com/topic/274097-php-docs-help/ Share on other sites More sharing options...
trq Posted February 6, 2013 Share Posted February 6, 2013 Firstly, these comments are *annotations* not php docs. Secondly, a User should not be extending a Business or some *finder* utility. This design smells bad. Thirdly, we would need to know what editor your using and how this editor implements it's reading of annotations to be able to help. There is no *standard* in regards to these things. Quote Link to comment https://forums.phpfreaks.com/topic/274097-php-docs-help/#findComment-1410414 Share on other sites More sharing options...
Darghon Posted February 6, 2013 Author Share Posted February 6, 2013 (edited) I'm using netbeans, And a little insight on my class structure A object/model has 3 layers (mapped to a database record) a business layer with all functions to work with this object a datalayer with all raw variables mapped to the record in the database (with input validation etc) a finderlayer with statements that retrieve records from the database, and return initialised business objects to the requester. so the user table for instance has: a User class which extends globale business function from the businesslayer a DUser class which extends globale data functions from the datalayer, and is added as a protected variable in the business model a FUser class which extends globale finder functions from the finderlayer so lets say I add a method to find a user by email address (byEmail($email)) to the FUser I'll be able to retrieve all users with that email address by the following statement: $users = User::Find()->byEmail($email); Edited February 6, 2013 by Darghon Quote Link to comment https://forums.phpfreaks.com/topic/274097-php-docs-help/#findComment-1410416 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.