[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:
Grzegorz Sadowski 2024-10-15 07:31:58 +02:00 committed by GitHub
commit 807fa2c595
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 31 additions and 27 deletions

View file

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

View file

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

View file

@ -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

View file

@ -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,
);
}
}

View file

@ -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(),

View file

@ -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),
);
}

View file

@ -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(

View file

@ -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 {

View file

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

View file

@ -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()

View file

@ -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

View file

@ -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]);
}
/**

View file

@ -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) {

View file

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

View file

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

View file

@ -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()