mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
[CS][DX] Refactor (#17230)
This PR has been generated automatically. For more details see [refactor.yaml](/Sylius/Sylius/blob/1.12/.github/workflows/refactor.yaml).
This commit is contained in:
commit
807fa2c595
16 changed files with 31 additions and 27 deletions
|
|
@ -19,7 +19,7 @@ final class PaymentMethodNotFoundException extends \RuntimeException
|
|||
public function __construct(
|
||||
string $message = 'Payment method not found.',
|
||||
int $code = 0,
|
||||
\Throwable $previous = null,
|
||||
?\Throwable $previous = null,
|
||||
) {
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,13 +34,13 @@ final class AddPaymentRequestHandlerTest extends TestCase
|
|||
{
|
||||
use ProphecyTrait;
|
||||
|
||||
private PaymentMethodRepositoryInterface|ObjectProphecy $paymentMethodRepository;
|
||||
private ObjectProphecy|PaymentMethodRepositoryInterface $paymentMethodRepository;
|
||||
|
||||
private PaymentRepositoryInterface|ObjectProphecy $paymentRepository;
|
||||
private ObjectProphecy|PaymentRepositoryInterface $paymentRepository;
|
||||
|
||||
private PaymentRequestFactoryInterface|ObjectProphecy $paymentRequestFactory;
|
||||
private ObjectProphecy|PaymentRequestFactoryInterface $paymentRequestFactory;
|
||||
|
||||
private PaymentRequestRepositoryInterface|ObjectProphecy $paymentRequestRepository;
|
||||
private ObjectProphecy|PaymentRequestRepositoryInterface $paymentRequestRepository;
|
||||
|
||||
private DefaultActionProviderInterface|ObjectProphecy $defaultActionProvider;
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ final class AddPaymentRequestHandlerTest extends TestCase
|
|||
$this->paymentRequestFactory->reveal(),
|
||||
$this->paymentRequestRepository->reveal(),
|
||||
$this->defaultActionProvider->reveal(),
|
||||
$this->defaultPayloadProvider->reveal()
|
||||
$this->defaultPayloadProvider->reveal(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ final class OrderPayController
|
|||
}
|
||||
}
|
||||
|
||||
throw new LogicException(sprintf('No "pay response provider" available for order (id %s).', $order->getId()));
|
||||
throw new LogicException(sprintf('No "pay response provider" available for order (id %s).', $order->getId()));
|
||||
}
|
||||
|
||||
public function afterPayAction(Request $request): Response
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@ final class AfterPayUrlProvider implements AfterPayUrlProviderInterface
|
|||
) {
|
||||
}
|
||||
|
||||
public function getUrl(PaymentRequestInterface $paymentRequest): string {
|
||||
public function getUrl(PaymentRequestInterface $paymentRequest): string
|
||||
{
|
||||
$context = [
|
||||
'paymentRequest' => $paymentRequest,
|
||||
'payment' => $paymentRequest->getPayment(),
|
||||
|
|
@ -39,7 +40,7 @@ final class AfterPayUrlProvider implements AfterPayUrlProviderInterface
|
|||
return $this->routeParametersProcessor->process(
|
||||
$this->afterPayRoute,
|
||||
$this->afterPayRouteParameters,
|
||||
$context
|
||||
$context,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ final class FinalUrlProvider implements FinalUrlProviderInterface
|
|||
) {
|
||||
}
|
||||
|
||||
public function getUrl(?PaymentInterface $payment): string {
|
||||
public function getUrl(?PaymentInterface $payment): string
|
||||
{
|
||||
$context = [
|
||||
'payment' => $payment,
|
||||
'order' => $payment?->getOrder(),
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ final class PaymentRequestWorkflowTest extends KernelTestCase
|
|||
|
||||
$this->paymentRequest = new PaymentRequest(
|
||||
$this->createMock(PaymentInterface::class),
|
||||
$this->createMock(PaymentMethodInterface::class)
|
||||
$this->createMock(PaymentMethodInterface::class),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ final class RouteParametersProcessorSpec extends ObjectBehavior
|
|||
|
||||
$router->generate(
|
||||
'a_route',
|
||||
['aParam'=>'value'],
|
||||
['aParam' => 'value'],
|
||||
)->willReturn('https://localhost/a_route?aParam=value');
|
||||
|
||||
$this->process(
|
||||
|
|
@ -59,12 +59,12 @@ final class RouteParametersProcessorSpec extends ObjectBehavior
|
|||
ExpressionLanguage $expressionLanguage,
|
||||
): void {
|
||||
$expressionLanguage->evaluate('value', [
|
||||
'value' => '1'
|
||||
'value' => '1',
|
||||
])->willReturn('1')->shouldBeCalledOnce();
|
||||
|
||||
$router->generate(
|
||||
'a_route',
|
||||
['aParam'=>'1'],
|
||||
['aParam' => '1'],
|
||||
)->willReturn('https://localhost/a_route?aParam=1');
|
||||
|
||||
$this->process(
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace spec\Sylius\Bundle\CoreBundle\OrderPay\Provider;
|
||||
|
||||
use Sylius\Bundle\CoreBundle\OrderPay\Processor\RouteParametersProcessorInterface;
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Sylius\Bundle\CoreBundle\OrderPay\Processor\RouteParametersProcessorInterface;
|
||||
use Sylius\Component\Core\Model\PaymentInterface;
|
||||
use Sylius\Component\Payment\Model\PaymentInterface as BasePaymentInterface;
|
||||
|
||||
|
|
@ -31,6 +31,7 @@ final class FinalUrlProviderSpec extends ObjectBehavior
|
|||
[],
|
||||
);
|
||||
}
|
||||
|
||||
function it_provides_a_final_url_from_null_payment(
|
||||
RouteParametersProcessorInterface $routeParametersProcessor,
|
||||
): void {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ final class NonExistingPayumTokenException extends \RuntimeException
|
|||
public function __construct(
|
||||
string $message = 'Payum token cannot be null.',
|
||||
int $code = 0,
|
||||
\Throwable $previous = null,
|
||||
?\Throwable $previous = null,
|
||||
) {
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use Sylius\Component\Payment\Model\GatewayConfig as BaseGatewayConfig;
|
|||
|
||||
class GatewayConfig extends BaseGatewayConfig implements GatewayConfigInterface
|
||||
{
|
||||
/** @var array<string, mixed> $decryptedConfig */
|
||||
/** @var array<string, mixed> */
|
||||
protected array $decryptedConfig;
|
||||
|
||||
public function __construct()
|
||||
|
|
|
|||
|
|
@ -53,19 +53,20 @@ final class PayumAfterPayResponseProvider implements AfterPayResponseProviderInt
|
|||
|
||||
$url = $this->router->generate(
|
||||
$resolveNextRoute->getRouteName(),
|
||||
$resolveNextRoute->getRouteParameters()
|
||||
$resolveNextRoute->getRouteParameters(),
|
||||
);
|
||||
|
||||
$this->getHttpRequestVerifier()->invalidate($token);
|
||||
|
||||
return new RedirectResponse($url);
|
||||
}
|
||||
|
||||
public function supports(RequestConfiguration $requestConfiguration): bool
|
||||
{
|
||||
$request = $requestConfiguration->getRequest();
|
||||
$hash = $request->attributes->get('payum_token', $request->get('payum_token', false));
|
||||
|
||||
return false !== $hash;
|
||||
return false !== $hash;
|
||||
}
|
||||
|
||||
private function getHttpRequestVerifier(): HttpRequestVerifierInterface
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ final class PayumPayResponseProvider implements PayResponseProviderInterface
|
|||
|
||||
public function getResponse(
|
||||
RequestConfiguration $requestConfiguration,
|
||||
OrderInterface $order
|
||||
OrderInterface $order,
|
||||
): Response {
|
||||
$payment = $this->paymentToPayResolver->getPayment($order);
|
||||
Assert::notNull($payment, sprintf('Order (id %s) must have last payment in state "new".', $order->getId()));
|
||||
|
|
@ -51,11 +51,11 @@ final class PayumPayResponseProvider implements PayResponseProviderInterface
|
|||
|
||||
return new RedirectResponse($token->getTargetUrl());
|
||||
}
|
||||
|
||||
public function supports(
|
||||
RequestConfiguration $requestConfiguration,
|
||||
OrderInterface $order
|
||||
OrderInterface $order,
|
||||
): bool {
|
||||
|
||||
$payment = $this->paymentToPayResolver->getPayment($order);
|
||||
if (null === $payment) {
|
||||
return false;
|
||||
|
|
@ -68,7 +68,7 @@ final class PayumPayResponseProvider implements PayResponseProviderInterface
|
|||
|
||||
$gatewayName = $gatewayConfig->getGatewayName() ?? '';
|
||||
|
||||
return isset($this->payum->getGateways()[$gatewayName]);
|
||||
return isset($this->payum->getGateways()[$gatewayName]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ final readonly class RequestProcessor implements RequestProcessorInterface
|
|||
$this->stateMachine->apply(
|
||||
$paymentRequest,
|
||||
PaymentRequestTransitions::GRAPH,
|
||||
PaymentRequestTransitions::TRANSITION_COMPLETE
|
||||
PaymentRequestTransitions::TRANSITION_COMPLETE,
|
||||
);
|
||||
|
||||
if (false === $request instanceof TokenAggregateInterface) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ final class InvalidPaymentRequestPayloadException extends \RuntimeException
|
|||
public function __construct(
|
||||
string $message = 'Payload of the payment request is invalid.',
|
||||
int $code = 0,
|
||||
\Throwable $previous = null,
|
||||
?\Throwable $previous = null,
|
||||
) {
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ final class PaymentRequestNotFoundException extends \RuntimeException
|
|||
public function __construct(
|
||||
string $message = 'Payment request not found.',
|
||||
int $code = 0,
|
||||
\Throwable $previous = null,
|
||||
?\Throwable $previous = null,
|
||||
) {
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class GatewayConfig implements GatewayConfigInterface
|
|||
|
||||
protected ?string $gatewayName = null;
|
||||
|
||||
/** @var array<string, mixed> $config */
|
||||
/** @var array<string, mixed> */
|
||||
protected array $config;
|
||||
|
||||
public function __construct()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue