---
title: "format/casts/no-short-bool"
pagination: false
---

{/* Generated by scripts/gen-rule-docs.py. Edit mapping.toml, not this file. */}

<RuleId id="format/casts/no-short-bool" />

In the [`format-laravel`](/docs/rules/presets/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

```toml title="pun.toml"
[format.rules]
"casts/no-short-bool" = true
```

To skip it in some files, add a [`@pun-ignore-file`](/docs/configuration/ignore-comments) comment.

## Replaces

- [`no_short_bool_cast`](https://cs.symfony.com/doc/rules/cast_notation/no_short_bool_cast.html) (php-cs-fixer)
- [`ReplaceMultipleBooleanNot`](https://getrector.com/rule-detail/replace-multiple-boolean-not-rector) (rector)
- [`no-short-bool-cast`](https://mago.carthage.software/1.61.0/en/tools/linter/rules/#no-short-bool-cast) (mago-linter)

[More format/casts rules](/docs/rules/format/casts) · [Edit this page](https://github.com/shipfastlabs/pun/edit/main/crates/pun-config/rules/mapping.toml)
