---
title: "lint/style/prefer-date-time-immutable"
pagination: false
---

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

<RuleId id="lint/style/prefer-date-time-immutable" />

Not in any set. Unsafe fix: it can change behaviour. Intent: suspicious.

## What it does

Class `DateTimeImmutable` should be used instead of `DateTime`.

## Configuration

```toml title="pun.toml"
[lint.rules]
"style/prefer-date-time-immutable" = "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

- [`date_time_immutable`](https://cs.symfony.com/doc/rules/class_usage/date_time_immutable.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)
