Skip to content
Code-Schnipsel Gruppen Projekte
Commit 0ce4a5f4 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

fix: code cleanup and minor corrections

Made several code corrections and clean up in `AttributeGroup.php`,
`AttributeGroupFrontendView.php`, `Folder.php`, `InputMultiLang.php`, `MultilangFrontendView.php`,
`Price.php`, `ProductAttributeList.php`, `TimePeriod.php`, `VatFrontendView.php`, `UniqueField.php`.
These changes consist of fixes in unions type declarations, rearrangements of conditions, removal
of unnecessary typecasts, and small alterations for better readability and performance.

Related: #397
Übergeordneter 6fbd1af5
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
2 Merge Requests!108Update 'next-3.x' with latest changes from 'main',!107refactor(phpstan): utils classes adapted to phpstan
Pipeline-Nr. 15335 fehlgeschlagen
werden angezeigt mit 29 Ergänzungen und 27 Löschungen
......@@ -36,7 +36,7 @@ class AttributeGroup extends QUI\ERP\Products\Field\Field
/**
* @var int|bool
*/
protected int|bool $searchDataType = Search::SEARCHDATATYPE_TEXT;
protected int | bool $searchDataType = Search::SEARCHDATATYPE_TEXT;
protected mixed $defaultValue = null;
......@@ -162,7 +162,7 @@ public function hideEntries(): void
*
* @param integer|string $entry
*/
public function disableEntry(int|string $entry): void
public function disableEntry(int | string $entry): void
{
$this->options['entries'][$entry]['disabled'] = true;
}
......@@ -172,7 +172,7 @@ public function disableEntry(int|string $entry): void
*
* @param integer|string $entry
*/
public function enableEntry(int|string $entry): void
public function enableEntry(int | string $entry): void
{
$this->options['entries'][$entry]['disabled'] = false;
}
......@@ -182,7 +182,7 @@ public function enableEntry(int|string $entry): void
*
* @param integer|string $entry
*/
public function showEntry(int|string $entry): void
public function showEntry(int | string $entry): void
{
$this->options['entries'][$entry]['hide'] = false;
}
......@@ -378,6 +378,8 @@ public function cleanup(mixed $value): mixed
}
if (is_array($value)) {
$check = $value;
if (!isset($check[0]) || !isset($check[1])) {
return null;
}
......
......@@ -136,9 +136,9 @@ public function create(): string
$userInput = '';
if (
$value === null && isset($option['selected']) && $option['selected']
$option['selected']
|| $value === $option['valueId']
|| is_numeric($value) && (int)$value === $option['valueId']
|| (int)$value === $option['valueId']
) {
$selected = 'selected="selected" ';
}
......
......@@ -143,7 +143,10 @@ public function isEmpty(): bool
return true;
}
return ($MediaFolder->getFiles(['count' => true]) + $MediaFolder->getImages(['count' => true])) < 1;
$filesCount = (int)$MediaFolder->getFiles(['count' => true]);
$imagesCount = (int)$MediaFolder->getImages(['count' => true]);
return ($filesCount + $imagesCount) < 1;
}
/**
......
......@@ -32,7 +32,7 @@
class InputMultiLang extends QUI\ERP\Products\Field\Field
{
protected string $columnType = 'TEXT';
protected int|bool $searchDataType = Search::SEARCHDATATYPE_TEXT;
protected int | bool $searchDataType = Search::SEARCHDATATYPE_TEXT;
/**
* @return View
......@@ -96,10 +96,6 @@ public function getValueByLocale(?Locale $Locale = null): string
return current($value);
}
if (is_string($value)) {
return $value;
}
return '';
}
......
......@@ -26,7 +26,6 @@ public function create(): string
$Engine = QUI::getTemplateManager()->getEngine();
/** @var UnitSelect $Field */
$value = $this->getValue();
$current = QUI::getLocale()->getCurrent();
$value = $value[$current] ?? $value[0];
......
......@@ -36,7 +36,7 @@ class Price extends QUI\ERP\Products\Field\Field
/**
* @var int|bool
*/
protected int|bool $searchDataType = Search::SEARCHDATATYPE_NUMERIC;
protected int | bool $searchDataType = Search::SEARCHDATATYPE_NUMERIC;
/**
* Official currency code (i.e. EUR)
......@@ -215,7 +215,7 @@ public function getDefaultSearchType(): string
* @param float|integer $max
* @return array - contains values from min to max with calculated steps inbetween
*/
public function calculateValueRange(null|float|int $min, null|float|int $max): array
public function calculateValueRange(null | float | int $min, null | float | int $max): array
{
if (!$min) {
$min = 0;
......@@ -235,7 +235,7 @@ public function calculateValueRange(null|float|int $min, null|float|int $max): a
// round down to lowest 10 (e.g.: 144 = 140; 2554 = 2550)
$floorPrecision = 1;
if ((string)mb_strlen((int)$min) > 1) {
if (mb_strlen((string)$min) > 1) {
$floorPrecision = 10;
}
......
......@@ -153,7 +153,7 @@ public function addEntry(array $entry = []): void
*
* @return string|false
*/
public function getUserInput(): bool|string
public function getUserInput(): bool | string
{
if (!is_null($this->value)) {
$value = json_decode($this->value, true);
......@@ -390,7 +390,7 @@ public function validate($value): void
* @param mixed $value
* @return string|array|int|null
*/
public function cleanup(mixed $value): string|array|int|null
public function cleanup(mixed $value): string | array | int | null
{
if ($value === '') {
return null;
......@@ -424,6 +424,8 @@ public function cleanup(mixed $value): string|array|int|null
}
if (is_array($value)) {
$check = $value;
if (!isset($check[0]) || !isset($check[1])) {
return null;
}
......@@ -462,7 +464,7 @@ public function disableEntries(): void
*
* @param integer|string $entry
*/
public function disableEntry(int|string $entry): void
public function disableEntry(int | string $entry): void
{
$this->options['entries'][$entry]['disabled'] = true;
}
......@@ -472,7 +474,7 @@ public function disableEntry(int|string $entry): void
*
* @param integer|string $entry
*/
public function enableEntry(int|string $entry): void
public function enableEntry(int | string $entry): void
{
$this->options['entries'][$entry]['disabled'] = false;
}
......
......@@ -62,7 +62,7 @@ public function getJavaScriptControl(): string
* Check the value
* is the value valid for the field type?
*
* @param mixed< $value
* @param mixed $value
* @throws Exception
*/
public function validate(mixed $value): void
......
......@@ -29,7 +29,7 @@ public function create(): string
return '';
}
$value = $this->getValue();
$value = (int)$this->getValue();
$taxTitle = '---';
if ($value >= 0) {
......
......@@ -49,7 +49,7 @@ class UniqueField implements QUI\ERP\Products\Interfaces\UniqueFieldInterface
* Field title
* @var string|array
*/
protected string|array $title;
protected string | array $title;
/**
* @var string
......@@ -97,7 +97,7 @@ class UniqueField implements QUI\ERP\Products\Interfaces\UniqueFieldInterface
*
* @var string|array|null
*/
protected string|array|null $searchvalue;
protected string | array | null $searchvalue;
/**
* is field public
......@@ -388,7 +388,7 @@ public function getName(): string
}
/**
* @return string|array
* @return mixed
*/
public function getValue(): mixed
{
......@@ -448,7 +448,7 @@ public function getOptions(): array
* @param Locale|null $Locale
* @return string|array|null
*/
public function getSearchCacheValue(null | QUI\Locale $Locale = null): null|string|array
public function getSearchCacheValue(null | QUI\Locale $Locale = null): null | string | array
{
return $this->searchvalue;
}
......@@ -547,7 +547,7 @@ public function getAttributes(): array
protected function getValueText(): string
{
if (isset($this->custom_calc['valueText'])) {
if (!is_string($this->custom_calc['valueText'])) {
if (is_string($this->custom_calc['valueText'])) {
return $this->custom_calc['valueText'];
}
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren