---
title: "lint/complexity/no-redundant-nullsafe"
pagination: false
---

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

<RuleId id="lint/complexity/no-redundant-nullsafe" />

In the [`code-quality`](/docs/rules/sets/code-quality) set. Safe fix.

## What it does

Flags the use of the nullsafe operator (`?->`) in contexts where its null-checking behavior is redundant.

## Configuration

```toml title="pun.toml"
[lint.rules]
"complexity/no-redundant-nullsafe" = "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

- [`Pun/no_redundant_nullsafe`](https://mago.carthage.software/1.61.0/en/tools/linter/rules/) (pun)
- [`NullsafeMethodCallRule`](https://phpstan.org/error-identifiers/nullsafe.neverNull) (phpstan-classes)
- [`NullsafePropertyFetchRule`](https://phpstan.org/error-identifiers/nullsafe.neverNull) (phpstan-classes)
- [`no-redundant-nullsafe`](https://mago.carthage.software/1.61.0/en/tools/linter/rules/#no-redundant-nullsafe) (mago-linter)
- [`RedundantNullsafeOperator`](https://mago.carthage.software/1.61.0/en/tools/analyzer/overview/) (mago-analyzer)
- [`nullsafe.neverNull`](https://phpstan.org/error-identifiers/nullsafe.neverNull) (phpstan)

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