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

fix(phpstan): remove unreachable branches and add method existence checks

This commit removes unreachable 'else' branches and irrelevant PHPStan error messages from the
PHPStan configuration file. It also updates the `InvoiceView` and `OutputProviderInvoice` classes
to add checks for the existence of methods before invoking them. This prevents runtime errors in
cases where the methods do not exist.

Related: #153
Übergeordneter 5eb74125
No related branches found
No related tags found
2 Merge Requests!92Update 'next-3.x' with latest changes from 'main',!91refactor(phpstan): update usage of types for better clarity
Pipeline #15052 bestanden mit Phase
in 2 Minuten und 27 Sekunden
......@@ -55,26 +55,6 @@ parameters:
count: 2
path: src/QUI/ERP/Accounting/Invoice/InvoiceTemporary.php
-
message: "#^Else branch is unreachable because previous condition is always true\\.$#"
count: 1
path: src/QUI/ERP/Accounting/Invoice/InvoiceView.php
-
message: "#^Unreachable statement \\- code above always terminates\\.$#"
count: 1
path: src/QUI/ERP/Accounting/Invoice/InvoiceView.php
-
message: "#^Call to an undefined method QUI\\\\ERP\\\\Accounting\\\\ArticleListUnique\\:\\:setUser\\(\\)\\.$#"
count: 1
path: src/QUI/ERP/Accounting/Invoice/Output/OutputProviderInvoice.php
-
message: "#^Call to an undefined method QUI\\\\ERP\\\\Accounting\\\\ArticleListUnique\\:\\:toUniqueList\\(\\)\\.$#"
count: 1
path: src/QUI/ERP/Accounting/Invoice/Output/OutputProviderInvoice.php
-
message: "#^Call to static method getInstance\\(\\) on an unknown class QUI\\\\ERP\\\\Order\\\\Handler\\.$#"
count: 1
......
......@@ -33,18 +33,10 @@ class InvoiceView extends QUI\QDOM
* InvoiceView constructor.
*
* @param Invoice|InvoiceTemporary $Invoice
*
* @throws Exception
*/
public function __construct(Invoice | InvoiceTemporary $Invoice)
{
if ($Invoice instanceof Invoice || $Invoice instanceof InvoiceTemporary) {
$this->Invoice = $Invoice;
return;
}
throw new Exception('$Invoice must be an instance of Invoice or InvoiceTemporary');
$this->Invoice = $Invoice;
}
/**
......@@ -308,7 +300,11 @@ class_exists('QUI\ERP\Accounting\Payments\Methods\AdvancePayment\Payment')
} else {
$timeForPayment = $Locale->get('quiqqer/invoice', 'additional.invoice.text.timeForPayment.0');
}
} else {
}
/*
// Else is unreachable because previous condition is always true.
else {
$timeForPayment = strtotime($timeForPayment);
if (date('Y-m-d') === date('Y-m-d', $timeForPayment)) {
......@@ -317,6 +313,7 @@ class_exists('QUI\ERP\Accounting\Payments\Methods\AdvancePayment\Payment')
$timeForPayment = $Formatter->format($timeForPayment);
}
}
*/
return $Locale->get(
'quiqqer/invoice',
......
......@@ -168,8 +168,13 @@ public static function getTemplateData(int | string $entityId): array
$Articles = $Invoice->getArticles();
if (get_class($Articles) !== QUI\ERP\Accounting\ArticleListUnique::class) {
$Articles->setUser($Customer);
$Articles = $Articles->toUniqueList();
if (method_exists($Articles, 'setUser')) {
$Articles->setUser($Customer);
}
if (method_exists($Articles, 'toUniqueList')) {
$Articles = $Articles->toUniqueList();
}
}
// Delivery address
......
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