<?
/**
* [test description]
* @param bool|boolean $test [description]
* @return [type] [description]
*/
function test(bool $test = true) : bool {
return false;
}
?>
When a function contains a declared parameter of bool and a default value set to true or false, it get incorrectly detected as boolean and thinks bool is different.
I recommend changing type boolean to bool.
In PHP boolean is a synonym of bool, but boolean values true and false are of type bool.
The importance of adhering to bool over boolean is because:
function test(boolean $test = true){ ... }
would produce a fatal error when the default is used.
References:
https://stackoverflow.com/questions/44009037/php-bool-vs-boolean-type-hinting
https://www.php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration
https://www.php.net/manual/en/language.types.boolean.php
When a function contains a declared parameter of
booland a default value set totrueorfalse, it get incorrectly detected asbooleanand thinksboolis different.I recommend changing type
booleantobool.In PHP
booleanis a synonym ofbool, but boolean valuestrueandfalseare of typebool.The importance of adhering to
booloverbooleanis because:would produce a fatal error when the default is used.
References:
https://stackoverflow.com/questions/44009037/php-bool-vs-boolean-type-hinting
https://www.php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration
https://www.php.net/manual/en/language.types.boolean.php