Skip to content

Latest commit

 

History

History
32 lines (23 loc) · 642 Bytes

date_time_immutable.rst

File metadata and controls

32 lines (23 loc) · 642 Bytes

Rule date_time_immutable

Class DateTimeImmutable should be used instead of DateTime.

Warning

Using this rule is risky

Risky when the code relies on modifying DateTime objects or if any of the date_create* functions are overridden.

Examples

Example #1

--- Original
+++ New
 <?php
-new DateTime();
+new DateTimeImmutable();

Source class

PhpCsFixer\Fixer\ClassUsage\DateTimeImmutableFixer