The expression $format of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.
In PHP, under loose comparison (like ==, or !=, or switch conditions),
values of different types might be equal.
For string values, the empty string '' is a special case, in particular
the following results might be unexpected:
''==false// true''==null// true'ab'==false// false'ab'==null// false// It is often better to use strict comparison''===false// false''===null// false
Loading history...
31
$date->format($format) :
32
$date
33
;
34
}
35
36
/**
37
* Returns object created at.
38
*
39
* @param string $format optional date format
40
*
41
* @return \DateTime|string
42
*/
43
public function getCreatedAt($format = null)
44
{
45
return $this->formatDateTime(
46
$this->createdAt,
47
$format
48
);
49
}
50
51
/**
52
* Define object created at.
53
*
54
* @param \DateTime $createdAt
55
*
56
* @return self
57
*/
58
public function setCreatedAt(\DateTime $createdAt)
59
{
60
$this->createdAt = $createdAt;
61
62
return $this;
63
}
64
65
/**
66
* Returns object updated at.
67
*
68
* @param string $format optional date format
69
*
70
* @return \DateTime|string
71
*/
72
public function getUpdatedAt($format = null)
73
{
74
return $this->formatDateTime(
75
$this->updatedAt,
76
$format
77
);
78
}
79
80
/**
81
* Define object updated at.
82
*
83
* @param \DateTime $updatedAt
84
*
85
* @return self
86
*/
87
public function setUpdatedAt(\DateTime $updatedAt)
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: