Skip to content

Commit

Permalink
chore: composer update
Browse files Browse the repository at this point in the history
Fixed phpstan issue:

 ------ -----------------------------------------------------------------------------------------------------------------------------
  Line   EMS/core-bundle/src/Form/DataField/TimeFieldType.php
 ------ -----------------------------------------------------------------------------------------------------------------------------
  46     Parameter #1 $value of function strval expects bool|float|int|resource|string|null, array|bool|float|int|string|null given.
  94     Parameter #1 $value of function strval expects bool|float|int|resource|string|null, array|bool|float|int|string|null given.
  108    Parameter #1 $value of function strval expects bool|float|int|resource|string|null, array|bool|float|int|string|null given.
 ------ -----------------------------------------------------------------------------------------------------------------------------
  • Loading branch information
Davidmattei committed May 30, 2023
1 parent 536174a commit 73f018f
Show file tree
Hide file tree
Showing 3 changed files with 337 additions and 396 deletions.
10 changes: 5 additions & 5 deletions EMS/core-bundle/src/Form/DataField/TimeFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public function importData(DataField $dataField, array|string|int|float|bool|nul
$format = $dataField->giveFieldType()->getMappingOptions()['format'];
$format = DateFieldType::convertJavaDateFormat($format);

$timeObject = \DateTime::createFromFormat($format, \strval($sourceArray));
$timeObject = !\is_array($sourceArray) ? \DateTime::createFromFormat($format, \strval($sourceArray)) : false;
if ($timeObject) {
$dataField->setRawData($timeObject->format(\DateTimeInterface::ISO8601));
$dataField->setRawData($timeObject->format(\DateTimeInterface::ATOM));
} else {
$dataField->addMessage('Not able to parse the date');
}
Expand Down Expand Up @@ -85,8 +85,8 @@ public function viewTransform(DataField $dataField)
{
$out = parent::viewTransform($dataField);

if (\is_array($out) && 0 === \count($out)) {
return ''; // empty array means null/empty
if (\is_array($out)) {
return '';
}

$format = static::getFormat($dataField->giveFieldType()->getOptions());
Expand All @@ -105,7 +105,7 @@ public function viewTransform(DataField $dataField)
public function reverseViewTransform($data, FieldType $fieldType): DataField
{
$format = static::getFormat($fieldType->getOptions());
$converted = \DateTime::createFromFormat($format, \strval($data));
$converted = !\is_array($data) ? \DateTime::createFromFormat($format, \strval($data)) : false;
if ($converted) {
$out = $converted->format($this::STOREFORMAT);
} else {
Expand Down
Loading

0 comments on commit 73f018f

Please sign in to comment.