Skip to content

Commit

Permalink
UNZER-523 phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniil Tkachev committed Nov 27, 2024
1 parent c43e7f4 commit e662f57
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 49 deletions.
23 changes: 3 additions & 20 deletions src/Controller/Admin/ModuleConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

/**
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class ModuleConfiguration extends ModuleConfiguration_parent
{
Expand Down Expand Up @@ -193,10 +194,6 @@ public function transferApplePayPaymentProcessingData(): void
}
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \OxidEsales\EshopCommunity\Core\Exception\FileException
*/
public function getApplePayPaymentProcessingKeyExists(): bool
{
$keyId = $this->moduleSettings->getApplePayPaymentKeyId();
Expand All @@ -215,10 +212,6 @@ public function getApplePayPaymentProcessingKeyExists(): bool
return false;
}

/**
* @throws GuzzleException
* @throws FileException
*/
public function getApplePayPaymentProcessingCertExists(): bool
{
$certId = $this->moduleSettings->getApplePayPaymentCertificateId();
Expand All @@ -242,11 +235,10 @@ public function getApplePayPaymentProcessingCertExists(): bool
}

/**
* @return void
* @throws FileException
* @SuppressWarnings(PHPMD.StaticAccess)
* @throws \OxidEsales\EshopCommunity\Core\Exception\FileException
*/
public function saveConfVars()
public function saveConfVars(): void
{
$moduleId = $this->getUnzerStringRequestEscapedParameter('oxid');
if ($moduleId === Module::MODULE_ID) {
Expand All @@ -269,9 +261,6 @@ public function saveConfVars()
parent::saveConfVars();
}

/**
* @throws \OxidEsales\EshopCommunity\Core\Exception\FileException
*/
private function saveMerchantKey(string $systemMode): void
{
$errorIds = [
Expand Down Expand Up @@ -318,9 +307,6 @@ private function saveMerchantCert(string $systemMode): void
}
}

/**
* @throws \OxidEsales\EshopCommunity\Core\Exception\FileException
*/
private function savePaymentKey(string $systemMode): void
{
$errorIds = [
Expand All @@ -343,9 +329,6 @@ private function savePaymentKey(string $systemMode): void
}
}

/**
* @throws \OxidEsales\EshopCommunity\Core\Exception\FileException
*/
private function savePaymentCert(string $systemMode): void
{
$errorIds = [
Expand Down
4 changes: 0 additions & 4 deletions src/Controller/Admin/OrderMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ protected function onOrderSend()
}
}

/**
* @param Order $oOrder
* @return void
*/
public function sendShipmentNotification(Order $oOrder): void
{
$paymentService = $this->getServiceFromContainer(PaymentService::class);
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/DispatcherController.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public function finalizeTmpOrder(
$oOrder = $flexibleSerializer->restoreOrderFromStrClass($tmpData['tmporder']);
}

if (method_exists($oOrder, 'finalizeTmpOrder')) {
if (!is_null($oOrder) && method_exists($oOrder, 'finalizeTmpOrder')) {
/** @var \OxidSolutionCatalysts\Unzer\Model\Order $oOrder */
$oOrder->finalizeTmpOrder($unzerPayment, $bError);
$tmpOrder->assign(['status' => 'FINISHED']);
Expand Down
2 changes: 1 addition & 1 deletion src/Service/FlexibleSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function restoreOrderFromStrClass(string $serialized): ?Order
&& !str_starts_with($property, "\0")
) {
if (method_exists($order, 'setFieldData')) {
$order->setFieldData($property, $value);
$order->assign([$property => $value]);
}
$order->$property = $value;
}
Expand Down
28 changes: 8 additions & 20 deletions src/Service/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,13 +442,11 @@ public function doUnzerCollect(
return true;
}

/**
* @param UnzerOrderModel|null $oOrder
* @param string $unzerid
* @param float $amount
* @return UnzerApiException|bool
*/
public function doUnzerAuthorizationCancel($oOrder, $unzerid, $amount)
public function doUnzerAuthorizationCancel(
UnzerOrderModel|null $oOrder,
string $unzerid,
float $amount
): UnzerApiException|bool
{
if (!($oOrder instanceof Order)) {
return false;
Expand All @@ -475,13 +473,10 @@ public function doUnzerAuthorizationCancel($oOrder, $unzerid, $amount)
}

/**
* @param UnzerOrderModel|null $oOrder
* @param string $sPaymentId
* @return UnzerApiException|bool
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @throws \UnzerSDK\Exceptions\UnzerApiException
*/
public function sendShipmentNotification($oOrder, $sPaymentId = null)
public function sendShipmentNotification(?Order $oOrder, string $sPaymentId = null): Exception|bool|UnzerApiException
{
if (!($oOrder instanceof Order)) {
return false;
Expand Down Expand Up @@ -545,11 +540,7 @@ public function sendShipmentNotification($oOrder, $sPaymentId = null)
return $blSuccess;
}

/**
* @param \UnzerSDK\Resources\Payment $unzerPayment
* @return BasePaymentType|AbstractUnzerResource The updated PaymentType object.
*/
public function setInstallmentDueDate($unzerPayment)
public function setInstallmentDueDate(UnzerPayment $unzerPayment): BasePaymentType|AbstractUnzerResource
{
/** @var InstallmentSecured $installment */
$installment = $unzerPayment->getPaymentType();
Expand All @@ -573,9 +564,6 @@ public function getTomorrowsTimestamp(): string
return date('Y-m-d', strtotime("+1 days"));
}

/**
* @return bool
*/
public function isPdfSession(): bool
{
return (bool)Registry::getRequest()->getRequestParameter('pdfConfirm', '0');
Expand Down
4 changes: 2 additions & 2 deletions tests/PhpStan/phpstan-bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ class_alias(

class_alias(
\OxidEsales\Eshop\Application\Model\Order::class,
\OxidEsales\Eshop\Application\Model\Order_parent::class,
\OxidSolutionCatalysts\Unzer\Model\Order_parent::class,
);

class_alias(
\OxidEsales\Eshop\Application\Model\Order::class,
\OxidSolutionCatalysts\Unzer\Model\Order::class,
\OxidEsales\Eshop\Application\Model\Order::class,
);

Expand Down
6 changes: 5 additions & 1 deletion tests/PhpStan/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ parameters:
- ../../vendor/oxid-esales/oxideshop-ce/source/oxfunctions.php
- ../../vendor/oxid-esales/oxideshop-ce/source/overridablefunctions.php
ignoreErrors:
- identifier: missingType.iterableValue
- identifier: missingType.iterableValue

- '#Call to an undefined method OxidEsales\\Eshop\\Application\\Model\\Order::markUnzerOrderAsPaid\(\)#'
- '#Call to an undefined method OxidEsales\\Eshop\\Application\\Model\\Order::getUnzerInvoiceNr\(\)#'
- '#Call to an undefined method OxidEsales\\Eshop\\Application\\Model\\Order::setUnzerTransId\(\)#'

0 comments on commit e662f57

Please sign in to comment.