-
Notifications
You must be signed in to change notification settings - Fork 274
Open
Description
<?
/**
* [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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels