From 443f72252c7b7a0e5781916a5ebd0e8f97d6683f Mon Sep 17 00:00:00 2001 From: Szymon Kostrubiec Date: Thu, 25 Jul 2024 09:23:07 +0200 Subject: [PATCH] OP-377 - Add fix for PHPSpec, PHPStan and run ECS --- spec/Action/NotifyActionSpec.php | 5 +++++ spec/Bridge/MercanetBnpParibasBridgeSpec.php | 2 +- src/Bridge/MercanetBnpParibasBridge.php | 10 ++++------ src/Bridge/MercanetBnpParibasBridgeInterface.php | 9 +++------ src/Legacy/Mercanet.php | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/spec/Action/NotifyActionSpec.php b/spec/Action/NotifyActionSpec.php index dcd329e..fbbaa99 100644 --- a/spec/Action/NotifyActionSpec.php +++ b/spec/Action/NotifyActionSpec.php @@ -45,8 +45,13 @@ function it_execute( FactoryInterface $stateMachineFactory, StateMachineInterface $stateMachine ) { + $params = [ + 'authorisationId' => '123' + ]; $request->getModel()->willReturn($arrayObject); $request->getFirstModel()->willReturn($payment); + $mercanetBnpParibasBridge->getAuthorisationId()->willReturn('123'); + $payment->getDetails()->willReturn($params); $mercanetBnpParibasBridge->isPostMethod()->willReturn(true); $mercanetBnpParibasBridge->paymentVerification()->willReturn(true); $stateMachineFactory->get($payment, PaymentTransitions::GRAPH)->willReturn($stateMachine); diff --git a/spec/Bridge/MercanetBnpParibasBridgeSpec.php b/spec/Bridge/MercanetBnpParibasBridgeSpec.php index 4a28b7d..a0cfc39 100644 --- a/spec/Bridge/MercanetBnpParibasBridgeSpec.php +++ b/spec/Bridge/MercanetBnpParibasBridgeSpec.php @@ -67,7 +67,7 @@ function it_payment_verification_has_been_thrown( { $request->isMethod('POST')->willReturn(true); $requestStack->getCurrentRequest()->willReturn($request); - + $this->setSecretKey('123'); $this ->shouldThrow(\InvalidArgumentException::class) ->during('paymentVerification', ['key']) diff --git a/src/Bridge/MercanetBnpParibasBridge.php b/src/Bridge/MercanetBnpParibasBridge.php index fbf2c4d..6b9c6a8 100644 --- a/src/Bridge/MercanetBnpParibasBridge.php +++ b/src/Bridge/MercanetBnpParibasBridge.php @@ -13,7 +13,6 @@ namespace BitBag\MercanetBnpParibasPlugin\Bridge; use BitBag\MercanetBnpParibasPlugin\Legacy\Mercanet; -use BitBag\MercanetBnpParibasPlugin\Legacy\ShaComposer; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; @@ -21,8 +20,7 @@ final class MercanetBnpParibasBridge implements MercanetBnpParibasBridgeInterfac { private RequestStack $requestStack; - /** @phpstan-ignore-next-line We should not change our business logic now*/ - private ShaComposer $secretKey; + private string $secretKey; private string $merchantId; @@ -38,7 +36,7 @@ public function __construct(RequestStack $requestStack) } /** @phpstan-ignore-next-line We should not change our business logic now*/ - public function createMercanet(ShaComposer $secretKey): Mercanet + public function createMercanet(string $secretKey): Mercanet { return new Mercanet($secretKey); } @@ -70,13 +68,13 @@ public function isPostMethod(): bool } /** @phpstan-ignore-next-line We should not change our business logic now*/ - public function getSecretKey(): ShaComposer + public function getSecretKey(): string { return $this->secretKey; } /** @phpstan-ignore-next-line We should not change our business logic now*/ - public function setSecretKey(ShaComposer $secretKey): void + public function setSecretKey(string $secretKey): void { $this->secretKey = $secretKey; } diff --git a/src/Bridge/MercanetBnpParibasBridgeInterface.php b/src/Bridge/MercanetBnpParibasBridgeInterface.php index 0c0d869..1759a6b 100644 --- a/src/Bridge/MercanetBnpParibasBridgeInterface.php +++ b/src/Bridge/MercanetBnpParibasBridgeInterface.php @@ -13,12 +13,11 @@ namespace BitBag\MercanetBnpParibasPlugin\Bridge; use BitBag\MercanetBnpParibasPlugin\Legacy\Mercanet; -use BitBag\MercanetBnpParibasPlugin\Legacy\ShaComposer; interface MercanetBnpParibasBridgeInterface { /** @phpstan-ignore-next-line We should not change our business logic now*/ - public function createMercanet(ShaComposer $secretKey): Mercanet; + public function createMercanet(string $secretKey): Mercanet; public function paymentVerification(): bool; @@ -26,11 +25,9 @@ public function getAuthorisationId(): string; public function isPostMethod(): bool; - /** @phpstan-ignore-next-line We should not change our business logic now*/ - public function getSecretKey(): ShaComposer; + public function getSecretKey(): string; - /** @phpstan-ignore-next-line We should not change our business logic now*/ - public function setSecretKey(ShaComposer $secretKey): void; + public function setSecretKey(string $secretKey): void; public function getMerchantId(): string; diff --git a/src/Legacy/Mercanet.php b/src/Legacy/Mercanet.php index a568d38..8e4b12f 100755 --- a/src/Legacy/Mercanet.php +++ b/src/Legacy/Mercanet.php @@ -52,7 +52,7 @@ class Mercanet ]; /** @phpstan-ignore-next-line We should not change our business logic now*/ - private ShaComposer $secretKey; + private string $secretKey; private string $pspURL = self::TEST; @@ -123,7 +123,7 @@ public static function getCurrencies(): array } /** @phpstan-ignore-next-line We should not change our business logic now*/ - public function __construct(ShaComposer $secret) + public function __construct(string $secret) { $this->secretKey = $secret; } @@ -530,7 +530,7 @@ public function toParameterString(): string } /** @phpstan-ignore-next-line We should not change our business logic now*/ - public static function createFromArray(ShaComposer $shaComposer, array $parameters): PaymentRequest|static + public static function createFromArray(string $shaComposer, array $parameters): PaymentRequest|static { /** @phpstan-ignore-next-line Unsafe usage of new static() */ $instance = new static($shaComposer);