---
title: "lint/classes/no-null-property-default"
pagination: false
---

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

<RuleId id="lint/classes/no-null-property-default" />

In the [`dead-code`](/docs/rules/sets/dead-code) set. Safe fix.

## What it does

Properties MUST not be explicitly initialised with `null` except when they have a type declaration (PHP 7.4).

## Configuration

```toml title="pun.toml"
[lint.rules]
"classes/no-null-property-default" = "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

- [`no_null_property_initialization`](https://cs.symfony.com/doc/rules/class_notation/no_null_property_initialization.html) (php-cs-fixer)
- [`RemoveNullPropertyInitialization`](https://getrector.com/rule-detail/remove-null-property-initialization-rector) (rector)
- [`no-null-property-init`](https://mago.carthage.software/1.61.0/en/tools/linter/rules/#no-null-property-init) (mago-linter)

## Merged rules

These old IDs are now this rule. A config that still names one stops with an error. See [merged rules](/docs/migrate/merged-rules).

- `lint/classes/no-null-property-init`

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