- **An `&&` or `||` guard narrows the operand beside it wherever the check is written.** The right-hand side of `&&` runs only when the left-hand side held, and the right-hand side of `||` only when it did not, so a check on the left says something about the value the right reads. PHPantom only drew that conclusion when the whole check was an `if`, `while`, or `for` condition or a `return` value. Written anywhere else the guard proved nothing, and the operand beside it was read at the type the guard had just ruled out. That covers most of the places these are written: assigned to a variable (`$ok = is_string($v) && strlen($v) > 0;`), passed as an argument, put in an array, used as a ternary's condition, or nested inside a larger check. A guard now narrows the operands that follow it in every position, so the false type errors those forms produced are gone. It stays a statement about the operands: nothing after the check the guard sits in is affected, exactly as before.
0 commit comments