Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

two or more datatypes in PHPdoc @param

ok I do have this phpdoc above of my class method

/**
 * this a function that translates the text
 * @param string|boolean $lang if string the string given in the parameter will be the language code that will represent the language desired, if true, this will translate based on the website's current language, if false will not translate.
 */

now my problem is, is how I can define the datatype of the $lang that can accept both string and boolean ONLY.

In other documentations I saw mixed but its not reflecting correctly in my Eclipse IDE with PDT.

My question is what is the standard way on how i can display that a certain @param is possible to accept two or more kinds of datatype.

NOTE: the phpdoc i have given is an existing documentation of the application I am working at now. Well I'm assigned for documenting everything well.

like image 247
Netorica Avatar asked Jul 26 '12 05:07

Netorica


1 Answers

You've done it right. The PHPDoc reference gives these two options for parameters that can be multiple data types (emphasis mine).

The datatype should be a valid PHP type (int, string, bool, etc), a class name for the type of object, or simply "mixed". Further, you can list multiple datatypes for a single parameter by delimiting them with the pipe (e.g. "@param int|string $p1").

like image 62
Ian Hunter Avatar answered Oct 12 '22 00:10

Ian Hunter