Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Type contains both true and false, bool must be used instead

Description

PHP has several types. They may combined to provide the same type safety one another: PHP reports those situations, and prevents them.

Here, the bool type represents true|false. So, when both true and false are used in the type, they should be replaced with bool.

bool|true or bool|false yields another error; bool&true is not possible, at all.

Example

<?php

function foo() : int|true|false {}

?>

Alternatives

  • Use the bool type instead.
  • Remove the usage of either true or false, or both.