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

refactor(phpstan): update type declaration format and add reflection for Shipping class

- Modified format for return types in declaration of functions `getAvatar`, `getConfig`, and
`getSetting` for increased readability.
- Added `ReflectionClass` usage to check for constant in `QUI\ERP\Shipping\Shipping` in
`getShippingTimeFrontendView` function, enhancing maintainability and robustness of the code.
- Adjusted the fail-safe condition inside `getShippingTimeFrontendView` to check for the existence
of the class 'Shipping' before checking for defined constant, reducing chance of errors.
- Imported `ReflectionClass` at the top of the file.
Übergeordneter 704e4892
No related branches found
No related tags found
2 Merge Requests!25Update 'next-3.x' with latest changes from 'main',!24fix: adjust paths to standard mail templates in quiqqer/core
Pipeline #14771 fehlgeschlagen mit Phase
in 2 Minuten und 29 Sekunden
......@@ -13,6 +13,8 @@
use QUI\Projects\Project;
use QUI\TemplateCologne\Controls\Payments;
use ReflectionClass;
use function class_exists;
use function count;
use function method_exists;
......@@ -31,7 +33,7 @@ class Utils
* @throws QUI\Exception
*
*/
public static function getAvatar(mixed $User): QUI\Projects\Media\Image|bool
public static function getAvatar(mixed $User): QUI\Projects\Media\Image | bool
{
if (!$User instanceof QUI\Interfaces\Users\User) {
throw new QUI\Exception([
......@@ -72,7 +74,7 @@ public static function getAvatar(mixed $User): QUI\Projects\Media\Image|bool
* @return array|bool|object|string
* @throws QUI\Exception
*/
public static function getConfig(array $params): object|array|bool|string
public static function getConfig(array $params): object | array | bool | string
{
$Site = $params['Site'];
$Project = $params['Project'];
......@@ -611,10 +613,16 @@ public static function getShippingTimeFrontendView(int $productId): bool | QUI\E
return false;
}
if (!defined('PRODUCT_FIELD_SHIPPING_TIME')) {
if (!class_exists('QUI\ERP\Shipping\Shipping')) {
return false;
}
$reflection = new ReflectionClass(Shipping::class);
if (!$reflection->hasConstant('PRODUCT_FIELD_SHIPPING_TIME')) {
return false;
}
try {
$ShippingField = $Product->getField(Shipping::PRODUCT_FIELD_SHIPPING_TIME);
} catch (\Exception $Exception) {
......@@ -710,7 +718,7 @@ public static function convertBrickCSSClass(array $classes): string
* @param string $settingName
* @return bool|array|int|string
*/
public static function getSetting(string $settingName): bool|array|int|string
public static function getSetting(string $settingName): bool | array | int | string
{
if (empty($settingName)) {
return false;
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren