Search code examples
phpphpdoc

In phpdoc comments, is there any way to limit the @var type to a set of allowed values?


In my classes, some 'boolean' values are stored as an integer, acceptable values being 1 or 0. So the actual type is not BOOLEAN, but INT. However, only 1 and 0 are acceptable values. In my phpdoc comment block, I would like to display this. How would I show that the only acceptable values are 1 and 0 as int?

Pseudo Example:

/**
 * @var int{0,1} $isAccepted
 */

Solution

  • You cannot limit ranges in phpDoc. You can only suggest it in the description like so:

    /**
     * @var int $isAccepted Boolean, accepts 1 or 0
     */