Skip to content

Commit

Permalink
run rector
Browse files Browse the repository at this point in the history
  • Loading branch information
mustapayev committed Nov 17, 2024
1 parent 4c53a77 commit 93b3433
Show file tree
Hide file tree
Showing 32 changed files with 54 additions and 69 deletions.
4 changes: 1 addition & 3 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,17 @@
LevelSetList::UP_TO_PHP_74,
])
->withSkip([
\Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector::class,
\Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector::class,
\Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector::class,
\Rector\Php74\Rector\Property\RestoreDefaultNullToNullableTypePropertyRector::class,
\Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector::class,

\Rector\Naming\Rector\Class_\RenamePropertyToMatchTypeRector::class,
\Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector::class,
\Rector\Naming\Rector\ClassMethod\RenameVariableToMatchNewTypeRector::class,
\Rector\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector::class,
\Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector::class,

\Rector\TypeDeclaration\Rector\ClassMethod\NumericReturnTypeFromStrictScalarReturnsRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictScalarReturnExprRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictParamRector::class,
])
->withPreparedSets(
Expand Down
4 changes: 1 addition & 3 deletions src/DataMapper/RequestDataMapper/EstPosRequestDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,7 @@ public function create3DFormData(AbstractPosAccount $posAccount, array $order, s
*/
public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array
{
$requestData += $this->getRequestAccountData($posAccount);

return $requestData;
return $requestData + $this->getRequestAccountData($posAccount);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,7 @@ public function create3DFormData(AbstractPosAccount $posAccount, array $order, s
*/
public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array
{
$requestData += $this->getRequestAccountData($posAccount);

return $requestData;
return $requestData + $this->getRequestAccountData($posAccount);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,7 @@ public function createRefundRequestData(AbstractPosAccount $posAccount, array $o
*/
public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array
{
$requestData += $this->getRequestAccountData($posAccount);

return $requestData;
return $requestData + $this->getRequestAccountData($posAccount);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,7 @@ public function createRefundRequestData(AbstractPosAccount $posAccount, array $o
*/
public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array
{
$requestData += $this->getRequestAccountData($posAccount);

return $requestData;
return $requestData + $this->getRequestAccountData($posAccount);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,9 @@ public function createHistoryRequestData(AbstractPosAccount $posAccount, array $
*/
public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array
{
$requestData += $this->getRequestAccountData($posAccount) + [
return $requestData + ($this->getRequestAccountData($posAccount) + [
'MbrId' => self::MBR_ID,
];

return $requestData;
]);
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,10 @@ public function create3DResolveMerchantRequestData(AbstractPosAccount $posAccoun
*/
public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array
{
$requestData += [
return $requestData + [
'mid' => $posAccount->getClientId(),
'tid' => $posAccount->getTerminalId(),
];

return $requestData;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public function mapOrderHistoryResponse(array $rawResponseData): array
}

if (!$isRecurringOrder) {
\usort($transactions, static function (array $tx1, array $tx2) {
\usort($transactions, static function (array $tx1, array $tx2): int {
if (null !== $tx1['transaction_time'] && null === $tx2['transaction_time']) {
return 1;
}
Expand Down
5 changes: 3 additions & 2 deletions src/Gateways/AbstractGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ public function customQuery(array $requestData, string $apiUrl = null): PosInter
}

$data = $this->serializer->encode($updatedRequestData, $txType);
$apiUrl = $apiUrl ?? $this->getQueryAPIUrl($txType);
$apiUrl ??= $this->getQueryAPIUrl($txType);
$this->response = $this->send(
$data,
$txType,
Expand Down Expand Up @@ -664,7 +664,8 @@ protected function check3DFormInputs(string $paymentModel, string $txType, Credi
throw new \LogicException('Bu banka altyapısı sağlanan ödeme modelini ya da işlem tipini desteklenmiyor.');
}

if ((PosInterface::MODEL_3D_SECURE === $paymentModel || PosInterface::MODEL_3D_PAY === $paymentModel) && null === $card) {
if ((PosInterface::MODEL_3D_SECURE === $paymentModel || PosInterface::MODEL_3D_PAY === $paymentModel)
&& !$card instanceof \Mews\Pos\Entity\Card\CreditCardInterface) {
throw new \InvalidArgumentException('Bu ödeme modeli için kart bilgileri zorunlu!');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ class PayForPosRequestDataMapperTest extends TestCase
/** @var CryptInterface & MockObject */
private CryptInterface $crypt;

private array $order;

/** @var EventDispatcherInterface & MockObject */
private EventDispatcherInterface $dispatcher;

Expand All @@ -52,16 +50,6 @@ protected function setUp(): void
'12345678'
);

$this->order = [
'id' => '2020110828BC',
'amount' => 100.01,
'installment' => '0',
'currency' => PosInterface::CURRENCY_TRY,
'success_url' => 'http://localhost/finansbank-payfor/3d/response.php',
'fail_url' => 'http://localhost/finansbank-payfor/3d/response.php',
'lang' => PosInterface::LANG_TR,
];

$this->crypt = $this->createMock(CryptInterface::class);
$this->dispatcher = $this->createMock(EventDispatcherInterface::class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
}

$this->assertArrayHasKey('3d_all', $actualData);
$this->assertIsArray($actualData['3d_all']);
$this->assertNotEmpty($actualData['3d_all']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
}

$this->assertArrayHasKey('3d_all', $actualData);
$this->assertIsArray($actualData['3d_all']);
$this->assertNotEmpty($actualData['3d_all']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
}

$this->assertArrayHasKey('3d_all', $actualData);
$this->assertIsArray($actualData['3d_all']);
$this->assertNotEmpty($actualData['3d_all']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public function testMapPaymentResponse(array $order, string $txType, array $resp
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
}

unset($actualData['all']);

\ksort($expectedData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
}

$this->assertArrayHasKey('3d_all', $actualData);
$this->assertIsArray($actualData['3d_all']);
$this->assertNotEmpty($actualData['3d_all']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
}

$this->assertArrayHasKey('3d_all', $actualData);
$this->assertIsArray($actualData['3d_all']);
$this->assertNotEmpty($actualData['3d_all']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
}

$this->assertArrayHasKey('3d_all', $actualData);
$this->assertIsArray($actualData['3d_all']);
$this->assertNotEmpty($actualData['3d_all']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
}

$this->assertArrayHasKey('3d_all', $actualData);
$this->assertIsArray($actualData['3d_all']);
$this->assertNotEmpty($actualData['3d_all']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
}

$this->assertArrayHasKey('3d_all', $actualData);
$this->assertIsArray($actualData['3d_all']);
$this->assertNotEmpty($actualData['3d_all']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
}

$this->assertArrayHasKey('3d_all', $actualData);
$this->assertIsArray($actualData['3d_all']);
$this->assertNotEmpty($actualData['3d_all']);
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Gateways/AkbankPosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ private function configureClientResponse(
->method('dispatch')
->with($this->logicalAnd(
$this->isInstanceOf(RequestDataPreparedEvent::class),
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) {
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool {
$updatedRequestDataPreparedEvent = $dispatchedEvent;

return get_class($this->pos) === $dispatchedEvent->getGatewayClass()
Expand All @@ -1042,7 +1042,7 @@ private function configureClientResponse(
&& $paymentModel === $dispatchedEvent->getPaymentModel();
}
)))
->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent) {
->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent {
$updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData();
$updatedRequestData['test-update-request-data-with-event'] = true;
$updatedRequestDataPreparedEvent->setRequestData($updatedRequestData);
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Gateways/EstPosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ private function configureClientResponse(
->method('dispatch')
->with($this->logicalAnd(
$this->isInstanceOf(RequestDataPreparedEvent::class),
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) {
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool {
$updatedRequestDataPreparedEvent = $dispatchedEvent;

return get_class($this->pos) === $dispatchedEvent->getGatewayClass()
Expand All @@ -889,7 +889,7 @@ private function configureClientResponse(
&& $paymentModel === $dispatchedEvent->getPaymentModel();
}
)))
->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent) {
->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent {
$updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData();
$updatedRequestData['test-update-request-data-with-event'] = true;
$updatedRequestDataPreparedEvent->setRequestData($updatedRequestData);
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Gateways/GarantiPosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ private function configureClientResponse(
->method('dispatch')
->with($this->logicalAnd(
$this->isInstanceOf(RequestDataPreparedEvent::class),
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) {
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool {
$updatedRequestDataPreparedEvent = $dispatchedEvent;

return get_class($this->pos) === $dispatchedEvent->getGatewayClass()
Expand All @@ -811,7 +811,7 @@ private function configureClientResponse(
&& $paymentModel === $dispatchedEvent->getPaymentModel();
}
)))
->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent) {
->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent {
$updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData();
$updatedRequestData['test-update-request-data-with-event'] = true;
$updatedRequestDataPreparedEvent->setRequestData($updatedRequestData);
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Gateways/InterPosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ private function configureClientResponse(
->method('dispatch')
->with($this->logicalAnd(
$this->isInstanceOf(RequestDataPreparedEvent::class),
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) {
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool {
$updatedRequestDataPreparedEvent = $dispatchedEvent;

return get_class($this->pos) === $dispatchedEvent->getGatewayClass()
Expand All @@ -752,7 +752,7 @@ private function configureClientResponse(
&& $paymentModel === $dispatchedEvent->getPaymentModel();
}
)))
->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent) {
->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent {
$updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData();
$updatedRequestData['test-update-request-data-with-event'] = true;
$updatedRequestDataPreparedEvent->setRequestData($updatedRequestData);
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/Gateways/KuveytPosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public function testMake3DPayment(
->method('dispatch')
->with($this->logicalAnd(
$this->isInstanceOf(RequestDataPreparedEvent::class),
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($create3DPaymentRequestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) {
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($create3DPaymentRequestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool {
$updatedRequestDataPreparedEvent = $dispatchedEvent;

return get_class($this->pos) === $dispatchedEvent->getGatewayClass()
Expand All @@ -317,7 +317,7 @@ public function testMake3DPayment(
&& $paymentModel === $dispatchedEvent->getPaymentModel();
}
)))
->willReturnCallback(function() use (&$updatedRequestDataPreparedEvent) {
->willReturnCallback(function() use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent {
$updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData();
$updatedRequestData['test-update-request-data-with-event'] = true;
$updatedRequestDataPreparedEvent->setRequestData($updatedRequestData);
Expand Down Expand Up @@ -664,7 +664,7 @@ private function configureClientResponse(
->method('dispatch')
->with($this->logicalAnd(
$this->isInstanceOf(RequestDataPreparedEvent::class),
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) {
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool {
$updatedRequestDataPreparedEvent = $dispatchedEvent;

return get_class($this->pos) === $dispatchedEvent->getGatewayClass()
Expand All @@ -674,7 +674,7 @@ private function configureClientResponse(
&& $paymentModel === $dispatchedEvent->getPaymentModel();
}
)))
->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent) {
->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent {
$updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData();
$updatedRequestData['test-update-request-data-with-event'] = true;
$updatedRequestDataPreparedEvent->setRequestData($updatedRequestData);
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Gateways/PayFlexCPV4PosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ private function configureClientResponse(
->method('dispatch')
->with($this->logicalAnd(
$this->isInstanceOf(RequestDataPreparedEvent::class),
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) {
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool {
$updatedRequestDataPreparedEvent = $dispatchedEvent;

return get_class($this->pos) === $dispatchedEvent->getGatewayClass()
Expand All @@ -709,7 +709,7 @@ private function configureClientResponse(
&& $paymentModel === $dispatchedEvent->getPaymentModel();
}
)))
->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent) {
->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent {
$updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData();
$updatedRequestData['test-update-request-data-with-event'] = true;
$updatedRequestDataPreparedEvent->setRequestData($updatedRequestData);
Expand Down
Loading

0 comments on commit 93b3433

Please sign in to comment.