---
title: "lint/style/prefer-cast-over-settype"
pagination: false
---

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

<RuleId id="lint/style/prefer-cast-over-settype" />

In the [`code-quality`](/docs/rules/sets/code-quality) set. Unsafe fix: it can change behaviour.

## What it does

Cast shall be used, not `settype`.

## Configuration

```toml title="pun.toml"
[lint.rules]
"style/prefer-cast-over-settype" = "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

- [`set_type_to_cast`](https://cs.symfony.com/doc/rules/alias/set_type_to_cast.html) (php-cs-fixer, risky)

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