implement immutable datetime

This commit is contained in:
Dennis Eichhorn 2020-09-10 20:18:46 +02:00
parent 914352a524
commit b17f7a1ce7
2 changed files with 4 additions and 4 deletions

View File

@ -49,7 +49,7 @@ class Comment
* @var \DateTime
* @since 1.0.0
*/
private \DateTime $createdAt;
private \DateTimeImmutable $createdAt;
/**
* Comment list this comment belongs to
@ -107,7 +107,7 @@ class Comment
public function __construct()
{
$this->createdBy = new NullAccount();
$this->createdAt = new \DateTime();
$this->createdAt = new \DateTimeImmutable();
}
/**
@ -311,7 +311,7 @@ class Comment
*
* @since 1.0.0
*/
public function getCreatedAt() : \DateTime
public function getCreatedAt() : \DateTimeInterface
{
return $this->createdAt;
}

View File

@ -42,7 +42,7 @@ final class CommentMapper extends DataMapperAbstract
'comments_comment_list' => ['name' => 'comments_comment_list', 'type' => 'int', 'internal' => 'list'],
'comments_comment_ref' => ['name' => 'comments_comment_ref', 'type' => 'int', 'internal' => 'ref'],
'comments_comment_created_by' => ['name' => 'comments_comment_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
'comments_comment_created_at' => ['name' => 'comments_comment_created_at', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true],
'comments_comment_created_at' => ['name' => 'comments_comment_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
];
/**