@@ -15,13 +15,16 @@ these comparisons are always made **BY REFERENCE**. That means the following cha
15
15
.. code-block :: php
16
16
17
17
<?php
18
- /** @Entity */
18
+
19
+ use DateTime;
20
+
21
+ #[Entity]
19
22
class Article
20
23
{
21
- /** @ Column(type=" datetime") */
22
- private $updated;
24
+ #[ Column(type=' datetime')]
25
+ private DateTime $updated;
23
26
24
- public function setUpdated()
27
+ public function setUpdated(): void
25
28
{
26
29
// will NOT be saved in the database
27
30
$this->updated->modify("now");
@@ -33,12 +36,14 @@ The way to go would be:
33
36
.. code-block :: php
34
37
35
38
<?php
39
+ use DateTime;
40
+
36
41
class Article
37
42
{
38
- public function setUpdated()
43
+ public function setUpdated(): DateTime
39
44
{
40
45
// WILL be saved in the database
41
- $this->updated = new \ DateTime("now");
46
+ $this->updated = new DateTime("now");
42
47
}
43
48
}
44
49
@@ -84,16 +89,14 @@ the UTC time at the time of the booking and the timezone the event happened in.
84
89
85
90
namespace DoctrineExtensions\DBAL\Types;
86
91
92
+ use DateTimeZone;
87
93
use Doctrine\DBAL\Platforms\AbstractPlatform;
88
94
use Doctrine\DBAL\Types\ConversionException;
89
95
use Doctrine\DBAL\Types\DateTimeType;
90
96
91
97
class UTCDateTimeType extends DateTimeType
92
98
{
93
- /**
94
- * @var \DateTimeZone
95
- */
96
- private static $utc;
99
+ private static DateTimeZone $utc;
97
100
98
101
public function convertToDatabaseValue($value, AbstractPlatform $platform)
99
102
{
@@ -126,10 +129,10 @@ the UTC time at the time of the booking and the timezone the event happened in.
126
129
127
130
return $converted;
128
131
}
129
-
130
- private static function getUtc(): \ DateTimeZone
132
+
133
+ private static function getUtc(): DateTimeZone
131
134
{
132
- return self::$utc ?: self::$utc = new \ DateTimeZone('UTC');
135
+ return self::$utc ?: self::$utc = new DateTimeZone('UTC');
133
136
}
134
137
}
135
138
0 commit comments