tags:

views:

36

answers:

2

I've got a function, which (for example) returns true if access is allowed, false when access is denied, and NULL when access is indeterminate.

What should the @return phpdoc be? bool doesn't seem to make sense...

+4  A: 
@return bool|null

See here:

The datatype should be a valid PHP type (int, string, bool, etc), a class name for the type of object returned, or simply "mixed". If you want to explicitly show multiple possible return types, list them pipe-delimited without spaces (e.g. "@return int|string").

Artefacto
Is `null` a valid php type? I thought `null` was absence of type...
Billy ONeal
@Billy http://www.php.net/manual/en/language.types.null.php
Gordon
+2  A: 

If you want to follow php.net style about the return type. When there is multiple possibility of return data type, they use the type mixed.

Example :

http://ca2.php.net/manual/en/function.array-rand.php

HoLyVieR
How the manual describes it is unrelated to PHPDoc, although in this matter it coincides.
Artefacto