---
title: "lint/classes/add-stringable"
pagination: false
---

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

<RuleId id="lint/classes/add-stringable" />

In the [`lint-recommended`](/docs/rules/presets/lint-recommended) preset and every stricter one. In Rector's [`rector/php80`](/docs/rules/sets/rector/php80) set. Safe fix.

## What it does

A class that implements the `__toString()` method must explicitly implement the `Stringable` interface.

## Configuration

```toml title="pun.toml"
[lint.rules]
"classes/add-stringable" = "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

- [`stringable_for_to_string`](https://cs.symfony.com/doc/rules/class_notation/stringable_for_to_string.html) (php-cs-fixer)
- [`StringableForToString`](https://getrector.com/rule-detail/stringable-for-to-string-rector) (rector)

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