True¶
true has two usages, as PHP keyword: the opposite of false, as a boolean value and a special type for functions that may return a boolean, but only true, never false.
true as a type was introduced in PHP 8.2.
<?php
function foo($a) : true|A {
if ($a == 1) {
return true;
} else {
return new A();
}
}
?>
See also PHP Boolean: Assigning True or False to a Variable.
Related : Boolean, Type System, False, Logical Operators, Minus One -1, PHP Natives, Standalone Types, Truthy