---
title: "lint/style/prefer-self-reference"
pagination: false
---

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

<RuleId id="lint/style/prefer-self-reference" />

Not in any set. Unsafe fix: it can change behaviour.

## What it does

Inside class or interface element `self` should be preferred to the class name itself.

## Configuration

```toml title="pun.toml"
[lint.rules]
"style/prefer-self-reference" = "error"
```

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

## Replaces

- [`self_accessor`](https://cs.symfony.com/doc/rules/class_notation/self_accessor.html) (php-cs-fixer, risky)
- [`prefer-self`](https://mago.carthage.software/1.61.0/en/tools/linter/rules/#prefer-self) (mago-linter)
- [`prefer-self-return-type`](https://mago.carthage.software/1.61.0/en/tools/linter/rules/#prefer-self-return-type) (mago-linter)

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