---
title: "format/classes/modifier-keywords"
pagination: false
---

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

<RuleId id="format/classes/modifier-keywords" />

In the [`format-laravel`](/docs/rules/presets/format-laravel) and [`format-psr12`](/docs/rules/presets/format-psr12) presets. Safe fix.

## What it does

Classes, constants, properties, and methods MUST have visibility declared, and keyword modifiers MUST be in the following order: inheritance modifier (`abstract` or `final`), visibility modifier (`public`, `protected`, or `private`), set-visibility modifier (`public(set)`, `protected(set)`, or `private(set)`), scope modifier (`static`), mutation modifier (`readonly`), type declaration, name.

## Configuration

```toml title="pun.toml"
[format.rules]
"classes/modifier-keywords" = true
```

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

## Options

| Name | Type | Allowed values | Default | Upstream name |
| --- | --- | --- | --- | --- |
| `elements` | `list` | `const`, `method`, `property` | `["const", "method", "property"]` | `elements` |

## Replaces

- [`modifier_keywords`](https://cs.symfony.com/doc/rules/class_notation/modifier_keywords.html) (php-cs-fixer)
- [`VarToPublicProperty`](https://getrector.com/rule-detail/var-to-public-property-rector) (rector)

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