mirror of
https://github.com/Karaka-Management/oms-ItemManagement.git
synced 2026-01-29 12:08:41 +00:00
phpstan fixes
This commit is contained in:
parent
07f6e51962
commit
114da0c417
|
|
@ -19,14 +19,17 @@ use Modules\ItemManagement\Models\Item;
|
|||
use Modules\ItemManagement\Models\ItemAttribute;
|
||||
use Modules\ItemManagement\Models\ItemAttributeMapper;
|
||||
use Modules\ItemManagement\Models\ItemAttributeType;
|
||||
use Modules\ItemManagement\Models\NullItemAttributeType;
|
||||
use Modules\ItemManagement\Models\ItemAttributeTypeL11n;
|
||||
use Modules\ItemManagement\Models\ItemAttributeTypeL11nMapper;
|
||||
use Modules\ItemManagement\Models\ItemAttributeTypeMapper;
|
||||
use Modules\ItemManagement\Models\ItemAttributeValue;
|
||||
use Modules\ItemManagement\Models\NullItemAttributeValue;
|
||||
use Modules\ItemManagement\Models\ItemAttributeValueMapper;
|
||||
use Modules\ItemManagement\Models\ItemL11n;
|
||||
use Modules\ItemManagement\Models\ItemL11nMapper;
|
||||
use Modules\ItemManagement\Models\ItemL11nType;
|
||||
use Modules\ItemManagement\Models\NullItemL11nType;
|
||||
use Modules\ItemManagement\Models\ItemL11nTypeMapper;
|
||||
use Modules\ItemManagement\Models\ItemMapper;
|
||||
use Modules\Media\Models\PathSettings;
|
||||
|
|
@ -149,9 +152,9 @@ final class ApiController extends Controller
|
|||
private function createItemAttributeFromRequest(RequestAbstract $request) : ItemAttribute
|
||||
{
|
||||
$attribute = new ItemAttribute();
|
||||
$attribute->setItem((int) $request->getData('item'));
|
||||
$attribute->setType((int) $request->getData('type'));
|
||||
$attribute->setValue((int) $request->getData('value'));
|
||||
$attribute->item = (int) $request->getData('item');
|
||||
$attribute->type = new NullItemAttributeType((int) $request->getData('type'));
|
||||
$attribute->value = new NullItemAttributeValue((int) $request->getData('value'));
|
||||
|
||||
return $attribute;
|
||||
}
|
||||
|
|
@ -350,7 +353,7 @@ final class ApiController extends Controller
|
|||
$attrValue = $this->createItemAttributeValueFromRequest($request);
|
||||
$this->createModel($request->header->account, $attrValue, ItemAttributeValueMapper::class, 'attr_value', $request->getOrigin());
|
||||
|
||||
if ($attrValue->isDefault()) {
|
||||
if ($attrValue->isDefault) {
|
||||
$this->createModelRelation(
|
||||
$request->header->account,
|
||||
(int) $request->getData('attributetype'),
|
||||
|
|
@ -377,17 +380,17 @@ final class ApiController extends Controller
|
|||
|
||||
$type = $request->getData('type') ?? 0;
|
||||
if ($type === AttributeValueType::_INT) {
|
||||
$attrValue->setValueInt((int) $request->getData('value'));
|
||||
$attrValue->valueInt = (int) $request->getData('value');
|
||||
} elseif ($type === AttributeValueType::_STRING) {
|
||||
$attrValue->setValueString((string) $request->getData('value'));
|
||||
$attrValue->valueStr = (string) $request->getData('value');
|
||||
} elseif ($type === AttributeValueType::_FLOAT) {
|
||||
$attrValue->setValueDecimal((float) $request->getData('value'));
|
||||
$attrValue->valueDec = (float) $request->getData('value');
|
||||
} elseif ($type === AttributeValueType::_DATETIME) {
|
||||
$attrValue->setValueDat(new \DateTime($request->getData('value') ?? ''));
|
||||
$attrValue->valueDat = new \DateTime($request->getData('value') ?? '');
|
||||
}
|
||||
|
||||
$attrValue->setType($type);
|
||||
$attrValue->setDefault((bool) ($request->getData('default') ?? false));
|
||||
$attrValue->type = $type;
|
||||
$attrValue->isDefault = (bool) ($request->getData('default') ?? false);
|
||||
|
||||
if ($request->hasData('language')) {
|
||||
$attrValue->setLanguage((string) ($request->getData('language') ?? $request->getLanguage()));
|
||||
|
|
@ -523,8 +526,8 @@ final class ApiController extends Controller
|
|||
private function createItemL11nFromRequest(RequestAbstract $request) : ItemL11n
|
||||
{
|
||||
$itemL11n = new ItemL11n();
|
||||
$itemL11n->setItem((int) ($request->getData('item') ?? 0));
|
||||
$itemL11n->setType((int) ($request->getData('type') ?? 0));
|
||||
$itemL11n->item = (int) ($request->getData('item') ?? 0);
|
||||
$itemL11n->type = new NullItemL11nType((int) ($request->getData('type') ?? 0));
|
||||
$itemL11n->setLanguage((string) (
|
||||
$request->getData('language') ?? $request->getLanguage()
|
||||
));
|
||||
|
|
|
|||
|
|
@ -43,14 +43,14 @@ class Item
|
|||
*/
|
||||
public string $number = '';
|
||||
|
||||
private $successor = 0;
|
||||
public int $successor = 0;
|
||||
|
||||
private int $type = 0;
|
||||
|
||||
/**
|
||||
* Files.
|
||||
*
|
||||
* @var int[]|Media[]
|
||||
* @var Media[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private array $files = [];
|
||||
|
|
@ -58,7 +58,7 @@ class Item
|
|||
/**
|
||||
* Localizations.
|
||||
*
|
||||
* @var int[]|ItemL11n[]
|
||||
* @var ItemL11n[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private array $l11n = [];
|
||||
|
|
@ -71,11 +71,11 @@ class Item
|
|||
*/
|
||||
private array $attributes = [];
|
||||
|
||||
private $partslist = null;
|
||||
private ?int $partslist = null;
|
||||
|
||||
private $purchase = [];
|
||||
private array $purchase = [];
|
||||
|
||||
private $disposal = null;
|
||||
private ?int $disposal = null;
|
||||
|
||||
/**
|
||||
* Created at.
|
||||
|
|
@ -85,7 +85,7 @@ class Item
|
|||
*/
|
||||
public \DateTimeImmutable $createdAt;
|
||||
|
||||
private $info = '';
|
||||
public string $info = '';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
|
@ -112,6 +112,8 @@ class Item
|
|||
/**
|
||||
* Set the successor item
|
||||
*
|
||||
* @param int $successor Successor item
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
|
|
@ -159,7 +161,7 @@ class Item
|
|||
public function getL11n(string $type) : ItemL11n
|
||||
{
|
||||
foreach ($this->l11n as $l11n) {
|
||||
if ($l11n->getType()->title === $type) {
|
||||
if ($l11n->type->title === $type) {
|
||||
return $l11n;
|
||||
}
|
||||
}
|
||||
|
|
@ -170,13 +172,13 @@ class Item
|
|||
/**
|
||||
* Add media to item
|
||||
*
|
||||
* @param int|Media $media Media
|
||||
* @param Media $media Media
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function addFile($media) : void
|
||||
public function addFile(Media $media) : void
|
||||
{
|
||||
$this->files[] = $media;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,23 +40,23 @@ class ItemAttribute implements \JsonSerializable, ArrayableInterface
|
|||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $item = 0;
|
||||
public int $item = 0;
|
||||
|
||||
/**
|
||||
* Attribute type the attribute belongs to
|
||||
*
|
||||
* @var int|ItemAttributeType
|
||||
* @var ItemAttributeType
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $type = 0;
|
||||
public ItemAttributeType $type;
|
||||
|
||||
/**
|
||||
* Attribute value the attribute belongs to
|
||||
*
|
||||
* @var int|ItemAttributeValue
|
||||
* @var ItemAttributeValue
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $value = 0;
|
||||
public ItemAttributeValue $value;
|
||||
|
||||
/**
|
||||
* Get id
|
||||
|
|
@ -70,48 +70,6 @@ class ItemAttribute implements \JsonSerializable, ArrayableInterface
|
|||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set item
|
||||
*
|
||||
* @param int|Item $item Item
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setItem($item) : void
|
||||
{
|
||||
$this->item = $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set type
|
||||
*
|
||||
* @param int|ItemAttributeType $type Type
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setType($type) : void
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value
|
||||
*
|
||||
* @param int|ItemAttributeValue $type Type
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setValue($value) : void
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class ItemAttributeValue implements \JsonSerializable, ArrayableInterface
|
|||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $type = 0;
|
||||
public int $type = 0;
|
||||
|
||||
/**
|
||||
* Int value
|
||||
|
|
@ -52,7 +52,7 @@ class ItemAttributeValue implements \JsonSerializable, ArrayableInterface
|
|||
* @var null|int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected ?int $valueInt = null;
|
||||
public ?int $valueInt = null;
|
||||
|
||||
/**
|
||||
* String value
|
||||
|
|
@ -60,7 +60,7 @@ class ItemAttributeValue implements \JsonSerializable, ArrayableInterface
|
|||
* @var null|string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected ?string $valueStr = null;
|
||||
public ?string $valueStr = null;
|
||||
|
||||
/**
|
||||
* Decimal value
|
||||
|
|
@ -68,7 +68,7 @@ class ItemAttributeValue implements \JsonSerializable, ArrayableInterface
|
|||
* @var null|float
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected ?float $valueDec = null;
|
||||
public ?float $valueDec = null;
|
||||
|
||||
/**
|
||||
* DateTime value
|
||||
|
|
@ -76,7 +76,7 @@ class ItemAttributeValue implements \JsonSerializable, ArrayableInterface
|
|||
* @var null|\DateTimeInterface
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected ?\DateTimeInterface $valueDat = null;
|
||||
public ?\DateTimeInterface $valueDat = null;
|
||||
|
||||
/**
|
||||
* Is a default value which can be selected
|
||||
|
|
@ -84,7 +84,7 @@ class ItemAttributeValue implements \JsonSerializable, ArrayableInterface
|
|||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected bool $isDefault = false;
|
||||
public bool $isDefault = false;
|
||||
|
||||
/**
|
||||
* Language
|
||||
|
|
@ -131,24 +131,10 @@ class ItemAttributeValue implements \JsonSerializable, ArrayableInterface
|
|||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value type
|
||||
*
|
||||
* @param int $type Type
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setType(int $type) : void
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value
|
||||
*
|
||||
* @param int|string|float $value Value
|
||||
* @param int|string|float|\DateTimeInterface $value Value
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
|
|
@ -167,88 +153,6 @@ class ItemAttributeValue implements \JsonSerializable, ArrayableInterface
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value
|
||||
*
|
||||
* @param int $value Value
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setValueInt(int $value) : void
|
||||
{
|
||||
$this->valueInt = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value
|
||||
*
|
||||
* @param string $value Value
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setValueString(string $value) : void
|
||||
{
|
||||
$this->valueString = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value
|
||||
*
|
||||
* @param float $value Value
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setValueDecimal(float $value) : void
|
||||
{
|
||||
$this->valueDec = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value
|
||||
*
|
||||
* @param \DateTimeInterface $value Value
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setValueDat(\DateTimeInterface $value) : void
|
||||
{
|
||||
$this->valueDat = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default
|
||||
*
|
||||
* @param bool $isDefault Default
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setDefault(bool $isDefault) : void
|
||||
{
|
||||
$this->isDefault = $isDefault;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is default value?
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function isDefault() : bool
|
||||
{
|
||||
return $this->isDefault;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set language
|
||||
*
|
||||
|
|
|
|||
|
|
@ -41,15 +41,15 @@ class ItemL11n implements \JsonSerializable, ArrayableInterface
|
|||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $item = 0;
|
||||
public int $item = 0;
|
||||
|
||||
/**
|
||||
* Item ID.
|
||||
*
|
||||
* @var int|ItemL11nType
|
||||
* @var ItemL11nType
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $type = 0;
|
||||
public ItemL11nType $type;
|
||||
|
||||
/**
|
||||
* Language.
|
||||
|
|
@ -70,15 +70,15 @@ class ItemL11n implements \JsonSerializable, ArrayableInterface
|
|||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param int|ItemL11nType $type Item localization type
|
||||
* @param string $description Description/content
|
||||
* @param string $language Language
|
||||
* @param ItemL11nType $type Item localization type
|
||||
* @param string $description Description/content
|
||||
* @param string $language Language
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct($type = 0, string $description = '', string $language = ISO639x1Enum::_EN)
|
||||
public function __construct(ItemL11nType $type = null, string $description = '', string $language = ISO639x1Enum::_EN)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->type = $type ?? new ItemL11nType();
|
||||
$this->description = $description;
|
||||
$this->language = $language;
|
||||
}
|
||||
|
|
@ -95,58 +95,6 @@ class ItemL11n implements \JsonSerializable, ArrayableInterface
|
|||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set item.
|
||||
*
|
||||
* @param int $item Item id
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setItem(int $item) : void
|
||||
{
|
||||
$this->item = $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get item
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getItem() : int
|
||||
{
|
||||
return $this->item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set type.
|
||||
*
|
||||
* @param int|ItemL11nType $type Item type
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setType($type) : void
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get type
|
||||
*
|
||||
* @return int|ItemL11nType
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get language
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user