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

fix(phpstan): resolve method and class checks

Several changes have been made, primarily around checking the existence of methods and classes and
removing unnecessary comments.

- Method checks have been introduced to ensure the `getCachePath()` method exists before calling it.
- Removed invalid phpDocs, e.g., @var $Site Site and @var $Project Project
- Fixed typing to align return types and updated a factory method to check class existence.
- Added variable definition comments in the settings.css.php file for clarity.

Related: #114
Übergeordneter 72beeb33
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 #14769 mit Warnungen bestanden mit Phase
in 2 Minuten und 23 Sekunden
parameters:
ignoreErrors:
-
message: "#^Call to an undefined method QUI\\\\Interfaces\\\\Projects\\\\Site\\:\\:getCachePath\\(\\)\\.$#"
count: 1
path: src/QUI/TemplateCologne/Controls/Menu/Categories.php
-
message: "#^Access to constant PRODUCT_FIELD_SHIPPING_TIME on an unknown class QUI\\\\ERP\\\\Shipping\\\\Shipping\\.$#"
count: 1
path: src/QUI/TemplateCologne/Utils.php
-
message: "#^Access to constant PRODUCT_FIELD_STOCK on an unknown class QUI\\\\ERP\\\\StockManagement\\\\StockManager\\.$#"
count: 1
path: src/QUI/TemplateCologne/Utils.php
-
message: "#^Call to method setProduct\\(\\) on an unknown class QUI\\\\ERP\\\\StockManagement\\\\Products\\\\Fields\\\\StockView\\.$#"
count: 1
path: src/QUI/TemplateCologne/Utils.php
-
message: "#^Call to static method getShippingTimeFrontendViewByProduct\\(\\) on an unknown class QUI\\\\ERP\\\\StockManagement\\\\StockManager\\.$#"
count: 1
path: src/QUI/TemplateCologne/Utils.php
-
message: "#^Method QUI\\\\TemplateCologne\\\\Utils\\:\\:getStockFrontendView\\(\\) should return QUI\\\\ERP\\\\Products\\\\Field\\\\View\\|false but returns QUI\\\\ERP\\\\StockManagement\\\\Products\\\\Fields\\\\StockView\\.$#"
count: 1
path: src/QUI/TemplateCologne/Utils.php
-
message: "#^PHPDoc tag @var for variable \\$StockView contains unknown class QUI\\\\ERP\\\\StockManagement\\\\Products\\\\Fields\\\\StockView\\.$#"
count: 1
path: src/QUI/TemplateCologne/Utils.php
-
message: "#^PHPDoc tag @var has invalid value \\(\\$Site Site\\)\\: Unexpected token \"\\$Site\", expected type at offset 9$#"
count: 1
path: src/QUI/TemplateCologne/Utils.php
-
message: "#^Variable \\$Project might not be defined\\.$#"
count: 2
path: src/QUI/TemplateCologne/settings.css.php
-
message: "#^Variable \\$Site might not be defined\\.$#"
count: 1
path: src/QUI/TemplateCologne/settings.css.php
ignoreErrors:
\ No newline at end of file
......@@ -72,10 +72,14 @@ public function getBody(): string
}
$cache = EventHandler::menuCacheName() . '/megaMenu/';
$cachePah = '';
if (method_exists($this->getSite(), 'getCachePath')) {
$cachePah = $this->getSite()->getCachePath();
}
$cache .= md5(
$this->getSite()->getCachePath() .
serialize($this->getAttributes())
$cachePah . serialize($this->getAttributes())
);
try {
......
......@@ -11,7 +11,6 @@
use QUI\ERP\Shipping\Shipping;
use QUI\ERP\StockManagement\StockManager;
use QUI\Projects\Project;
use QUI\Projects\Site;
use QUI\TemplateCologne\Controls\Payments;
use function class_exists;
......@@ -75,13 +74,8 @@ public static function getAvatar(mixed $User): QUI\Projects\Media\Image|bool
*/
public static function getConfig(array $params): object|array|bool|string
{
/** @var $Site Site */
$Site = $params['Site'];
/* @var $Project Project */
$Project = $params['Project'];
/* @var $Project QUI\Template */
$Template = $params['Template'];
$cacheName = md5($Site->getId() . $Project->getName() . $Project->getLang());
......@@ -599,7 +593,7 @@ private static function getPredefinedFooter(Project $Project): array
*
* @return false|QUI\ERP\Products\Field\View
*/
public static function getShippingTimeFrontendView(int $productId)
public static function getShippingTimeFrontendView(int $productId): bool | QUI\ERP\Products\Field\View
{
try {
$Product = QUI\ERP\Products\Handler\Products::getProduct($productId);
......@@ -609,7 +603,7 @@ public static function getShippingTimeFrontendView(int $productId)
return false;
}
if (QUI::getPackageManager()->isInstalled('quiqqer/stock-management')) {
if (class_exists('QUI\ERP\StockManagement\StockManager')) {
return StockManager::getShippingTimeFrontendViewByProduct($Product);
}
......@@ -656,6 +650,10 @@ public static function getStockFrontendView(int $productId)
return false;
}
if (!class_exists('QUI\ERP\StockManagement\StockManager')) {
return false;
}
try {
$Product = QUI\ERP\Products\Handler\Products::getProduct($productId);
$StockField = $Product->getField(StockManager::PRODUCT_FIELD_STOCK);
......@@ -665,7 +663,6 @@ public static function getStockFrontendView(int $productId)
return false;
}
/** @var QUI\ERP\StockManagement\Products\Fields\StockView $StockView */
$StockView = $StockField->getFrontendView();
if (method_exists($StockView, 'setProduct')) {
......
<?php
/**
* cologne template file
*
* @var QUI\Projects\Project $Project
* @var QUI\Projects\Site $Site
* @var QUI\Interfaces\Template\EngineInterface $Engine
* @var QUI\Template $Template
**/
$largeSpacing = $Site->getAttribute('templateCologne.largeSpacing');
$headerImagePosition = $Project->getConfig('templateCologne.settings.headerImagePosition');
......@@ -7,7 +15,6 @@
ob_start();
?>
<?php if ($largeSpacing) { ?>
/* more spacing */
.page-content-header,
......
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