Skip to content

Commit 0eca247

Browse files
committed
docs: add sample code
1 parent acedd91 commit 0eca247

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

user_guide_src/source/installation/upgrade_430.rst

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,39 @@ Validation Changes
8383
Time Fixes
8484
==========
8585

86-
Due to bug fixes, some methods in :doc:`Time <../libraries/time>` have changed from mutable behavior to immutable; ``Time`` now extends ``DateTimeImmutable``. See :ref:`ChangeLog <v430-time-fix>` for details.
86+
- Due to bug fixes, some methods in :doc:`Time <../libraries/time>` have changed from mutable behavior to immutable; ``Time`` now extends ``DateTimeImmutable``. See :ref:`ChangeLog <v430-time-fix>` for details.
87+
- If you need the behavior of ``Time`` before the modification, a compatible ``TimeLegacy`` class has been added. Please replace all ``Time`` with ``TimeLegacy`` in your application code.
88+
- But ``TimeLegacy`` is deprecated. So we recommend you update your code.
8789

88-
If you need the behavior of ``Time`` before the modification, a compatible ``TimeLegacy`` class has been added. Please replace all ``Time`` with ``TimeLegacy`` in your application code.
90+
E.g.::
8991

90-
But ``TimeLegacy`` is deprecated. So we recommend you update your code.
92+
// Before
93+
$time = Time::now();
94+
// ...
95+
if ($time instanceof DateTime) {
96+
// ...
97+
}
98+
99+
// After
100+
$time = Time::now();
101+
// ...
102+
if ($time instanceof DateTimeInterface) {
103+
// ...
104+
}
105+
106+
::
107+
108+
// Before
109+
$time1 = new Time('2022-10-31 12:00');
110+
$time2 = $time1->modify('+1 day');
111+
echo $time1; // 2022-11-01 12:00:00
112+
echo $time2; // 2022-11-01 12:00:00
113+
114+
// After
115+
$time1 = new Time('2022-10-31 12:00');
116+
$time2 = $time1->modify('+1 day');
117+
echo $time1; // 2022-10-31 12:00:00
118+
echo $time2; // 2022-11-01 12:00:00
91119

92120
.. _upgrade-430-stream-filter:
93121

0 commit comments

Comments
 (0)