Skip to content
Esc
↑↓navigate↵open⌘Jpreview
On this page

format/casts/no-short-bool

In the format-laravel preset. Safe fix.

What it does

Short cast bool using double exclamation mark should not be used.

Why

(bool) binds tighter than instanceof, but ! does not. So !!$a instanceof Foo is true when $a is a Foo, while the rewritten (bool) $a instanceof Foo is always false. Pint rewrites it the same way. Write !!($a instanceof Foo) to keep the check.

Configuration

[format.rules]
"casts/no-short-bool" = true

To skip it in some files, add a @pun-ignore-file comment.

Replaces

More format/casts rules · Edit this page

Last updated on

Was this page helpful?