From 26a2b80b1b1ce7399d2c513e4ea3973bddcd6d32 Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Mon, 25 Sep 2023 11:26:37 +0100 Subject: [PATCH] Fix lint --- modules/ppcp-api-client/services.php | 2 +- .../src/Helper/FailureRegistry.php | 20 ++++++++++++------- .../src/Assets/AppleProductStatus.php | 3 +-- .../src/Helper/DCCProductStatus.php | 2 +- .../Helper/PayUponInvoiceProductStatus.php | 2 +- psalm-baseline.xml | 5 +++++ 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/modules/ppcp-api-client/services.php b/modules/ppcp-api-client/services.php index 8f31382e3..a222f0782 100644 --- a/modules/ppcp-api-client/services.php +++ b/modules/ppcp-api-client/services.php @@ -848,7 +848,7 @@ return array( $purchase_unit_sanitizer = $container->get( 'api.helper.purchase-unit-sanitizer' ); return new OrderTransient( $cache, $purchase_unit_sanitizer ); }, - 'api.helper.failure-registry' => static function( ContainerInterface $container ): FailureRegistry { + 'api.helper.failure-registry' => static function( ContainerInterface $container ): FailureRegistry { $cache = new Cache( 'ppcp-paypal-api-status-cache' ); return new FailureRegistry( $cache ); }, diff --git a/modules/ppcp-api-client/src/Helper/FailureRegistry.php b/modules/ppcp-api-client/src/Helper/FailureRegistry.php index a7919758c..0dbeb3b5b 100644 --- a/modules/ppcp-api-client/src/Helper/FailureRegistry.php +++ b/modules/ppcp-api-client/src/Helper/FailureRegistry.php @@ -39,12 +39,14 @@ class FailureRegistry { } /** - * @param string $key - * @param int $seconds + * Returns if there was a failure within a given timeframe. + * + * @param string $key The cache key. + * @param int $seconds The timeframe in seconds. * @return bool */ public function has_failure_in_timeframe( string $key, int $seconds ): bool { - $cache_key = $this->cache_key( $key ); + $cache_key = $this->cache_key( $key ); $failure_time = $this->cache->get( $cache_key ); if ( ! $failure_time ) { @@ -56,7 +58,9 @@ class FailureRegistry { } /** - * @param string $key + * Registers a failure. + * + * @param string $key The cache key. * @return void */ public function add_failure( string $key ) { @@ -65,7 +69,9 @@ class FailureRegistry { } /** - * @param string $key + * Clear a given failure. + * + * @param string $key The cache key. * @return void */ public function clear_failures( string $key ) { @@ -79,9 +85,9 @@ class FailureRegistry { * Build cache key. * * @param string $key The cache key. - * @return string|null + * @return string */ - private function cache_key( string $key ): ?string { + private function cache_key( string $key ): string { return implode( '_', array( self::CACHE_KEY, $key ) ); } diff --git a/modules/ppcp-applepay/src/Assets/AppleProductStatus.php b/modules/ppcp-applepay/src/Assets/AppleProductStatus.php index ce23b9cfc..83b6e7942 100644 --- a/modules/ppcp-applepay/src/Assets/AppleProductStatus.php +++ b/modules/ppcp-applepay/src/Assets/AppleProductStatus.php @@ -11,7 +11,6 @@ namespace WooCommerce\PayPalCommerce\Applepay\Assets; use Throwable; use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PartnersEndpoint; -use WooCommerce\PayPalCommerce\ApiClient\Entity\SellerStatusProduct; use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache; use WooCommerce\PayPalCommerce\ApiClient\Helper\FailureRegistry; use WooCommerce\PayPalCommerce\Onboarding\State; @@ -128,7 +127,7 @@ class AppleProductStatus { try { $seller_status = $this->partners_endpoint->seller_status(); } catch ( Throwable $error ) { - $this->has_request_failure = true; + $this->has_request_failure = true; $this->current_status_cache = false; return false; } diff --git a/modules/ppcp-wc-gateway/src/Helper/DCCProductStatus.php b/modules/ppcp-wc-gateway/src/Helper/DCCProductStatus.php index c501dadac..772a76e3a 100644 --- a/modules/ppcp-wc-gateway/src/Helper/DCCProductStatus.php +++ b/modules/ppcp-wc-gateway/src/Helper/DCCProductStatus.php @@ -140,7 +140,7 @@ class DCCProductStatus { try { $seller_status = $this->partners_endpoint->seller_status(); } catch ( Throwable $error ) { - $this->has_request_failure = true; + $this->has_request_failure = true; $this->current_status_cache = false; return false; } diff --git a/modules/ppcp-wc-gateway/src/Helper/PayUponInvoiceProductStatus.php b/modules/ppcp-wc-gateway/src/Helper/PayUponInvoiceProductStatus.php index 7295b7e89..f1a3221eb 100644 --- a/modules/ppcp-wc-gateway/src/Helper/PayUponInvoiceProductStatus.php +++ b/modules/ppcp-wc-gateway/src/Helper/PayUponInvoiceProductStatus.php @@ -128,7 +128,7 @@ class PayUponInvoiceProductStatus { try { $seller_status = $this->partners_endpoint->seller_status(); } catch ( Throwable $error ) { - $this->has_request_failure = true; + $this->has_request_failure = true; $this->current_status_cache = false; return false; } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 1c735db2f..e96206781 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -264,6 +264,11 @@ DAY_IN_SECONDS + + + DAY_IN_SECONDS + + realpath( __FILE__ )