Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -10860,12 +10860,6 @@ parameters:
count: 1
path: src/lib/Persistence/Legacy/Content/FieldValue/Converter/CountryConverter.php

-
message: '#^Cannot access offset ''timestamp'' on array\|bool\|float\|int\|string\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: src/lib/Persistence/Legacy/Content/FieldValue/Converter/DateAndTimeConverter.php

-
message: '#^Method Ibexa\\Core\\Persistence\\Legacy\\Content\\FieldValue\\Converter\\DateAndTimeConverter\:\:getDateIntervalFromXML\(\) should return DateInterval but empty return statement found\.$#'
identifier: return.empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function toStorageValue(FieldValue $value, StorageFieldValue $storageFiel
{
// @todo: One should additionally store the timezone here. This could

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are SO CLOSE to this. Can we drop that comment? ;)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I just remove it?
Or somehow store the timezone here? 😅

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove it.

// be done in a backwards compatible way, I think…
$storageFieldValue->dataInt = ($value->data !== null ? $value->data['timestamp'] : null);
$storageFieldValue->dataInt = is_array($value->data) ? ($value->data['timestamp'] ?? null) : null;
$storageFieldValue->sortKeyInt = (int)$value->sortKey;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

Check warning on line 1 in tests/lib/Persistence/Legacy/Content/FieldValue/Converter/DateAndTimeTest.php

View workflow job for this annotation

GitHub Actions / Run code style check (8.3)

Found violation(s) of type: single_blank_line_before_namespace

Check warning on line 1 in tests/lib/Persistence/Legacy/Content/FieldValue/Converter/DateAndTimeTest.php

View workflow job for this annotation

GitHub Actions / Run code style check (8.3)

Found violation(s) of type: header_comment

Check warning on line 1 in tests/lib/Persistence/Legacy/Content/FieldValue/Converter/DateAndTimeTest.php

View workflow job for this annotation

GitHub Actions / Run code style check (8.3)

Found violation(s) of type: trailing_comma_in_multiline

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
Expand Down Expand Up @@ -84,6 +84,45 @@
self::assertSame($storageFieldValue->sortKeyInt, $fieldValue->sortKey);
}

/**
* @return mixed[]
*/
public function providerForTestToStorageValueMissingData(): array
{
return [
[
[
'current_time' => 1048633200,
'rfc850' => 'Thu, 01 Jan 2003 00:00:00 GMT',
],
Comment on lines +94 to +97

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to wrap it in several arrays?

],
[
null,
]
];
}

/**
* @group fieldType
* @group dateTime
*
* @dataProvider providerForTestToStorageValueMissingData
*
* @param mixed[]|null $data
*/
public function testToStorageValueNoTimestampKey(?array $data): void
{
$value = new FieldValue();
$value->data = $data;
$value->sortKey = $this->date->getTimestamp();
$storageFieldValue = new StorageFieldValue();

$this->converter->toStorageValue($value, $storageFieldValue);
self::assertNull($storageFieldValue->dataInt);
self::assertSame($value->sortKey, $storageFieldValue->sortKeyInt);
self::assertSame('', $storageFieldValue->sortKeyString);
}

/**
* @group fieldType
* @group dateTime
Expand Down
Loading