Skip to content

Commit

Permalink
Non-nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed Jun 26, 2024
1 parent 868924c commit 31708c8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/en/reference/custom-mapping-types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ a ``DateTimeImmutable``.
// This trait provides default closureToPHP used during data hydration
use ClosureToPHP;
public function convertToPHPValue($value): ?DateTimeImmutable
public function convertToPHPValue($value): DateTimeImmutable
{
$timeZone = new DateTimeZone($value['tz']);
$dateTime = $value['utc']
Expand All @@ -41,7 +41,7 @@ a ``DateTimeImmutable``.
return DateTimeImmutable::createFromMutable($dateTime);
}
public function convertToDatabaseValue($value): ?array
public function convertToDatabaseValue($value): array
{
return [
'utc' => new UTCDateTime($value),
Expand Down
13 changes: 11 additions & 2 deletions tests/Documentation/CustomMapping/DateTimeWithTimezoneType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Documentation\CustomMapping;

use DateTimeImmutable;
use DateTimeInterface;
use DateTimeZone;
use Doctrine\ODM\MongoDB\Types\ClosureToPHP;
use Doctrine\ODM\MongoDB\Types\Type;
Expand All @@ -15,7 +16,10 @@ class DateTimeWithTimezoneType extends Type
// This trait provides default closureToPHP used during data hydration
use ClosureToPHP;

public function convertToPHPValue($value): ?DateTimeImmutable
/**

Check failure on line 19 in tests/Documentation/CustomMapping/DateTimeWithTimezoneType.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.3)

Found multi-line doc comment with single line content, use one-line doc comment instead.
* @param array{utc: UTCDateTime, tz: string} $value
*/
public function convertToPHPValue($value): DateTimeImmutable
{
$timeZone = new DateTimeZone($value['tz']);
$dateTime = $value['utc']
Expand All @@ -25,7 +29,12 @@ public function convertToPHPValue($value): ?DateTimeImmutable
return DateTimeImmutable::createFromMutable($dateTime);
}

public function convertToDatabaseValue($value): ?array
/**
* @param DateTimeInterface $value
*
* @return array{utc: UTCDateTime, tz: string}
*/
public function convertToDatabaseValue($value): array
{
return [
'utc' => new UTCDateTime($value),
Expand Down

0 comments on commit 31708c8

Please sign in to comment.