diff --git a/src/Components/CardRepository/CardRepository.php b/src/Components/CardRepository/CardRepository.php index fb4c3a92c..53a0fd38d 100644 --- a/src/Components/CardRepository/CardRepository.php +++ b/src/Components/CardRepository/CardRepository.php @@ -107,6 +107,9 @@ public function getExistingCard( new EqualsFilter('payone_payment_card.customerId', $customer->getId()) ); - return $this->cardRepository->search($criteria, $context)->first(); + /** @var PayonePaymentCardEntity|null $card */ + $card = $this->cardRepository->search($criteria, $context)->first(); + + return $card; } } diff --git a/src/Components/Helper/OrderFetcher.php b/src/Components/Helper/OrderFetcher.php index 0944d6b21..391a297d1 100644 --- a/src/Components/Helper/OrderFetcher.php +++ b/src/Components/Helper/OrderFetcher.php @@ -28,7 +28,10 @@ public function getOrderById(string $orderId, Context $context): ?OrderEntity $criteria = $this->getOrderCriteria(); $criteria->addFilter(new EqualsFilter('id', $orderId)); - return $this->orderRepository->search($criteria, $context)->first(); + /** @var OrderEntity|null $order */ + $order = $this->orderRepository->search($criteria, $context)->first(); + + return $order; } public function getOrderBillingAddress(OrderEntity $order): OrderAddressEntity diff --git a/src/Components/KlarnaSessionService/KlarnaSessionService.php b/src/Components/KlarnaSessionService/KlarnaSessionService.php index 3b6a8bee6..ac0949ade 100644 --- a/src/Components/KlarnaSessionService/KlarnaSessionService.php +++ b/src/Components/KlarnaSessionService/KlarnaSessionService.php @@ -10,6 +10,7 @@ use PayonePayment\Payone\RequestParameter\Struct\KlarnaCreateSessionStruct; use PayonePayment\Storefront\Struct\CheckoutKlarnaSessionData; use Shopware\Core\Checkout\Cart\SalesChannel\CartService; +use Shopware\Core\Checkout\Order\OrderEntity; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\System\SalesChannel\SalesChannelContext; @@ -28,6 +29,7 @@ public function createKlarnaSession(SalesChannelContext $salesChannelContext, ?s { if ($orderId) { $orderCriteria = $this->cartHasher->getCriteriaForOrder($orderId); + /** @var OrderEntity|null $order */ $order = $this->orderEntityRepository->search($orderCriteria, $salesChannelContext->getContext())->first(); } diff --git a/src/Components/MandateService/MandateService.php b/src/Components/MandateService/MandateService.php index b534e4f9d..67f638d9a 100644 --- a/src/Components/MandateService/MandateService.php +++ b/src/Components/MandateService/MandateService.php @@ -117,6 +117,9 @@ protected function getExistingMandate( new EqualsFilter('customerId', $customer->getId()) ); - return $this->mandateRepository->search($criteria, $context)->first(); + /** @var PayonePaymentMandateEntity|null $mandate */ + $mandate = $this->mandateRepository->search($criteria, $context)->first(); + + return $mandate; } } diff --git a/src/Components/TransactionHandler/AbstractTransactionHandler.php b/src/Components/TransactionHandler/AbstractTransactionHandler.php index 061482f30..7811379c3 100644 --- a/src/Components/TransactionHandler/AbstractTransactionHandler.php +++ b/src/Components/TransactionHandler/AbstractTransactionHandler.php @@ -198,6 +198,9 @@ protected function getTransaction(string $transactionId): ?OrderTransactionEntit $criteria->addAssociation('order.deliveries'); $criteria->addAssociation('paymentMethod'); - return $this->transactionRepository->search($criteria, $this->context)->first(); + /** @var OrderTransactionEntity|null $transaction */ + $transaction = $this->transactionRepository->search($criteria, $this->context)->first(); + + return $transaction; } } diff --git a/src/Controller/SettingsController.php b/src/Controller/SettingsController.php index 2dc05073c..8da6a8902 100644 --- a/src/Controller/SettingsController.php +++ b/src/Controller/SettingsController.php @@ -51,7 +51,9 @@ public function validateApiCredentials(Request $request, Context $context): Json $criteria = (new Criteria())->addFilter(new EqualsFilter('handlerIdentifier', $paymentClass)); $paymentMethod = $this->paymentMethodRepository->search($criteria, $context)->first(); - if (!$paymentMethod || !$paymentMethod->getActive() || \in_array($paymentMethod->getHandlerIdentifier(), Handler\PaymentHandlerGroups::RATEPAY, true)) { + if (!$paymentMethod instanceof PaymentMethodEntity + || !$paymentMethod->getActive() + || \in_array($paymentMethod->getHandlerIdentifier(), Handler\PaymentHandlerGroups::RATEPAY, true)) { continue; } diff --git a/src/EventListener/CheckoutFinishEventListener.php b/src/EventListener/CheckoutFinishEventListener.php index e0ee28aac..03790002f 100644 --- a/src/EventListener/CheckoutFinishEventListener.php +++ b/src/EventListener/CheckoutFinishEventListener.php @@ -80,7 +80,10 @@ private function getMandate(string $mandateIdentification, Context $context): ?P $criteria = new Criteria(); $criteria->addFilter(new EqualsFilter('identification', $mandateIdentification)); - return $this->mandateRepository->search($criteria, $context)->first(); + /** @var PayonePaymentMandateEntity|null $mandate */ + $mandate = $this->mandateRepository->search($criteria, $context)->first(); + + return $mandate; } private function getMandateIdentification(OrderEntity $order, Context $context): ?string diff --git a/src/Installer/PaymentMethodInstaller.php b/src/Installer/PaymentMethodInstaller.php index 156df8906..5b1f6b7c0 100644 --- a/src/Installer/PaymentMethodInstaller.php +++ b/src/Installer/PaymentMethodInstaller.php @@ -211,9 +211,12 @@ private function getPaymentMethods(): array private function findPaymentMethodEntity(string $id, Context $context): ?PaymentMethodEntity { - return $this->paymentMethodRepository + /** @var PaymentMethodEntity|null $paymentMethod */ + $paymentMethod = $this->paymentMethodRepository ->search(new Criteria([$id]), $context) ->first(); + + return $paymentMethod; } private function upsertPaymentMethod(PaymentMethodInterface $paymentMethod, Context $context): void diff --git a/src/Payone/RequestParameter/Builder/ApplePay/AuthorizeRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/ApplePay/AuthorizeRequestParameterBuilder.php index 6418a6552..e86dab5d1 100644 --- a/src/Payone/RequestParameter/Builder/ApplePay/AuthorizeRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/ApplePay/AuthorizeRequestParameterBuilder.php @@ -150,7 +150,10 @@ private function getOrderById(AbstractRequestParameterStruct $arguments): ?Order $criteria->addAssociation('addresses'); $criteria->addAssociation('addresses.country'); - return $this->orderRepository->search($criteria, $context)->first(); + /** @var OrderEntity|null $order */ + $order = $this->orderRepository->search($criteria, $context)->first(); + + return $order; } private function getCardType(ParameterBag $requestDataBag): string diff --git a/src/Payone/RequestParameter/Builder/CustomerRequestParameterBuilder.php b/src/Payone/RequestParameter/Builder/CustomerRequestParameterBuilder.php index 07a04c8b7..fccafff23 100644 --- a/src/Payone/RequestParameter/Builder/CustomerRequestParameterBuilder.php +++ b/src/Payone/RequestParameter/Builder/CustomerRequestParameterBuilder.php @@ -171,7 +171,7 @@ private function getCustomerSalutation(CustomerAddressEntity $addressEntity, Con $salutation = $this->salutationRepository->search($criteria, $context)->first(); - if ($salutation === null) { + if (!$salutation instanceof SalutationEntity) { throw new \RuntimeException('missing order customer salutation'); } diff --git a/src/Storefront/Controller/Account/AccountOrderControllerDecorator.php b/src/Storefront/Controller/Account/AccountOrderControllerDecorator.php index f6405ab36..a8b0ce724 100644 --- a/src/Storefront/Controller/Account/AccountOrderControllerDecorator.php +++ b/src/Storefront/Controller/Account/AccountOrderControllerDecorator.php @@ -5,6 +5,7 @@ namespace PayonePayment\Storefront\Controller\Account; use PayonePayment\PaymentHandler\PaymentHandlerGroups; +use Shopware\Core\Checkout\Order\OrderEntity; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; @@ -77,6 +78,7 @@ protected function isRatepayOrder(string $orderId, Context $context): bool $criteria = new Criteria([$orderId]); $criteria->addAssociation('transactions.paymentMethod'); + /** @var OrderEntity|null $order */ $order = $this->orderRepository->search($criteria, $context)->first(); if ($order && $order->getTransactions()) {