---
title: "format/control-flow/yoda"
pagination: false
---

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

<RuleId id="format/control-flow/yoda" />

In the [`format-laravel`](/docs/rules/presets/format-laravel) preset. Safe fix.

## What it does

Write conditions in Yoda style (`true`), non-Yoda style (`['equal' => false, 'identical' => false, 'less_and_greater' => false]`) or ignore those conditions (`null`) based on configuration.

## Configuration

```toml title="pun.toml"
[format.rules]
"control-flow/yoda" = true
```

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

## Options

| Name | Type | Allowed values | Default | Upstream name |
| --- | --- | --- | --- | --- |
| `always-move-variable` | `bool` | Any | `false` | `always_move_variable` |
| `equal` | `bool` | Any | `true` | `equal` |
| `identical` | `bool` | Any | `true` | `identical` |
| `less-and-greater` | `bool` | Any | `"ignore"` | `less_and_greater` |

## Replaces

- [`yoda_style`](https://cs.symfony.com/doc/rules/control_structure/yoda_style.html) (php-cs-fixer)
- [`yoda-conditions`](https://mago.carthage.software/1.61.0/en/tools/linter/rules/#yoda-conditions) (mago-linter)

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