Class DateTimeImmutable should be used instead of DateTime.
Risky when the code relies on modifying DateTime objects or if any of the
date_create* functions are overridden.
--- Original
+++ New
<?php
-new DateTime();
+new DateTimeImmutable();- Fixer class: PhpCsFixer\Fixer\ClassUsage\DateTimeImmutableFixer
- Test class: PhpCsFixer\Tests\Fixer\ClassUsage\DateTimeImmutableFixerTest
The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.