From 7e5ab6043b251bce5057d03dd84de15876854884 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 14:02:51 +0100 Subject: [PATCH 01/32] Check that files are valid for all supported versions --- .github/workflows/Lint.yml | 52 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/Lint.yml diff --git a/.github/workflows/Lint.yml b/.github/workflows/Lint.yml new file mode 100644 index 0000000..49617df --- /dev/null +++ b/.github/workflows/Lint.yml @@ -0,0 +1,52 @@ +name: Lint + +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + matrix: + php: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer:v2 + + - name: Lint + run: | + error=0 + for file in $(find Trustly -type f -name "*.php"); do + php -l -n $file | grep -v "No syntax errors detected" && error=1 + done + if [ $error -eq 1 ]; then + echo "Syntax errors were found." + exit 1 + else + echo "No syntax errors were detected." + fi + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: | + ~/.cache/composer/files + key: ${{ matrix.php }}-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ matrix.php }}- + + - name: Check dependencies + run: composer install From e428a6e86aa813816f36c798a437ad3ee40c50f2 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 14:18:34 +0100 Subject: [PATCH 02/32] Correct signature for Trustly_Data_JSONRPCNotificationResponse::setSignature() --- Trustly/Data/jsonrpcnotificationresponse.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Trustly/Data/jsonrpcnotificationresponse.php b/Trustly/Data/jsonrpcnotificationresponse.php index 87894a8..9c46b29 100644 --- a/Trustly/Data/jsonrpcnotificationresponse.php +++ b/Trustly/Data/jsonrpcnotificationresponse.php @@ -91,7 +91,7 @@ public function setSuccess($success=NULL) { * * @param string $signature Signature of the outgoing data. * - * @return string $signature + * @return void */ public function setSignature($signature) { $this->setResult('signature', $signature); From 56319d8b09c379cf647d7a8dd11ea98bbb0efd0b Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 14:18:54 +0100 Subject: [PATCH 03/32] Add missing properties --- Trustly/Api/api.php | 3 +++ Trustly/Api/signed.php | 6 ++++++ Trustly/exceptions.php | 2 ++ 3 files changed, 11 insertions(+) diff --git a/Trustly/Api/api.php b/Trustly/Api/api.php index c9fee7d..1057d09 100644 --- a/Trustly/Api/api.php +++ b/Trustly/Api/api.php @@ -67,6 +67,9 @@ abstract class Trustly_Api { */ public $last_request = NULL; + /** @var mixed */ + public $trustly_publickey = NULL; + /** * API Constructor * diff --git a/Trustly/Api/signed.php b/Trustly/Api/signed.php index 69d0b5b..e8f6caf 100644 --- a/Trustly/Api/signed.php +++ b/Trustly/Api/signed.php @@ -41,6 +41,12 @@ class Trustly_Api_Signed extends Trustly_Api { */ private $merchant_privatekey = NULL; + /** @var string */ + public $api_username; + + /** @var string */ + public $api_password; + /** * Constructor. * diff --git a/Trustly/exceptions.php b/Trustly/exceptions.php index e1a9724..a3ae482 100644 --- a/Trustly/exceptions.php +++ b/Trustly/exceptions.php @@ -47,6 +47,8 @@ class Trustly_JSONRPCVersionException extends Exception { } * indication that message contents are being tampered with. */ class Trustly_SignatureException extends Exception { + /** @var mixed */ + public $signature_data = NULL; /** * Constructor From 291b3867ee697841df0814ceb7e24a096e68e6d9 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 14:37:20 +0100 Subject: [PATCH 04/32] Check for basic issues (level 0) with PHPStan --- .github/workflows/Lint.yml | 6 ++++++ phpstan.neon | 4 ++++ 2 files changed, 10 insertions(+) create mode 100644 phpstan.neon diff --git a/.github/workflows/Lint.yml b/.github/workflows/Lint.yml index 49617df..5685838 100644 --- a/.github/workflows/Lint.yml +++ b/.github/workflows/Lint.yml @@ -50,3 +50,9 @@ jobs: - name: Check dependencies run: composer install + + - name: PHPStan + if: ${{ startsWith(matrix.php, '7.') || startsWith(matrix.php, '8.') }} + run: | + composer require --dev phpstan/phpstan + vendor/bin/phpstan analyze --no-progress diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..9eecb82 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,4 @@ +parameters: + level: 0 + paths: + - ./Trustly/ From 906e85dfaed5cc555780abc97ec99c106b9af5f8 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 16:33:52 +0100 Subject: [PATCH 05/32] Make action command compatible with PHPStan 0.9 (PHP 7.0) --- .github/workflows/Lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Lint.yml b/.github/workflows/Lint.yml index 5685838..802abad 100644 --- a/.github/workflows/Lint.yml +++ b/.github/workflows/Lint.yml @@ -55,4 +55,4 @@ jobs: if: ${{ startsWith(matrix.php, '7.') || startsWith(matrix.php, '8.') }} run: | composer require --dev phpstan/phpstan - vendor/bin/phpstan analyze --no-progress + vendor/bin/phpstan analyze Trustly --no-progress --level 0 From 34a27562fe06ed92bff9edffb08b75df5e07f550 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 14:21:01 +0100 Subject: [PATCH 06/32] Add composer generated files to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index e52ccc1..e005a0c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ example/var/ +/vendor +/composer.lock From 88d67cd89900b2868828d4dd11693ecd11e77d13 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 14:59:08 +0100 Subject: [PATCH 07/32] Correct return type for various methodes with null return --- Trustly/Api/api.php | 6 +++--- Trustly/Data/data.php | 6 +++--- Trustly/Data/jsonrpcnotificationrequest.php | 8 ++++---- Trustly/Data/jsonrpcnotificationresponse.php | 6 +++--- Trustly/Data/jsonrpcrequest.php | 4 ++-- Trustly/Data/jsonrpcresponse.php | 4 ++-- Trustly/Data/jsonrpcsignedresponse.php | 4 ++-- Trustly/Data/request.php | 6 +++--- Trustly/Data/response.php | 10 +++++----- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Trustly/Api/api.php b/Trustly/Api/api.php index 1057d09..c77970a 100644 --- a/Trustly/Api/api.php +++ b/Trustly/Api/api.php @@ -174,7 +174,7 @@ public function serializeData($data) { * * @param string $uuid UUID in the API call * - * @param string $signature in the API call + * @param ?string $signature in the API call * * @param array $data in the API call * @@ -487,9 +487,9 @@ public function call($request) { /** * Return a boolean value formatted for communicating with the API. * - * @param boolean $value Boolean value to encode + * @param ?boolean $value Boolean value to encode * - * @return API encoded boolean value + * @return ?string API encoded boolean value */ protected function apiBool($value) { if(isset($value)) { diff --git a/Trustly/Data/data.php b/Trustly/Data/data.php index a77274b..7320a35 100644 --- a/Trustly/Data/data.php +++ b/Trustly/Data/data.php @@ -54,9 +54,9 @@ public function __construct() { * values. This is used to keep the requests cleaner rather then * supplying NULL values in the payload * - * @param array $data data to clean + * @param mixed $data data to clean * - * @return array cleaned data + * @return mixed cleaned data */ public function vacuum($data) { if(is_null($data)) { @@ -106,7 +106,7 @@ public function get($name=NULL) { * * @param string $str String to process * - * @return string UTF-8 variant of string + * @return ?string UTF-8 variant of string */ public static function ensureUTF8($str) { if($str == NULL) { diff --git a/Trustly/Data/jsonrpcnotificationrequest.php b/Trustly/Data/jsonrpcnotificationrequest.php index 6be3c5f..8bfc66a 100644 --- a/Trustly/Data/jsonrpcnotificationrequest.php +++ b/Trustly/Data/jsonrpcnotificationrequest.php @@ -135,7 +135,7 @@ public function getData($name=NULL) { /** * Get the UUID from the request. * - * @return string The UUID value + * @return ?string The UUID value */ public function getUUID() { return $this->getParams('uuid'); @@ -145,7 +145,7 @@ public function getUUID() { /** * Get the Method from the request. * - * @return string The Method value. + * @return ?string The Method value. */ public function getMethod() { return $this->get('method'); @@ -155,7 +155,7 @@ public function getMethod() { /** * Get the Signature from the request. * - * @return string The Signature value. + * @return ?string The Signature value. */ public function getSignature() { return $this->getParams('signature'); @@ -165,7 +165,7 @@ public function getSignature() { /** * Get the JSON RPC version from the request. * - * @return string The Version. + * @return ?string The Version. */ public function getVersion() { return $this->get('version'); diff --git a/Trustly/Data/jsonrpcnotificationresponse.php b/Trustly/Data/jsonrpcnotificationresponse.php index 9c46b29..bd4f29a 100644 --- a/Trustly/Data/jsonrpcnotificationresponse.php +++ b/Trustly/Data/jsonrpcnotificationresponse.php @@ -73,7 +73,7 @@ public function __construct($request, $success=NULL) { * @param boolean $success Set to true to indicate that the notification * was successfully processed. * - * @return $success + * @return ?boolean $success */ public function setSuccess($success=NULL) { $status = 'OK'; @@ -198,7 +198,7 @@ public function setData($name, $value) { /** * Get the Method value from the response. * - * @return string The Method value. + * @return ?string The Method value. */ public function getMethod() { return $this->getResult('method'); @@ -208,7 +208,7 @@ public function getMethod() { /** * Get the UUID value from the response. * - * @return string The UUID value + * @return ?string The UUID value */ public function getUUID() { return $this->getResult('uuid'); diff --git a/Trustly/Data/jsonrpcrequest.php b/Trustly/Data/jsonrpcrequest.php index 2b10f9a..35bb820 100644 --- a/Trustly/Data/jsonrpcrequest.php +++ b/Trustly/Data/jsonrpcrequest.php @@ -149,7 +149,7 @@ public function setUUID($uuid) { /** * Get the UUID value from the outgoing call. * - * @return string The UUID value + * @return ?string The UUID value */ public function getUUID() { if(isset($this->payload['params']['UUID'])) { @@ -173,7 +173,7 @@ public function setMethod($method) { /** * Get the Method value from the outgoing call. * - * @return string The Method value. + * @return ?string The Method value. */ public function getMethod() { return $this->get('method'); diff --git a/Trustly/Data/jsonrpcresponse.php b/Trustly/Data/jsonrpcresponse.php index 98a2c4c..a53a72e 100644 --- a/Trustly/Data/jsonrpcresponse.php +++ b/Trustly/Data/jsonrpcresponse.php @@ -78,7 +78,7 @@ public function __construct($response_body) { /** * Get error code (if any) from the API response * - * @return integer The error code (numerical) + * @return ?integer The error code (numerical) */ public function getErrorCode() { if($this->isError() && isset($this->response_result['code'])) { @@ -90,7 +90,7 @@ public function getErrorCode() { /** * Get error message (if any) from the API response * - * @return string The error message + * @return ?string The error message */ public function getErrorMessage() { if($this->isError() && isset($this->response_result['message'])) { diff --git a/Trustly/Data/jsonrpcsignedresponse.php b/Trustly/Data/jsonrpcsignedresponse.php index 4b16b02..e26fa7a 100644 --- a/Trustly/Data/jsonrpcsignedresponse.php +++ b/Trustly/Data/jsonrpcsignedresponse.php @@ -116,7 +116,7 @@ public function getData($name=NULL) { /** * Get error code (if any) from the API call * - * @return integer The error code (numerical) + * @return ?integer The error code (numerical) */ public function getErrorCode() { if($this->isError() && isset($this->response_result['data']['code'])) { @@ -129,7 +129,7 @@ public function getErrorCode() { /** * Get error message (if any) from the API call * - * @return string The error message + * @return ?string The error message */ public function getErrorMessage() { if($this->isError() && isset($this->response_result['data']['message'])) { diff --git a/Trustly/Data/request.php b/Trustly/Data/request.php index 3daaca7..6a0b776 100644 --- a/Trustly/Data/request.php +++ b/Trustly/Data/request.php @@ -36,7 +36,7 @@ class Trustly_Data_Request extends Trustly_Data { /** * Call method name - * @var string + * @var ?string */ var $method = NULL; @@ -62,7 +62,7 @@ public function __construct($method=NULL, $payload=NULL) { /** * Convenience function for getting the uuid from the call * - * @return string uuid + * @return ?string uuid */ public function getUUID() { if(isset($this->payload['uuid'])) { @@ -85,7 +85,7 @@ public function setUUID($uuid) { /** * Get the method in the outgoing call * - * @return string method name + * @return ?string method name */ public function getMethod() { return $this->method; diff --git a/Trustly/Data/response.php b/Trustly/Data/response.php index 0f4b97b..4c6e682 100644 --- a/Trustly/Data/response.php +++ b/Trustly/Data/response.php @@ -135,7 +135,7 @@ public function isSuccess() { /** * Get error message (if any) from the API response * - * @return string The error message + * @return ?string The error message */ public function getErrorMessage() { if($this->isError()) { @@ -150,7 +150,7 @@ public function getErrorMessage() { /** * Get error code (if any) from the API response * - * @return integer The error code (numerical) + * @return ?integer The error code (numerical) */ public function getErrorCode() { if($this->isError()) { @@ -188,7 +188,7 @@ public function getResult($name=NULL) { /** * Convenience function for getting the uuid in the response * - * @param string uuid + * @return ?string uuid */ public function getUUID() { if(isset($this->response_result['uuid'])) { @@ -201,7 +201,7 @@ public function getUUID() { /** * Get the method from the response * - * @return string method name + * @return ?string method name */ public function getMethod() { if(isset($this->response_result['method'])) { @@ -214,7 +214,7 @@ public function getMethod() { /** * Get the signature from the response * - * @return string signature + * @return ?string signature */ public function getSignature() { if(isset($this->response_result['signature'])) { From 26199d03bfd43934e3bdfa47462e8e0ca7ae323c Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 15:07:18 +0100 Subject: [PATCH 08/32] Correct number of given argument --- Trustly/Api/api.php | 2 +- Trustly/Api/signed.php | 2 +- Trustly/Api/unsigned.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Trustly/Api/api.php b/Trustly/Api/api.php index c77970a..6300788 100644 --- a/Trustly/Api/api.php +++ b/Trustly/Api/api.php @@ -92,7 +92,7 @@ abstract class Trustly_Api { public function __construct($host='trustly.com', $port=443, $is_https=TRUE) { $this->api_is_https = $is_https; - if($this->loadTrustlyPublicKey($host, $port, $is_https) === FALSE) { + if($this->loadTrustlyPublicKey($host, $port) === FALSE) { $error = openssl_error_string(); throw new InvalidArgumentException("Cannot load Trustly public key file for host $host".(isset($error)?", error $error":'')); } diff --git a/Trustly/Api/signed.php b/Trustly/Api/signed.php index e8f6caf..08b7d71 100644 --- a/Trustly/Api/signed.php +++ b/Trustly/Api/signed.php @@ -200,7 +200,7 @@ protected function insertCredentials($request) { * @return Trustly_Data_JSONRPCSignedResponse */ protected function handleResponse($request, $body, $response_code) { - $response = new Trustly_Data_JSONRPCSignedResponse($body, $response_code); + $response = new Trustly_Data_JSONRPCSignedResponse($body); if($this->verifyTrustlySignedResponse($response) !== TRUE) { throw new Trustly_SignatureException('Incomming message signature is not valid', $response); diff --git a/Trustly/Api/unsigned.php b/Trustly/Api/unsigned.php index c62d6b9..6e471cb 100644 --- a/Trustly/Api/unsigned.php +++ b/Trustly/Api/unsigned.php @@ -113,7 +113,7 @@ protected function urlPath($request=NULL) { */ protected function handleResponse($request, $body, $response_code) { /* No signature here, just build the response object */ - return new Trustly_Data_JSONRPCResponse($body, $response_code); + return new Trustly_Data_JSONRPCResponse($body); } From c42c90c1eb22fb4b3d2480f8dbb6204ec2910016 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 15:07:40 +0100 Subject: [PATCH 09/32] Fix error message on openssl_error_string() failure --- Trustly/Api/api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Trustly/Api/api.php b/Trustly/Api/api.php index 6300788..8eff6ce 100644 --- a/Trustly/Api/api.php +++ b/Trustly/Api/api.php @@ -94,7 +94,7 @@ public function __construct($host='trustly.com', $port=443, $is_https=TRUE) { if($this->loadTrustlyPublicKey($host, $port) === FALSE) { $error = openssl_error_string(); - throw new InvalidArgumentException("Cannot load Trustly public key file for host $host".(isset($error)?", error $error":'')); + throw new InvalidArgumentException("Cannot load Trustly public key file for host $host".($error?", error $error":'')); } /* Make sure the curl extension is loaded so we can open URL's */ @@ -267,7 +267,7 @@ public function setHost($host=NULL, $port=NULL, $is_https=NULL) { if($this->loadTrustlyPublicKey($host, $port) === FALSE) { $error = openssl_error_string(); - throw new InvalidArgumentException("Cannot load Trustly public key file for host $host".(isset($error)?", error $error":'')); + throw new InvalidArgumentException("Cannot load Trustly public key file for host $host".($error?", error $error":'')); } if(isset($is_https)) { From d7c5f0758b09f287d511c8c33e2a0b0e1edc67af Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 15:09:12 +0100 Subject: [PATCH 10/32] Bump PHPStan to level 1 --- .github/workflows/Lint.yml | 2 +- phpstan.neon | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Lint.yml b/.github/workflows/Lint.yml index 802abad..60823d6 100644 --- a/.github/workflows/Lint.yml +++ b/.github/workflows/Lint.yml @@ -55,4 +55,4 @@ jobs: if: ${{ startsWith(matrix.php, '7.') || startsWith(matrix.php, '8.') }} run: | composer require --dev phpstan/phpstan - vendor/bin/phpstan analyze Trustly --no-progress --level 0 + vendor/bin/phpstan analyze Trustly --no-progress --level 1 diff --git a/phpstan.neon b/phpstan.neon index 9eecb82..6db2711 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,4 @@ parameters: - level: 0 + level: 1 paths: - ./Trustly/ From 98470b9c76f1c0b5120572887b7cc4b48c93174d Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 15:08:06 +0100 Subject: [PATCH 11/32] Correct signature of nullable arguments --- Trustly/Api/api.php | 18 ++++----- Trustly/Api/signed.php | 40 ++++++++++---------- Trustly/Api/unsigned.php | 14 +++---- Trustly/Data/data.php | 2 +- Trustly/Data/jsonrpcnotificationrequest.php | 4 +- Trustly/Data/jsonrpcnotificationresponse.php | 8 ++-- Trustly/Data/jsonrpcrequest.php | 4 +- Trustly/Data/jsonrpcsignedresponse.php | 2 +- Trustly/Data/request.php | 4 +- Trustly/Data/response.php | 4 +- Trustly/exceptions.php | 2 +- 11 files changed, 51 insertions(+), 51 deletions(-) diff --git a/Trustly/Api/api.php b/Trustly/Api/api.php index 8eff6ce..320e094 100644 --- a/Trustly/Api/api.php +++ b/Trustly/Api/api.php @@ -170,9 +170,9 @@ public function serializeData($data) { * * @link https://eu.developers.trustly.com/doc/reference/authentication * - * @param string $method Method in the API call + * @param ?string $method Method in the API call * - * @param string $uuid UUID in the API call + * @param ?string $uuid UUID in the API call * * @param ?string $signature in the API call * @@ -246,14 +246,14 @@ public function verifyTrustlySignedNotification($notification) { * @throws InvalidArgumentException If the public key for the API host * cannot be loaded. * - * @param string $host API host used for communication. Fully qualified + * @param ?string $host API host used for communication. Fully qualified * hostname. When integrating with our public API this is typically * either 'test.trustly.com' or 'trustly.com'. NULL means do not change. * - * @param integer $port Port on API host used for communicaiton. Normally + * @param ?integer $port Port on API host used for communicaiton. Normally * 443 for https, or 80 for http. NULL means do not change. * - * @param bool $is_https Indicator wether the port on the API host expects + * @param ?bool $is_https Indicator wether the port on the API host expects * https. NULL means do not change. */ public function setHost($host=NULL, $port=NULL, $is_https=NULL) { @@ -278,9 +278,9 @@ public function setHost($host=NULL, $port=NULL, $is_https=NULL) { /** * Setup and return a curl handle for submitting data to the API peer. * - * @param string $url The URL to communicate with + * @param ?string $url The URL to communicate with * - * @param string $postdata The (optional) data to post. + * @param ?string $postdata The (optional) data to post. * * @return Array($body, $response_code) */ @@ -395,7 +395,7 @@ public function baseURL() { /** * Return a URL to the API to the given request path. * - * @param Trustly_Data_Request $request Data to send in the request + * @param ?Trustly_Data_Request $request Data to send in the request * * @return URL to the API peer with the given query path. */ @@ -509,7 +509,7 @@ protected function apiBool($value) { * * See specific class implementing the call for more information. * - * @param Trustly_Data_Request $request Data to send in the request + * @param ?Trustly_Data_Request $request Data to send in the request * * @return string The URL path */ diff --git a/Trustly/Api/signed.php b/Trustly/Api/signed.php index 08b7d71..289abff 100644 --- a/Trustly/Api/signed.php +++ b/Trustly/Api/signed.php @@ -245,7 +245,7 @@ public function notificationResponse($request, $success=TRUE) { * * See specific class implementing the call for more information. * - * @param Trustly_Data_JSONRPCRequest $request Data to send in the request + * @param ?Trustly_Data_JSONRPCRequest $request Data to send in the request * * @return string The URL path */ @@ -986,70 +986,70 @@ public function accountPayout($notificationurl, $accountid, $enduserid, * * @param string $messageid Your unique ID for the deposit. * - * @param string $locale The end-users localization preference in the + * @param ?string $locale The end-users localization preference in the * format [language[_territory]]. Language is the ISO 639-1 code and * territory the ISO 3166-1-alpha-2 code. * - * @param float $amount with exactly two decimals in the currency specified + * @param ?float $amount with exactly two decimals in the currency specified * by Currency. Do not use this attribute in combination with * SuggestedMinAmount or SuggestedMaxAmount. Only digits. Use dot (.) * as decimal separator. * - * @param string $currency The currency of the end-user's account in the + * @param ?string $currency The currency of the end-user's account in the * merchant's system. * - * @param string $country The ISO 3166-1-alpha-2 code of the end-user's + * @param ?string $country The ISO 3166-1-alpha-2 code of the end-user's * country. This will be used for preselecting the correct country for * the end-user in the iframe. * - * @param string $mobilephone The mobile phonenumber to the end-user in + * @param ?string $mobilephone The mobile phonenumber to the end-user in * international format. This is used for KYC and AML routines. * - * @param string $firstname The end-user's firstname. Useful for some banks + * @param ?string $firstname The end-user's firstname. Useful for some banks * for identifying transactions. * - * @param string $lastname The end-user's lastname. Useful for some banks + * @param ?string $lastname The end-user's lastname. Useful for some banks * for identifying transactions. * - * @param string $nationalidentificationnumber The end-user's social + * @param ?string $nationalidentificationnumber The end-user's social * security number / personal number / birth number / etc. Useful for * some banks for identifying transactions and KYC/AML. * - * @param string $shopperstatement The text to show on the end-user's bank + * @param ?string $shopperstatement The text to show on the end-user's bank * statement. * - * @param string $ip The IP-address of the end-user. + * @param ?string $ip The IP-address of the end-user. * - * @param string $successurl The URL to which the end-user should be + * @param ?string $successurl The URL to which the end-user should be * redirected after a successful deposit. Do not put any logic on that * page since it's not guaranteed that the end-user will in fact visit * it. * - * @param string $failurl The URL to which the end-user should be + * @param ?string $failurl The URL to which the end-user should be * redirected after a failed deposit. Do not put any logic on that * page since it's not guaranteed that the end-user will in fact visit * it. * - * @param string $templateurl The URL to your template page for the + * @param ?string $templateurl The URL to your template page for the * checkout process. * - * @param string $urltarget The html target/framename of the SuccessURL. + * @param ?string $urltarget The html target/framename of the SuccessURL. * Only _top, _self and _parent are suported. * - * @param float $suggestedminamount The minimum amount the end-user is + * @param ?float $suggestedminamount The minimum amount the end-user is * allowed to deposit in the currency specified by Currency. Only * digits. Use dot (.) as decimal separator. * - * @param float $suggestedmaxamount The maximum amount the end-user is + * @param ?float $suggestedmaxamount The maximum amount the end-user is * allowed to deposit in the currency specified by Currency. Only * digits. Use dot (.) as decimal separator. * - * @param string $integrationmodule Version information for your + * @param ?string $integrationmodule Version information for your * integration module. This is for informational purposes only and can * be useful when troubleshooting problems. Should contain enough * version information to be useful. * - * @param boolean $holdnotifications Do not deliver notifications for this + * @param ?boolean $holdnotifications Do not deliver notifications for this * order. This is a parameter available when using test.trustly.com * and can be used for manually delivering notifications to your local * system during development. Intead you can get you notifications on @@ -1192,7 +1192,7 @@ public function void($orderid) { * @param string $currency The currency of the end-user's account in the * merchant's system. * - * @param string $shopperstatement The text to show on the end-user's bank + * @param ?string $shopperstatement The text to show on the end-user's bank * statement. * * @return Trustly_Data_JSONRPCSignedResponse diff --git a/Trustly/Api/unsigned.php b/Trustly/Api/unsigned.php index 6e471cb..23e33c7 100644 --- a/Trustly/Api/unsigned.php +++ b/Trustly/Api/unsigned.php @@ -87,7 +87,7 @@ public function __construct($username, $password, $host='trustly.com', $port=443 * * See specific class implementing the call for more information. * - * @param Trustly_Data_JSONRPCRequest $request Data to send in the request + * @param ?Trustly_Data_JSONRPCRequest $request Data to send in the request * * @return string The URL path */ @@ -181,11 +181,11 @@ public function newSessionCookie() { * * @param string $viewname Name of view * - * @param string $dateorder 'OLDER'|'NEVER' or NULL + * @param ?string $dateorder 'OLDER'|'NEVER' or NULL * - * @param string $datestamp Order used in relation with $dateorder + * @param ?string $datestamp Order used in relation with $dateorder * - * @param array $filterkeys Array of arrays of filters to apply to the data. + * @param ?array> $filterkeys Array of arrays of filters to apply to the data. * Arrays in the array consists of 1. Key name, 2. Key value, 3. * Operator, 4. Key value 2. Operator is one of 'NOT', 'BETWEEN' (in * which case Key value 2 must be set), 'LIKE', 'DECRYPTED', 'IN' @@ -195,11 +195,11 @@ public function newSessionCookie() { * * @param integer $offset Skip these many records in the start of the request * - * @param string $params Parameters for the view + * @param ?string $params Parameters for the view * - * @param string $sortby Column to sort by + * @param ?string $sortby Column to sort by * - * @param string $sortorder Sort order ASC or DESC + * @param ?string $sortorder Sort order ASC or DESC * * @return Trustly_Data_JSONRPCResponse Response from the API. * diff --git a/Trustly/Data/data.php b/Trustly/Data/data.php index 7320a35..810c1fc 100644 --- a/Trustly/Data/data.php +++ b/Trustly/Data/data.php @@ -83,7 +83,7 @@ public function vacuum($data) { * Get the specific data value from the payload or the full payload if * no value is supplied * - * @param string $name The optional data parameter to get. If NULL then the + * @param ?string $name The optional data parameter to get. If NULL then the * entire payload will be returned. * * @return mixed value diff --git a/Trustly/Data/jsonrpcnotificationrequest.php b/Trustly/Data/jsonrpcnotificationrequest.php index 8bfc66a..50edecc 100644 --- a/Trustly/Data/jsonrpcnotificationrequest.php +++ b/Trustly/Data/jsonrpcnotificationrequest.php @@ -84,7 +84,7 @@ public function __construct($notification_body) { /** * Get value from or the entire params payload. * - * @param string $name Name of the params parameter to obtain. Leave blank + * @param ?string $name Name of the params parameter to obtain. Leave blank * to get the entire payload * * @return mixed The value for the params parameter or the entire payload @@ -110,7 +110,7 @@ public function getParams($name=NULL) { * Get the value of a parameter in the params->data section of the * notification response. * - * @param string $name The name of the parameter. Leave as NULL to get the + * @param ?string $name The name of the parameter. Leave as NULL to get the * entire payload. * * @return mixed The value sought after or the entire payload depending on diff --git a/Trustly/Data/jsonrpcnotificationresponse.php b/Trustly/Data/jsonrpcnotificationresponse.php index bd4f29a..737dcbd 100644 --- a/Trustly/Data/jsonrpcnotificationresponse.php +++ b/Trustly/Data/jsonrpcnotificationresponse.php @@ -42,7 +42,7 @@ class Trustly_Data_JSONRPCNotificationResponse extends Trustly_Data { * @param Trustly_Data_JSONRPCNotificationRequest $request Incoming * notification request to which we are responding * - * @param boolean $success Set to true to indicate that the notification + * @param ?boolean $success Set to true to indicate that the notification * was successfully processed. */ public function __construct($request, $success=NULL) { @@ -70,7 +70,7 @@ public function __construct($request, $success=NULL) { /** * Set the success status in the response. * - * @param boolean $success Set to true to indicate that the notification + * @param ?boolean $success Set to true to indicate that the notification * was successfully processed. * * @return ?boolean $success @@ -120,7 +120,7 @@ public function setResult($name, $value) { * Get the value of a parameter in the result section of the notification * response. * - * @param string $name The name of the parameter. Leave as NULL to get the + * @param ?string $name The name of the parameter. Leave as NULL to get the * entire payload. * * @return mixed The value sought after or the entire payload depending on @@ -148,7 +148,7 @@ public function getResult($name=NULL) { * Get the value of a parameter in the result->data section of the * notification response. * - * @param string $name The name of the parameter. Leave as NULL to get the + * @param ?string $name The name of the parameter. Leave as NULL to get the * entire payload. * * @return mixed The value sought after or the entire payload depending on diff --git a/Trustly/Data/jsonrpcrequest.php b/Trustly/Data/jsonrpcrequest.php index 35bb820..30be647 100644 --- a/Trustly/Data/jsonrpcrequest.php +++ b/Trustly/Data/jsonrpcrequest.php @@ -41,7 +41,7 @@ class Trustly_Data_JSONRPCRequest extends Trustly_Data_Request { * @throws Trustly_DataException If the combination of $data and * $attributes is invalid * - * @param string $method Outgoing call API method + * @param ?string $method Outgoing call API method * * @param mixed $data Outputgoing call Data (if any). This can be either an * array or a simple non-complex value. @@ -202,7 +202,7 @@ public function setData($name, $value) { * Get the value of one parameter in the params->Data section of the * request. Or the entire Data section if no name is given. * - * @param string $name Name of the Data param to obtain. Leave as NULL to + * @param ?string $name Name of the Data param to obtain. Leave as NULL to * get the entire structure. * * @return mixed The value or the entire Data depending on $name diff --git a/Trustly/Data/jsonrpcsignedresponse.php b/Trustly/Data/jsonrpcsignedresponse.php index e26fa7a..5ff0d1d 100644 --- a/Trustly/Data/jsonrpcsignedresponse.php +++ b/Trustly/Data/jsonrpcsignedresponse.php @@ -88,7 +88,7 @@ public function __construct($response_body) { /** * Get data from the data section of the response * - * @param string $name Name of the data parameter to fetch. NULL value will + * @param ?string $name Name of the data parameter to fetch. NULL value will * return entire data section. * * @return mixed The value for parameter $name or the entire data block if diff --git a/Trustly/Data/request.php b/Trustly/Data/request.php index 6a0b776..fda82a4 100644 --- a/Trustly/Data/request.php +++ b/Trustly/Data/request.php @@ -43,9 +43,9 @@ class Trustly_Data_Request extends Trustly_Data { /** * Constructor. * - * @param string $method Method name for the call + * @param ?string $method Method name for the call * - * @param array $payload Call payload + * @param ?array $payload Call payload */ public function __construct($method=NULL, $payload=NULL) { parent::__construct(); diff --git a/Trustly/Data/response.php b/Trustly/Data/response.php index 4c6e682..814c17e 100644 --- a/Trustly/Data/response.php +++ b/Trustly/Data/response.php @@ -64,7 +64,7 @@ class Trustly_Data_Response extends Trustly_Data { * * @param string $response_body RAW response body from the API call * - * @param integer $response_code HTTP response code from the API call + * @param ?integer $response_code HTTP response code from the API call */ public function __construct($response_body, $response_code=NULL) { parent::__construct(); @@ -165,7 +165,7 @@ public function getErrorCode() { /** * Get data from the result section of the response * - * @param string $name Name of the result parameter to fetch. NULL value + * @param ?string $name Name of the result parameter to fetch. NULL value * will return entire result section. * * @return mixed The value for parameter $name or the entire result block diff --git a/Trustly/exceptions.php b/Trustly/exceptions.php index a3ae482..2a20043 100644 --- a/Trustly/exceptions.php +++ b/Trustly/exceptions.php @@ -55,7 +55,7 @@ class Trustly_SignatureException extends Exception { * * @param string $message Exception message * - * @param array $data Data that was signed with an invalid signature + * @param mixed $data Data that was signed with an invalid signature */ public function __construct($message, $data=NULL) { parent::__construct($message); From 27651cd30163ba444ad011bbb7b6f7a9c5f503d2 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 15:28:33 +0100 Subject: [PATCH 12/32] Correct args where the name was not specificed correctly --- Trustly/Api/api.php | 2 +- Trustly/Api/signed.php | 2 +- Trustly/Data/jsonrpcnotificationrequest.php | 2 +- Trustly/Data/request.php | 8 ++++++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Trustly/Api/api.php b/Trustly/Api/api.php index 320e094..e07144e 100644 --- a/Trustly/Api/api.php +++ b/Trustly/Api/api.php @@ -226,7 +226,7 @@ public function verifyTrustlySignedResponse($response) { * Trustly_Data_JSONRPCNotificationRequest) has been signed with the * correct key originating from the host * - * @param Trustly_Data_JSONRPCNotificationRequest incoming notification + * @param Trustly_Data_JSONRPCNotificationRequest $notification incoming notification * * @return boolean Indicating if the data was indeed properly signed by the * API we think we are talking to diff --git a/Trustly/Api/signed.php b/Trustly/Api/signed.php index 289abff..57ef78b 100644 --- a/Trustly/Api/signed.php +++ b/Trustly/Api/signed.php @@ -521,7 +521,7 @@ public function deposit($notificationurl, $enduserid, $messageid, * @param float $amount The amount to refund the customer with exactly two * decimals. Only digits. Use dot (.) as decimal separator. * - * @param string currency The currency of the amount to refund the + * @param string $currency The currency of the amount to refund the * customer. * * @return Trustly_Data_JSONRPCSignedResponse diff --git a/Trustly/Data/jsonrpcnotificationrequest.php b/Trustly/Data/jsonrpcnotificationrequest.php index 50edecc..af0b7a5 100644 --- a/Trustly/Data/jsonrpcnotificationrequest.php +++ b/Trustly/Data/jsonrpcnotificationrequest.php @@ -52,7 +52,7 @@ class Trustly_Data_JSONRPCNotificationRequest extends Trustly_Data { * request seems to be valid but is for a JSON RPC version we do not * support. * - * @param string $notification RAW incoming notification body + * @param string $notification_body RAW incoming notification body */ public function __construct($notification_body) { parent::__construct(); diff --git a/Trustly/Data/request.php b/Trustly/Data/request.php index fda82a4..8079c12 100644 --- a/Trustly/Data/request.php +++ b/Trustly/Data/request.php @@ -75,7 +75,9 @@ public function getUUID() { /** * Convenience function for setting the uuid in the call * - * @param string uuid + * @param string $uuid + * + * @return void */ public function setUUID($uuid) { $this->set('uuid', $uuid); @@ -95,7 +97,9 @@ public function getMethod() { /** * Set the medhod in the call * - * @param string method name + * @param string $method method name + * + * @return void */ public function setMethod($method) { $this->method = $method; From c282e576f6a61de6af9ece74d28db6bfef20e9be Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 15:28:51 +0100 Subject: [PATCH 13/32] Correct missing return types --- Trustly/Api/api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Trustly/Api/api.php b/Trustly/Api/api.php index e07144e..1a25f97 100644 --- a/Trustly/Api/api.php +++ b/Trustly/Api/api.php @@ -381,7 +381,7 @@ public function post($url=NULL, $postdata=NULL) { /** * Return a properly formed url to communicate with this API. * - * @return URL pointing to the API peer. + * @return string URL pointing to the API peer. */ public function baseURL() { if($this->api_is_https) { @@ -397,7 +397,7 @@ public function baseURL() { * * @param ?Trustly_Data_Request $request Data to send in the request * - * @return URL to the API peer with the given query path. + * @return string URL to the API peer with the given query path. */ public function url($request=NULL) { return $this->baseURL() . $this->urlPath($request); From b9e462609cfe97de4e7723fac6ee7a8616911b97 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 15:29:16 +0100 Subject: [PATCH 14/32] Correct signature of Trustly_Api::serializeData() --- Trustly/Api/api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Trustly/Api/api.php b/Trustly/Api/api.php index 1a25f97..c28ff18 100644 --- a/Trustly/Api/api.php +++ b/Trustly/Api/api.php @@ -142,9 +142,9 @@ public function loadTrustlyPublicKey($host, $port) { * * @link https://eu.developers.trustly.com/doc/reference/authentication * - * @param array $data Input data to serialize + * @param mixed $data Input data to serialize * - * @return array The input data in a serialized form + * @return string The input data in a serialized form */ public function serializeData($data) { if(is_array($data)) { From b3cc7991d6fe04eeb571a1c153e8341e7030d83f Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 15:41:17 +0100 Subject: [PATCH 15/32] Corrrect signature of Trustly_Api::verifyTrustlySignedResponse() --- Trustly/Api/api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Trustly/Api/api.php b/Trustly/Api/api.php index c28ff18..8929f99 100644 --- a/Trustly/Api/api.php +++ b/Trustly/Api/api.php @@ -176,7 +176,7 @@ public function serializeData($data) { * * @param ?string $signature in the API call * - * @param array $data in the API call + * @param mixed $data in the API call * * @return boolean Indicating wether or not the host key was used for * signing this data. @@ -207,7 +207,7 @@ protected function verifyTrustlySignedData($method, $uuid, $signature, $data) { * Trustly_Data_Response) has been signed with the correct key when * originating from the host * - * @param Trustly_Data_Response $response Response from the API call. + * @param Trustly_Data_JSONRPCSignedResponse $response Response from the API call. * * @return boolean Indicating if the data was indeed properly signed by the * API we think we are talking to From 8b6a01a023d61b9f1bc5cebfe4fe1b8a22324711 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 15:41:39 +0100 Subject: [PATCH 16/32] Bump PHPStan to level 2 --- .github/workflows/Lint.yml | 2 +- phpstan.neon | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Lint.yml b/.github/workflows/Lint.yml index 60823d6..2b31021 100644 --- a/.github/workflows/Lint.yml +++ b/.github/workflows/Lint.yml @@ -55,4 +55,4 @@ jobs: if: ${{ startsWith(matrix.php, '7.') || startsWith(matrix.php, '8.') }} run: | composer require --dev phpstan/phpstan - vendor/bin/phpstan analyze Trustly --no-progress --level 1 + vendor/bin/phpstan analyze Trustly --no-progress --level 2 diff --git a/phpstan.neon b/phpstan.neon index 6db2711..f4bbf05 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,4 @@ parameters: - level: 1 + level: 2 paths: - ./Trustly/ From 7de88f971b98a51c4f3ba920e7ed501b0892e078 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 17:18:50 +0100 Subject: [PATCH 17/32] Correct decleration of properties --- Trustly/Api/api.php | 8 ++++---- Trustly/Api/signed.php | 4 ++-- Trustly/Api/unsigned.php | 6 +++--- Trustly/Data/data.php | 10 +--------- Trustly/Data/jsonrpcnotificationrequest.php | 4 +--- Trustly/Data/jsonrpcnotificationresponse.php | 3 --- Trustly/Data/request.php | 4 +--- Trustly/Data/response.php | 12 +++++------- 8 files changed, 17 insertions(+), 34 deletions(-) diff --git a/Trustly/Api/api.php b/Trustly/Api/api.php index 8929f99..e644c3e 100644 --- a/Trustly/Api/api.php +++ b/Trustly/Api/api.php @@ -44,13 +44,13 @@ abstract class Trustly_Api { * * @var string FQHN */ - protected $api_host = NULL; + protected $api_host; /** * API port used for communication. * * @var integer Normally either 443 (https) or 80 (http) */ - protected $api_port = NULL; + protected $api_port; /** * Inidicator wether the API host is communicating using https * @@ -63,7 +63,7 @@ abstract class Trustly_Api { * * @see Trustly_Api::getLastRequest() * - * @var array Last API call in data form. + * @var ?Trustly_Data_Request Last API call in data form. */ public $last_request = NULL; @@ -407,7 +407,7 @@ public function url($request=NULL) { /** * Return the last request that we attempted to make via this API * - * @return array Last request data structure. + * @return ?Trustly_Data_Request Last request data structure. */ public function getLastRequest() { return $this->last_request; diff --git a/Trustly/Api/signed.php b/Trustly/Api/signed.php index 57ef78b..d0d7dfa 100644 --- a/Trustly/Api/signed.php +++ b/Trustly/Api/signed.php @@ -37,7 +37,7 @@ class Trustly_Api_Signed extends Trustly_Api { /** * Loaded merchant private key resource - * @var resource from openssl with the loaded privatekey + * @var mixed from openssl with the loaded privatekey */ private $merchant_privatekey = NULL; @@ -76,7 +76,7 @@ public function __construct($merchant_privatekey, $username, $password, $host='t parent::__construct($host, $port, $is_https); $this->api_username = $username; - $this->api_password = $password; + $this->api_password = $password; if($merchant_privatekey != NULL) { if(strpos($merchant_privatekey, "\n") !== FALSE) { if($this->useMerchantPrivateKey($merchant_privatekey) === FALSE) { diff --git a/Trustly/Api/unsigned.php b/Trustly/Api/unsigned.php index 23e33c7..a34414e 100644 --- a/Trustly/Api/unsigned.php +++ b/Trustly/Api/unsigned.php @@ -41,16 +41,16 @@ class Trustly_Api_Unsigned extends Trustly_Api { * newSessionCookie after which the $session_uuid is used instead. * @var string */ - private $api_username = NULL; + private $api_username; /** * Login password when using the API. Used only in the first API call to * newSessionCookie after which the $session_uuid is used instead. * @var string */ - private $api_password = NULL; + private $api_password; /** * Session UUID used for authenticating calls. - * @var string + * @var ?string */ private $session_uuid = NULL; diff --git a/Trustly/Data/data.php b/Trustly/Data/data.php index 810c1fc..cabd82c 100644 --- a/Trustly/Data/data.php +++ b/Trustly/Data/data.php @@ -39,15 +39,7 @@ class Trustly_Data { * Data payload * @var array */ - protected $payload = NULL; - - /** - * Constructur. - */ - public function __construct() { - $this->payload = array(); - } - + protected $payload = array(); /** * Utility function to vacuum the supplied data end remove unset diff --git a/Trustly/Data/jsonrpcnotificationrequest.php b/Trustly/Data/jsonrpcnotificationrequest.php index af0b7a5..4134ab5 100644 --- a/Trustly/Data/jsonrpcnotificationrequest.php +++ b/Trustly/Data/jsonrpcnotificationrequest.php @@ -40,7 +40,7 @@ class Trustly_Data_JSONRPCNotificationRequest extends Trustly_Data { * The RAW incoming notification body * @var string */ - var $notification_body = NULL; + public $notification_body; /** @@ -55,8 +55,6 @@ class Trustly_Data_JSONRPCNotificationRequest extends Trustly_Data { * @param string $notification_body RAW incoming notification body */ public function __construct($notification_body) { - parent::__construct(); - $this->notification_body = $notification_body; if(empty($notification_body)) { diff --git a/Trustly/Data/jsonrpcnotificationresponse.php b/Trustly/Data/jsonrpcnotificationresponse.php index 737dcbd..57d4afe 100644 --- a/Trustly/Data/jsonrpcnotificationresponse.php +++ b/Trustly/Data/jsonrpcnotificationresponse.php @@ -46,9 +46,6 @@ class Trustly_Data_JSONRPCNotificationResponse extends Trustly_Data { * was successfully processed. */ public function __construct($request, $success=NULL) { - - parent::__construct(); - $uuid = $request->getUUID(); $method = $request->getMethod(); diff --git a/Trustly/Data/request.php b/Trustly/Data/request.php index 8079c12..817b91f 100644 --- a/Trustly/Data/request.php +++ b/Trustly/Data/request.php @@ -38,7 +38,7 @@ class Trustly_Data_Request extends Trustly_Data { * Call method name * @var ?string */ - var $method = NULL; + public $method = NULL; /** * Constructor. @@ -48,8 +48,6 @@ class Trustly_Data_Request extends Trustly_Data { * @param ?array $payload Call payload */ public function __construct($method=NULL, $payload=NULL) { - parent::__construct(); - $vpayload = $this->vacuum($payload); if(isset($vpayload)) { $this->payload = $vpayload; diff --git a/Trustly/Data/response.php b/Trustly/Data/response.php index 814c17e..a19ab85 100644 --- a/Trustly/Data/response.php +++ b/Trustly/Data/response.php @@ -37,21 +37,21 @@ class Trustly_Data_Response extends Trustly_Data { /** * Raw copy of the incoming response body - * @var integer + * @var ?string */ - var $response_body = NULL; + public $response_body = NULL; /** * The response HTTP code - * @var integer + * @var ?integer */ - var $response_code = NULL; + public $response_code = NULL; /** * Shortcut to the part of the result being actually interesting. The guts will contain all returned data. * @var mixed */ - var $response_result = NULL; + public $response_result = NULL; /** @@ -67,8 +67,6 @@ class Trustly_Data_Response extends Trustly_Data { * @param ?integer $response_code HTTP response code from the API call */ public function __construct($response_body, $response_code=NULL) { - parent::__construct(); - $this->response_code = $response_code; $this->response_body = $response_body; From 75fa5698d110b1d86137c76c95e58d29de6825ca Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 18:59:04 +0100 Subject: [PATCH 18/32] Correct signature of signMerchantRequest --- Trustly/Api/signed.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Trustly/Api/signed.php b/Trustly/Api/signed.php index d0d7dfa..0dacb6c 100644 --- a/Trustly/Api/signed.php +++ b/Trustly/Api/signed.php @@ -130,7 +130,9 @@ public function useMerchantPrivateKey($cert) { * @throws Trustly_SignatureException if private key has not been loaded * yet or if we for some other reason fail to sign the request. * - * @param Trustly_Data_JSONRPCRequest $request Request to sign. + * @param Trustly_Data_JSONRPCRequest|Trustly_Data_JSONRPCNotificationResponse $request Request to sign. + * + * @return string */ public function signMerchantRequest($request) { if(!isset($this->merchant_privatekey)) { @@ -172,9 +174,6 @@ protected function insertCredentials($request) { $request->setData('Password', $this->api_password); $signature = $this->signMerchantRequest($request); - if($signature === FALSE) { - return FALSE; - } $request->setParam('Signature', $signature); return TRUE; @@ -229,9 +228,6 @@ public function notificationResponse($request, $success=TRUE) { $response = new Trustly_Data_JSONRPCNotificationResponse($request, $success); $signature = $this->signMerchantRequest($response); - if($signature === FALSE) { - return FALSE; - } $response->setSignature($signature); return $response; From dbc79b0a9895b64e227067dc8eb0100c83d76b81 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 17:22:10 +0100 Subject: [PATCH 19/32] Make Trustly_Api_Unsigned::call() compatible with Trustly_Api::call() --- Trustly/Api/unsigned.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Trustly/Api/unsigned.php b/Trustly/Api/unsigned.php index a34414e..69ed507 100644 --- a/Trustly/Api/unsigned.php +++ b/Trustly/Api/unsigned.php @@ -208,7 +208,8 @@ public function getViewStable($viewname, $dateorder=NULL, $datestamp=NULL, $filterkeys=NULL, $limit=100, $offset=0, $params=NULL, $sortby=NULL, $sortorder=NULL) { - return $this->call('GetViewStable', array( + $request = new Trustly_Data_JSONRPCRequest('GetViewStable'); + return $this->call($request, array( 'DateOrder' => $dateorder, 'Datestamp' => $datestamp, 'FilterKeys' => $filterkeys, @@ -229,15 +230,13 @@ public function getViewStable($viewname, $dateorder=NULL, $datestamp=NULL, * the outgoing call. Take care when supplying the arguments for the call * so they match the function prototype properly. * - * @param string $method API method to call + * @param Trustly_Data_JSONRPCRequest $request Outgoing request * - * @param Trustly_Data_JSONRPCRequest $params Outgoing call params + * @param ?array $params Outgoing call params * * @return Trustly_Data_JSONRPCResponse Response from the API. */ - public function call($method, $params=NULL) { - $request = new Trustly_Data_JSONRPCRequest($method); - + public function call($request, $params=NULL) { if(isset($params)) { foreach($params as $key => $value) { $request->setParam($key, $value); From 401f1b7cf855899a9a0a301d43668353f7a6f383 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 17:22:39 +0100 Subject: [PATCH 20/32] Bump PHPStan level to 3 --- .github/workflows/Lint.yml | 2 +- phpstan.neon | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Lint.yml b/.github/workflows/Lint.yml index 2b31021..f5333b3 100644 --- a/.github/workflows/Lint.yml +++ b/.github/workflows/Lint.yml @@ -55,4 +55,4 @@ jobs: if: ${{ startsWith(matrix.php, '7.') || startsWith(matrix.php, '8.') }} run: | composer require --dev phpstan/phpstan - vendor/bin/phpstan analyze Trustly --no-progress --level 2 + vendor/bin/phpstan analyze Trustly --no-progress --level 3 diff --git a/phpstan.neon b/phpstan.neon index f4bbf05..8fb3e18 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,4 @@ parameters: - level: 2 + level: 3 paths: - ./Trustly/ From d712dd49cf3cb0d7fc0e168f75059644342765fc Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 18:26:18 +0100 Subject: [PATCH 21/32] defined() to check if const is defined --- Trustly/Api/api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Trustly/Api/api.php b/Trustly/Api/api.php index e644c3e..d9b89e0 100644 --- a/Trustly/Api/api.php +++ b/Trustly/Api/api.php @@ -298,13 +298,13 @@ public function post($url=NULL, $postdata=NULL) { curl_setopt($curl, CURLOPT_PORT, $this->api_port); if($this->api_is_https) { - if(@CURLOPT_PROTOCOLS != 'CURLOPT_PROTOCOLS') { + if(defined('CURLOPT_PROTOCOLS')) { curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS); } curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, TRUE); } else { - if(@CURLOPT_PROTOCOLS != 'CURLOPT_PROTOCOLS') { + if(defined('CURLOPT_PROTOCOLS')) { curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTP); } } From 5d232e8e25a91c42486d483ca312d24a5f4d0a1f Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 18:26:50 +0100 Subject: [PATCH 22/32] Fix error message for unknown cURL errors --- Trustly/Api/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Trustly/Api/api.php b/Trustly/Api/api.php index d9b89e0..431cc76 100644 --- a/Trustly/Api/api.php +++ b/Trustly/Api/api.php @@ -318,7 +318,7 @@ public function post($url=NULL, $postdata=NULL) { $body = curl_exec($curl); if($body === FALSE) { $error = curl_error($curl); - if($error === NULL) { + if(!$error) { $error = 'Failed to connect to the Trusly API'; } throw new Trustly_ConnectionException($error); From 107a25595a1617b7a67fcbd79a5e69cf01450e6e Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 18:27:54 +0100 Subject: [PATCH 23/32] Correct signature of Trustly_Data::useMerchantPrivateKey() --- Trustly/Api/signed.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Trustly/Api/signed.php b/Trustly/Api/signed.php index 0dacb6c..98d9bbb 100644 --- a/Trustly/Api/signed.php +++ b/Trustly/Api/signed.php @@ -113,7 +113,9 @@ public function loadMerchantPrivateKey($filename) { * * @see https://eu.developers.trustly.com/doc/reference/authentication * - * @param string $cert Loaded private RSA key as a string + * @param string|false $cert Loaded private RSA key as a string + * + * @return bool */ public function useMerchantPrivateKey($cert) { if($cert !== FALSE) { From b5e867c421d55d937f00778600f143999cc4e3e8 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 18:48:50 +0100 Subject: [PATCH 24/32] Remove redundant cast --- Trustly/Api/unsigned.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Trustly/Api/unsigned.php b/Trustly/Api/unsigned.php index 69ed507..5c86f9c 100644 --- a/Trustly/Api/unsigned.php +++ b/Trustly/Api/unsigned.php @@ -141,7 +141,7 @@ public function insertCredentials($request) { * @return boolean indicating wether we have a sessionuuid */ protected function hasSessionUUID() { - return (bool)isset($this->session_uuid); + return isset($this->session_uuid); } From e7fb6755918dee13a68375d9140ab50a4e5038ac Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 19:04:34 +0100 Subject: [PATCH 25/32] Bump PHPStan level to 5 --- .github/workflows/Lint.yml | 2 +- phpstan.neon | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Lint.yml b/.github/workflows/Lint.yml index f5333b3..ba57182 100644 --- a/.github/workflows/Lint.yml +++ b/.github/workflows/Lint.yml @@ -55,4 +55,4 @@ jobs: if: ${{ startsWith(matrix.php, '7.') || startsWith(matrix.php, '8.') }} run: | composer require --dev phpstan/phpstan - vendor/bin/phpstan analyze Trustly --no-progress --level 3 + vendor/bin/phpstan analyze Trustly --no-progress --level 5 diff --git a/phpstan.neon b/phpstan.neon index 8fb3e18..7bfc834 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,4 @@ parameters: - level: 3 + level: 5 paths: - ./Trustly/ From f5221151ba2f5d414bec32de4c83a848b4a8a75c Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 19:38:20 +0100 Subject: [PATCH 26/32] Add missing types --- Trustly/Api/api.php | 9 ++++++++- Trustly/Api/signed.php | 2 ++ Trustly/Data/data.php | 6 ++++-- Trustly/exceptions.php | 2 ++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Trustly/Api/api.php b/Trustly/Api/api.php index 431cc76..8e96e0e 100644 --- a/Trustly/Api/api.php +++ b/Trustly/Api/api.php @@ -255,6 +255,8 @@ public function verifyTrustlySignedNotification($notification) { * * @param ?bool $is_https Indicator wether the port on the API host expects * https. NULL means do not change. + * + * @return void */ public function setHost($host=NULL, $port=NULL, $is_https=NULL) { if(!isset($host)) { @@ -282,7 +284,7 @@ public function setHost($host=NULL, $port=NULL, $is_https=NULL) { * * @param ?string $postdata The (optional) data to post. * - * @return Array($body, $response_code) + * @return array{string, int} Array($body, $response_code) */ public function post($url=NULL, $postdata=NULL) { /* Do note that that if you are going to POST JSON you need to set the @@ -468,6 +470,7 @@ public function notificationResponse($request, $success=TRUE) { * * @param Trustly_Data_Request $request Outgoing data request. * + * @return Trustly_Data_JSONRPCResponse */ public function call($request) { if($this->insertCredentials($request) !== TRUE) { @@ -527,6 +530,8 @@ abstract protected function urlPath($request=NULL); * @param string $body The body recieved in response to the request * * @param integer $response_code the HTTP response code for the call + * + * @return Trustly_Data_JSONRPCResponse */ abstract protected function handleResponse($request, $body, $response_code); @@ -538,6 +543,8 @@ abstract protected function handleResponse($request, $body, $response_code); * * @param Trustly_Data_Request $request Request to be used in the outgoing * call + * + * @return bool */ abstract protected function insertCredentials($request); diff --git a/Trustly/Api/signed.php b/Trustly/Api/signed.php index 98d9bbb..e031d8f 100644 --- a/Trustly/Api/signed.php +++ b/Trustly/Api/signed.php @@ -255,6 +255,8 @@ protected function urlPath($request=NULL) { /** * Quirks mode implementation of clearing all pending openssl error messages. + * + * @return void */ private function clearOpenSSLError() { /* Not really my favourite part of this library implementation. As diff --git a/Trustly/Data/data.php b/Trustly/Data/data.php index cabd82c..92a408f 100644 --- a/Trustly/Data/data.php +++ b/Trustly/Data/data.php @@ -37,7 +37,7 @@ class Trustly_Data { /** * Data payload - * @var array + * @var array */ protected $payload = array(); @@ -171,7 +171,9 @@ public function json($pretty=FALSE) { * pretty printer * * @param mixed $data Payload to sort. Will be sorted in place - * */ + * + * @return void + */ private function sortRecursive(&$data) { if(is_array($data)) { foreach($data as $k => $v) { diff --git a/Trustly/exceptions.php b/Trustly/exceptions.php index 2a20043..f4fa489 100644 --- a/Trustly/exceptions.php +++ b/Trustly/exceptions.php @@ -67,6 +67,8 @@ public function __construct($message, $data=NULL) { * Get the data that had an invalid signature. This is the only way to get * data from anything with a bad signature. This should be used for * DEBUGGING ONLY. You should NEVER rely on the contents. + * + * @return mixed */ public function getBadData() { return $this->signature_data; From 03b74d595065b8846454282238cf98d56107173e Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 20:38:13 +0100 Subject: [PATCH 27/32] Correct return type of Trustly_Data::set() --- Trustly/Data/data.php | 2 ++ Trustly/Data/jsonrpcrequest.php | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Trustly/Data/data.php b/Trustly/Data/data.php index 92a408f..372266e 100644 --- a/Trustly/Data/data.php +++ b/Trustly/Data/data.php @@ -120,6 +120,8 @@ public static function ensureUTF8($str) { * @param string $name * * @param mixed $value + * + * @return void */ public function set($name, $value) { $this->payload[$name] = Trustly_Data::ensureUTF8($value); diff --git a/Trustly/Data/jsonrpcrequest.php b/Trustly/Data/jsonrpcrequest.php index 30be647..57c481e 100644 --- a/Trustly/Data/jsonrpcrequest.php +++ b/Trustly/Data/jsonrpcrequest.php @@ -163,10 +163,10 @@ public function getUUID() { * * @param string $method The name of the API method this call is for * - * @return string $method + * @return void */ public function setMethod($method) { - return $this->set('method', $method); + $this->set('method', $method); } From 4f72e699a829ffedf78fe60a2f86b84aee6f0cdd Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 20:40:38 +0100 Subject: [PATCH 28/32] Add return type to Trustly_Api::call() --- Trustly/Api/signed.php | 32 ++++++++++++++++++-------------- Trustly/Api/unsigned.php | 6 ++---- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/Trustly/Api/signed.php b/Trustly/Api/signed.php index e031d8f..6e10810 100644 --- a/Trustly/Api/signed.php +++ b/Trustly/Api/signed.php @@ -309,7 +309,7 @@ protected function generateUUID() { * * @param Trustly_Data_JSONRPCRequest $request Outgoing request * - * @return Trustly_Data_JSONRPCSignedResponse Response from the API. + * @return Trustly_Data_JSONRPCResponse Response from the API. */ public function call($request) { $uuid = $request->getUUID(); @@ -443,7 +443,7 @@ public function call($request) { * in the previously used account being preselected * @param bool $requestKYC Flag to pass whether we request KYC check or not (Pay N Play feature) * - * @return Trustly_Data_JSONRPCSignedResponse + * @return Trustly_Data_JSONRPCResponse */ public function deposit($notificationurl, $enduserid, $messageid, $locale=NULL, $amount=NULL, $currency=NULL, $country=NULL, @@ -524,7 +524,7 @@ public function deposit($notificationurl, $enduserid, $messageid, * @param string $currency The currency of the amount to refund the * customer. * - * @return Trustly_Data_JSONRPCSignedResponse + * @return Trustly_Data_JSONRPCResponse */ public function refund($orderid, $amount, $currency) { @@ -623,7 +623,7 @@ public function refund($orderid, $amount, $currency) { * * @param string $address The account holders address * - * @return Trustly_Data_JSONRPCSignedResponse + * @return Trustly_Data_JSONRPCResponse */ public function withdraw($notificationurl, $enduserid, $messageid, $locale=NULL, $currency=NULL, $country=NULL, @@ -682,7 +682,7 @@ public function withdraw($notificationurl, $enduserid, $messageid, * * @param integer $orderid The OrderID of the withdrawal to approve. * - * @return Trustly_Data_JSONRPCSignedResponse + * @return Trustly_Data_JSONRPCResponse */ public function approveWithdrawal($orderid) { @@ -705,7 +705,7 @@ public function approveWithdrawal($orderid) { * * @param integer $orderid The OrderID of the withdrawal to deny. * - * @return Trustly_Data_JSONRPCSignedResponse + * @return Trustly_Data_JSONRPCResponse */ public function denyWithdrawal($orderid) { @@ -773,7 +773,7 @@ public function denyWithdrawal($orderid) { * @param boolean $requestdirectdebitmandate Initiate a direct debit * mandate request for the selected account. * - * @return Trustly_Data_JSONRPCSignedResponse + * @return Trustly_Data_JSONRPCResponse */ public function selectAccount($notificationurl, $enduserid, $messageid, $locale=NULL, $country=NULL, $ip=NULL, $successurl=NULL, $urltarget=NULL, @@ -866,7 +866,7 @@ public function selectAccount($notificationurl, $enduserid, $messageid, * * @param string $address The account holders address * - * @return Trustly_Data_JSONRPCSignedResponse + * @return Trustly_Data_JSONRPCResponse */ public function registerAccount($enduserid, $clearinghouse, $banknumber, $accountnumber, $firstname, $lastname, $mobilephone=NULL, @@ -941,7 +941,7 @@ public function registerAccount($enduserid, $clearinghouse, $banknumber, * system during development. Intead you can get you notifications on * https://test.trustly.com/notifications.html * - * @return Trustly_Data_JSONRPCSignedResponse + * @return Trustly_Data_JSONRPCResponse */ public function accountPayout($notificationurl, $accountid, $enduserid, $messageid, $amount, $currency, $holdnotifications=NULL) { @@ -1055,7 +1055,11 @@ public function accountPayout($notificationurl, $accountid, $enduserid, * system during development. Intead you can get you notifications on * https://test.trustly.com/notifications.html * - * @return Trustly_Data_JSONRPCSignedResponse + * @param mixed $authorizeonly + * + * @param mixed $templatedata + * + * @return Trustly_Data_JSONRPCResponse */ public function p2p($notificationurl,$enduserid, $messageid, $locale=NULL, $amount=NULL, $currency=NULL, $country=NULL, @@ -1121,7 +1125,7 @@ public function p2p($notificationurl,$enduserid, $messageid, * * @param integer $currency The currency of the amount * - * @return Trustly_Data_JSONRPCSignedResponse + * @return Trustly_Data_JSONRPCResponse */ public function capture($orderid, $amount, $currency) { @@ -1148,7 +1152,7 @@ public function capture($orderid, $amount, $currency) { * * @param integer $orderid The OrderID of the deposit to void * - * @return Trustly_Data_JSONRPCSignedResponse + * @return Trustly_Data_JSONRPCResponse */ public function void($orderid) { @@ -1195,7 +1199,7 @@ public function void($orderid) { * @param ?string $shopperstatement The text to show on the end-user's bank * statement. * - * @return Trustly_Data_JSONRPCSignedResponse + * @return Trustly_Data_JSONRPCResponse */ public function charge($accountid, $notificationurl, $enduserid, $messageid, $amount, $currency, $shopperstatement=NULL) { @@ -1226,7 +1230,7 @@ public function charge($accountid, $notificationurl, $enduserid, $messageid, * * @param integer $orderid The OrderID of the order to query * - * @return Trustly_Data_JSONRPCSignedResponse + * @return Trustly_Data_JSONRPCResponse */ public function getWithdrawals($orderid) { diff --git a/Trustly/Api/unsigned.php b/Trustly/Api/unsigned.php index 5c86f9c..def7776 100644 --- a/Trustly/Api/unsigned.php +++ b/Trustly/Api/unsigned.php @@ -163,10 +163,8 @@ public function newSessionCookie() { * missing session uuid here and call this function if it is not set */ $response = parent::call($request); - if(isset($response)) { - if($response->isSuccess()) { - $this->session_uuid = $response->getResult('sessionuuid'); - } + if($response->isSuccess()) { + $this->session_uuid = $response->getResult('sessionuuid'); } if(!isset($this->session_uuid)) { throw new Trustly_AuthentificationException(); From 96a39408af3a075005bb9a59b5c2b606fa52d0d8 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 20:41:34 +0100 Subject: [PATCH 29/32] Bump PHPStan level to 6 --- .github/workflows/Lint.yml | 2 +- phpstan.neon | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Lint.yml b/.github/workflows/Lint.yml index ba57182..04e1ff6 100644 --- a/.github/workflows/Lint.yml +++ b/.github/workflows/Lint.yml @@ -55,4 +55,4 @@ jobs: if: ${{ startsWith(matrix.php, '7.') || startsWith(matrix.php, '8.') }} run: | composer require --dev phpstan/phpstan - vendor/bin/phpstan analyze Trustly --no-progress --level 5 + vendor/bin/phpstan analyze Trustly --no-progress --level 6 diff --git a/phpstan.neon b/phpstan.neon index 7bfc834..4c43620 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,4 @@ parameters: - level: 5 + level: 6 paths: - ./Trustly/ From 4f5c963eaab48ed933a56ac35257220fd556c39f Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 21:10:08 +0100 Subject: [PATCH 30/32] Correct signature of Trustly_Data::json() --- Trustly/Api/api.php | 3 +++ Trustly/Data/data.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Trustly/Api/api.php b/Trustly/Api/api.php index 8e96e0e..f3cc169 100644 --- a/Trustly/Api/api.php +++ b/Trustly/Api/api.php @@ -479,6 +479,9 @@ public function call($request) { $this->last_request = $request; $jsonstr = $request->json(); + if($jsonstr === FALSE) { + throw new Trustly_DataException('Unable to json encode payload'); + } $url = $this->url($request); list($body, $response_code) = $this->post($url, $jsonstr); diff --git a/Trustly/Data/data.php b/Trustly/Data/data.php index 372266e..df0c510 100644 --- a/Trustly/Data/data.php +++ b/Trustly/Data/data.php @@ -152,7 +152,7 @@ public function pop($name) { * @param boolean $pretty Format the output in a prettified easy-to-read * formatting * - * @return string The current payload in JSON + * @return string|false The current payload in JSON */ public function json($pretty=FALSE) { if($pretty) { From aa26097334b161b9fa2a03996b56ec6d5ac48263 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 21:10:47 +0100 Subject: [PATCH 31/32] Narrow validation of curl_exec() --- Trustly/Api/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Trustly/Api/api.php b/Trustly/Api/api.php index f3cc169..5c5cfc4 100644 --- a/Trustly/Api/api.php +++ b/Trustly/Api/api.php @@ -318,7 +318,7 @@ public function post($url=NULL, $postdata=NULL) { curl_setopt($curl, CURLOPT_URL, $url); $body = curl_exec($curl); - if($body === FALSE) { + if(!is_string($body)) { $error = curl_error($curl); if(!$error) { $error = 'Failed to connect to the Trusly API'; From 27fff7d11f6e0c4be738aac3708b1668a979c1f9 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 13 Mar 2024 21:11:16 +0100 Subject: [PATCH 32/32] Bump PHPStan level to 8 --- .github/workflows/Lint.yml | 2 +- phpstan.neon | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Lint.yml b/.github/workflows/Lint.yml index 04e1ff6..4567bfc 100644 --- a/.github/workflows/Lint.yml +++ b/.github/workflows/Lint.yml @@ -55,4 +55,4 @@ jobs: if: ${{ startsWith(matrix.php, '7.') || startsWith(matrix.php, '8.') }} run: | composer require --dev phpstan/phpstan - vendor/bin/phpstan analyze Trustly --no-progress --level 6 + vendor/bin/phpstan analyze Trustly --no-progress --level 7 diff --git a/phpstan.neon b/phpstan.neon index 4c43620..85237fc 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,4 @@ parameters: - level: 6 + level: 8 paths: - ./Trustly/