---
title: "format/types/nullable-for-null-default"
pagination: false
---

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

<RuleId id="format/types/nullable-for-null-default" />

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

## What it does

Adds or removes `?` before single type declarations or `|null` at the end of union types when parameters have a default `null` value.

## Configuration

```toml title="pun.toml"
[format.rules]
"types/nullable-for-null-default" = 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 |
| --- | --- | --- | --- | --- |
| `use-nullable-type-declaration` | `bool` | Any | `true` | `use_nullable_type_declaration` |

## Replaces

- [`nullable_type_declaration_for_default_null_value`](https://cs.symfony.com/doc/rules/function_notation/nullable_type_declaration_for_default_null_value.html) (php-cs-fixer)
- [`ExplicitNullableParamType`](https://getrector.com/rule-detail/explicit-nullable-param-type-rector) (rector)
- [`explicit-nullable-param`](https://mago.carthage.software/1.61.0/en/tools/linter/rules/#explicit-nullable-param) (mago-linter)
- [`parameter.implicitlyNullable`](https://phpstan.org/error-identifiers/parameter.implicitlyNullable) (phpstan)

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