I am trying to figure out if it is possible to use PHPdoc to define the object properties being returned by a function or a object method.
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 properties of the output object (of a stdClass) 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?
@return \stdClass holding type, name and age
or explain so in the long description of the Doc Block. At least it's documented then. That won't make your IDE magically know the properties though. – PodiumProductDetails
and then either document it by giving it public properties or by adding @property annotations – Podium@return
for the class? Do we both on the same page? Class can have any number of methods which can return any type results. – Gulfweed@return stdClass
whereby the members of that class are enumerated. – Agostino