diff --git a/.phive/phars.xml b/.phive/phars.xml index 5bfa092bfad10dad9d23240281a5a2041acb815b..cccdab55e6792f5161b502854bef53c1667a4add 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <phive xmlns="https://phar.io/phive"> - <phar name="phpstan" version="1.11.8" installed="1.11.8" location="./tools/phpstan" copy="false"/> + <phar name="phpstan" version="1.*" installed="1.12.13" location="./tools/phpstan" copy="false"/> <phar name="phpunit" version="^10.5.20" installed="10.5.20" location="./tools/phpunit" copy="false"/> <phar name="phpcs" version="^3.10.1" installed="3.10.1" location="./tools/phpcs" copy="false"/> <phar name="phpcbf" version="^3.10.1" installed="3.10.1" location="./tools/phpcbf" copy="false"/> diff --git a/ajax/backend/rules/getRules.php b/ajax/backend/rules/getRules.php index 0d0b73421c014ce337f141f6d86dba286275a513..d35aaa8e7416f5014a9d2841b73b5bc19888a2ca 100644 --- a/ajax/backend/rules/getRules.php +++ b/ajax/backend/rules/getRules.php @@ -9,6 +9,9 @@ * * @return array */ + +use QUI\System\Log; + QUI::$Ajax->registerFunction( 'package_quiqqer_shipping_ajax_backend_rules_getRules', function ($ruleIds) { @@ -25,28 +28,20 @@ function ($ruleIds) { try { $result[] = $Rules->getChild($ruleId)->toArray(); } catch (QUI\Exception $Exception) { - \QUI\System\Log::addDebug($Exception); + Log::addDebug($Exception); } } // sort by priority usort($result, function ($a, $b) { - if (!isset($a['priority'])) { - $a['priority'] = 0; - } - - if (!isset($b['priority'])) { - $b['priority'] = 0; - } - - $priorityA = (int)$a['priority']; - $priorityB = (int)$b['priority']; + $priorityA = $a['priority'] ?? 0; + $priorityB = $b['priority'] ?? 0; if ($priorityA === $priorityB) { - return $a['id'] > $b['priority']; + return $a['id'] <=> $b['id']; } - return $priorityA > $priorityB; + return $priorityB <=> $priorityA; }); return $result; diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 8fb0e0c1fd0a752576f1be8c94d6c729b2be9921..7ab43eb86f19b5ea36b23971411ffa9db7d8a240 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,261 +1,62 @@ parameters: - ignoreErrors: - - - message: "#^Parameter \\#2 \\$callback of function usort expects callable\\(array, array\\)\\: int, Closure\\(mixed, mixed\\)\\: bool given\\.$#" - count: 1 - path: ajax/backend/rules/getRules.php - - - - message: "#^Call to an undefined method QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry\\:\\:setTitle\\(\\)\\.$#" - count: 1 - path: ajax/backend/rules/update.php - - - - message: "#^Call to an undefined method QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry\\:\\:setWorkingTitle\\(\\)\\.$#" - count: 1 - path: ajax/backend/rules/update.php - - - - message: "#^Parameter \\$Invoice of method QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry\\:\\:getInvoiceInformationText\\(\\) has invalid type QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\Invoice\\.$#" - count: 2 - path: src/QUI/ERP/Shipping/Api/AbstractShippingEntry.php - - - - message: "#^Parameter \\$Invoice of method QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry\\:\\:getInvoiceInformationText\\(\\) has invalid type QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\InvoiceTemporary\\.$#" - count: 2 - path: src/QUI/ERP/Shipping/Api/AbstractShippingEntry.php - - - - message: "#^Parameter \\$Invoice of method QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry\\:\\:getInvoiceInformationText\\(\\) has invalid type QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\InvoiceView\\.$#" - count: 2 - path: src/QUI/ERP/Shipping/Api/AbstractShippingEntry.php - - - - message: "#^Call to an undefined method QUI\\\\ERP\\\\Order\\\\AbstractOrder\\:\\:save\\(\\)\\.$#" - count: 5 - path: src/QUI/ERP/Shipping/EventHandler.php - - - - message: "#^Call to method addCustomDataEntry\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\InvoiceTemporary\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/EventHandler.php - - - - message: "#^Call to method addCustomDataEntry\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Offers\\\\AbstractOffer\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/EventHandler.php - - - - message: "#^Call to method getArticles\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\InvoiceTemporary\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/EventHandler.php - - - - message: "#^Call to method getArticles\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Offers\\\\AbstractOffer\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/EventHandler.php - - - - message: "#^Call to method getArticles\\(\\) on an unknown class QUI\\\\ERP\\\\SalesOrders\\\\SalesOrder\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/EventHandler.php - - - - message: "#^Call to method getCustomDataEntry\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\InvoiceTemporary\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/EventHandler.php - - - - message: "#^Call to method getCustomDataEntry\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Offers\\\\AbstractOffer\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/EventHandler.php - - - - message: "#^Call to method getGlobalProcessId\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\InvoiceTemporary\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/EventHandler.php - - - - message: "#^Call to method getGlobalProcessId\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Offers\\\\AbstractOffer\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/EventHandler.php - - - - message: "#^Call to method getGlobalProcessId\\(\\) on an unknown class QUI\\\\ERP\\\\SalesOrders\\\\SalesOrder\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/EventHandler.php - - - - message: "#^Call to method update\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\InvoiceTemporary\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/EventHandler.php - - - - message: "#^Call to method update\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Offers\\\\AbstractOffer\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/EventHandler.php - - - - message: "#^Call to method update\\(\\) on an unknown class QUI\\\\ERP\\\\SalesOrders\\\\SalesOrder\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/EventHandler.php - - - - message: "#^Negated boolean expression is always false\\.$#" - count: 2 - path: src/QUI/ERP/Shipping/EventHandler.php - - - - message: "#^Offset 'options' does not exist on array\\{title\\: array\\{de\\: 'Lieferzeit', en\\: 'Delivery time'\\}, type\\: 'shipping…', public\\: true, standard\\: true\\}\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/EventHandler.php - - - - message: "#^Offset 'options' on array\\{title\\: array\\{de\\: 'Lieferzeit', en\\: 'Delivery time'\\}, type\\: 'shipping…', public\\: true, standard\\: true\\} in empty\\(\\) does not exist\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/EventHandler.php - - - - message: "#^Offset 'public' on array\\{title\\: array\\{de\\: 'Lieferzeit', en\\: 'Delivery time'\\}, type\\: 'shipping…', public\\: true, standard\\: true\\} in empty\\(\\) always exists and is not falsy\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/EventHandler.php - - - - message: "#^Offset 'standard' on array\\{title\\: array\\{de\\: 'Lieferzeit', en\\: 'Delivery time'\\}, type\\: 'shipping…', public\\: true, standard\\: true\\} in empty\\(\\) always exists and is not falsy\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/EventHandler.php - - - - message: "#^Parameter \\#1 \\$Locale of method QUI\\\\ERP\\\\Shipping\\\\Types\\\\ShippingEntry\\:\\:toPriceFactor\\(\\) expects null, QUI\\\\Locale given\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/EventHandler.php - - - - message: "#^Parameter \\$Offer of method QUI\\\\ERP\\\\Shipping\\\\EventHandler\\:\\:onQuiqqerOffersCreated\\(\\) has invalid type QUI\\\\ERP\\\\Accounting\\\\Offers\\\\AbstractOffer\\.$#" - count: 2 - path: src/QUI/ERP/Shipping/EventHandler.php - - - - message: "#^Parameter \\$Sales of method QUI\\\\ERP\\\\Shipping\\\\EventHandler\\:\\:onQuiqqerSalesOrdersCreated\\(\\) has invalid type QUI\\\\ERP\\\\SalesOrders\\\\SalesOrder\\.$#" - count: 2 - path: src/QUI/ERP/Shipping/EventHandler.php - - - - message: "#^Parameter \\$TemporaryInvoice of method QUI\\\\ERP\\\\Shipping\\\\EventHandler\\:\\:onQuiqqerInvoiceTemporaryInvoiceCreated\\(\\) has invalid type QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\InvoiceTemporary\\.$#" - count: 2 - path: src/QUI/ERP/Shipping/EventHandler.php - - - - message: "#^Negated boolean expression is always false\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/Methods/Digital/ShippingType.php - - - - message: "#^Negated boolean expression is always false\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/Methods/Standard/ShippingType.php - - - - message: "#^Call to an undefined method QUI\\\\ERP\\\\Order\\\\AbstractOrder\\:\\:save\\(\\)\\.$#" - count: 2 - path: src/QUI/ERP/Shipping/Order/Shipping.php - - - - message: "#^Method QUI\\\\ERP\\\\Shipping\\\\Products\\\\Fields\\\\ShippingTimeFrontendView\\:\\:getValue\\(\\) should return array\\|string but returns null\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/Products/Fields/ShippingTimeFrontendView.php - - - - message: "#^Variable \\$Field in PHPDoc tag @var does not match assigned variable \\$value\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/Products/Fields/ShippingTimeFrontendView.php - - - - message: "#^Return type \\(QUI\\\\ERP\\\\Shipping\\\\Products\\\\Fields\\\\ShippingTimeFrontendView\\) of method QUI\\\\ERP\\\\Shipping\\\\Products\\\\Fields\\\\ShippingTimePeriod\\:\\:getFrontendView\\(\\) should be compatible with return type \\(QUI\\\\ERP\\\\Products\\\\Field\\\\Types\\\\UnitSelectFrontendView\\) of method QUI\\\\ERP\\\\Products\\\\Field\\\\Types\\\\TimePeriod\\:\\:getFrontendView\\(\\)$#" - count: 1 - path: src/QUI/ERP/Shipping/Products/Fields/ShippingTimePeriod.php - - - - message: "#^Method QUI\\\\ERP\\\\Shipping\\\\Rules\\\\Factory\\:\\:createChild\\(\\) should return QUI\\\\ERP\\\\Shipping\\\\Rules\\\\ShippingRule but returns QUI\\\\CRUD\\\\Child\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/Rules/Factory.php - - - - message: "#^Method QUI\\\\ERP\\\\Shipping\\\\Rules\\\\Factory\\:\\:getChild\\(\\) should return QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry but returns QUI\\\\CRUD\\\\Child\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/Rules/Factory.php - - - - message: "#^Call to an undefined method QUI\\\\ERP\\\\ErpEntityInterface\\:\\:count\\(\\)\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/Rules/ShippingRule.php - - - - message: "#^Parameter \\#1 \\$precision of method QUI\\\\ERP\\\\Accounting\\\\CalculationValue\\:\\:precision\\(\\) expects bool, int given\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/Rules/ShippingRule.php - - - - message: "#^Parameter \\#2 \\$key of method QUI\\\\Config\\:\\:setValue\\(\\) expects string\\|null, int given\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/ShippingStatus/Factory.php - - - - message: "#^Parameter \\#2 \\$key of method QUI\\\\Config\\:\\:del\\(\\) expects string\\|null, int given\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/ShippingStatus/Handler.php - - - - message: "#^Parameter \\#2 \\$key of method QUI\\\\Config\\:\\:setValue\\(\\) expects string\\|null, int given\\.$#" - count: 2 - path: src/QUI/ERP/Shipping/ShippingStatus/Handler.php - - - - message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed\\)\\: bool\\)\\|null, Closure\\(mixed\\)\\: int given\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/Tracking/Tracking.php - - - - message: "#^Call to an undefined method QUI\\\\CRUD\\\\Child\\:\\:getShippingType\\(\\)\\.$#" - count: 2 - path: src/QUI/ERP/Shipping/Types/Factory.php - - - - message: "#^Method QUI\\\\ERP\\\\Shipping\\\\Types\\\\Factory\\:\\:createChild\\(\\) should return QUI\\\\ERP\\\\Shipping\\\\Types\\\\ShippingEntry but returns QUI\\\\CRUD\\\\Child\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/Types/Factory.php - - - - message: "#^Method QUI\\\\ERP\\\\Shipping\\\\Types\\\\Factory\\:\\:getChild\\(\\) should return QUI\\\\ERP\\\\Shipping\\\\Types\\\\ShippingEntry but returns QUI\\\\CRUD\\\\Child\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/Types/Factory.php - - - - message: "#^Call to an undefined method QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry\\:\\:canUsedIn\\(\\)\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/Types/ShippingEntry.php - - - - message: "#^Call to an undefined method QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry\\:\\:getPriority\\(\\)\\.$#" - count: 2 - path: src/QUI/ERP/Shipping/Types/ShippingEntry.php - - - - message: "#^Call to an undefined method QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry\\:\\:isValid\\(\\)\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/Types/ShippingEntry.php - - - - message: "#^Call to an undefined method QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry\\:\\:noRulesAfter\\(\\)\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/Types/ShippingEntry.php - - - - message: "#^Method QUI\\\\ERP\\\\Shipping\\\\Types\\\\ShippingEntry\\:\\:getShippingRules\\(\\) should return array\\<QUI\\\\ERP\\\\Shipping\\\\Rules\\\\ShippingRule\\> but returns array\\<int\\<0, max\\>, QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry\\>\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/Types/ShippingEntry.php - - - - message: "#^Parameter \\#1 \\$Rule of method QUI\\\\ERP\\\\Shipping\\\\Types\\\\ShippingEntry\\:\\:addShippingRule\\(\\) expects QUI\\\\ERP\\\\Shipping\\\\Rules\\\\ShippingRule, QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry given\\.$#" - count: 1 - path: src/QUI/ERP/Shipping/Types/ShippingEntry.php + ignoreErrors: + - + message: "#^Parameter \\$Invoice of method QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry::getInvoiceInformationText\\(\\) has invalid type QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\Invoice\\.$#" + path: src/QUI/ERP/Shipping/Api/AbstractShippingEntry.php + - + message: "#^Parameter \\$Invoice of method QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry::getInvoiceInformationText\\(\\) has invalid type QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\InvoiceTemporary\\.$#" + path: src/QUI/ERP/Shipping/Api/AbstractShippingEntry.php + - + message: "#^Parameter \\$Invoice of method QUI\\\\ERP\\\\Shipping\\\\Api\\\\AbstractShippingEntry::getInvoiceInformationText\\(\\) has invalid type QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\InvoiceView\\.$#" + path: src/QUI/ERP/Shipping/Api/AbstractShippingEntry.php + - + message: "#^Parameter \\$TemporaryInvoice of method QUI\\\\ERP\\\\Shipping\\\\EventHandler::onQuiqqerInvoiceTemporaryInvoiceCreated\\(\\) has invalid type QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\InvoiceTemporary\\.$#" + path: src/QUI/ERP/Shipping/EventHandler.php + - + message: "#^Call to method getCustomDataEntry\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\InvoiceTemporary\\.$#" + path: src/QUI/ERP/Shipping/EventHandler.php + - + message: "#^Call to method getGlobalProcessId\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\InvoiceTemporary\\.$#" + path: src/QUI/ERP/Shipping/EventHandler.php + - + message: "#^Call to method getArticles\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\InvoiceTemporary\\.$#" + path: src/QUI/ERP/Shipping/EventHandler.php + - + message: "#^Call to method addCustomDataEntry\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\InvoiceTemporary\\.$#" + path: src/QUI/ERP/Shipping/EventHandler.php + - + message: "#^Call to method update\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Invoice\\\\InvoiceTemporary\\.$#" + path: src/QUI/ERP/Shipping/EventHandler.php + - + message: "#^Parameter \\$Offer of method QUI\\\\ERP\\\\Shipping\\\\EventHandler::onQuiqqerOffersCreated\\(\\) has invalid type QUI\\\\ERP\\\\Accounting\\\\Offers\\\\AbstractOffer\\.$#" + path: src/QUI/ERP/Shipping/EventHandler.php + - + message: "#^Call to method getCustomDataEntry\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Offers\\\\AbstractOffer\\.$#" + path: src/QUI/ERP/Shipping/EventHandler.php + - + message: "#^Call to method getGlobalProcessId\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Offers\\\\AbstractOffer\\.$#" + path: src/QUI/ERP/Shipping/EventHandler.php + - + message: "#^Call to method getArticles\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Offers\\\\AbstractOffer\\.$#" + path: src/QUI/ERP/Shipping/EventHandler.php + - + message: "#^Call to method addCustomDataEntry\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Offers\\\\AbstractOffer\\.$#" + path: src/QUI/ERP/Shipping/EventHandler.php + - + message: "#^Call to method update\\(\\) on an unknown class QUI\\\\ERP\\\\Accounting\\\\Offers\\\\AbstractOffer\\.$#" + path: src/QUI/ERP/Shipping/EventHandler.php + - + message: "#^Parameter \\$Sales of method QUI\\\\ERP\\\\Shipping\\\\EventHandler::onQuiqqerSalesOrdersCreated\\(\\) has invalid type QUI\\\\ERP\\\\SalesOrders\\\\SalesOrder\\.$#" + path: src/QUI/ERP/Shipping/EventHandler.php + - + message: "#^Call to method getGlobalProcessId\\(\\) on an unknown class QUI\\\\ERP\\\\SalesOrders\\\\SalesOrder\\.$#" + path: src/QUI/ERP/Shipping/EventHandler.php + - + message: "#^Call to method getArticles\\(\\) on an unknown class QUI\\\\ERP\\\\SalesOrders\\\\SalesOrder\\.$#" + path: src/QUI/ERP/Shipping/EventHandler.php + - + message: "#^Call to method update\\(\\) on an unknown class QUI\\\\ERP\\\\SalesOrders\\\\SalesOrder\\.$#" + path: src/QUI/ERP/Shipping/EventHandler.php + - + message: "#^Return type \\(QUI\\\\ERP\\\\Shipping\\\\Products\\\\Fields\\\\ShippingTimeFrontendView\\) of method QUI\\\\ERP\\\\Shipping\\\\Products\\\\Fields\\\\ShippingTimePeriod::getFrontendView\\(\\) should be compatible with return type \\(QUI\\\\ERP\\\\Products\\\\Field\\\\Types\\\\UnitSelectFrontendView\\) of method QUI\\\\ERP\\\\Products\\\\Field\\\\Types\\\\TimePeriod::getFrontendView\\(\\)\\s*$#" + path: src/QUI/ERP/Shipping/Products/Fields/ShippingTimePeriod.php \ No newline at end of file diff --git a/src/QUI/ERP/Shipping/Api/AbstractShippingEntry.php b/src/QUI/ERP/Shipping/Api/AbstractShippingEntry.php index cdf860c8fdefac07508ff81899eab05afecf84ed..f2d14e80b2e6ffa549e19197d07a20d8f1e6aeff 100644 --- a/src/QUI/ERP/Shipping/Api/AbstractShippingEntry.php +++ b/src/QUI/ERP/Shipping/Api/AbstractShippingEntry.php @@ -92,7 +92,7 @@ abstract public function getTitle($Locale = null): string; * @param null|QUI\Locale $Locale * @return string */ - abstract public function getDescription(QUI\Locale $Locale = null): string; + abstract public function getDescription(null | QUI\Locale $Locale = null): string; /** * @return string @@ -146,7 +146,7 @@ public function isVisible(): bool * @return string */ public function getInvoiceInformationText( - QUI\ERP\Accounting\Invoice\Invoice|QUI\ERP\Accounting\Invoice\InvoiceTemporary|QUI\ERP\Accounting\Invoice\InvoiceView $Invoice + QUI\ERP\Accounting\Invoice\Invoice | QUI\ERP\Accounting\Invoice\InvoiceTemporary | QUI\ERP\Accounting\Invoice\InvoiceView $Invoice ): string { return ''; } diff --git a/src/QUI/ERP/Shipping/Api/AbstractShippingType.php b/src/QUI/ERP/Shipping/Api/AbstractShippingType.php index a53354a79cb10428e8baaf9ffe9ff881b04cc7b6..3141e78bd3ae202a6034c5d1b991156c1cf8ca5f 100644 --- a/src/QUI/ERP/Shipping/Api/AbstractShippingType.php +++ b/src/QUI/ERP/Shipping/Api/AbstractShippingType.php @@ -30,7 +30,7 @@ public function getType(): string * @param QUI\Locale|null $Locale * @return array */ - public function toArray(QUI\Locale $Locale = null): array + public function toArray(null | QUI\Locale $Locale = null): array { if ($Locale === null) { $Locale = QUI::getLocale(); @@ -46,7 +46,7 @@ public function toArray(QUI\Locale $Locale = null): array * @param QUI\Locale|null $Locale * @return string */ - abstract public function getTitle(QUI\Locale $Locale = null): string; + abstract public function getTitle(null | QUI\Locale $Locale = null): string; /** * @return string diff --git a/src/QUI/ERP/Shipping/Api/ShippingInterface.php b/src/QUI/ERP/Shipping/Api/ShippingInterface.php index c96c5a2bcbf1981ab888aefa79713f1d07f83952..57bb2f6767683e7c046aa9998a1df6414fdb3208 100644 --- a/src/QUI/ERP/Shipping/Api/ShippingInterface.php +++ b/src/QUI/ERP/Shipping/Api/ShippingInterface.php @@ -18,19 +18,19 @@ interface ShippingInterface /** * @return int|string */ - public function getId(): int|string; + public function getId(): int | string; /** * @param null|QUI\Locale $Locale * @return string */ - public function getTitle(QUI\Locale $Locale = null): string; + public function getTitle(null | QUI\Locale $Locale = null): string; /** * @param null|QUI\Locale $Locale * @return string */ - public function getDescription(QUI\Locale $Locale = null): string; + public function getDescription(null | QUI\Locale $Locale = null): string; /** * @return string @@ -48,7 +48,7 @@ public function getShippingType(): ShippingTypeInterface; * * @return float|int */ - public function getPrice(): float|int; + public function getPrice(): float | int; /** * Return the price display diff --git a/src/QUI/ERP/Shipping/Api/ShippingTypeInterface.php b/src/QUI/ERP/Shipping/Api/ShippingTypeInterface.php index 997eee2312488e721369dcef678b8bf56914980a..4e06868a05e1c2c7942765f1ef1ecd047a3cac8f 100644 --- a/src/QUI/ERP/Shipping/Api/ShippingTypeInterface.php +++ b/src/QUI/ERP/Shipping/Api/ShippingTypeInterface.php @@ -22,7 +22,7 @@ public function getType(): string; * @param null|QUI\Locale $Locale * @return string */ - public function getTitle(QUI\Locale $Locale = null): string; + public function getTitle(null | QUI\Locale $Locale = null): string; /** * @return string @@ -35,5 +35,5 @@ public function getIcon(): string; * @param QUI\Locale|null $Locale * @return array */ - public function toArray(QUI\Locale $Locale = null): array; + public function toArray(null | QUI\Locale $Locale = null): array; } diff --git a/src/QUI/ERP/Shipping/EventHandler.php b/src/QUI/ERP/Shipping/EventHandler.php index a19143ed3d9656b7838f9ecbcd3baecd9d4537f5..863491f6b0fb2d1df7fd5939cb0f2bafd9bffc60 100644 --- a/src/QUI/ERP/Shipping/EventHandler.php +++ b/src/QUI/ERP/Shipping/EventHandler.php @@ -9,6 +9,7 @@ use Exception; use QUI; use QUI\ERP\Accounting\ArticleList; +use QUI\ERP\Accounting\ArticleListUnique; use QUI\ERP\Accounting\Invoice\InvoiceTemporary; use QUI\ERP\Accounting\Offers\AbstractOffer; use QUI\ERP\Order\AbstractOrder; @@ -16,6 +17,7 @@ use QUI\ERP\Products\Handler\Fields as ProductFields; use QUI\ERP\SalesOrders\SalesOrder; use QUI\ERP\Shipping\Shipping as ShippingHandler; +use QUI\ExceptionStack; use QUI\Smarty\Collector; use function array_merge; @@ -271,7 +273,10 @@ public static function onQuiqqerOrderOrderProcessCheckoutOutputBefore( try { $DeliveryAddress = $Customer->getAddress($addressId); $Order->setDeliveryAddress($DeliveryAddress); - $Order->save(QUI::getUsers()->getSystemUser()); + + if (method_exists($Order, 'save')) { + $Order->save(QUI::getUsers()->getSystemUser()); + } } catch (Exception) { } } @@ -283,6 +288,10 @@ public static function onQuiqqerOrderOrderProcessCheckoutOutputBefore( * @param OrderCheckoutStepControl $Checkout * @param string $text * @return void + * + * @throws QUI\Database\Exception + * @throws QUI\Exception + * @throws ExceptionStack */ public static function onQuiqqerOrderOrderProcessCheckoutOutput( OrderCheckoutStepControl $Checkout, @@ -324,7 +333,10 @@ class_exists('QUI\ERP\Order\Guest\GuestOrderUser') ); $Order->setDeliveryAddress($ErpDeliveryAddress); - $Order->save(QUI::getUsers()->getSystemUser()); + + if (method_exists($Order, 'save')) { + $Order->save(QUI::getUsers()->getSystemUser()); + } } catch (Exception $Exception) { QUI\System\Log::writeException($Exception); } @@ -362,7 +374,10 @@ public static function onQuiqqerOrderCustomerDataSave( // same address like the invoice address if ((int)$_REQUEST['shipping-address'] === -1) { $Order->setDeliveryAddress($Order->getInvoiceAddress()); - $Order->save(); + + if (method_exists($Order, 'save')) { + $Order->save(); + } return; } @@ -370,7 +385,10 @@ public static function onQuiqqerOrderCustomerDataSave( $Address = $User->getAddress($_REQUEST['shipping-address']); } catch (QUI\Exception) { $Order->clearAddressDelivery(); - $Order->save(); + + if (method_exists($Order, 'save')) { + $Order->save(); + } return; } @@ -379,7 +397,10 @@ public static function onQuiqqerOrderCustomerDataSave( ); $Order->setDeliveryAddress($ErpAddress); - $Order->save(); + + if (method_exists($Order, 'save')) { + $Order->save(); + } } /** @@ -499,9 +520,9 @@ protected static function createProductFields(): void 'titles' => $field['title'], 'workingtitles' => $field['title'], 'systemField' => 0, - 'standardField' => !empty($field['standard']) ? 1 : 0, - 'publicField' => !empty($field['public']) ? 1 : 0, - 'options' => !empty($field['options']) ? $field['options'] : null + 'standardField' => !empty($field['standard']) ? 1 : 0, // @phpstan-ignore-line + 'publicField' => !empty($field['public']) ? 1 : 0, // @phpstan-ignore-line + 'options' => !empty($field['options']) ? $field['options'] : null // @phpstan-ignore-line ]); } catch (Exception $Exception) { QUI\System\Log::writeException($Exception); @@ -610,7 +631,10 @@ public static function onQuiqqerOffersCreated(AbstractOffer $Offer): void if (count($Process->getEntities()) <= 1) { self::addDefaultShipping($Offer->getArticles()); $Offer->addCustomDataEntry(self::DEFAULT_SHIPPING_TIME_KEY, time()); - $Offer->update(QUI::getUsers()->getSystemUser()); + + if (method_exists($Offer, 'update')) { + $Offer->update(QUI::getUsers()->getSystemUser()); + } } } catch (Exception $Exception) { QUI\System\Log::addError($Exception->getMessage()); @@ -642,11 +666,11 @@ public static function onQuiqqerSalesOrdersCreated(SalesOrder $Sales): void /** * event: addDefaultShipping * - * @param ArticleList $Articles + * @param ArticleList|ArticleListUnique $Articles * @return void * @throws QUI\Exception */ - protected static function addDefaultShipping(ArticleList $Articles): void + protected static function addDefaultShipping(ArticleList | ArticleListUnique $Articles): void { if (!QUI::isBackend()) { return; @@ -675,7 +699,11 @@ protected static function addDefaultShipping(ArticleList $Articles): void if (!$shippingFactor) { $PriceFactor = Shipping::getInstance()->getDefaultPriceFactor(); - $Articles->addPriceFactor($PriceFactor); + + if (method_exists($Articles, 'addPriceFactor')) { + $Articles->addPriceFactor($PriceFactor); + } + $Articles->recalculate(); } } catch (QUI\Exception) { diff --git a/src/QUI/ERP/Shipping/Methods/Digital/ShippingType.php b/src/QUI/ERP/Shipping/Methods/Digital/ShippingType.php index 0412e815d661375e467fb031f17ae868b744b364..fecdd50127772414dea2f800d6ebdd2de72f3eb3 100644 --- a/src/QUI/ERP/Shipping/Methods/Digital/ShippingType.php +++ b/src/QUI/ERP/Shipping/Methods/Digital/ShippingType.php @@ -67,7 +67,6 @@ public function canUsedInOrder( } // Check if order contains NON-digital products - /** @var QUI\ERP\Accounting\Article $Article */ foreach ($Entity->getArticles() as $Article) { try { // Do not parse coupon codes / discounts diff --git a/src/QUI/ERP/Shipping/Methods/Standard/ShippingType.php b/src/QUI/ERP/Shipping/Methods/Standard/ShippingType.php index 46600d32cc282376c4fedf461fcd742eaed508ca..02748e0ef3ba9acfa84f0bd5a176263037855c05 100644 --- a/src/QUI/ERP/Shipping/Methods/Standard/ShippingType.php +++ b/src/QUI/ERP/Shipping/Methods/Standard/ShippingType.php @@ -80,7 +80,6 @@ public function canUsedInOrder( // Check if order contains only digital products $digitalProductsOnly = true; - /** @var QUI\ERP\Accounting\Article $Article */ foreach ($ArticleList as $Article) { try { // Do not parse coupon codes / discounts diff --git a/src/QUI/ERP/Shipping/Order/Shipping.php b/src/QUI/ERP/Shipping/Order/Shipping.php index 63c5807997966fec4022ca1d3685e6cf7745b4bc..631620fcd2dd21d0d6ca3eec59c0bcbb3e8cacaf 100644 --- a/src/QUI/ERP/Shipping/Order/Shipping.php +++ b/src/QUI/ERP/Shipping/Order/Shipping.php @@ -38,7 +38,7 @@ public function __construct(array $attributes = []) * @param null|QUI\Locale $Locale * @return string */ - public function getName($Locale = null): string + public function getName(null | QUI\Locale $Locale = null): string { return 'Shipping'; } @@ -55,6 +55,7 @@ public function getIcon(): string * @return string * * @throws QUI\Exception + * @throws \PHPMailer\PHPMailer\Exception */ public function getBody(): string { @@ -166,7 +167,10 @@ public function validate(): void if ($Shipping === null && count($shippingList) === 1) { try { $Order->setShipping($shippingList[0]); - $Order->save(); + + if (method_exists($Order, 'save')) { + $Order->save(); + } } catch (QUI\Exception $Exception) { QUI\System\Log::addDebug($Exception->getMessage()); } @@ -260,11 +264,13 @@ public function save(): void } } catch (QUI\ERP\Shipping\Exception $Exception) { QUI\System\Log::writeDebugException($Exception); - return; } $Order->setShipping($ShippingEntry); - $Order->save(); + + if (method_exists($Order, 'save')) { + $Order->save(); + } } } diff --git a/src/QUI/ERP/Shipping/Products/Fields/ShippingTimeFrontendView.php b/src/QUI/ERP/Shipping/Products/Fields/ShippingTimeFrontendView.php index 1336fb0dbd5f4873e2b65a172d2774d676797ac7..9a1c13266fe069e6f7ab6c26e36fc4ace9ae06e0 100644 --- a/src/QUI/ERP/Shipping/Products/Fields/ShippingTimeFrontendView.php +++ b/src/QUI/ERP/Shipping/Products/Fields/ShippingTimeFrontendView.php @@ -29,8 +29,6 @@ public function create(): string $Engine = QUI::getTemplateManager()->getEngine(); $L = QUI::getLocale(); $lg = 'quiqqer/shipping'; - - /** @var ShippingTimePeriod $Field */ $value = $this->getValue(); if (empty($value)) { @@ -113,7 +111,7 @@ public function create(): string /** * Return the current value * - * @return string|array + * @return mixed */ public function getValue(): mixed { diff --git a/src/QUI/ERP/Shipping/Rules/Factory.php b/src/QUI/ERP/Shipping/Rules/Factory.php index 39c679d32064add874a94fac7ed5f41f019d2bdb..b062a4ef6d6b5948a58c6b5d3fafe322bc32212e 100644 --- a/src/QUI/ERP/Shipping/Rules/Factory.php +++ b/src/QUI/ERP/Shipping/Rules/Factory.php @@ -66,10 +66,11 @@ public function __construct() * * @throws QUI\Exception */ - public function createChild(array $data = []): QUI\CRUD\Child + public function createChild(array $data = []): ShippingRule { // filter $allowed = array_flip([ + 'active', 'title', 'workingTitle', 'date_from', @@ -229,6 +230,7 @@ public function createChild(array $data = []): QUI\CRUD\Child QUI::getEvents()->fireEvent('shippingCreateEnd', [$NewChild]); + // @phpstan-ignore-next-line return $NewChild; } @@ -284,25 +286,26 @@ public function getChildAttributes(): array /** * @param int $id * - * @return QUI\ERP\Shipping\Api\AbstractShippingEntry + * @return ShippingRule * * @throws QUI\Exception */ - public function getChild($id): QUI\CRUD\Child + public function getChild($id): ShippingRule { - /* @var QUI\ERP\Shipping\Api\AbstractShippingEntry $Shipping */ + /* @var ShippingRule $Shipping */ $Shipping = parent::getChild($id); + // @phpstan-ignore-next-line return $Shipping; } /** * Creates a locale * - * @param $var - * @param $title + * @param string $var + * @param string $title */ - protected function createShippingLocale($var, $title): void + protected function createShippingLocale(string $var, string $title): void { $current = QUI::getLocale()->getCurrent(); diff --git a/src/QUI/ERP/Shipping/Rules/ShippingRule.php b/src/QUI/ERP/Shipping/Rules/ShippingRule.php index 7d67255c374537c03a206516e61718bfecd72dad..c94681a2a87be119caa497ab7e6dbbc16dfdef25 100644 --- a/src/QUI/ERP/Shipping/Rules/ShippingRule.php +++ b/src/QUI/ERP/Shipping/Rules/ShippingRule.php @@ -191,7 +191,7 @@ public function toArray(): array * @param Locale|null $Locale * @return string */ - public function getTitle(QUI\Locale $Locale = null): string + public function getTitle(null | QUI\Locale $Locale = null): string { if ($Locale === null) { $Locale = QUI::getLocale(); @@ -337,7 +337,7 @@ public function canUsedBy(QUI\Interfaces\Users\User $User): bool * @param Address|QUI\Users\Address|null $Address * @return bool */ - public function canUsedWithAddress(QUI\ERP\Address|QUI\Users\Address $Address = null): bool + public function canUsedWithAddress(null | QUI\ERP\Address | QUI\Users\Address $Address = null): bool { if (!$Address) { return false; @@ -365,7 +365,7 @@ public function canUsedWithAddress(QUI\ERP\Address|QUI\Users\Address $Address = * @param QUI\ERP\ErpEntityInterface|null $ErpEntity * @return bool */ - public function canUsedIn(QUI\ERP\ErpEntityInterface $ErpEntity = null): bool + public function canUsedIn(null | QUI\ERP\ErpEntityInterface $ErpEntity = null): bool { if (!$this->isValid()) { Debug::addLog("{$this->getTitle()} :: is not valid"); @@ -649,7 +649,12 @@ public function canUsedIn(QUI\ERP\ErpEntityInterface $ErpEntity = null): bool // quantity check - $count = $ErpEntity->count(); + $count = 0; + + if (method_exists($ErpEntity, 'count')) { + $count = $ErpEntity->count(); + } + if (!empty($quantityFrom) && $quantityFrom < $count) { QUI\ERP\Shipping\Debug::addLog( @@ -819,7 +824,7 @@ public function getDiscountType(): int * * @return bool|array */ - public function getUnitTerms(): bool|array + public function getUnitTerms(): bool | array { $unitTerms = $this->getAttribute('unit_terms'); diff --git a/src/QUI/ERP/Shipping/Shipping.php b/src/QUI/ERP/Shipping/Shipping.php index 70bdd4252b8ee6e829b1ced28e68e6fa3e827be7..575490bde37d6fd34da9166c8c83f05b40349b76 100644 --- a/src/QUI/ERP/Shipping/Shipping.php +++ b/src/QUI/ERP/Shipping/Shipping.php @@ -239,7 +239,7 @@ public function getShippingType(string $shippingType): Api\ShippingTypeInterface * * @throws Exception */ - public function getShippingEntry(int|string $shippingId): Types\ShippingEntry + public function getShippingEntry(int | string $shippingId): Types\ShippingEntry { try { return Factory::getInstance()->getChild($shippingId); @@ -277,8 +277,10 @@ public function getShippingList(array $queryParams = []): array * @param QUI\ERP\ErpEntityInterface|null $Entity - optional * @return QUI\ERP\Shipping\Types\ShippingEntry[] */ - public function getUserShipping(User $User = null, QUI\ERP\ErpEntityInterface $Entity = null): array - { + public function getUserShipping( + null | User $User = null, + null | QUI\ERP\ErpEntityInterface $Entity = null + ): array { if ($User === null) { $User = QUI::getUserBySession(); } @@ -302,8 +304,9 @@ public function getUserShipping(User $User = null, QUI\ERP\ErpEntityInterface $E * @param QUI\ERP\ErpEntityInterface $Entity * @return PriceFactorInterface|ErpPriceFactor|null */ - public function getShippingPriceFactor(QUI\ERP\ErpEntityInterface $Entity): ErpPriceFactor|PriceFactorInterface|null - { + public function getShippingPriceFactor( + QUI\ERP\ErpEntityInterface $Entity + ): ErpPriceFactor | PriceFactorInterface | null { $PriceFactors = $Entity->getArticles()->getPriceFactors(); foreach ($PriceFactors as $PriceFactor) { @@ -321,7 +324,7 @@ public function getShippingPriceFactor(QUI\ERP\ErpEntityInterface $Entity): ErpP * * @deprecated use getShippingPriceFactor */ - public function getShippingPriceFactorByOrder(AbstractOrder $Order): ErpPriceFactor|PriceFactorInterface|null + public function getShippingPriceFactorByOrder(AbstractOrder $Order): ErpPriceFactor | PriceFactorInterface | null { QUI\System\Log::addNotice( 'Shipping->getShippingPriceFactorByOrder() is deprecated, use getShippingPriceFactor' @@ -421,7 +424,7 @@ public function getHost(): string */ public function getShippingByObject( QUI\ERP\ErpEntityInterface $Entity - ): Types\ShippingEntry|Types\ShippingUnique|null { + ): Types\ShippingEntry | Types\ShippingUnique | null { $Shipping = null; $Delivery = $Entity->getDeliveryAddress(); @@ -440,7 +443,7 @@ public function getShippingByObject( * @param $orderId * @return ShippingEntry|ShippingUnique|null */ - public function getShippingByOrderId($orderId): ShippingEntry|ShippingUnique|null + public function getShippingByOrderId($orderId): ShippingEntry | ShippingUnique | null { try { $Order = QUI\ERP\Order\Handler::getInstance()->getOrderById($orderId); @@ -551,7 +554,7 @@ public function getVat(QUI\ERP\ErpEntityInterface $ErpEntity): mixed public function sendStatusChangeNotification( ErpEntityInterface $ErpEntity, int $statusId, - string $message = null + null | string $message = null ): void { $Customer = $ErpEntity->getCustomer(); $customerEmail = $Customer->getAttribute('email'); diff --git a/src/QUI/ERP/Shipping/ShippingStatus/Factory.php b/src/QUI/ERP/Shipping/ShippingStatus/Factory.php index 93b91f1c9f160ae2d2348f7b6916555cb3cdeb1d..995ad717c694310190dab13ca0609623fe8ed6e6 100644 --- a/src/QUI/ERP/Shipping/ShippingStatus/Factory.php +++ b/src/QUI/ERP/Shipping/ShippingStatus/Factory.php @@ -32,7 +32,7 @@ class Factory extends QUI\Utils\Singleton * * @todo permissions */ - public function createShippingStatus(int|string $id, string $color, array $title): void + public function createShippingStatus(int | string $id, string $color, array $title): void { $list = Handler::getInstance()->getList(); $id = (int)$id; @@ -49,7 +49,7 @@ public function createShippingStatus(int|string $id, string $color, array $title $Package = QUI::getPackage('quiqqer/shipping'); $Config = $Package->getConfig(); - $Config->setValue('shipping_status', $id, $color); + $Config->setValue('shipping_status', (string)$id, $color); $Config->save(); // translations diff --git a/src/QUI/ERP/Shipping/ShippingStatus/Handler.php b/src/QUI/ERP/Shipping/ShippingStatus/Handler.php index f4de39755edaab9c1ba5ac3ae0b1fa3660a008a7..68b02c05efebe03174f82b2c6d309a94136a8a79 100644 --- a/src/QUI/ERP/Shipping/ShippingStatus/Handler.php +++ b/src/QUI/ERP/Shipping/ShippingStatus/Handler.php @@ -111,7 +111,7 @@ public function getShippingStatusList(): array * * @throws Exception */ - public function getShippingStatus(int $id): StatusUnknown|Status + public function getShippingStatus(int $id): StatusUnknown | Status { if ($id === 0) { return new StatusUnknown(); @@ -130,7 +130,7 @@ public function getShippingStatus(int $id): StatusUnknown|Status * * @todo permissions */ - public function deleteShippingStatus(int|string $id): void + public function deleteShippingStatus(int | string $id): void { $Status = $this->getShippingStatus($id); @@ -146,7 +146,7 @@ public function deleteShippingStatus(int|string $id): void $Package = QUI::getPackage('quiqqer/shipping'); $Config = $Package->getConfig(); - $Config->del('shipping_status', $Status->getId()); + $Config->del('shipping_status', (string)$Status->getId()); $Config->save(); } @@ -168,7 +168,7 @@ public function setShippingStatusNotification(int $id, bool $notify): void $Package = QUI::getPackage('quiqqer/shipping'); $Config = $Package->getConfig(); - $Config->setValue('shipping_status_notification', $Status->getId(), $notify ? "1" : "0"); + $Config->setValue('shipping_status_notification', (string)$Status->getId(), $notify ? "1" : "0"); $Config->save(); } @@ -183,7 +183,7 @@ public function setShippingStatusNotification(int $id, bool $notify): void * * @todo permissions */ - public function updateShippingStatus(int $id, int|string $color, array $title): void + public function updateShippingStatus(int $id, int | string $color, array $title): void { $Status = $this->getShippingStatus($id); @@ -216,7 +216,7 @@ public function updateShippingStatus(int $id, int|string $color, array $title): $Package = QUI::getPackage('quiqqer/shipping'); $Config = $Package->getConfig(); - $Config->setValue('shipping_status', $Status->getId(), $color); + $Config->setValue('shipping_status', (string)$Status->getId(), $color); $Config->save(); } @@ -277,7 +277,7 @@ public function createNotificationTranslations(int $id): void public function sendStatusChangeNotification( QUI\ERP\ErpEntityInterface $ErpEntity, int $statusId, - string $message = null + null | string $message = null ): void { $Customer = $ErpEntity->getCustomer(); $customerEmail = $Customer->getAttribute('email'); diff --git a/src/QUI/ERP/Shipping/ShippingStatus/Status.php b/src/QUI/ERP/Shipping/ShippingStatus/Status.php index 0a0b2b0e104c1040ae31a7c342703177223dda60..804ca18a98e3b31b6bafb8ecb89efc1cd4da552a 100644 --- a/src/QUI/ERP/Shipping/ShippingStatus/Status.php +++ b/src/QUI/ERP/Shipping/ShippingStatus/Status.php @@ -85,7 +85,7 @@ public function getId(): int * @param null|QUI\Locale $Locale (optional) $Locale * @return string */ - public function getTitle(QUI\Locale $Locale = null): string + public function getTitle(null | QUI\Locale $Locale = null): string { if (!($Locale instanceof QUI\Locale)) { $Locale = QUI::getLocale(); @@ -101,7 +101,7 @@ public function getTitle(QUI\Locale $Locale = null): string * @param QUI\Locale|null $Locale (optional) - [default: QUI::getLocale()] * @return string */ - public function getStatusChangeNotificationText(AbstractOrder $Order, QUI\Locale $Locale = null): string + public function getStatusChangeNotificationText(AbstractOrder $Order, null | QUI\Locale $Locale = null): string { if (!($Locale instanceof QUI\Locale)) { $Locale = QUI::getLocale(); @@ -156,7 +156,7 @@ public function isAutoNotification(): bool * @param null|QUI\Locale $Locale - optional. if no locale, all translations would be returned * @return array */ - public function toArray(QUI\Locale $Locale = null): array + public function toArray(null |QUI\Locale $Locale = null): array { $title = $this->getTitle($Locale); $statusChangeText = []; diff --git a/src/QUI/ERP/Shipping/ShippingStatus/StatusUnknown.php b/src/QUI/ERP/Shipping/ShippingStatus/StatusUnknown.php index ca864443fb8299ac974411b783f509cf302dea66..9cef0467eac28fa0fe05a9823eefebdcade1c368 100644 --- a/src/QUI/ERP/Shipping/ShippingStatus/StatusUnknown.php +++ b/src/QUI/ERP/Shipping/ShippingStatus/StatusUnknown.php @@ -43,7 +43,7 @@ public function __construct() * @param null|QUI\Locale $Locale (optional) $Locale * @return string */ - public function getTitle(QUI\Locale $Locale = null): string + public function getTitle(null | QUI\Locale $Locale = null): string { if (!($Locale instanceof QUI\Locale)) { $Locale = QUI::getLocale(); diff --git a/src/QUI/ERP/Shipping/Tracking/Tracking.php b/src/QUI/ERP/Shipping/Tracking/Tracking.php index 9252a26c53e9d9c3cc2c41b7cdbdfc3cf51b4b05..ab5a7adbb5230af9abd4a5bc21458567dc605272 100644 --- a/src/QUI/ERP/Shipping/Tracking/Tracking.php +++ b/src/QUI/ERP/Shipping/Tracking/Tracking.php @@ -131,7 +131,7 @@ public static function getActiveCarriers(): array ); return array_filter($data, function ($entry) { - return (int)$entry['active']; + return (bool)(int)$entry['active']; }); } diff --git a/src/QUI/ERP/Shipping/Types/Factory.php b/src/QUI/ERP/Shipping/Types/Factory.php index 665c171899449df8ed016c35d870b6d9bd71c1eb..bcc6ac9048cabf24379e74389be5edeb06275232 100644 --- a/src/QUI/ERP/Shipping/Types/Factory.php +++ b/src/QUI/ERP/Shipping/Types/Factory.php @@ -44,7 +44,7 @@ public function __construct() * @throws QUI\ERP\Shipping\Exception * @throws QUI\Exception */ - public function createChild(array $data = []): QUI\CRUD\Child + public function createChild(array $data = []): ShippingEntry { if (!isset($data['active']) || !is_integer($data['active'])) { $data['active'] = 0; @@ -64,17 +64,17 @@ public function createChild(array $data = []): QUI\CRUD\Child QUI::getEvents()->fireEvent('shippingCreateBegin', [$data['shipping_type']]); - /* @var $NewChild ShippingEntry */ + /* @var ShippingEntry $NewChild */ $NewChild = parent::createChild($data); $this->createShippingLocale( 'shipping.' . $NewChild->getId() . '.title', - $NewChild->getShippingType()->getTitle() + $NewChild->getShippingType()->getTitle() // @phpstan-ignore-line ); $this->createShippingLocale( 'shipping.' . $NewChild->getId() . '.workingTitle', - $NewChild->getShippingType()->getTitle() . ' - ' . $NewChild->getId() + $NewChild->getShippingType()->getTitle() . ' - ' . $NewChild->getId() // @phpstan-ignore-line ); // description @@ -88,6 +88,7 @@ public function createChild(array $data = []): QUI\CRUD\Child QUI::getEvents()->fireEvent('shippingCreateEnd', [$NewChild]); + // @phpstan-ignore-next-line return $NewChild; } @@ -130,15 +131,16 @@ public function getChildAttributes(): array /** * @param int $id * - * @return QUI\ERP\Shipping\Types\ShippingEntry + * @return ShippingEntry * * @throws QUI\Exception */ - public function getChild($id): QUI\CRUD\Child + public function getChild($id): ShippingEntry { - /* @var QUI\ERP\Shipping\Types\ShippingEntry $Shipping */ + /* @var ShippingEntry $Shipping */ $Shipping = parent::getChild($id); + // @phpstan-ignore-next-line return $Shipping; } diff --git a/src/QUI/ERP/Shipping/Types/ShippingEntry.php b/src/QUI/ERP/Shipping/Types/ShippingEntry.php index 50104b96fa12d0279ecc6f7291b549aa8dfe27a4..7b9bab934c9a6a3ee0312915990bff82aac609c3 100644 --- a/src/QUI/ERP/Shipping/Types/ShippingEntry.php +++ b/src/QUI/ERP/Shipping/Types/ShippingEntry.php @@ -8,6 +8,8 @@ use QUI; use QUI\CRUD\Factory; +use QUI\ERP\ErpEntityInterface; +use QUI\ERP\Products\Utils\PriceFactor; use QUI\ERP\Shipping\Api; use QUI\ERP\Shipping\Debug; use QUI\ERP\Shipping\Rules\Factory as RuleFactory; @@ -42,7 +44,7 @@ class ShippingEntry extends QUI\CRUD\Child implements Api\ShippingInterface /** * @var null|QUI\ERP\Address|QUI\Users\Address */ - protected QUI\Users\Address|QUI\ERP\Address|null $Address = null; + protected QUI\Users\Address | QUI\ERP\Address | null $Address = null; /** * Shipping constructor. @@ -258,7 +260,7 @@ public function getPriceDisplay(): string * * @return float|int */ - public function getPrice(): float|int + public function getPrice(): float | int { $rules = $this->getShippingRules(); $price = 0; @@ -399,7 +401,7 @@ public function deactivate(): void * @param null|Locale $Locale * @return string */ - public function getTitle(QUI\Locale $Locale = null): string + public function getTitle(null | QUI\Locale $Locale = null): string { if ($Locale === null) { $Locale = QUI::getLocale(); @@ -414,10 +416,10 @@ public function getTitle(QUI\Locale $Locale = null): string /** * Return the shipping description * - * @param null $Locale + * @param Locale|null $Locale * @return string */ - public function getDescription($Locale = null): string + public function getDescription(null | QUI\Locale $Locale = null): string { if ($Locale === null) { $Locale = QUI::getLocale(); @@ -432,10 +434,10 @@ public function getDescription($Locale = null): string /** * Return the shipping working title * - * @param null $Locale + * @param Locale|null $Locale * @return array|string */ - public function getWorkingTitle($Locale = null): array|string + public function getWorkingTitle(null | QUI\Locale $Locale = null): array | string { if ($Locale === null) { $Locale = QUI::getLocale(); @@ -607,7 +609,6 @@ public function addShippingRule(ShippingRule $Rule): void */ public function addShippingRuleId(int $shippingRuleId): void { - /* @var $Rule ShippingRule */ $Rule = RuleFactory::getInstance()->getChild($shippingRuleId); $this->addShippingRule($Rule); } @@ -790,14 +791,14 @@ public function setOrder(QUI\ERP\ErpEntityInterface $ErpEntity): void } /** - * @param null $Locale - * @param QUI\ERP\ErpEntityInterface|null $ErpEntity + * @param Locale|null $Locale + * @param ErpEntityInterface|null $ErpEntity * - * @return QUI\ERP\Products\Utils\PriceFactor + * @return PriceFactor */ public function toPriceFactor( - $Locale = null, - QUI\ERP\ErpEntityInterface $ErpEntity = null + null | QUI\Locale $Locale = null, + null | QUI\ERP\ErpEntityInterface $ErpEntity = null ): QUI\ERP\Products\Utils\PriceFactor { if ($ErpEntity === null) { $ErpEntity = $this->ErpEntity; @@ -863,7 +864,7 @@ public function setAddress($Address): void /** * Return the address */ - public function getAddress(): QUI\ERP\Address|QUI\Users\Address|null + public function getAddress(): QUI\ERP\Address | QUI\Users\Address | null { return $this->Address; }