---
title: "lint/php-8.6/prefer-readonly-property-default"
pagination: false
---

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

<RuleId id="lint/php-8.6/prefer-readonly-property-default" />

In the [`lint-strict`](/docs/rules/presets/lint-strict) preset. In Rector's [`rector/php86`](/docs/rules/sets/rector/php86) set. Unsafe fix: it can change behavior. Runs only when `[php] version` is 8.6 or later.

## What it does

Move a constant constructor assignment of a readonly property to a property default value

## Configuration

```toml title="pun.toml"
[lint.rules]
"php-8.6/prefer-readonly-property-default" = "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

- [`ConstructorReadonlyAssignToDefault`](https://getrector.com/rule-detail/constructor-readonly-assign-to-default-rector) (rector)

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