diff --git a/src/Controller/PaymentController.php b/src/Controller/PaymentController.php index 2a57a33..54811af 100644 --- a/src/Controller/PaymentController.php +++ b/src/Controller/PaymentController.php @@ -34,10 +34,6 @@ class PaymentController extends AbstractController public const TOKEN_HASH_SESSION_KEY = 'webgriffe_klarna_token_hash'; - /** - * @param OrderRepositoryInterface $orderRepository - * @param PaymentRepositoryInterface $paymentRepository - */ public function __construct( private readonly OrderRepositoryInterface $orderRepository, private readonly RequestStack $requestStack, diff --git a/src/Helper/PaymentDetailsHelper.php b/src/Helper/PaymentDetailsHelper.php index e123a17..8fd35bf 100644 --- a/src/Helper/PaymentDetailsHelper.php +++ b/src/Helper/PaymentDetailsHelper.php @@ -9,6 +9,8 @@ use Webmozart\Assert\InvalidArgumentException; /** + * @psalm-suppress TypeDoesNotContainType + * * @psalm-import-type StoredPaymentDetails from PaymentDetails */ final class PaymentDetailsHelper diff --git a/src/Payum/Action/CancelAction.php b/src/Payum/Action/CancelAction.php index 8f5373b..599fd5e 100644 --- a/src/Payum/Action/CancelAction.php +++ b/src/Payum/Action/CancelAction.php @@ -20,6 +20,8 @@ use Webmozart\Assert\Assert; /** + * @psalm-suppress TypeDoesNotContainType + * * @psalm-import-type StoredPaymentDetails from PaymentDetails */ final class CancelAction implements ActionInterface @@ -42,9 +44,12 @@ public function execute($request): void $payment = $request->getModel(); Assert::isInstanceOf($payment, SyliusPaymentInterface::class); + /** @var string|int $paymentId */ + $paymentId = $payment->getId(); + $this->logger->info(sprintf( 'Start cancel action for Sylius payment with ID "%s".', - $payment->getId(), + $paymentId, )); $paymentDetails = $payment->getDetails(); @@ -53,7 +58,7 @@ public function execute($request): void $this->logger->info('Redirecting the user to the Sylius Klarna Payments waiting page.'); $session = $this->requestStack->getSession(); - $session->set(PaymentController::PAYMENT_ID_SESSION_KEY, $payment->getId()); + $session->set(PaymentController::PAYMENT_ID_SESSION_KEY, $paymentId); $cancelToken = $request->getToken(); Assert::isInstanceOf($cancelToken, TokenInterface::class); $session->set(PaymentController::TOKEN_HASH_SESSION_KEY, $cancelToken->getHash()); diff --git a/src/Payum/Action/CaptureAction.php b/src/Payum/Action/CaptureAction.php index 2d2c4fa..1e94815 100644 --- a/src/Payum/Action/CaptureAction.php +++ b/src/Payum/Action/CaptureAction.php @@ -40,6 +40,7 @@ /** * @psalm-suppress PropertyNotSetInConstructor + * @psalm-suppress TypeDoesNotContainType * * @psalm-import-type StoredPaymentDetails from PaymentDetails */ @@ -74,9 +75,11 @@ public function execute($request): void /** @var SyliusPaymentInterface $payment */ $payment = $request->getModel(); + /** @var string|int $paymentId */ + $paymentId = $payment->getId(); $this->logger->info(sprintf( 'Start capture action for Sylius payment with ID "%s".', - $payment->getId(), + $paymentId, )); $captureToken = $request->getToken(); @@ -106,7 +109,7 @@ public function execute($request): void )); $session = $this->requestStack->getSession(); - $session->set(PaymentController::PAYMENT_ID_SESSION_KEY, $payment->getId()); + $session->set(PaymentController::PAYMENT_ID_SESSION_KEY, $paymentId); $session->set(PaymentController::TOKEN_HASH_SESSION_KEY, $captureToken->getHash()); $order = $payment->getOrder(); @@ -166,10 +169,12 @@ private function createPaymentSession( $paymentSession = $createPaymentSession->getPaymentSession(); Assert::isInstanceOf($paymentSession, PaymentSession::class); + /** @var string|int $paymentId */ + $paymentId = $payment->getId(); $this->logger->info(sprintf( 'Created Klarna Payment Session with ID "%s" for Sylius payment "%s".', $paymentSession->getSessionId(), - $payment->getId(), + $paymentId, )); return PaymentDetails::createFromPaymentSession($paymentSession); diff --git a/src/Payum/Action/NotifyAction.php b/src/Payum/Action/NotifyAction.php index 5877940..4e4e376 100644 --- a/src/Payum/Action/NotifyAction.php +++ b/src/Payum/Action/NotifyAction.php @@ -20,6 +20,9 @@ use Webmozart\Assert\Assert; /** + * @psalm-suppress PropertyNotSetInConstructor + * @psalm-suppress TypeDoesNotContainType + * * @psalm-import-type StoredPaymentDetails from PaymentDetails */ final class NotifyAction implements ActionInterface, GatewayAwareInterface @@ -43,9 +46,11 @@ public function execute($request): void $payment = $request->getModel(); Assert::isInstanceOf($payment, SyliusPaymentInterface::class); + /** @var string|int $paymentId */ + $paymentId = $payment->getId(); $this->logger->info(sprintf( 'Start notify action for Sylius payment with ID "%s".', - $payment->getId(), + $paymentId, )); // This is needed to populate the http request with GET and POST params from current request @@ -56,7 +61,7 @@ public function execute($request): void $this->logger->info(sprintf( 'Received Klarna notification for payment with ID "%s".', - $payment->getId(), + $paymentId, ), ['Request parameters' => $requestParameters]); $storedPaymentDetails = $payment->getDetails(); diff --git a/tests/Behat/Context/PayumPaymentTrait.php b/tests/Behat/Context/PayumPaymentTrait.php index 5829ad9..744f762 100644 --- a/tests/Behat/Context/PayumPaymentTrait.php +++ b/tests/Behat/Context/PayumPaymentTrait.php @@ -35,7 +35,6 @@ private function getCurrentPayment(): PaymentInterface */ private function getCurrentPaymentSecurityTokens(PaymentInterface $payment): array { - /** @var PaymentSecurityTokenInterface[] $allPaymentTokens */ $allPaymentTokens = $this->getPaymentTokenRepository()->findAll(); $paymentSecurityTokens = array_filter($allPaymentTokens, static function (PaymentSecurityTokenInterface $token) use ($payment): bool { return $token->getDetails()->getId() === $payment->getId() &&