Per the phpDoc documentation,
@return may contain a set of pipe-delimited return types. The most common use case for this would be error handling when exceptions aren't being used, and code completion in that case is not as useful.
However, we are using code that when an array of ids are passed in, an array of corresponding objects are returned. If a single value is passed in, a single object (not an array of objects) is returned.
Currently, phpEd does not seem to support multiple return type parameters. They work individually, and if a pipe delimiter is used, only the value preceding the pipe is respected by phpEd. This request is for supporting multiple return type functionality with phpDoc comments.
class Something{
/** @var string $id */
public $id;
public function __construct($id){
$this->id = $id;
}
/**
* Get instantiated objects of Something
*
* @var $id string|array Request one or more ids
* @return Something|Something[] Returns a single instance if a single id was passed, else returns an associative array where the key is the id from the array, and the value is a Something object instance.
public static function get($id){
if(is_array($id)){
$return = array();
foreach($id AS $i){
$return[$i] = new Something($i);
}
return $return;
}
return new Something($id);
}
}
|