Skip to content

Commit

Permalink
Fix phpstan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Moritz Müller committed Nov 15, 2023
1 parent 98e94cd commit 5cb5ed8
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/Components/CardRepository/CardRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
5 changes: 4 additions & 1 deletion src/Components/Helper/OrderFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/Components/KlarnaSessionService/KlarnaSessionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
}

Expand Down
5 changes: 4 additions & 1 deletion src/Components/MandateService/MandateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
4 changes: 3 additions & 1 deletion src/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 4 additions & 1 deletion src/EventListener/CheckoutFinishEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/Installer/PaymentMethodInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()) {
Expand Down

0 comments on commit 5cb5ed8

Please sign in to comment.