phpDocumentor phpDocumentor
[ class tree: phpDocumentor ] [ index: phpDocumentor ] [ all elements ]
Prev Next
@return

@return

Specify the return type of a function or method

by Gregory Beaver
Tag Documentation written by [email protected]
Copyright 2002, Gregory Beaver
(phpDocumentor 0.1+)
@return datatype description

Description

The @return tag is used to document the return value of functions or methods. @returns is an alias for @return to support tag formats of other automatic documentors

datatype should be a valid PHP type, a class name or "mixed." If a class name is used in the @return tag, phpDocumentor will automatically create a link to that class's documentation. In addition, if a function returns multiple possible values, separate them using the | character, and phpDocumentor will parse out any class names in the return value. phpDocumentor will display the optional description unmodified

Example

Here's an example:

  1. /**
  2.  * example of basic @return usage
  3.  * @return mixed 
  4.  */
  5. function function1($baz)
  6. {
  7.    if ($baz)
  8.    {
  9.       $a 5;
  10.    else
  11.    {
  12.       $a array(1,4);
  13.    }
  14.    return $a;
  15. }
  16.  
  17. class class1
  18. {
  19.    /**
  20.     * example of documenting a method, and using optional description with @return
  21.     * @return string de-html_entitied string (no entities at all)
  22.     */
  23.    function bar($foo)
  24.    {
  25.       return strtr($foo,array_flip(get_html_translation_table(HTML_ENTITIES)));
  26.    }
  27.    
  28.    /**
  29.     * example of using @return with a class name
  30.     * @param integer even or odd integer
  31.     * @return Parser|falsephpDocumentor Parser object or error
  32.     */
  33.    function &factory($number)
  34.    {
  35.       $returnval true;
  36.       if ($number 2)
  37.       {
  38.           $returnval new Parser;
  39.       else
  40.       {
  41.           $returnval false;
  42.       }
  43.       return $returnval;
  44.    }
  45. }

Prev Up Next
@param phpDocumentor tags @see

Documentation generated on Tue, 24 Oct 2006 09:20:10 -0500 by phpDocumentor 1.3.1