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

fix(phpstan): improve typehints and resolve phpstan errors

- Added spaces in typehints for readability
- Added `@phpstan-ignore-line` for DEVELOPMENT condition in `setFieldsToAllProducts()` to mitigate
stan error
- Cast `max_execution_time` to int before calling `set_time_limit`
- Typecast integer variables to string in `str_pad` in `execute()` in GenerateProductCache.php for
PHP compatibility
- Added a check for `getCustomDataEntry` method existence before using it in `updateProductPrices`
in UpdatePrices.php for run-time safety.

Related: #397
Übergeordneter 2532c540
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. 15337 fehlgeschlagen
......@@ -71,7 +71,7 @@ class Category extends QUI\QDOM implements QUI\ERP\Products\Interfaces\CategoryI
/**
* @var array|null
*/
protected array|null $defaultSites = [];
protected array | null $defaultSites = [];
/**
* db data
......@@ -259,7 +259,7 @@ public function getParents(): array
*
* @return integer|boolean
*/
public function getParentId(): bool|int
public function getParentId(): bool | int
{
if ($this->getId() === 0) {
return false;
......@@ -295,7 +295,7 @@ public function setParentId(int $parentId): void
* @return bool|QUI\ERP\Products\Interfaces\CategoryInterface
* @throws QUI\Exception
*/
public function getParent(): bool|QUI\ERP\Products\Interfaces\CategoryInterface
public function getParent(): bool | QUI\ERP\Products\Interfaces\CategoryInterface
{
if ($this->getId() === 0) {
return false;
......@@ -349,7 +349,7 @@ public function getAttributes(): array
/**
* @return ViewFrontend|ViewBackend
*/
public function getView(): ViewBackend|ViewFrontend
public function getView(): ViewBackend | ViewFrontend
{
switch ($this->getAttribute('viewType')) {
case 'backend':
......@@ -752,7 +752,7 @@ public function setFieldsToAllProducts(): void
$ExceptionStack = new QUI\ExceptionStack();
foreach ($productIds as $productId) {
if (!DEVELOPMENT) {
if (!DEVELOPMENT) { // @phpstan-ignore-line
set_time_limit(3);
}
......@@ -770,7 +770,7 @@ public function setFieldsToAllProducts(): void
}
// reset time limit
set_time_limit(ini_get('max_execution_time'));
set_time_limit((int)ini_get('max_execution_time'));
QUI::getEvents()->fireEvent(
'onQuiqqerProductsCategorySetFieldsToAllProducts',
......@@ -1084,7 +1084,7 @@ protected function getSiteCacheName(): string
* @param string $key
* @param float|array|int|string|null $value - Must be serializable
*/
public function setCustomDataEntry(string $key, float|array|int|string|null $value): void
public function setCustomDataEntry(string $key, float | array | int | string | null $value): void
{
if (!is_string($value) && !is_numeric($value) && !is_array($value)) {
return;
......
......@@ -98,7 +98,7 @@ public function execute(): void
Products::cleanProductInstanceMemCache();
$out = str_pad($i, mb_strlen($count), '0', STR_PAD_LEFT);
$out = str_pad((string)$i, mb_strlen((string)$count), '0', STR_PAD_LEFT);
$time = date('H:i:s');
$this->writeLn('- ' . $time . ' :: ' . $out . ' of ' . $count);
......
......@@ -83,6 +83,10 @@ public function updateProductPrices(bool $activeOnly = false, ?int $categoryId =
$categories = QUI\ERP\Products\Handler\Categories::getCategories();
foreach ($categories as $Category) {
if (!method_exists($Category, 'getCustomDataEntry')) {
continue;
}
$priceFieldFactors = $Category->getCustomDataEntry('priceFieldFactors');
if (empty($priceFieldFactors)) {
......
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