From 3fc6b8b3e233fce0f07b4778347b82b81068c453 Mon Sep 17 00:00:00 2001 From: mustapayev Date: Tue, 24 Dec 2024 17:36:17 +0100 Subject: [PATCH] refactor: upgrade phpstan and fix new errors --- composer.json | 12 +- phpstan-baseline.neon | 128 ++++++++++++------ src/Crypt/EstV3PosCrypt.php | 2 +- src/Crypt/PosNetV1PosCrypt.php | 2 +- .../KuveytPosRequestDataMapper.php | 12 +- .../VakifKatilimPosRequestDataMapper.php | 10 +- .../KuveytPosResponseDataMapper.php | 2 +- .../NonPaymentResponseMapperInterface.php | 8 +- .../PaymentResponseMapperInterface.php | 6 +- .../VakifKatilimPosResponseDataMapper.php | 4 +- src/Factory/SerializerFactory.php | 2 +- src/Gateways/PosNet.php | 5 +- 12 files changed, 123 insertions(+), 70 deletions(-) diff --git a/composer.json b/composer.json index 006fe0c6..ee42d1ca 100644 --- a/composer.json +++ b/composer.json @@ -39,10 +39,10 @@ "escapestudios/symfony2-coding-standard": "^3.11", "monolog/monolog": "^2.8", "php-http/curl-client": "^2.2", - "phpstan/phpstan": "^1.11", - "phpstan/phpstan-strict-rules": "^1.4", + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", "phpunit/phpunit": "^9", - "rector/rector": "^1.1", + "rector/rector": "^2.0", "slim/psr7": "^1.4", "squizlabs/php_codesniffer": "^3.5", "symfony/event-dispatcher": "^5.4", @@ -57,5 +57,11 @@ "allow-plugins": { "php-http/discovery": true } + }, + "scripts": { + "test": "./vendor/bin/phpunit --testsuite=unit", + "phpstan": "./vendor/bin/phpstan", + "baseline": "./vendor/bin/phpstan --generate-baseline", + "rector": "./vendor/bin/rector" } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index dc95d65a..2097f0ca 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,191 +1,235 @@ parameters: ignoreErrors: - - message: "#^Parameter \\#1 \\$body of method Psr\\\\Http\\\\Message\\\\MessageInterface\\:\\:withBody\\(\\) expects Psr\\\\Http\\\\Message\\\\StreamInterface, Psr\\\\Http\\\\Message\\\\StreamInterface\\|null given\\.$#" + message: '#^Parameter \#1 \$body of method Psr\\Http\\Message\\MessageInterface\:\:withBody\(\) expects Psr\\Http\\Message\\StreamInterface, Psr\\Http\\Message\\StreamInterface\|null given\.$#' + identifier: argument.type count: 1 path: src/Client/HttpClient.php - - message: "#^Parameter \\#1 \\$content of method Psr\\\\Http\\\\Message\\\\StreamFactoryInterface\\:\\:createStream\\(\\) expects string, array\\\\|string given\\.$#" + message: '#^Parameter \#1 \$content of method Psr\\Http\\Message\\StreamFactoryInterface\:\:createStream\(\) expects string, array\\|string given\.$#' + identifier: argument.type count: 1 path: src/Client/HttpClient.php - - message: "#^Default value of the parameter \\#3 \\$order \\(array\\{\\}\\) of method Mews\\\\Pos\\\\Crypt\\\\PosNetCrypt\\:\\:createHash\\(\\) is incompatible with type array\\{amount\\: int, currency\\: string, id\\: string\\}\\.$#" + message: '#^Default value of the parameter \#3 \$order \(array\{\}\) of method Mews\\Pos\\Crypt\\PosNetCrypt\:\:createHash\(\) is incompatible with type array\{amount\: int, currency\: string, id\: string\}\.$#' + identifier: parameter.defaultValue count: 1 path: src/Crypt/PosNetCrypt.php - - message: "#^Parameter \\#1 \\$currency of method Mews\\\\Pos\\\\DataMapper\\\\RequestDataMapper\\\\AkbankPosRequestDataMapper\\:\\:mapCurrency\\(\\) expects 'EUR'\\|'GBP'\\|'JPY'\\|'RUB'\\|'TRY'\\|'USD', string given\\.$#" + message: '#^PHPDoc tag @var with type array\ is not subtype of native type array\{mixed, mixed, mixed, mixed, mixed, mixed, string\}\.$#' + identifier: varTag.nativeType + count: 1 + path: src/Crypt/PosNetV1PosCrypt.php + + - + message: '#^Parameter \#1 \$currency of method Mews\\Pos\\DataMapper\\RequestDataMapper\\AkbankPosRequestDataMapper\:\:mapCurrency\(\) expects ''EUR''\|''GBP''\|''JPY''\|''RUB''\|''TRY''\|''USD'', string given\.$#' + identifier: argument.type count: 5 path: src/DataMapper/RequestDataMapper/AkbankPosRequestDataMapper.php - - message: "#^Expression on left side of \\?\\? is not nullable\\.$#" + message: '#^Expression on left side of \?\? is not nullable\.$#' + identifier: nullCoalesce.expr count: 1 path: src/DataMapper/RequestDataMapper/EstPosRequestDataMapper.php - - message: "#^Parameter \\#1 \\$currency of method Mews\\\\Pos\\\\DataMapper\\\\RequestDataMapper\\\\EstPosRequestDataMapper\\:\\:mapCurrency\\(\\) expects 'EUR'\\|'GBP'\\|'JPY'\\|'RUB'\\|'TRY'\\|'USD', string given\\.$#" + message: '#^Parameter \#1 \$currency of method Mews\\Pos\\DataMapper\\RequestDataMapper\\EstPosRequestDataMapper\:\:mapCurrency\(\) expects ''EUR''\|''GBP''\|''JPY''\|''RUB''\|''TRY''\|''USD'', string given\.$#' + identifier: argument.type count: 1 path: src/DataMapper/RequestDataMapper/EstPosRequestDataMapper.php - - message: "#^Expression on left side of \\?\\? is not nullable\\.$#" + message: '#^Expression on left side of \?\? is not nullable\.$#' + identifier: nullCoalesce.expr count: 1 path: src/DataMapper/RequestDataMapper/GarantiPosRequestDataMapper.php - - message: "#^Expression on left side of \\?\\? is not nullable\\.$#" + message: '#^Expression on left side of \?\? is not nullable\.$#' + identifier: nullCoalesce.expr count: 1 path: src/DataMapper/RequestDataMapper/InterPosRequestDataMapper.php - - message: "#^Default value of the parameter \\#7 \\$extraData \\(array\\{\\}\\) of method Mews\\\\Pos\\\\DataMapper\\\\RequestDataMapper\\\\PayFlexCPV4PosRequestDataMapper\\:\\:create3DFormData\\(\\) is incompatible with type array\\{CommonPaymentUrl\\: string, PaymentToken\\: string\\}\\.$#" + message: '#^Default value of the parameter \#7 \$extraData \(array\{\}\) of method Mews\\Pos\\DataMapper\\RequestDataMapper\\PayFlexCPV4PosRequestDataMapper\:\:create3DFormData\(\) is incompatible with type array\{CommonPaymentUrl\: string, PaymentToken\: string\}\.$#' + identifier: parameter.defaultValue count: 1 path: src/DataMapper/RequestDataMapper/PayFlexCPV4PosRequestDataMapper.php - - message: "#^Expression on left side of \\?\\? is not nullable\\.$#" + message: '#^Expression on left side of \?\? is not nullable\.$#' + identifier: nullCoalesce.expr count: 1 path: src/DataMapper/RequestDataMapper/PayFlexCPV4PosRequestDataMapper.php - - message: "#^Default value of the parameter \\#7 \\$extraData \\(array\\{\\}\\) of method Mews\\\\Pos\\\\DataMapper\\\\RequestDataMapper\\\\PayFlexV4PosRequestDataMapper\\:\\:create3DFormData\\(\\) is incompatible with type array\\{PaReq\\: string, TermUrl\\: string, MD\\: string, ACSUrl\\: string\\}\\.$#" + message: '#^Default value of the parameter \#7 \$extraData \(array\{\}\) of method Mews\\Pos\\DataMapper\\RequestDataMapper\\PayFlexV4PosRequestDataMapper\:\:create3DFormData\(\) is incompatible with type array\{PaReq\: string, TermUrl\: string, MD\: string, ACSUrl\: string\}\.$#' + identifier: parameter.defaultValue count: 1 path: src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php - - message: "#^Expression on left side of \\?\\? is not nullable\\.$#" + message: '#^Expression on left side of \?\? is not nullable\.$#' + identifier: nullCoalesce.expr count: 1 path: src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\RequestDataMapper\\\\PayFlexV4PosRequestDataMapper\\:\\:create3DEnrollmentCheckRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method Mews\\Pos\\DataMapper\\RequestDataMapper\\PayFlexV4PosRequestDataMapper\:\:create3DEnrollmentCheckRequestData\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/DataMapper/RequestDataMapper/PayFlexV4PosRequestDataMapper.php - - message: "#^Default value of the parameter \\#2 \\$data \\(array\\{\\}\\) of method Mews\\\\Pos\\\\DataMapper\\\\RequestDataMapper\\\\PayForPosRequestDataMapper\\:\\:createHistoryRequestData\\(\\) is incompatible with type array\\{transaction_date\\: DateTimeInterface\\}\\.$#" + message: '#^Default value of the parameter \#2 \$data \(array\{\}\) of method Mews\\Pos\\DataMapper\\RequestDataMapper\\PayForPosRequestDataMapper\:\:createHistoryRequestData\(\) is incompatible with type array\{transaction_date\: DateTimeInterface\}\.$#' + identifier: parameter.defaultValue count: 1 path: src/DataMapper/RequestDataMapper/PayForPosRequestDataMapper.php - - message: "#^Expression on left side of \\?\\? is not nullable\\.$#" + message: '#^Expression on left side of \?\? is not nullable\.$#' + identifier: nullCoalesce.expr count: 1 path: src/DataMapper/RequestDataMapper/PayForPosRequestDataMapper.php - - message: "#^Cannot assign offset 'authCode' to array\\\\|string\\.$#" + message: '#^Cannot assign offset ''authCode'' to array\\|string\.$#' + identifier: offsetAssign.dimType count: 1 path: src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php - - message: "#^Cannot assign offset 'hostLogKey' to array\\\\|string\\.$#" + message: '#^Cannot assign offset ''hostLogKey'' to array\\|string\.$#' + identifier: offsetAssign.dimType count: 1 path: src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php - - message: "#^Cannot assign offset 'hostLogKey' to array\\\\|string\\.$#" + message: '#^Cannot assign offset ''hostLogKey'' to array\\|string\.$#' + identifier: offsetAssign.dimType count: 1 path: src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php - - message: "#^Cannot assign offset 'orderID' to array\\\\|string\\.$#" + message: '#^Cannot assign offset ''orderID'' to array\\|string\.$#' + identifier: offsetAssign.dimType count: 1 path: src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php - - message: "#^Cannot assign offset 'orderID' to array\\\\|string\\.$#" + message: '#^Cannot assign offset ''orderID'' to array\\|string\.$#' + identifier: offsetAssign.dimType count: 1 path: src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\RequestDataMapper\\\\PosNetRequestDataMapper\\:\\:create3DEnrollmentCheckRequestData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method Mews\\Pos\\DataMapper\\RequestDataMapper\\PosNetRequestDataMapper\:\:create3DEnrollmentCheckRequestData\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\RequestDataMapper\\\\PosNetV1PosRequestDataMapper\\:\\:create3DFormData\\(\\) has parameter \\$extraData with no type specified\\.$#" + message: '#^Method Mews\\Pos\\DataMapper\\RequestDataMapper\\PosNetV1PosRequestDataMapper\:\:create3DFormData\(\) has parameter \$extraData with no type specified\.$#' + identifier: missingType.parameter count: 1 path: src/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapper.php - - message: "#^Argument of an invalid type array\\|object supplied for foreach, only iterables are supported\\.$#" + message: '#^Argument of an invalid type array\\|object supplied for foreach, only iterables are supported\.$#' + identifier: foreach.nonIterable count: 1 path: src/DataMapper/ResponseDataMapper/AbstractResponseDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\GarantiPosResponseDataMapper\\:\\:mapCancelResponse\\(\\) should return array\\ but returns array\\\\|string\\>\\|string\\|null\\>\\|string\\|null\\>\\.$#" - count: 1 - path: src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php - - - - message: "#^Offset 'ErrorMsg' does not exist on array\\\\|string\\.$#" + message: '#^Offset ''ErrorMsg'' might not exist on array\\|string\.$#' + identifier: offsetAccess.notFound count: 2 path: src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php - - message: "#^Offset 'ReasonCode' does not exist on array\\\\|string\\.$#" + message: '#^Offset ''ReasonCode'' might not exist on array\\|string\.$#' + identifier: offsetAccess.notFound count: 2 path: src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\KuveytPosResponseDataMapper\\:\\:mapStatusResponse\\(\\) has parameter \\$rawResponseData with no value type specified in iterable type array\\.$#" + message: '#^Method Mews\\Pos\\DataMapper\\ResponseDataMapper\\KuveytPosResponseDataMapper\:\:mapStatusResponse\(\) has parameter \$rawResponseData with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\PayFlexV4PosResponseDataMapper\\:\\:getCommonPaymentResponse\\(\\) should return array\\ but returns array\\\\|string\\|null\\>\\.$#" + message: '#^Method Mews\\Pos\\DataMapper\\ResponseDataMapper\\PayFlexV4PosResponseDataMapper\:\:getCommonPaymentResponse\(\) should return array\ but returns array\\|string\|null\>\.$#' + identifier: return.type count: 1 path: src/DataMapper/ResponseDataMapper/PayFlexV4PosResponseDataMapper.php - - message: "#^Property Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\AbstractResponseDataMapper\\:\\:\\$secureTypeMappings \\(array\\\\) does not accept non\\-empty\\-array\\<1\\|2\\|3\\|string, '3d'\\|'3d_host'\\|'3d_pay'\\|'3d_pay_hosting'\\|'regular'\\>\\.$#" + message: '#^Property Mews\\Pos\\DataMapper\\ResponseDataMapper\\AbstractResponseDataMapper\:\:\$secureTypeMappings \(array\\) does not accept non\-empty\-array\<1\|2\|3\|string, ''3d''\|''3d_host''\|''3d_pay''\|''3d_pay_hosting''\|''regular''\>\.$#' + identifier: assign.propertyType count: 1 path: src/DataMapper/ResponseDataMapper/PayFlexV4PosResponseDataMapper.php - - message: "#^Property Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\AbstractResponseDataMapper\\:\\:\\$currencyMappings \\(array\\\\) does not accept non\\-empty\\-array\\<392\\|643\\|826\\|840\\|949\\|978\\|string, 'EUR'\\|'GBP'\\|'JPY'\\|'RUB'\\|'TRY'\\|'USD'\\>\\.$#" + message: '#^Property Mews\\Pos\\DataMapper\\ResponseDataMapper\\AbstractResponseDataMapper\:\:\$currencyMappings \(array\\) does not accept non\-empty\-array\<392\|643\|826\|840\|949\|978\|string, ''EUR''\|''GBP''\|''JPY''\|''RUB''\|''TRY''\|''USD''\>\.$#' + identifier: assign.propertyType count: 1 path: src/DataMapper/ResponseDataMapper/PosNetV1PosResponseDataMapper.php - - message: "#^Method Mews\\\\Pos\\\\Factory\\\\PosFactory\\:\\:createPosGateway\\(\\) should return Mews\\\\Pos\\\\PosInterface but returns object\\.$#" + message: '#^Method Mews\\Pos\\Factory\\PosFactory\:\:createPosGateway\(\) should return Mews\\Pos\\PosInterface but returns object\.$#' + identifier: return.type count: 1 path: src/Factory/PosFactory.php - - message: "#^Parameter \\#2 \\$rawPaymentResponseData of method Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\GarantiPosResponseDataMapper\\:\\:map3DPaymentData\\(\\) expects array\\{Order\\: array\\\\|string\\>, Response\\: array\\, Transaction\\: array\\\\|string\\>\\}\\|null, array\\ given\\.$#" + message: '#^Strict comparison using \=\=\= between ''3d_host'' and ''3d_host'' will always evaluate to true\.$#' + identifier: identical.alwaysTrue + count: 1 + path: src/Gateways/AbstractGateway.php + + - + message: '#^Parameter \#2 \$rawPaymentResponseData of method Mews\\Pos\\DataMapper\\ResponseDataMapper\\GarantiPosResponseDataMapper\:\:map3DPaymentData\(\) expects array\{Order\: array\\|string\>, Response\: array\, Transaction\: array\\|string\>\}\|null, array\ given\.$#' + identifier: argument.type count: 1 path: src/Gateways/GarantiPos.php - - message: "#^Parameter \\#1 \\$raw3DAuthResponseData of method Mews\\\\Pos\\\\DataMapper\\\\ResponseDataMapper\\\\PayFlexCPV4PosResponseDataMapper\\:\\:map3DPayResponseData\\(\\) expects array\\{ErrorCode\\: string\\}\\|array\\{Rc\\: string, AuthCode\\: string, TransactionId\\: string, PaymentToken\\: string, MaskedPan\\: string\\}\\|array\\{Rc\\: string, Message\\: string, TransactionId\\: string, PaymentToken\\: string\\}, array given\\.$#" + message: '#^Parameter \#1 \$raw3DAuthResponseData of method Mews\\Pos\\DataMapper\\ResponseDataMapper\\PayFlexCPV4PosResponseDataMapper\:\:map3DPayResponseData\(\) expects array\{ErrorCode\: string\}\|array\{Rc\: string, AuthCode\: string, TransactionId\: string, PaymentToken\: string, MaskedPan\: string\}\|array\{Rc\: string, Message\: string, TransactionId\: string, PaymentToken\: string\}, array given\.$#' + identifier: argument.type count: 1 path: src/Gateways/PayFlexCPV4Pos.php - - message: "#^Parameter \\#7 \\$extraData of method Mews\\\\Pos\\\\DataMapper\\\\RequestDataMapper\\\\PayFlexCPV4PosRequestDataMapper\\:\\:create3DFormData\\(\\) expects array\\{CommonPaymentUrl\\: string, PaymentToken\\: string\\}, array\\{CommonPaymentUrl\\: string\\|null, PaymentToken\\: string\\|null, ErrorCode\\: null, ResponseMessage\\: string\\|null\\} given\\.$#" + message: '#^Parameter \#7 \$extraData of method Mews\\Pos\\DataMapper\\RequestDataMapper\\PayFlexCPV4PosRequestDataMapper\:\:create3DFormData\(\) expects array\{CommonPaymentUrl\: string, PaymentToken\: string\}, array\{CommonPaymentUrl\: string\|null, PaymentToken\: string\|null, ErrorCode\: null, ResponseMessage\: string\|null\} given\.$#' + identifier: argument.type count: 1 path: src/Gateways/PayFlexCPV4Pos.php - - message: "#^Parameter \\#2 \\$creditCard of method Mews\\\\Pos\\\\Gateways\\\\PayFlexV4Pos\\:\\:sendEnrollmentRequest\\(\\) expects Mews\\\\Pos\\\\Entity\\\\Card\\\\CreditCardInterface, Mews\\\\Pos\\\\Entity\\\\Card\\\\CreditCardInterface\\|null given\\.$#" + message: '#^Parameter \#2 \$creditCard of method Mews\\Pos\\Gateways\\PayFlexV4Pos\:\:sendEnrollmentRequest\(\) expects Mews\\Pos\\Entity\\Card\\CreditCardInterface, Mews\\Pos\\Entity\\Card\\CreditCardInterface\|null given\.$#' + identifier: argument.type count: 1 path: src/Gateways/PayFlexV4Pos.php - - message: "#^Method Mews\\\\Pos\\\\Gateways\\\\PosNet\\:\\:getOosTransactionData\\(\\) should return array\\{approved\\: string, respCode\\: string, respText\\: string, oosRequestDataResponse\\?\\: array\\{data1\\: string, data2\\: string, sign\\: string\\}\\} but returns array\\\\.$#" + message: '#^Method Mews\\Pos\\Gateways\\PosNet\:\:getOosTransactionData\(\) should return array\{approved\: string, respCode\: string, respText\: string, oosRequestDataResponse\?\: array\{data1\: string, data2\: string, sign\: string\}\} but returns array\\.$#' + identifier: return.type count: 1 path: src/Gateways/PosNet.php - - message: "#^Offset 'oosRequestDataRespo…' does not exist on array\\{approved\\: string, respCode\\: string, respText\\: string, oosRequestDataResponse\\?\\: array\\{data1\\: string, data2\\: string, sign\\: string\\}\\}\\.$#" + message: '#^Offset ''oosRequestDataResponse'' might not exist on array\{approved\: string, respCode\: string, respText\: string, oosRequestDataResponse\?\: array\{data1\: string, data2\: string, sign\: string\}\}\.$#' + identifier: offsetAccess.notFound count: 1 path: src/Gateways/PosNet.php - - message: "#^Parameter \\#4 \\$creditCard of method Mews\\\\Pos\\\\Gateways\\\\PosNet\\:\\:getOosTransactionData\\(\\) expects Mews\\\\Pos\\\\Entity\\\\Card\\\\CreditCardInterface, Mews\\\\Pos\\\\Entity\\\\Card\\\\CreditCardInterface\\|null given\\.$#" + message: '#^Parameter \#4 \$creditCard of method Mews\\Pos\\Gateways\\PosNet\:\:getOosTransactionData\(\) expects Mews\\Pos\\Entity\\Card\\CreditCardInterface, Mews\\Pos\\Entity\\Card\\CreditCardInterface\|null given\.$#' + identifier: argument.type count: 1 path: src/Gateways/PosNet.php diff --git a/src/Crypt/EstV3PosCrypt.php b/src/Crypt/EstV3PosCrypt.php index 0250c6d4..0ac9b1c7 100644 --- a/src/Crypt/EstV3PosCrypt.php +++ b/src/Crypt/EstV3PosCrypt.php @@ -35,7 +35,7 @@ public function create3DHash(AbstractPosAccount $posAccount, array $formInputs): } } - $formInputs[] = $posAccount->getStoreKey(); + $formInputs[] = $posAccount->getStoreKey() ?? ''; // escape | and \ characters $data = \str_replace("\\", "\\\\", \array_values($formInputs)); $data = \str_replace(self::HASH_SEPARATOR, "\\".self::HASH_SEPARATOR, $data); diff --git a/src/Crypt/PosNetV1PosCrypt.php b/src/Crypt/PosNetV1PosCrypt.php index 00fc85f6..bf9fc1f1 100644 --- a/src/Crypt/PosNetV1PosCrypt.php +++ b/src/Crypt/PosNetV1PosCrypt.php @@ -80,7 +80,7 @@ public function createHash(AbstractPosAccount $posAccount, array $requestData): $threeDSecureData['CavvData'], $threeDSecureData['Eci'], $threeDSecureData['MdStatus'], - $posAccount->getStoreKey(), + $posAccount->getStoreKey() ?? '', ]; $hashStr = \implode(static::HASH_SEPARATOR, $hashData); diff --git a/src/DataMapper/RequestDataMapper/KuveytPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/KuveytPosRequestDataMapper.php index 5cff29a2..c82211d0 100644 --- a/src/DataMapper/RequestDataMapper/KuveytPosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/KuveytPosRequestDataMapper.php @@ -114,7 +114,7 @@ public function create3DPaymentRequestData(AbstractPosAccount $posAccount, array * @param string $txType * @param CreditCardInterface|null $creditCard * - * @return array + * @return array|int|string> * * @throws UnsupportedTransactionTypeException */ @@ -131,16 +131,16 @@ public function create3DEnrollmentCheckRequestData(KuveytPosAccount $kuveytPosAc //DisplayAmount: Amount değeri ile aynı olacak şekilde gönderilmelidir. 'DisplayAmount' => $this->formatAmount($order['amount']), 'CurrencyCode' => $this->mapCurrency($order['currency']), - 'MerchantOrderId' => $order['id'], - 'OkUrl' => $order['success_url'], - 'FailUrl' => $order['fail_url'], + 'MerchantOrderId' => (string) $order['id'], + 'OkUrl' => (string) $order['success_url'], + 'FailUrl' => (string) $order['fail_url'], 'DeviceData' => [ - 'ClientIP' => $order['ip'], + 'ClientIP' => (string) $order['ip'], ], ]; if ($creditCard instanceof CreditCardInterface) { - $requestData['CardHolderName'] = $creditCard->getHolderName(); + $requestData['CardHolderName'] = (string) $creditCard->getHolderName(); $requestData['CardType'] = $this->cardTypeMapping[$creditCard->getType()]; $requestData['CardNumber'] = $creditCard->getNumber(); $requestData['CardExpireDateYear'] = $creditCard->getExpireYear(self::CREDIT_CARD_EXP_YEAR_FORMAT); diff --git a/src/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapper.php index 30685c95..5f94929a 100644 --- a/src/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/VakifKatilimPosRequestDataMapper.php @@ -95,7 +95,7 @@ public function create3DPaymentRequestData(AbstractPosAccount $posAccount, array * @param string $txType * @param CreditCardInterface|null $creditCard * - * @return array + * @return array */ public function create3DEnrollmentCheckRequestData(KuveytPosAccount $kuveytPosAccount, array $order, string $paymentModel, string $txType, ?CreditCardInterface $creditCard = null): array { @@ -109,13 +109,13 @@ public function create3DEnrollmentCheckRequestData(KuveytPosAccount $kuveytPosAc 'Amount' => $this->formatAmount($order['amount']), 'DisplayAmount' => $this->formatAmount($order['amount']), 'FECCurrencyCode' => $this->mapCurrency($order['currency']), - 'MerchantOrderId' => $order['id'], - 'OkUrl' => $order['success_url'], - 'FailUrl' => $order['fail_url'], + 'MerchantOrderId' => (string) $order['id'], + 'OkUrl' => (string) $order['success_url'], + 'FailUrl' => (string) $order['fail_url'], ]; if ($creditCard instanceof CreditCardInterface) { - $requestData['CardHolderName'] = $creditCard->getHolderName(); + $requestData['CardHolderName'] = (string) $creditCard->getHolderName(); $requestData['CardNumber'] = $creditCard->getNumber(); $requestData['CardExpireDateYear'] = $creditCard->getExpireYear(self::CREDIT_CARD_EXP_YEAR_FORMAT); $requestData['CardExpireDateMonth'] = $creditCard->getExpireMonth(self::CREDIT_CARD_EXP_MONTH_FORMAT); diff --git a/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php index c3fcf983..74c68238 100644 --- a/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapper.php @@ -413,7 +413,7 @@ protected function mapResponseTransactionSecurity(string $mdStatus): string * * @param array $raw3DAuthResponseData * - * @return array + * @return array */ protected function map3DCommonResponseData(array $raw3DAuthResponseData): array { diff --git a/src/DataMapper/ResponseDataMapper/NonPaymentResponseMapperInterface.php b/src/DataMapper/ResponseDataMapper/NonPaymentResponseMapperInterface.php index 91bdca76..9789bac0 100644 --- a/src/DataMapper/ResponseDataMapper/NonPaymentResponseMapperInterface.php +++ b/src/DataMapper/ResponseDataMapper/NonPaymentResponseMapperInterface.php @@ -10,14 +10,14 @@ interface NonPaymentResponseMapperInterface /** * @param array $rawResponseData * - * @return array + * @return array */ public function mapRefundResponse(array $rawResponseData): array; /** * @param array $rawResponseData * - * @return array + * @return array */ public function mapCancelResponse(array $rawResponseData): array; @@ -31,14 +31,14 @@ public function mapStatusResponse(array $rawResponseData): array; /** * @param array|string> $rawResponseData * - * @return array> + * @return array */ public function mapHistoryResponse(array $rawResponseData): array; /** * @param array|string> $rawResponseData * - * @return array> + * @return array */ public function mapOrderHistoryResponse(array $rawResponseData): array; } diff --git a/src/DataMapper/ResponseDataMapper/PaymentResponseMapperInterface.php b/src/DataMapper/ResponseDataMapper/PaymentResponseMapperInterface.php index dad10bd4..fac21d67 100644 --- a/src/DataMapper/ResponseDataMapper/PaymentResponseMapperInterface.php +++ b/src/DataMapper/ResponseDataMapper/PaymentResponseMapperInterface.php @@ -16,7 +16,7 @@ interface PaymentResponseMapperInterface * @param string $txType * @param array $order * - * @return array + * @return array */ public function mapPaymentResponse(array $rawPaymentResponseData, string $txType, array $order): array; @@ -39,7 +39,7 @@ public function map3DPaymentData(array $raw3DAuthResponseData, ?array $rawPaymen * @param string $txType * @param array $order * - * @return array + * @return array */ public function map3DPayResponseData(array $raw3DAuthResponseData, string $txType, array $order): array; @@ -50,7 +50,7 @@ public function map3DPayResponseData(array $raw3DAuthResponseData, string $txTyp * @param string $txType * @param array $order * - * @return array + * @return array */ public function map3DHostResponseData(array $raw3DAuthResponseData, string $txType, array $order): array; diff --git a/src/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapper.php index 347a57b7..bed9c4db 100644 --- a/src/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapper.php @@ -426,7 +426,7 @@ protected function mapResponseTransactionSecurity(string $mdStatus): string * * @param array $raw3DAuthResponseData * - * @return array + * @return array */ protected function map3DCommonResponseData(array $raw3DAuthResponseData): array { @@ -527,7 +527,7 @@ private function mapSingleOrderHistoryTransaction(array $rawTx): array * @param string $txType * @param array $order * - * @return array + * @return array */ private function map3DPaymentPaymentResponse(array $rawPaymentResponseData, string $txType, array $order): array { diff --git a/src/Factory/SerializerFactory.php b/src/Factory/SerializerFactory.php index 008ed86d..a8000fe5 100644 --- a/src/Factory/SerializerFactory.php +++ b/src/Factory/SerializerFactory.php @@ -32,7 +32,6 @@ class SerializerFactory */ public static function createGatewaySerializer(string $gatewayClass): SerializerInterface { - /** @var SerializerInterface[] $serializers */ $serializers = [ AkbankPosSerializer::class, EstPosSerializer::class, @@ -48,6 +47,7 @@ public static function createGatewaySerializer(string $gatewayClass): Serializer VakifKatilimPosSerializer::class, ]; + /** @var class-string $serializer */ foreach ($serializers as $serializer) { if ($serializer::supports($gatewayClass)) { return new $serializer(); diff --git a/src/Gateways/PosNet.php b/src/Gateways/PosNet.php index 678e6654..476a31d2 100644 --- a/src/Gateways/PosNet.php +++ b/src/Gateways/PosNet.php @@ -177,6 +177,9 @@ public function get3DFormData(array $order, string $paymentModel, string $txType $this->logger->debug('preparing 3D form data'); + /** @var array{data1: string, data2: string, sign: string} $responseData */ + $responseData = $data['oosRequestDataResponse']; + return $this->requestDataMapper->create3DFormData( $this->account, $order, @@ -184,7 +187,7 @@ public function get3DFormData(array $order, string $paymentModel, string $txType $txType, $this->get3DGatewayURL($paymentModel), null, - $data['oosRequestDataResponse'] + $responseData ); }