diff --git a/Models/QAAnswer.php b/Models/QAAnswer.php index fa1ba27..86b1f42 100755 --- a/Models/QAAnswer.php +++ b/Models/QAAnswer.php @@ -83,7 +83,7 @@ class QAAnswer implements \JsonSerializable * @var \DateTime * @since 1.0.0 */ - private \DateTime $createdAt; + private \DateTimeImmutable $createdAt; /** * Constructor. @@ -92,7 +92,7 @@ class QAAnswer implements \JsonSerializable */ public function __construct() { - $this->createdAt = new \DateTime('now'); + $this->createdAt = new \DateTimeImmutable('now'); $this->createdBy = new NullAccount(); $this->question = new NullQAQuestion(); } @@ -246,7 +246,7 @@ class QAAnswer implements \JsonSerializable * * @since 1.0.0 */ - public function getCreatedAt() : \DateTime + public function getCreatedAt() : \DateTimeInterface { return $this->createdAt; } diff --git a/Models/QAAnswerMapper.php b/Models/QAAnswerMapper.php index b2e7812..a472056 100755 --- a/Models/QAAnswerMapper.php +++ b/Models/QAAnswerMapper.php @@ -40,7 +40,7 @@ final class QAAnswerMapper extends DataMapperAbstract 'qa_answer_status' => ['name' => 'qa_answer_status', 'type' => 'int', 'internal' => 'status'], 'qa_answer_accepted' => ['name' => 'qa_answer_accepted', 'type' => 'bool', 'internal' => 'isAccepted'], 'qa_answer_created_by' => ['name' => 'qa_answer_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true], - 'qa_answer_created_at' => ['name' => 'qa_answer_created_at', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true], + 'qa_answer_created_at' => ['name' => 'qa_answer_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true], ]; /** diff --git a/Models/QAQuestion.php b/Models/QAQuestion.php index e3b7784..231e6e7 100755 --- a/Models/QAQuestion.php +++ b/Models/QAQuestion.php @@ -84,7 +84,7 @@ class QAQuestion implements \JsonSerializable * @var \DateTime * @since 1.0.0 */ - private \DateTime $createdAt; + private \DateTimeImmutable $createdAt; /** * Badges. @@ -109,7 +109,7 @@ class QAQuestion implements \JsonSerializable */ public function __construct() { - $this->createdAt = new \DateTime('now'); + $this->createdAt = new \DateTimeImmutable('now'); $this->createdBy = new NullAccount(); } @@ -324,7 +324,7 @@ class QAQuestion implements \JsonSerializable * * @since 1.0.0 */ - public function getCreatedAt() : \DateTime + public function getCreatedAt() : \DateTimeInterface { return $this->createdAt; } diff --git a/Models/QAQuestionMapper.php b/Models/QAQuestionMapper.php index 4d00227..1d9958f 100755 --- a/Models/QAQuestionMapper.php +++ b/Models/QAQuestionMapper.php @@ -41,7 +41,7 @@ final class QAQuestionMapper extends DataMapperAbstract 'qa_question_status' => ['name' => 'qa_question_status', 'type' => 'int', 'internal' => 'status'], 'qa_question_category' => ['name' => 'qa_question_category', 'type' => 'int', 'internal' => 'category'], 'qa_question_created_by' => ['name' => 'qa_question_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true], - 'qa_question_created_at' => ['name' => 'qa_question_created_at', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true], + 'qa_question_created_at' => ['name' => 'qa_question_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true], ]; /** diff --git a/tests/Models/QAAnswerTest.php b/tests/Models/QAAnswerTest.php index 416e067..7c9495a 100755 --- a/tests/Models/QAAnswerTest.php +++ b/tests/Models/QAAnswerTest.php @@ -34,7 +34,7 @@ class QAAnswerTest extends \PHPUnit\Framework\TestCase self::assertFalse($answer->isAccepted()); self::assertEquals(QAAnswerStatus::ACTIVE, $answer->getStatus()); self::assertEquals(0, $answer->getCreatedBy()->getId()); - self::assertInstanceOf('\DateTime', $answer->getCreatedAt()); + self::assertInstanceOf('\DateTimeImmutable', $answer->getCreatedAt()); } public function testSetGet() : void diff --git a/tests/Models/QAQuestionTest.php b/tests/Models/QAQuestionTest.php index 563c903..c5d9526 100755 --- a/tests/Models/QAQuestionTest.php +++ b/tests/Models/QAQuestionTest.php @@ -35,7 +35,7 @@ class QAQuestionTest extends \PHPUnit\Framework\TestCase self::assertEquals(0, $question->getCategory()->getId()); self::assertEquals('', $question->getLanguage()); self::assertEquals(0, $question->getCreatedBy()->getId()); - self::assertInstanceOf('\DateTime', $question->getCreatedAt()); + self::assertInstanceOf('\DateTimeImmutable', $question->getCreatedAt()); self::assertEquals([], $question->getBadges()); }