Wednesday, 10 October 2018

phpdoc - defining return object variables for a method

I have been searching on this for a while and either I am not using the right search terms or I am missing something.

I am trying to figure out if it is possible to use PHPdoc to define the variables being returned by the object.

Say I have the following class:

class SomeClass {
    public function staffDetails($id){

        $object = new stdClass();
        $object->type = "person";
        $object->name = "dave";
        $object->age = "46";        

        return $object;
    }
}

Now, it is easy enough to define input parameters.

 /**
 * Get Staff Member Details
 * 
 * @param   string  $id    staff id number
 * 
 * @return  object
 */

class SomeClass {
    public function staffDetails($id){
        $object = new stdClass();
        $object->type = "person";
        $object->name = "dave";
        $object->age = "46";        

        return $object;
    }
}

The question is is there a similar thing for defining the output variables of the object returned by the method in question so that another programmer does not have to open this class and manually look into the method to see what the return object is returning?



from phpdoc - defining return object variables for a method

No comments:

Post a Comment