---
title: "lint/style/no-short-ternary"
pagination: false
---

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

<RuleId id="lint/style/no-short-ternary" />

In the [`coding-style`](/docs/rules/sets/coding-style) set. Report only. Upstream gates: `strictRules.disallowedShortTernary`.

## What it does

Detects the use of the shorthand ternary and elvis operators.

## Configuration

```toml title="pun.toml"
[lint.rules]
"style/no-short-ternary" = "error"
```

To skip it in some files or lines, add an [override](/docs/configuration/pun-toml#lint) or an [ignore comment](/docs/configuration/ignore-comments).

## Replaces

- [`DisallowedShortTernaryRule`](https://github.com/phpstan/phpstan-strict-rules#readme) (phpstan-classes)
- [`no-shorthand-ternary`](https://mago.carthage.software/1.61.0/en/tools/linter/rules/#no-shorthand-ternary) (mago-linter)
- [`ternary.shortNotAllowed`](https://phpstan.org/error-identifiers/ternary.shortNotAllowed) (phpstan-strict-rules)

## Linked rules

- Conflicts with [`lint/style/prefer-short-ternary`](/docs/rules/lint/style/prefer-short-ternary). You cannot enable both.

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