Skip to content

Commit

Permalink
Some type fixes (pimcore#13789)
Browse files Browse the repository at this point in the history
* some type fixes

* Update models/DataObject/Data/Video.php

Co-authored-by: Sebastian Blank <[email protected]>

Co-authored-by: mcop1 <[email protected]>
Co-authored-by: Sebastian Blank <[email protected]>
  • Loading branch information
3 people authored Dec 14, 2022
1 parent 6fd7e7a commit fba610b
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ public static function getCountByReservation($seriesId = null)
* @param int $length
* @param int|string|null $seriesId
*
* @return null|string
* @return null|int
*/
public static function getCountByLength(int $length, int|string $seriesId = null): ?string
public static function getCountByLength(int $length, int|string $seriesId = null): ?int
{
$query = 'SELECT COUNT(*) as count FROM ' . \Pimcore\Bundle\EcommerceFrameworkBundle\VoucherService\Token\Dao::TABLE_NAME . ' WHERE length = ?';
$params = [$length];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ public function prepareConfigurationView(array &$viewParamsBag, array $params):
$tokens = new Token\Listing();

try {
$tokens->setFilterConditions($params['id'], $params);
$tokens->setFilterConditions((int) $params['id'], $params);
} catch (\Exception $e) {
$this->template = '@PimcoreEcommerceFramework/voucher/voucher_code_tab_error.html.twig';
$viewParamsBag['errors'][] = $e->getMessage() . ' | Error-Code: ' . $e->getCode();
Expand Down Expand Up @@ -578,7 +578,7 @@ public function prepareConfigurationView(array &$viewParamsBag, array $params):
protected function getExportData(array $params): array
{
$tokens = new Token\Listing();
$tokens->setFilterConditions($params['id'], $params);
$tokens->setFilterConditions((int) $params['id'], $params);

$data = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ public function getDataFromEditmode(mixed $data, DataObject\Concrete $object = n
}

$data = $data['data'];
$activeGroups = $data['activeGroups'];
$groupCollectionMapping = $data['groupCollectionMapping'];
$activeGroups = $data['activeGroups'] ?? [];
$groupCollectionMapping = $data['groupCollectionMapping'] ?? [];

$correctedMapping = [];

Expand Down
4 changes: 2 additions & 2 deletions models/DataObject/ClassDefinition/Data/Multiselect.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,12 @@ public function getDataForGrid(?array $data, Concrete $object = null, array $par
* @param null|DataObject\Concrete $object
* @param array $params
*
* @return string
* @return mixed
*
* @see Data::getDataFromEditmode
*
*/
public function getDataFromEditmode(mixed $data, DataObject\Concrete $object = null, array $params = []): string
public function getDataFromEditmode(mixed $data, DataObject\Concrete $object = null, array $params = []): mixed
{
return $data;
}
Expand Down
4 changes: 2 additions & 2 deletions models/DataObject/ClassDefinition/Data/Objectbricks.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,13 @@ private function getDataForField(Objectbrick\Data\AbstractData $item, string $ke
* @param Concrete|null $object
* @param array $params
*
* @return Objectbrick\Data\AbstractData
* @return Objectbrick
*
* @throws \Exception
*
* @see Data::getDataFromEditmode
*/
public function getDataFromEditmode(mixed $data, DataObject\Concrete $object = null, array $params = []): Objectbrick\Data\AbstractData
public function getDataFromEditmode(mixed $data, DataObject\Concrete $object = null, array $params = []): Objectbrick
{
$container = $this->getDataFromObjectParam($object);

Expand Down
2 changes: 1 addition & 1 deletion models/DataObject/ClassDefinition/Data/QuantityValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ public function getDataFromGridEditor(array $data, Concrete $object = null, arra
*/
public function getDataFromEditmode(mixed $data, DataObject\Concrete $object = null, array $params = []): ?Model\DataObject\Data\QuantityValue
{
if (strlen($data['value']) > 0 || $data['unit']) {
if (strlen((string)$data['value']) > 0 || $data['unit']) {
if (empty($data['unit']) || $data['unit'] == -1) {
return new Model\DataObject\Data\QuantityValue($data['value'], null);
}
Expand Down
2 changes: 1 addition & 1 deletion models/DataObject/ClassDefinition/Data/UrlSlug.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function getDataFromEditmode(mixed $data, DataObject\Concrete $object = n
foreach ($data as $siteId => $item) {
$siteId = $item[0];
$slug = $item[1];
$slug = new Model\DataObject\Data\UrlSlug($slug, $siteId);
$slug = new Model\DataObject\Data\UrlSlug($slug, (int) $siteId);

if ($item[2]) {
$slug->setPreviousSlug($item[2]);
Expand Down
2 changes: 1 addition & 1 deletion models/DataObject/ClassDefinition/Data/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function getDataFromResource(mixed $data, Concrete $object = null, array
}
}

return $data;
return $data ? (string) $data : null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion models/DataObject/Data/AbstractQuantityValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function getUnitId(): string|null

public function getUnit(): ?Unit
{
if (empty($this->unit)) {
if (empty($this->unit) && !empty($this->unitId)) {
$this->unit = Unit::getById($this->unitId);
}

Expand Down
6 changes: 3 additions & 3 deletions models/DataObject/Data/Video.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Video implements OwnerAwareFieldInterface

protected string|int|ElementInterface|Asset|\Pimcore\Model\Element\ElementDescriptor $data;

protected string|int|Asset|\Pimcore\Model\Element\ElementDescriptor $poster;
protected string|int|Asset|\Pimcore\Model\Element\ElementDescriptor|null $poster = null;

protected string $title;

Expand Down Expand Up @@ -70,13 +70,13 @@ public function getDescription(): string
return $this->description;
}

public function setPoster(Asset|int|string $poster)
public function setPoster(Asset|int|string|null $poster)
{
$this->poster = $poster;
$this->markMeDirty();
}

public function getPoster(): Asset|int|string
public function getPoster(): Asset|int|string|null
{
return $this->poster;
}
Expand Down
2 changes: 1 addition & 1 deletion models/DataObject/QuantityValue/Unit.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Unit extends Model\AbstractModel

protected string $longname;

protected string $baseunit;
protected ?string $baseunit = null;

protected string $reference;

Expand Down

0 comments on commit fba610b

Please sign in to comment.