Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an PHPDoc type hint for an boolean parameter?

Tags:

php

phpdoc

I wasn't able to find an overview of the types which can be hinted with PHPDoc. I know array or string, but is there also bool? Like:

/**
 * @param bool loadLazy
 * @return array Array with objects
 */
public function getObjects($loadLazy=false) {
like image 987
openfrog Avatar asked Jan 04 '10 16:01

openfrog


2 Answers

As a "type hint" is only a "hint", I would say you can use pretty much whatever you like.

Still, I tend to use the types that are found in the official PHP manual -- which means, for a Boolean, I would use boolean.

like image 71
Pascal MARTIN Avatar answered Oct 01 '22 08:10

Pascal MARTIN


According to the documentation, you can use any valid PHP type, class names, or mixed. You can also list multiple types by separating them with a | (e.g., @param int|bool $var)

like image 34
Jordan Ryan Moore Avatar answered Oct 01 '22 10:10

Jordan Ryan Moore