diff --git a/composer.json b/composer.json index e413904cf..3fe329cc6 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "container-interop/service-provider": "^0.4.0", "dhii/containers": "^0.1.0-alpha1", "inpsyde/modularity": "^1.7", - "woocommerce/woocommerce-sniffs": "^0.1.0", + "woocommerce/woocommerce-sniffs": "^1.0.0", "phpunit/phpunit": "^7.0 | ^8.0 | ^9.0", "brain/monkey": "^2.4", "php-stubs/wordpress-stubs": "^5.0@stable", diff --git a/composer.lock b/composer.lock index 05ea6e974..5b80e9e7b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6ca9c2c7864d2649617db6d3850382c5", + "content-hash": "fd277e5a82374078694b99b0e6aef07c", "packages": [ { "name": "container-interop/service-provider", @@ -1263,35 +1263,38 @@ }, { "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "v0.7.2", + "version": "v1.1.2", "source": { "type": "git", - "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", - "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db" + "url": "https://github.com/PHPCSStandards/composer-installer.git", + "reference": "e9cf5e4bbf7eeaf9ef5db34938942602838fc2b1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", - "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", + "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/e9cf5e4bbf7eeaf9ef5db34938942602838fc2b1", + "reference": "e9cf5e4bbf7eeaf9ef5db34938942602838fc2b1", "shasum": "" }, "require": { - "composer-plugin-api": "^1.0 || ^2.0", - "php": ">=5.3", + "composer-plugin-api": "^2.2", + "php": ">=5.4", "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" }, "require-dev": { - "composer/composer": "*", - "php-parallel-lint/php-parallel-lint": "^1.3.1", - "phpcompatibility/php-compatibility": "^9.0" + "composer/composer": "^2.2", + "ext-json": "*", + "ext-zip": "*", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcompatibility/php-compatibility": "^9.0", + "yoast/phpunit-polyfills": "^1.0" }, "type": "composer-plugin", "extra": { - "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" }, "autoload": { "psr-4": { - "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1301,17 +1304,16 @@ "authors": [ { "name": "Franck Nijhof", - "email": "franck.nijhof@dealerdirect.com", - "homepage": "http://www.frenck.nl", - "role": "Developer / IT Manager" + "email": "opensource@frenck.dev", + "homepage": "https://frenck.dev", + "role": "Open source developer" }, { "name": "Contributors", - "homepage": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer/graphs/contributors" + "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors" } ], "description": "PHP_CodeSniffer Standards Composer Installer Plugin", - "homepage": "http://www.dealerdirect.com", "keywords": [ "PHPCodeSniffer", "PHP_CodeSniffer", @@ -1331,10 +1333,29 @@ "tests" ], "support": { - "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", - "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" + "issues": "https://github.com/PHPCSStandards/composer-installer/issues", + "security": "https://github.com/PHPCSStandards/composer-installer/security/policy", + "source": "https://github.com/PHPCSStandards/composer-installer" }, - "time": "2022-02-04T12:51:07+00:00" + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" + } + ], + "time": "2025-07-17T20:45:56+00:00" }, { "name": "dhii/collections-interface", @@ -2817,6 +2838,181 @@ ], "time": "2025-05-12T16:38:37+00:00" }, + { + "name": "phpcsstandards/phpcsextra", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHPCSExtra.git", + "reference": "fa4b8d051e278072928e32d817456a7fdb57b6ca" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/fa4b8d051e278072928e32d817456a7fdb57b6ca", + "reference": "fa4b8d051e278072928e32d817456a7fdb57b6ca", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "phpcsstandards/phpcsutils": "^1.1.0", + "squizlabs/php_codesniffer": "^3.13.0 || ^4.0" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcsstandards/phpcsdevcs": "^1.1.6", + "phpcsstandards/phpcsdevtools": "^1.2.1", + "phpunit/phpunit": "^4.5 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-stable": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHPCSExtra/graphs/contributors" + } + ], + "description": "A collection of sniffs and standards for use with PHP_CodeSniffer.", + "keywords": [ + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", + "phpcs", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/PHPCSExtra/issues", + "security": "https://github.com/PHPCSStandards/PHPCSExtra/security/policy", + "source": "https://github.com/PHPCSStandards/PHPCSExtra" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" + } + ], + "time": "2025-06-14T07:40:39+00:00" + }, + { + "name": "phpcsstandards/phpcsutils", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", + "reference": "f7eb16f2fa4237d5db9e8fed8050239bee17a9bd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/f7eb16f2fa4237d5db9e8fed8050239bee17a9bd", + "reference": "f7eb16f2fa4237d5db9e8fed8050239bee17a9bd", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", + "php": ">=5.4", + "squizlabs/php_codesniffer": "^3.13.0 || ^4.0" + }, + "require-dev": { + "ext-filter": "*", + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcsstandards/phpcsdevcs": "^1.1.6", + "yoast/phpunit-polyfills": "^1.1.0 || ^2.0.0 || ^3.0.0" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-stable": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "autoload": { + "classmap": [ + "PHPCSUtils/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHPCSUtils/graphs/contributors" + } + ], + "description": "A suite of utility functions for use with PHP_CodeSniffer", + "homepage": "https://phpcsutils.com/", + "keywords": [ + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", + "phpcs", + "phpcs3", + "phpcs4", + "standards", + "static analysis", + "tokens", + "utility" + ], + "support": { + "docs": "https://phpcsutils.com/", + "issues": "https://github.com/PHPCSStandards/PHPCSUtils/issues", + "security": "https://github.com/PHPCSStandards/PHPCSUtils/security/policy", + "source": "https://github.com/PHPCSStandards/PHPCSUtils" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" + } + ], + "time": "2025-08-10T01:04:45+00:00" + }, { "name": "phpdocumentor/reflection-common", "version": "2.2.0", @@ -5737,74 +5933,77 @@ }, { "name": "woocommerce/woocommerce-sniffs", - "version": "0.1.3", + "version": "1.0.0", "source": { "type": "git", "url": "https://github.com/woocommerce/woocommerce-sniffs.git", - "reference": "4576d54595614d689bc4436acff8baaece3c5bb0" + "reference": "3a65b917ff5ab5e65609e5dcb7bc62f9455bbef8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/woocommerce/woocommerce-sniffs/zipball/4576d54595614d689bc4436acff8baaece3c5bb0", - "reference": "4576d54595614d689bc4436acff8baaece3c5bb0", + "url": "https://api.github.com/repos/woocommerce/woocommerce-sniffs/zipball/3a65b917ff5ab5e65609e5dcb7bc62f9455bbef8", + "reference": "3a65b917ff5ab5e65609e5dcb7bc62f9455bbef8", "shasum": "" }, "require": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0.0", "php": ">=7.0", "phpcompatibility/phpcompatibility-wp": "^2.1.0", - "wp-coding-standards/wpcs": "^2.3.0" + "wp-coding-standards/wpcs": "^3.0.0" }, "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "authors": [ - { - "name": "Claudio Sanches", - "email": "claudio@automattic.com" - } - ], "description": "WooCommerce sniffs", "keywords": [ "phpcs", "standards", + "static analysis", "woocommerce", "wordpress" ], "support": { "issues": "https://github.com/woocommerce/woocommerce-sniffs/issues", - "source": "https://github.com/woocommerce/woocommerce-sniffs/tree/0.1.3" + "source": "https://github.com/woocommerce/woocommerce-sniffs/tree/1.0.0" }, - "time": "2022-02-17T15:34:51+00:00" + "time": "2023-09-29T13:52:33+00:00" }, { "name": "wp-coding-standards/wpcs", - "version": "2.3.0", + "version": "3.2.0", "source": { "type": "git", "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", - "reference": "7da1894633f168fe244afc6de00d141f27517b62" + "reference": "d2421de7cec3274ae622c22c744de9a62c7925af" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/7da1894633f168fe244afc6de00d141f27517b62", - "reference": "7da1894633f168fe244afc6de00d141f27517b62", + "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/d2421de7cec3274ae622c22c744de9a62c7925af", + "reference": "d2421de7cec3274ae622c22c744de9a62c7925af", "shasum": "" }, "require": { + "ext-filter": "*", + "ext-libxml": "*", + "ext-tokenizer": "*", + "ext-xmlreader": "*", "php": ">=5.4", - "squizlabs/php_codesniffer": "^3.3.1" + "phpcsstandards/phpcsextra": "^1.4.0", + "phpcsstandards/phpcsutils": "^1.1.0", + "squizlabs/php_codesniffer": "^3.13.0" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || ^0.6", + "php-parallel-lint/php-console-highlighter": "^1.0.0", + "php-parallel-lint/php-parallel-lint": "^1.4.0", "phpcompatibility/php-compatibility": "^9.0", - "phpcsstandards/phpcsdevtools": "^1.0", - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "phpcsstandards/phpcsdevtools": "^1.2.0", + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" }, "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.6 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically." + "ext-iconv": "For improved results", + "ext-mbstring": "For improved results" }, "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", @@ -5821,6 +6020,7 @@ "keywords": [ "phpcs", "standards", + "static analysis", "wordpress" ], "support": { @@ -5828,14 +6028,20 @@ "source": "https://github.com/WordPress/WordPress-Coding-Standards", "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" }, - "time": "2020-05-13T23:57:56+00:00" + "funding": [ + { + "url": "https://opencollective.com/php_codesniffer", + "type": "custom" + } + ], + "time": "2025-07-24T20:08:31+00:00" } ], "aliases": [], "minimum-stability": "dev", "stability-flags": { - "php-stubs/wordpress-stubs": 0, - "php-stubs/woocommerce-stubs": 0 + "php-stubs/woocommerce-stubs": 0, + "php-stubs/wordpress-stubs": 0 }, "prefer-stable": true, "prefer-lowest": false, @@ -5843,7 +6049,7 @@ "php": "^7.4 | ^8.0", "ext-json": "*" }, - "platform-dev": [], + "platform-dev": {}, "platform-overrides": { "php": "7.4" }, diff --git a/modules/ppcp-admin-notices/src/AdminNotices.php b/modules/ppcp-admin-notices/src/AdminNotices.php index 47067f25e..0eb9d18e5 100644 --- a/modules/ppcp-admin-notices/src/AdminNotices.php +++ b/modules/ppcp-admin-notices/src/AdminNotices.php @@ -49,7 +49,7 @@ class AdminNotices implements ServiceModule, ExtendingModule, ExecutableModule { add_action( 'admin_notices', - function() use ( $renderer ) { + function () use ( $renderer ) { $renderer->render(); } ); @@ -113,11 +113,10 @@ class AdminNotices implements ServiceModule, ExtendingModule, ExecutableModule { add_action( 'woocommerce_init', - function() { + function () { if ( is_admin() && is_callable( array( WC(), 'is_wc_admin_active' ) ) && WC()->is_wc_admin_active() && class_exists( 'Automattic\WooCommerce\Admin\Notes\Notes' ) ) { MexicoInstallmentsNote::init(); } - } ); diff --git a/modules/ppcp-admin-notices/src/Endpoint/MuteMessageEndpoint.php b/modules/ppcp-admin-notices/src/Endpoint/MuteMessageEndpoint.php index 9a67b8511..3ef41b220 100644 --- a/modules/ppcp-admin-notices/src/Endpoint/MuteMessageEndpoint.php +++ b/modules/ppcp-admin-notices/src/Endpoint/MuteMessageEndpoint.php @@ -53,7 +53,7 @@ class MuteMessageEndpoint { * * @return string */ - public static function nonce() : string { + public static function nonce(): string { return self::ENDPOINT; } @@ -62,7 +62,7 @@ class MuteMessageEndpoint { * * @return void */ - public function handle_request() : void { + public function handle_request(): void { try { $data = $this->request_data->read_request( $this->nonce() ); } catch ( RuntimeException $ex ) { diff --git a/modules/ppcp-admin-notices/src/Entity/Message.php b/modules/ppcp-admin-notices/src/Entity/Message.php index c41bc131c..7fa744777 100644 --- a/modules/ppcp-admin-notices/src/Entity/Message.php +++ b/modules/ppcp-admin-notices/src/Entity/Message.php @@ -62,7 +62,7 @@ class Message { * * @return string */ - public function message() : string { + public function message(): string { return $this->message; } @@ -71,7 +71,7 @@ class Message { * * @return string */ - public function type() : string { + public function type(): string { return $this->type; } @@ -80,7 +80,7 @@ class Message { * * @return bool */ - public function is_dismissible() : bool { + public function is_dismissible(): bool { return $this->dismissible; } @@ -89,7 +89,7 @@ class Message { * * @return string */ - public function wrapper() : string { + public function wrapper(): string { return $this->wrapper; } @@ -98,7 +98,7 @@ class Message { * * @return array */ - public function to_array() : array { + public function to_array(): array { return array( 'type' => $this->type, 'message' => $this->message, @@ -114,7 +114,7 @@ class Message { * * @return Message */ - public static function from_array( array $data ) : Message { + public static function from_array( array $data ): Message { return new Message( (string) ( $data['message'] ?? '' ), (string) ( $data['type'] ?? '' ), diff --git a/modules/ppcp-admin-notices/src/Entity/PersistentMessage.php b/modules/ppcp-admin-notices/src/Entity/PersistentMessage.php index 4a173a02d..de232cd52 100644 --- a/modules/ppcp-admin-notices/src/Entity/PersistentMessage.php +++ b/modules/ppcp-admin-notices/src/Entity/PersistentMessage.php @@ -47,7 +47,7 @@ class PersistentMessage extends Message { * * @return string */ - public function id( bool $with_db_prefix = false ) : string { + public function id( bool $with_db_prefix = false ): string { if ( ! $this->message_id ) { return ''; } @@ -58,7 +58,7 @@ class PersistentMessage extends Message { /** * {@inheritDoc} */ - public function to_array() : array { + public function to_array(): array { $data = parent::to_array(); $data['id'] = $this->message_id; @@ -70,7 +70,7 @@ class PersistentMessage extends Message { * * @return PersistentMessage */ - public static function from_array( array $data ) : Message { + public static function from_array( array $data ): Message { return new PersistentMessage( (string) ( $data['id'] ?? '' ), (string) ( $data['message'] ?? '' ), @@ -84,7 +84,7 @@ class PersistentMessage extends Message { * * @return bool */ - public function is_muted() : bool { + public function is_muted(): bool { $user_id = get_current_user_id(); if ( ! $this->message_id || ! $user_id ) { @@ -99,7 +99,7 @@ class PersistentMessage extends Message { * * @return void */ - public function mute() : void { + public function mute(): void { $user_id = get_current_user_id(); if ( $this->message_id && $user_id && ! $this->is_muted() ) { @@ -112,7 +112,7 @@ class PersistentMessage extends Message { * * @return void */ - public static function clear_all() : void { + public static function clear_all(): void { global $wpdb; $wpdb->query( diff --git a/modules/ppcp-admin-notices/src/Renderer/Renderer.php b/modules/ppcp-admin-notices/src/Renderer/Renderer.php index 527d83dd4..bcf220fef 100644 --- a/modules/ppcp-admin-notices/src/Renderer/Renderer.php +++ b/modules/ppcp-admin-notices/src/Renderer/Renderer.php @@ -95,7 +95,7 @@ class Renderer implements RendererInterface { /** * {@inheritDoc} */ - public function enqueue_admin() : void { + public function enqueue_admin(): void { if ( ! $this->can_mute_message ) { return; } @@ -129,7 +129,7 @@ class Renderer implements RendererInterface { * * @return array */ - protected function script_data_for_admin() : array { + protected function script_data_for_admin(): array { $ajax_url = admin_url( 'admin-ajax.php' ); return array( diff --git a/modules/ppcp-admin-notices/src/Renderer/RendererInterface.php b/modules/ppcp-admin-notices/src/Renderer/RendererInterface.php index ad0044341..c4376e8b0 100644 --- a/modules/ppcp-admin-notices/src/Renderer/RendererInterface.php +++ b/modules/ppcp-admin-notices/src/Renderer/RendererInterface.php @@ -26,5 +26,5 @@ interface RendererInterface { * * @return void */ - public function enqueue_admin() : void; + public function enqueue_admin(): void; } diff --git a/modules/ppcp-admin-notices/src/Repository/Repository.php b/modules/ppcp-admin-notices/src/Repository/Repository.php index 72d88c69c..d3fc5e367 100644 --- a/modules/ppcp-admin-notices/src/Repository/Repository.php +++ b/modules/ppcp-admin-notices/src/Repository/Repository.php @@ -25,7 +25,7 @@ class Repository implements RepositoryInterface { * * @return Message[] */ - public function current_message() : array { + public function current_message(): array { return array_filter( /** * Returns the list of admin messages. @@ -34,7 +34,7 @@ class Repository implements RepositoryInterface { self::NOTICES_FILTER, array() ), - function ( $element ) : bool { + function ( $element ): bool { if ( $element instanceof PersistentMessage ) { return ! $element->is_muted(); } @@ -51,7 +51,7 @@ class Repository implements RepositoryInterface { * * @return void */ - public function persist( Message $message ) : void { + public function persist( Message $message ): void { $persisted_notices = get_option( self::PERSISTED_NOTICES_OPTION ) ?: array(); $persisted_notices[] = $message->to_array(); @@ -64,7 +64,7 @@ class Repository implements RepositoryInterface { * * @return array|Message[] */ - public function get_persisted_and_clear() : array { + public function get_persisted_and_clear(): array { $notices = array(); $persisted_data = get_option( self::PERSISTED_NOTICES_OPTION ) ?: array(); diff --git a/modules/ppcp-api-client/services.php b/modules/ppcp-api-client/services.php index 92d5319d8..581839943 100644 --- a/modules/ppcp-api-client/services.php +++ b/modules/ppcp-api-client/services.php @@ -86,7 +86,7 @@ use WooCommerce\PayPalCommerce\WcGateway\Helper\EnvironmentConfig; use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings; return array( - 'api.host' => static function( ContainerInterface $container ) : string { + 'api.host' => static function ( ContainerInterface $container ): string { $environment = $container->get( 'settings.environment' ); assert( $environment instanceof Environment ); @@ -96,25 +96,25 @@ return array( return (string) $container->get( 'api.production-host' ); }, - 'api.paypal-host' => function( ContainerInterface $container ) : string { + 'api.paypal-host' => function ( ContainerInterface $container ): string { return PAYPAL_API_URL; }, // It seems this 'api.paypal-website-url' key is always overridden in ppcp-onboarding/services.php. - 'api.paypal-website-url' => function( ContainerInterface $container ) : string { + 'api.paypal-website-url' => function ( ContainerInterface $container ): string { return PAYPAL_URL; }, - 'api.factory.paypal-checkout-url' => function( ContainerInterface $container ) : callable { + 'api.factory.paypal-checkout-url' => function ( ContainerInterface $container ): callable { return function ( string $id ) use ( $container ): string { return $container->get( 'api.paypal-website-url' ) . '/checkoutnow?token=' . $id; }; }, - 'api.partner_merchant_id' => static function () : string { + 'api.partner_merchant_id' => static function (): string { return ''; }, - 'api.merchant_email' => function () : string { + 'api.merchant_email' => function (): string { return ''; }, - 'api.merchant_id' => function () : string { + 'api.merchant_id' => function (): string { return ''; }, 'api.key' => static function (): string { @@ -142,7 +142,7 @@ return array( $container->get( 'wcgateway.settings' ) ); }, - 'api.endpoint.partners' => static function ( ContainerInterface $container ) : PartnersEndpoint { + 'api.endpoint.partners' => static function ( ContainerInterface $container ): PartnersEndpoint { return new PartnersEndpoint( $container->get( 'api.host' ), $container->get( 'api.bearer' ), @@ -153,10 +153,10 @@ return array( $container->get( 'api.helper.failure-registry' ) ); }, - 'api.factory.sellerstatus' => static function ( ContainerInterface $container ) : SellerStatusFactory { + 'api.factory.sellerstatus' => static function ( ContainerInterface $container ): SellerStatusFactory { return new SellerStatusFactory(); }, - 'api.endpoint.payment-token' => static function ( ContainerInterface $container ) : PaymentTokenEndpoint { + 'api.endpoint.payment-token' => static function ( ContainerInterface $container ): PaymentTokenEndpoint { return new PaymentTokenEndpoint( $container->get( 'api.host' ), $container->get( 'api.bearer' ), @@ -166,14 +166,14 @@ return array( $container->get( 'api.repository.customer' ) ); }, - 'api.endpoint.payment-tokens' => static function( ContainerInterface $container ) : PaymentTokensEndpoint { + 'api.endpoint.payment-tokens' => static function ( ContainerInterface $container ): PaymentTokensEndpoint { return new PaymentTokensEndpoint( $container->get( 'api.host' ), $container->get( 'api.bearer' ), $container->get( 'woocommerce.logger.woocommerce' ) ); }, - 'api.endpoint.webhook' => static function ( ContainerInterface $container ) : WebhookEndpoint { + 'api.endpoint.webhook' => static function ( ContainerInterface $container ): WebhookEndpoint { return new WebhookEndpoint( $container->get( 'api.host' ), @@ -183,7 +183,7 @@ return array( $container->get( 'woocommerce.logger.woocommerce' ) ); }, - 'api.endpoint.partner-referrals' => static function ( ContainerInterface $container ) : PartnerReferrals { + 'api.endpoint.partner-referrals' => static function ( ContainerInterface $container ): PartnerReferrals { return new PartnerReferrals( $container->get( 'api.host' ), @@ -191,7 +191,7 @@ return array( $container->get( 'woocommerce.logger.woocommerce' ) ); }, - 'api.endpoint.partner-referrals-sandbox' => static function ( ContainerInterface $container ) : PartnerReferrals { + 'api.endpoint.partner-referrals-sandbox' => static function ( ContainerInterface $container ): PartnerReferrals { return new PartnerReferrals( CONNECT_WOO_SANDBOX_URL, @@ -199,7 +199,7 @@ return array( $container->get( 'woocommerce.logger.woocommerce' ) ); }, - 'api.endpoint.partner-referrals-production' => static function ( ContainerInterface $container ) : PartnerReferrals { + 'api.endpoint.partner-referrals-production' => static function ( ContainerInterface $container ): PartnerReferrals { return new PartnerReferrals( CONNECT_WOO_URL, @@ -207,7 +207,7 @@ return array( $container->get( 'woocommerce.logger.woocommerce' ) ); }, - 'api.endpoint.identity-token' => static function ( ContainerInterface $container ) : IdentityToken { + 'api.endpoint.identity-token' => static function ( ContainerInterface $container ): IdentityToken { $logger = $container->get( 'woocommerce.logger.woocommerce' ); $settings = $container->get( 'wcgateway.settings' ); $customer_repository = $container->get( 'api.repository.customer' ); @@ -232,7 +232,7 @@ return array( $logger ); }, - 'api.endpoint.login-seller' => static function ( ContainerInterface $container ) : LoginSeller { + 'api.endpoint.login-seller' => static function ( ContainerInterface $container ): LoginSeller { $logger = $container->get( 'woocommerce.logger.woocommerce' ); return new LoginSeller( @@ -287,7 +287,7 @@ return array( $container->get( 'woocommerce.logger.woocommerce' ) ); }, - 'api.endpoint.billing-plans' => static function( ContainerInterface $container ): BillingPlans { + 'api.endpoint.billing-plans' => static function ( ContainerInterface $container ): BillingPlans { return new BillingPlans( $container->get( 'api.host' ), $container->get( 'api.bearer' ), @@ -296,21 +296,21 @@ return array( $container->get( 'woocommerce.logger.woocommerce' ) ); }, - 'api.endpoint.billing-subscriptions' => static function( ContainerInterface $container ): BillingSubscriptions { + 'api.endpoint.billing-subscriptions' => static function ( ContainerInterface $container ): BillingSubscriptions { return new BillingSubscriptions( $container->get( 'api.host' ), $container->get( 'api.bearer' ), $container->get( 'woocommerce.logger.woocommerce' ) ); }, - 'api.endpoint.payment-method-tokens' => static function( ContainerInterface $container ): PaymentMethodTokensEndpoint { + 'api.endpoint.payment-method-tokens' => static function ( ContainerInterface $container ): PaymentMethodTokensEndpoint { return new PaymentMethodTokensEndpoint( $container->get( 'api.host' ), $container->get( 'api.bearer' ), $container->get( 'woocommerce.logger.woocommerce' ) ); }, - 'api.repository.partner-referrals-data' => static function ( ContainerInterface $container ) : PartnerReferralsData { + 'api.repository.partner-referrals-data' => static function ( ContainerInterface $container ): PartnerReferralsData { $dcc_applies = $container->get( 'api.helpers.dccapplies' ); return new PartnerReferralsData( $dcc_applies ); @@ -320,11 +320,11 @@ return array( $merchant_id = $container->get( 'api.merchant_id' ); return new PayeeRepository( $merchant_email, $merchant_id ); }, - 'api.repository.customer' => static function( ContainerInterface $container ): CustomerRepository { + 'api.repository.customer' => static function ( ContainerInterface $container ): CustomerRepository { $prefix = $container->get( 'api.prefix' ); return new CustomerRepository( $prefix ); }, - 'api.repository.order' => static function( ContainerInterface $container ): OrderRepository { + 'api.repository.order' => static function ( ContainerInterface $container ): OrderRepository { return new OrderRepository( $container->get( 'api.endpoint.order' ) ); @@ -345,10 +345,10 @@ return array( $container->get( 'settings.merchant-details' ) ); }, - 'api.factory.payment-token' => static function ( ContainerInterface $container ) : PaymentTokenFactory { + 'api.factory.payment-token' => static function ( ContainerInterface $container ): PaymentTokenFactory { return new PaymentTokenFactory(); }, - 'api.factory.payment-token-action-links' => static function ( ContainerInterface $container ) : PaymentTokenActionLinksFactory { + 'api.factory.payment-token-action-links' => static function ( ContainerInterface $container ): PaymentTokenActionLinksFactory { return new PaymentTokenActionLinksFactory(); }, 'api.factory.webhook' => static function ( ContainerInterface $container ): WebhookFactory { @@ -485,25 +485,25 @@ return array( 'api.factory.fraud-processor-response' => static function ( ContainerInterface $container ): FraudProcessorResponseFactory { return new FraudProcessorResponseFactory(); }, - 'api.factory.product' => static function( ContainerInterface $container ): ProductFactory { + 'api.factory.product' => static function ( ContainerInterface $container ): ProductFactory { return new ProductFactory(); }, - 'api.factory.billing-cycle' => static function( ContainerInterface $container ): BillingCycleFactory { + 'api.factory.billing-cycle' => static function ( ContainerInterface $container ): BillingCycleFactory { return new BillingCycleFactory( $container->get( 'api.shop.currency.getter' ) ); }, - 'api.factory.payment-preferences' => static function( ContainerInterface $container ):PaymentPreferencesFactory { + 'api.factory.payment-preferences' => static function ( ContainerInterface $container ): PaymentPreferencesFactory { return new PaymentPreferencesFactory( $container->get( 'api.shop.currency.getter' ) ); }, - 'api.factory.plan' => static function( ContainerInterface $container ): PlanFactory { + 'api.factory.plan' => static function ( ContainerInterface $container ): PlanFactory { return new PlanFactory( $container->get( 'api.factory.billing-cycle' ), $container->get( 'api.factory.payment-preferences' ) ); }, - 'api.factory.card-authentication-result-factory' => static function( ContainerInterface $container ): CardAuthenticationResultFactory { + 'api.factory.card-authentication-result-factory' => static function ( ContainerInterface $container ): CardAuthenticationResultFactory { return new CardAuthenticationResultFactory(); }, - 'api.helpers.dccapplies' => static function ( ContainerInterface $container ) : DccApplies { + 'api.helpers.dccapplies' => static function ( ContainerInterface $container ): DccApplies { return new DccApplies( $container->get( 'api.dcc-supported-country-currency-matrix' ), $container->get( 'api.dcc-supported-country-card-matrix' ), @@ -512,21 +512,21 @@ return array( ); }, - 'api.shop.currency.getter' => static function ( ContainerInterface $container ) : CurrencyGetter { + 'api.shop.currency.getter' => static function ( ContainerInterface $container ): CurrencyGetter { return new CurrencyGetter(); }, - 'api.shop.country' => static function ( ContainerInterface $container ) : string { + 'api.shop.country' => static function ( ContainerInterface $container ): string { $location = wc_get_base_location(); return $location['country']; }, - 'api.shop.is-psd2-country' => static function ( ContainerInterface $container ) : bool { + 'api.shop.is-psd2-country' => static function ( ContainerInterface $container ): bool { return in_array( $container->get( 'api.shop.country' ), $container->get( 'api.psd2-countries' ), true ); }, - 'api.shop.is-currency-supported' => static function ( ContainerInterface $container ) : bool { + 'api.shop.is-currency-supported' => static function ( ContainerInterface $container ): bool { return in_array( $container->get( 'api.shop.currency.getter' )->get(), $container->get( 'api.supported-currencies' ), @@ -593,7 +593,7 @@ return array( * * From https://developer.paypal.com/docs/reports/reference/paypal-supported-currencies/ */ - 'api.supported-currencies' => static function ( ContainerInterface $container ) : array { + 'api.supported-currencies' => static function ( ContainerInterface $container ): array { return array( 'AUD', 'BRL', @@ -626,7 +626,7 @@ return array( /** * The matrix which countries and currency combinations can be used for DCC. */ - 'api.dcc-supported-country-currency-matrix' => static function ( ContainerInterface $container ) : array { + 'api.dcc-supported-country-currency-matrix' => static function ( ContainerInterface $container ): array { $default_currencies = apply_filters( 'woocommerce_paypal_payments_supported_currencies', array( @@ -712,7 +712,7 @@ return array( /** * Which countries support which credit cards. Empty credit card arrays mean no restriction on currency. */ - 'api.dcc-supported-country-card-matrix' => static function ( ContainerInterface $container ) : array { + 'api.dcc-supported-country-card-matrix' => static function ( ContainerInterface $container ): array { $mastercard_visa_amex = array( 'mastercard' => array(), 'visa' => array(), @@ -793,7 +793,7 @@ return array( ); }, - 'api.psd2-countries' => static function ( ContainerInterface $container ) : array { + 'api.psd2-countries' => static function ( ContainerInterface $container ): array { return array( 'AT', 'BE', @@ -826,7 +826,7 @@ return array( ); }, - 'api.paylater-countries' => static function ( ContainerInterface $container ) : array { + 'api.paylater-countries' => static function ( ContainerInterface $container ): array { return apply_filters( 'woocommerce_paypal_payments_supported_paylater_countries', array( @@ -840,20 +840,20 @@ return array( ) ); }, - 'api.order-helper' => static function( ContainerInterface $container ): OrderHelper { + 'api.order-helper' => static function ( ContainerInterface $container ): OrderHelper { return new OrderHelper(); }, - 'api.helper.order-transient' => static function( ContainerInterface $container ): OrderTransient { + 'api.helper.order-transient' => static function ( ContainerInterface $container ): OrderTransient { $cache = $container->get( 'api.paypal-bearer-cache' ); $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 ); }, 'api.helper.purchase-unit-sanitizer' => SingletonDecorator::make( - static function( ContainerInterface $container ): PurchaseUnitSanitizer { + static function ( ContainerInterface $container ): PurchaseUnitSanitizer { $settings = $container->get( 'wcgateway.settings' ); assert( $settings instanceof Settings ); @@ -862,24 +862,24 @@ return array( return new PurchaseUnitSanitizer( $behavior, $line_name ); } ), - 'api.client-credentials' => static function( ContainerInterface $container ): ClientCredentials { + 'api.client-credentials' => static function ( ContainerInterface $container ): ClientCredentials { return new ClientCredentials( $container->get( 'wcgateway.settings' ) ); }, - 'api.paypal-bearer-cache' => static function( ContainerInterface $container ): Cache { + 'api.paypal-bearer-cache' => static function ( ContainerInterface $container ): Cache { return new Cache( 'ppcp-paypal-bearer' ); }, - 'api.client-credentials-cache' => static function( ContainerInterface $container ): Cache { + 'api.client-credentials-cache' => static function ( ContainerInterface $container ): Cache { return new Cache( 'ppcp-client-credentials-cache' ); }, - 'api.user-id-token-cache' => static function( ContainerInterface $container ): Cache { + 'api.user-id-token-cache' => static function ( ContainerInterface $container ): Cache { return new Cache( 'ppcp-id-token-cache' ); }, - 'api.reference-transaction-status-cache' => static function( ContainerInterface $container ): Cache { + 'api.reference-transaction-status-cache' => static function ( ContainerInterface $container ): Cache { return new Cache( 'ppcp-reference-transaction-status-cache' ); }, - 'api.user-id-token' => static function( ContainerInterface $container ): UserIdToken { + 'api.user-id-token' => static function ( ContainerInterface $container ): UserIdToken { return new UserIdToken( $container->get( 'api.host' ), $container->get( 'woocommerce.logger.woocommerce' ), @@ -887,7 +887,7 @@ return array( $container->get( 'api.user-id-token-cache' ) ); }, - 'api.sdk-client-token' => static function( ContainerInterface $container ): SdkClientToken { + 'api.sdk-client-token' => static function ( ContainerInterface $container ): SdkClientToken { return new SdkClientToken( $container->get( 'api.host' ), $container->get( 'woocommerce.logger.woocommerce' ), @@ -895,39 +895,39 @@ return array( $container->get( 'api.client-credentials-cache' ) ); }, - 'api.paypal-host-production' => static function( ContainerInterface $container ) : string { + 'api.paypal-host-production' => static function ( ContainerInterface $container ): string { return PAYPAL_API_URL; }, - 'api.paypal-host-sandbox' => static function( ContainerInterface $container ) : string { + 'api.paypal-host-sandbox' => static function ( ContainerInterface $container ): string { return PAYPAL_SANDBOX_API_URL; }, - 'api.paypal-website-url-production' => static function( ContainerInterface $container ) : string { + 'api.paypal-website-url-production' => static function ( ContainerInterface $container ): string { return PAYPAL_URL; }, - 'api.paypal-website-url-sandbox' => static function( ContainerInterface $container ) : string { + 'api.paypal-website-url-sandbox' => static function ( ContainerInterface $container ): string { return PAYPAL_SANDBOX_URL; }, - 'api.partner_merchant_id-production' => static function( ContainerInterface $container ) : string { + 'api.partner_merchant_id-production' => static function ( ContainerInterface $container ): string { return CONNECT_WOO_MERCHANT_ID; }, - 'api.partner_merchant_id-sandbox' => static function( ContainerInterface $container ) : string { + 'api.partner_merchant_id-sandbox' => static function ( ContainerInterface $container ): string { return CONNECT_WOO_SANDBOX_MERCHANT_ID; }, - 'api.endpoint.login-seller-production' => static function ( ContainerInterface $container ) : LoginSeller { + 'api.endpoint.login-seller-production' => static function ( ContainerInterface $container ): LoginSeller { return new LoginSeller( $container->get( 'api.paypal-host-production' ), $container->get( 'api.partner_merchant_id-production' ), $container->get( 'woocommerce.logger.woocommerce' ) ); }, - 'api.endpoint.login-seller-sandbox' => static function ( ContainerInterface $container ) : LoginSeller { + 'api.endpoint.login-seller-sandbox' => static function ( ContainerInterface $container ): LoginSeller { return new LoginSeller( $container->get( 'api.paypal-host-sandbox' ), $container->get( 'api.partner_merchant_id-sandbox' ), $container->get( 'woocommerce.logger.woocommerce' ) ); }, - 'api.env.paypal-host' => static function ( ContainerInterface $container ) : EnvironmentConfig { + 'api.env.paypal-host' => static function ( ContainerInterface $container ): EnvironmentConfig { /** * Environment specific API host names. * @@ -939,7 +939,7 @@ return array( $container->get( 'api.paypal-host-sandbox' ) ); }, - 'api.env.endpoint.login-seller' => static function ( ContainerInterface $container ) : EnvironmentConfig { + 'api.env.endpoint.login-seller' => static function ( ContainerInterface $container ): EnvironmentConfig { /** * Environment specific LoginSeller API instances. * @@ -951,7 +951,7 @@ return array( $container->get( 'api.endpoint.login-seller-sandbox' ) ); }, - 'api.env.endpoint.partner-referrals' => static function ( ContainerInterface $container ) : EnvironmentConfig { + 'api.env.endpoint.partner-referrals' => static function ( ContainerInterface $container ): EnvironmentConfig { /** * Environment specific PartnerReferrals API instances. * @@ -981,7 +981,7 @@ return array( return CONNECT_WOO_URL; }, - 'api.helper.partner-attribution' => static function ( ContainerInterface $container ) : PartnerAttribution { + 'api.helper.partner-attribution' => static function ( ContainerInterface $container ): PartnerAttribution { return new PartnerAttribution( 'ppcp_bn_code', array( diff --git a/modules/ppcp-api-client/src/ApiModule.php b/modules/ppcp-api-client/src/ApiModule.php index 031974c06..06a52cad7 100644 --- a/modules/ppcp-api-client/src/ApiModule.php +++ b/modules/ppcp-api-client/src/ApiModule.php @@ -66,7 +66,7 @@ class ApiModule implements ServiceModule, FactoryModule, ExtendingModule, Execut ); add_filter( 'ppcp_create_order_request_body_data', - function( array $data ) use ( $c ) { + function ( array $data ) use ( $c ) { foreach ( ( $data['purchase_units'] ?? array() ) as $purchase_unit_index => $purchase_unit ) { foreach ( ( $purchase_unit['items'] ?? array() ) as $item_index => $item ) { diff --git a/modules/ppcp-api-client/src/Authentication/PayPalBearer.php b/modules/ppcp-api-client/src/Authentication/PayPalBearer.php index 7f176c218..575599938 100644 --- a/modules/ppcp-api-client/src/Authentication/PayPalBearer.php +++ b/modules/ppcp-api-client/src/Authentication/PayPalBearer.php @@ -100,7 +100,7 @@ class PayPalBearer implements Bearer { * @throws RuntimeException When request fails. * @return Token */ - public function bearer() : Token { + public function bearer(): Token { try { $bearer = Token::from_json( (string) $this->cache->get( self::CACHE_KEY ) ); @@ -115,7 +115,7 @@ class PayPalBearer implements Bearer { * * @return string The client ID from settings, or the key defined via constructor. */ - private function get_key() : string { + private function get_key(): string { if ( $this->settings && $this->settings->has( 'client_id' ) @@ -132,7 +132,7 @@ class PayPalBearer implements Bearer { * * @return string The client secret from settings, or the value defined via constructor. */ - private function get_secret() : string { + private function get_secret(): string { if ( $this->settings && $this->settings->has( 'client_secret' ) @@ -150,7 +150,7 @@ class PayPalBearer implements Bearer { * @throws RuntimeException When request fails. * @return Token */ - private function newBearer() : Token { + private function newBearer(): Token { $key = $this->get_key(); $secret = $this->get_secret(); $url = trailingslashit( $this->host ) . 'v1/oauth2/token?grant_type=client_credentials'; diff --git a/modules/ppcp-api-client/src/Endpoint/BillingSubscriptions.php b/modules/ppcp-api-client/src/Endpoint/BillingSubscriptions.php index 281afe0ec..1d17da263 100644 --- a/modules/ppcp-api-client/src/Endpoint/BillingSubscriptions.php +++ b/modules/ppcp-api-client/src/Endpoint/BillingSubscriptions.php @@ -65,7 +65,7 @@ class BillingSubscriptions { * @throws RuntimeException If the request fails. * @throws PayPalApiException If the request fails. */ - public function suspend( string $id ):void { + public function suspend( string $id ): void { $data = array( 'reason' => sprintf( 'Suspended by %s.', is_admin() ? 'merchant' : 'customer' ), ); @@ -214,6 +214,4 @@ class BillingSubscriptions { return $json; } - - } diff --git a/modules/ppcp-api-client/src/Endpoint/PartnersEndpoint.php b/modules/ppcp-api-client/src/Endpoint/PartnersEndpoint.php index a663c70a3..53e141ea7 100644 --- a/modules/ppcp-api-client/src/Endpoint/PartnersEndpoint.php +++ b/modules/ppcp-api-client/src/Endpoint/PartnersEndpoint.php @@ -108,7 +108,7 @@ class PartnersEndpoint { * @return SellerStatus * @throws RuntimeException When request could not be fulfilled. */ - public function seller_status() : SellerStatus { + public function seller_status(): SellerStatus { $url = trailingslashit( $this->host ) . 'v1/customer/partners/' . $this->partner_id . '/merchant-integrations/' . $this->merchant_id; $bearer = $this->bearer->bearer(); $args = array( diff --git a/modules/ppcp-api-client/src/Endpoint/PaymentsEndpoint.php b/modules/ppcp-api-client/src/Endpoint/PaymentsEndpoint.php index 484b89a94..b3ed88bb9 100644 --- a/modules/ppcp-api-client/src/Endpoint/PaymentsEndpoint.php +++ b/modules/ppcp-api-client/src/Endpoint/PaymentsEndpoint.php @@ -203,7 +203,7 @@ class PaymentsEndpoint { * @throws RuntimeException If the request fails. * @throws PayPalApiException If the request fails. */ - public function reauthorize( string $authorization_id, ?Money $amount = null ) : string { + public function reauthorize( string $authorization_id, ?Money $amount = null ): string { $bearer = $this->bearer->bearer(); $url = trailingslashit( $this->host ) . 'v2/payments/authorizations/' . $authorization_id . '/reauthorize'; @@ -249,7 +249,7 @@ class PaymentsEndpoint { * @throws RuntimeException If the request fails. * @throws PayPalApiException If the request fails. */ - public function refund( RefundCapture $refund ) : string { + public function refund( RefundCapture $refund ): string { $bearer = $this->bearer->bearer(); $url = trailingslashit( $this->host ) . 'v2/payments/captures/' . $refund->for_capture()->id() . '/refund'; $args = array( @@ -289,7 +289,7 @@ class PaymentsEndpoint { * @throws RuntimeException If the request fails. * @throws PayPalApiException If the request fails. */ - public function void( Authorization $authorization ) : void { + public function void( Authorization $authorization ): void { $bearer = $this->bearer->bearer(); $url = trailingslashit( $this->host ) . 'v2/payments/authorizations/' . $authorization->id() . '/void'; $args = array( diff --git a/modules/ppcp-api-client/src/Endpoint/WebhookEndpoint.php b/modules/ppcp-api-client/src/Endpoint/WebhookEndpoint.php index 1156dfd86..c532f5197 100644 --- a/modules/ppcp-api-client/src/Endpoint/WebhookEndpoint.php +++ b/modules/ppcp-api-client/src/Endpoint/WebhookEndpoint.php @@ -348,7 +348,7 @@ class WebhookEndpoint { if ( isset( $expected_headers[ $key ] ) ) { $expected_headers[ $key ] = $header; } - }; + } foreach ( $expected_headers as $key => $value ) { if ( ! empty( $value ) ) { diff --git a/modules/ppcp-api-client/src/Entity/Authorization.php b/modules/ppcp-api-client/src/Entity/Authorization.php index 007e12475..9e0d3c960 100644 --- a/modules/ppcp-api-client/src/Entity/Authorization.php +++ b/modules/ppcp-api-client/src/Entity/Authorization.php @@ -86,7 +86,7 @@ class Authorization { * * @return FraudProcessorResponse|null */ - public function fraud_processor_response() : ?FraudProcessorResponse { + public function fraud_processor_response(): ?FraudProcessorResponse { return $this->fraud_processor_response; } diff --git a/modules/ppcp-api-client/src/Entity/Capture.php b/modules/ppcp-api-client/src/Entity/Capture.php index 98543437b..3d85daadd 100644 --- a/modules/ppcp-api-client/src/Entity/Capture.php +++ b/modules/ppcp-api-client/src/Entity/Capture.php @@ -120,7 +120,7 @@ class Capture { * * @return string */ - public function id() : string { + public function id(): string { return $this->id; } @@ -129,7 +129,7 @@ class Capture { * * @return CaptureStatus */ - public function status() : CaptureStatus { + public function status(): CaptureStatus { return $this->status; } @@ -138,7 +138,7 @@ class Capture { * * @return Amount */ - public function amount() : Amount { + public function amount(): Amount { return $this->amount; } @@ -147,7 +147,7 @@ class Capture { * * @return bool */ - public function final_capture() : bool { + public function final_capture(): bool { return $this->final_capture; } @@ -165,7 +165,7 @@ class Capture { * * @return string */ - public function invoice_id() : string { + public function invoice_id(): string { return $this->invoice_id; } @@ -174,7 +174,7 @@ class Capture { * * @return string */ - public function custom_id() : string { + public function custom_id(): string { return $this->custom_id; } @@ -183,7 +183,7 @@ class Capture { * * @return SellerReceivableBreakdown|null */ - public function seller_receivable_breakdown() : ?SellerReceivableBreakdown { + public function seller_receivable_breakdown(): ?SellerReceivableBreakdown { return $this->seller_receivable_breakdown; } @@ -192,7 +192,7 @@ class Capture { * * @return FraudProcessorResponse|null */ - public function fraud_processor_response() : ?FraudProcessorResponse { + public function fraud_processor_response(): ?FraudProcessorResponse { return $this->fraud_processor_response; } @@ -201,7 +201,7 @@ class Capture { * * @return array */ - public function to_array() : array { + public function to_array(): array { $data = array( 'id' => $this->id(), 'status' => $this->status()->name(), diff --git a/modules/ppcp-api-client/src/Entity/Item.php b/modules/ppcp-api-client/src/Entity/Item.php index 90a270cf1..3e75a9512 100644 --- a/modules/ppcp-api-client/src/Entity/Item.php +++ b/modules/ppcp-api-client/src/Entity/Item.php @@ -204,7 +204,7 @@ class Item { * * @return string */ - public function url():string { + public function url(): string { return $this->url; } @@ -213,7 +213,7 @@ class Item { * * @return string */ - public function image_url():string { + public function image_url(): string { return $this->validate_image_url() ? $this->image_url : ''; } @@ -222,7 +222,7 @@ class Item { * * @return float */ - public function tax_rate():float { + public function tax_rate(): float { return round( (float) $this->tax_rate, 2 ); } @@ -231,7 +231,7 @@ class Item { * * @return string|null */ - public function cart_item_key():?string { + public function cart_item_key(): ?string { return $this->cart_item_key; } diff --git a/modules/ppcp-api-client/src/Entity/PaymentPreferences.php b/modules/ppcp-api-client/src/Entity/PaymentPreferences.php index b257c2389..998061ab9 100644 --- a/modules/ppcp-api-client/src/Entity/PaymentPreferences.php +++ b/modules/ppcp-api-client/src/Entity/PaymentPreferences.php @@ -104,7 +104,7 @@ class PaymentPreferences { * * @return array */ - public function to_array():array { + public function to_array(): array { return array( 'setup_fee' => $this->setup_fee(), 'auto_bill_outstanding' => $this->auto_bill_outstanding(), diff --git a/modules/ppcp-api-client/src/Entity/PaymentToken.php b/modules/ppcp-api-client/src/Entity/PaymentToken.php index 65796d6b8..56df4ca1f 100644 --- a/modules/ppcp-api-client/src/Entity/PaymentToken.php +++ b/modules/ppcp-api-client/src/Entity/PaymentToken.php @@ -124,5 +124,4 @@ class PaymentToken { ) ); } - } diff --git a/modules/ppcp-api-client/src/Entity/Plan.php b/modules/ppcp-api-client/src/Entity/Plan.php index 06747776b..f8bc3af35 100644 --- a/modules/ppcp-api-client/src/Entity/Plan.php +++ b/modules/ppcp-api-client/src/Entity/Plan.php @@ -141,7 +141,7 @@ class Plan { * * @return array */ - public function to_array():array { + public function to_array(): array { return array( 'id' => $this->id(), 'name' => $this->name(), diff --git a/modules/ppcp-api-client/src/Entity/Refund.php b/modules/ppcp-api-client/src/Entity/Refund.php index eb44fe00a..8da6806ea 100644 --- a/modules/ppcp-api-client/src/Entity/Refund.php +++ b/modules/ppcp-api-client/src/Entity/Refund.php @@ -119,7 +119,7 @@ class Refund { * * @return string */ - public function id() : string { + public function id(): string { return $this->id; } @@ -128,7 +128,7 @@ class Refund { * * @return RefundStatus */ - public function status() : RefundStatus { + public function status(): RefundStatus { return $this->status; } @@ -137,7 +137,7 @@ class Refund { * * @return Amount */ - public function amount() : Amount { + public function amount(): Amount { return $this->amount; } @@ -146,7 +146,7 @@ class Refund { * * @return string */ - public function invoice_id() : string { + public function invoice_id(): string { return $this->invoice_id; } @@ -155,7 +155,7 @@ class Refund { * * @return string */ - public function custom_id() : string { + public function custom_id(): string { return $this->custom_id; } @@ -164,7 +164,7 @@ class Refund { * * @return SellerPayableBreakdown|null */ - public function seller_payable_breakdown() : ?SellerPayableBreakdown { + public function seller_payable_breakdown(): ?SellerPayableBreakdown { return $this->seller_payable_breakdown; } @@ -173,7 +173,7 @@ class Refund { * * @return string */ - public function acquirer_reference_number() : string { + public function acquirer_reference_number(): string { return $this->acquirer_reference_number; } @@ -182,7 +182,7 @@ class Refund { * * @return string */ - public function note_to_payer() : string { + public function note_to_payer(): string { return $this->note_to_payer; } @@ -191,7 +191,7 @@ class Refund { * * @return RefundPayer|null */ - public function payer() : ?RefundPayer { + public function payer(): ?RefundPayer { return $this->payer; } @@ -200,7 +200,7 @@ class Refund { * * @return array */ - public function to_array() : array { + public function to_array(): array { $data = array( 'id' => $this->id(), 'status' => $this->status()->name(), diff --git a/modules/ppcp-api-client/src/Entity/RefundCapture.php b/modules/ppcp-api-client/src/Entity/RefundCapture.php index cef578a5c..c225141af 100644 --- a/modules/ppcp-api-client/src/Entity/RefundCapture.php +++ b/modules/ppcp-api-client/src/Entity/RefundCapture.php @@ -67,7 +67,7 @@ class RefundCapture { * * @return Capture */ - public function for_capture() : Capture { + public function for_capture(): Capture { return $this->capture; } @@ -76,7 +76,7 @@ class RefundCapture { * * @return string */ - public function invoice_id() : string { + public function invoice_id(): string { return $this->invoice_id; } @@ -85,7 +85,7 @@ class RefundCapture { * * @return string */ - public function note_to_payer() : string { + public function note_to_payer(): string { return $this->note_to_payer; } @@ -103,7 +103,7 @@ class RefundCapture { * * @return array */ - public function to_array() : array { + public function to_array(): array { $data = array( 'invoice_id' => $this->invoice_id(), ); diff --git a/modules/ppcp-api-client/src/Entity/SellerStatus.php b/modules/ppcp-api-client/src/Entity/SellerStatus.php index fd948b276..d23ba0f31 100644 --- a/modules/ppcp-api-client/src/Entity/SellerStatus.php +++ b/modules/ppcp-api-client/src/Entity/SellerStatus.php @@ -68,7 +68,7 @@ class SellerStatus { * * @return SellerStatusProduct[] */ - public function products() : array { + public function products(): array { return $this->products; } @@ -77,7 +77,7 @@ class SellerStatus { * * @return SellerStatusCapability[] */ - public function capabilities() : array { + public function capabilities(): array { return $this->capabilities; } @@ -86,7 +86,7 @@ class SellerStatus { * * @return string */ - public function country() : string { + public function country(): string { return $this->country; } @@ -95,16 +95,16 @@ class SellerStatus { * * @return array */ - public function to_array() : array { + public function to_array(): array { $products = array_map( - function( SellerStatusProduct $product ) : array { + function ( SellerStatusProduct $product ): array { return $product->to_array(); }, $this->products() ); $capabilities = array_map( - function( SellerStatusCapability $capability ) : array { + function ( SellerStatusCapability $capability ): array { return $capability->to_array(); }, $this->capabilities() diff --git a/modules/ppcp-api-client/src/Entity/SellerStatusCapability.php b/modules/ppcp-api-client/src/Entity/SellerStatusCapability.php index 7fdb7df04..02b7caec7 100644 --- a/modules/ppcp-api-client/src/Entity/SellerStatusCapability.php +++ b/modules/ppcp-api-client/src/Entity/SellerStatusCapability.php @@ -49,7 +49,7 @@ class SellerStatusCapability { * * @return string */ - public function name() : string { + public function name(): string { return $this->name; } @@ -58,7 +58,7 @@ class SellerStatusCapability { * * @return string */ - public function status() : string { + public function status(): string { return $this->status; } @@ -67,11 +67,10 @@ class SellerStatusCapability { * * @return array */ - public function to_array() : array { + public function to_array(): array { return array( 'name' => $this->name(), 'status' => $this->status(), ); } - } diff --git a/modules/ppcp-api-client/src/Entity/SellerStatusProduct.php b/modules/ppcp-api-client/src/Entity/SellerStatusProduct.php index 3dd4d7129..b1818472a 100644 --- a/modules/ppcp-api-client/src/Entity/SellerStatusProduct.php +++ b/modules/ppcp-api-client/src/Entity/SellerStatusProduct.php @@ -69,7 +69,7 @@ class SellerStatusProduct { * * @return string */ - public function name() : string { + public function name(): string { return $this->name; } @@ -78,7 +78,7 @@ class SellerStatusProduct { * * @return string */ - public function vetting_status() : string { + public function vetting_status(): string { return $this->vetting_status; } @@ -87,7 +87,7 @@ class SellerStatusProduct { * * @return string[] */ - public function capabilities() : array { + public function capabilities(): array { return $this->capabilities; } @@ -96,13 +96,11 @@ class SellerStatusProduct { * * @return array */ - public function to_array() : array { + public function to_array(): array { return array( 'name' => $this->name(), 'vetting_status' => $this->vetting_status(), 'capabilities' => $this->capabilities(), ); } - - } diff --git a/modules/ppcp-api-client/src/Entity/Shipping.php b/modules/ppcp-api-client/src/Entity/Shipping.php index 9623e006a..2fc8ea38c 100644 --- a/modules/ppcp-api-client/src/Entity/Shipping.php +++ b/modules/ppcp-api-client/src/Entity/Shipping.php @@ -91,7 +91,7 @@ class Shipping { * * @return null|string */ - public function email_address() : ?string { + public function email_address(): ?string { return $this->email_address; } @@ -100,7 +100,7 @@ class Shipping { * * @return null|Phone */ - public function phone_number() : ?Phone { + public function phone_number(): ?Phone { return $this->phone_number; } diff --git a/modules/ppcp-api-client/src/Factory/CaptureFactory.php b/modules/ppcp-api-client/src/Factory/CaptureFactory.php index 7f479f30e..60e490f53 100644 --- a/modules/ppcp-api-client/src/Factory/CaptureFactory.php +++ b/modules/ppcp-api-client/src/Factory/CaptureFactory.php @@ -66,7 +66,7 @@ class CaptureFactory { * @return Capture * @throws RuntimeException When capture amount data is invalid. */ - public function from_paypal_response( \stdClass $data ) : Capture { + public function from_paypal_response( \stdClass $data ): Capture { $reason = $data->status_details->reason ?? null; $seller_receivable_breakdown = isset( $data->seller_receivable_breakdown ) ? $this->seller_receivable_breakdown_factory->from_paypal_response( $data->seller_receivable_breakdown ) diff --git a/modules/ppcp-api-client/src/Factory/ContactPreferenceFactory.php b/modules/ppcp-api-client/src/Factory/ContactPreferenceFactory.php index 286297ae8..86483c715 100644 --- a/modules/ppcp-api-client/src/Factory/ContactPreferenceFactory.php +++ b/modules/ppcp-api-client/src/Factory/ContactPreferenceFactory.php @@ -48,7 +48,7 @@ class ContactPreferenceFactory { * @param string $payment_source_key Name of the payment_source. * @return string|null */ - public function from_state( string $payment_source_key ) : ?string { + public function from_state( string $payment_source_key ): ?string { $payment_sources_with_contact = array( 'paypal', 'venmo' ); /** diff --git a/modules/ppcp-api-client/src/Factory/ExperienceContextBuilder.php b/modules/ppcp-api-client/src/Factory/ExperienceContextBuilder.php index 9d826e365..3c3f4c090 100644 --- a/modules/ppcp-api-client/src/Factory/ExperienceContextBuilder.php +++ b/modules/ppcp-api-client/src/Factory/ExperienceContextBuilder.php @@ -214,7 +214,7 @@ class ExperienceContextBuilder { * * @param string|null $preference The new preference to apply. */ - public function with_contact_preference( ?string $preference = null ) : ExperienceContextBuilder { + public function with_contact_preference( ?string $preference = null ): ExperienceContextBuilder { $builder = clone $this; $builder->experience_context = $builder->experience_context diff --git a/modules/ppcp-api-client/src/Factory/PatchCollectionFactory.php b/modules/ppcp-api-client/src/Factory/PatchCollectionFactory.php index 6eed34a38..122d4b805 100644 --- a/modules/ppcp-api-client/src/Factory/PatchCollectionFactory.php +++ b/modules/ppcp-api-client/src/Factory/PatchCollectionFactory.php @@ -53,7 +53,7 @@ class PatchCollectionFactory { $from, static function ( PurchaseUnit $unit ) use ( $purchase_unit_to ): bool { // Loose comparison needed to compare two objects. - // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison + // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual return $unit == $purchase_unit_to; } ) diff --git a/modules/ppcp-api-client/src/Factory/PaymentPreferencesFactory.php b/modules/ppcp-api-client/src/Factory/PaymentPreferencesFactory.php index 692471b5d..043945e33 100644 --- a/modules/ppcp-api-client/src/Factory/PaymentPreferencesFactory.php +++ b/modules/ppcp-api-client/src/Factory/PaymentPreferencesFactory.php @@ -41,7 +41,7 @@ class PaymentPreferencesFactory { * @param WC_Product $product WC product. * @return PaymentPreferences */ - public function from_wc_product( WC_Product $product ):PaymentPreferences { + public function from_wc_product( WC_Product $product ): PaymentPreferences { return new PaymentPreferences( array( 'value' => $product->get_meta( '_subscription_sign_up_fee' ) ?: '0', diff --git a/modules/ppcp-api-client/src/Factory/PurchaseUnitFactory.php b/modules/ppcp-api-client/src/Factory/PurchaseUnitFactory.php index fa9348528..b6ea5e431 100644 --- a/modules/ppcp-api-client/src/Factory/PurchaseUnitFactory.php +++ b/modules/ppcp-api-client/src/Factory/PurchaseUnitFactory.php @@ -175,7 +175,8 @@ class PurchaseUnitFactory { $shipping = null; $customer = \WC()->customer; - if ( $this->shipping_needed( ... array_values( $items ) ) && is_a( $customer, \WC_Customer::class ) ) { + /** @psalm-suppress RedundantConditionGivenDocblockType False positive. Ignored because $customer can be null as well. */ + if ( $this->shipping_needed( ...array_values( $items ) ) && is_a( $customer, \WC_Customer::class ) ) { $shipping = $this->shipping_factory->from_wc_customer( \WC()->customer, $with_shipping_options ); $shipping_address = $shipping->address(); if ( @@ -254,7 +255,7 @@ class PurchaseUnitFactory { $shipping = $this->shipping_factory->from_paypal_response( $data->shipping ); } } catch ( RuntimeException $error ) { - ; + $shipping = null; } $payments = null; try { @@ -262,7 +263,7 @@ class PurchaseUnitFactory { $payments = $this->payments_factory->from_paypal_response( $data->payments ); } } catch ( RuntimeException $error ) { - ; + $payments = null; } $purchase_unit = new PurchaseUnit( @@ -333,7 +334,7 @@ class PurchaseUnitFactory { * * @return string The sanitized soft descriptor. */ - private function sanitize_soft_descriptor( string $soft_descriptor ) : string { + private function sanitize_soft_descriptor( string $soft_descriptor ): string { $decoded = html_entity_decode( $soft_descriptor, ENT_QUOTES, 'UTF-8' ); $sanitized = preg_replace( '/[^a-zA-Z0-9 *\-.]/', '', $decoded ) ?: ''; @@ -349,9 +350,9 @@ class PurchaseUnitFactory { * @return bool */ private function should_disable_shipping( array $items, ?Address $shipping_address ): bool { - return ! $this->shipping_needed( ... array_values( $items ) ) || - ! $shipping_address || - empty( $shipping_address->country_code() ) || - ( ! $shipping_address->postal_code() && ! $this->country_without_postal_code( $shipping_address->country_code() ) ); + return ! $this->shipping_needed( ...array_values( $items ) ) || + ! $shipping_address || + empty( $shipping_address->country_code() ) || + ( ! $shipping_address->postal_code() && ! $this->country_without_postal_code( $shipping_address->country_code() ) ); } } diff --git a/modules/ppcp-api-client/src/Factory/RefundFactory.php b/modules/ppcp-api-client/src/Factory/RefundFactory.php index e9cbbe542..4d7e8aeb6 100644 --- a/modules/ppcp-api-client/src/Factory/RefundFactory.php +++ b/modules/ppcp-api-client/src/Factory/RefundFactory.php @@ -65,7 +65,7 @@ class RefundFactory { * @return Refund * @throws RuntimeException When refund amount data is invalid. */ - public function from_paypal_response( \stdClass $data ) : Refund { + public function from_paypal_response( \stdClass $data ): Refund { $reason = $data->status_details->reason ?? null; $seller_payable_breakdown = isset( $data->seller_payable_breakdown ) ? $this->seller_payable_breakdown_factory->from_paypal_response( $data->seller_payable_breakdown ) diff --git a/modules/ppcp-api-client/src/Factory/SellerStatusFactory.php b/modules/ppcp-api-client/src/Factory/SellerStatusFactory.php index 4182b5815..2dfe828d6 100644 --- a/modules/ppcp-api-client/src/Factory/SellerStatusFactory.php +++ b/modules/ppcp-api-client/src/Factory/SellerStatusFactory.php @@ -25,9 +25,9 @@ class SellerStatusFactory { * * @return SellerStatus */ - public function from_paypal_response( \stdClass $json ) : SellerStatus { + public function from_paypal_response( \stdClass $json ): SellerStatus { $products = array_map( - function( $json ) : SellerStatusProduct { + function ( $json ): SellerStatusProduct { $product = new SellerStatusProduct( isset( $json->name ) ? (string) $json->name : '', isset( $json->vetting_status ) ? (string) $json->vetting_status : '', @@ -39,7 +39,7 @@ class SellerStatusFactory { ); $capabilities = array_map( - function( $json ) : SellerStatusCapability { + function ( $json ): SellerStatusCapability { $capability = new SellerStatusCapability( isset( $json->name ) ? (string) $json->name : '', isset( $json->status ) ? (string) $json->status : '' diff --git a/modules/ppcp-api-client/src/Helper/Cache.php b/modules/ppcp-api-client/src/Helper/Cache.php index e77f78825..7454ea160 100644 --- a/modules/ppcp-api-client/src/Helper/Cache.php +++ b/modules/ppcp-api-client/src/Helper/Cache.php @@ -48,7 +48,7 @@ class Cache { * * @return bool */ - public function has( string $key ) : bool { + public function has( string $key ): bool { $value = $this->get( $key ); return false !== $value; @@ -59,7 +59,7 @@ class Cache { * * @param string $key The key. */ - public function delete( string $key ) : void { + public function delete( string $key ): void { delete_transient( $this->prefix . $key ); } @@ -72,7 +72,7 @@ class Cache { * * @return bool */ - public function set( string $key, $value, int $expiration = 0 ) : bool { + public function set( string $key, $value, int $expiration = 0 ): bool { return (bool) set_transient( $this->prefix . $key, $value, $expiration ); } @@ -81,7 +81,7 @@ class Cache { * * @return void */ - public function flush() : void { + public function flush(): void { global $wpdb; // Get a list of all transients with the relevant "group prefix" from the DB. diff --git a/modules/ppcp-api-client/src/Helper/DccApplies.php b/modules/ppcp-api-client/src/Helper/DccApplies.php index 8f8a1c942..94f09c6cf 100644 --- a/modules/ppcp-api-client/src/Helper/DccApplies.php +++ b/modules/ppcp-api-client/src/Helper/DccApplies.php @@ -94,7 +94,7 @@ class DccApplies { * * @return array */ - public function valid_cards() : array { + public function valid_cards(): array { $cards = array(); if ( ! isset( $this->country_card_matrix[ $this->country ] ) ) { return $cards; @@ -122,7 +122,7 @@ class DccApplies { * * @return bool */ - public function can_process_card( string $card ) : bool { + public function can_process_card( string $card ): bool { if ( ! isset( $this->country_card_matrix[ $this->country ] ) ) { return false; } diff --git a/modules/ppcp-api-client/src/Helper/FailureRegistry.php b/modules/ppcp-api-client/src/Helper/FailureRegistry.php index 68889b13c..6dda4b984 100644 --- a/modules/ppcp-api-client/src/Helper/FailureRegistry.php +++ b/modules/ppcp-api-client/src/Helper/FailureRegistry.php @@ -90,5 +90,4 @@ class FailureRegistry { private function cache_key( string $key ): string { return implode( '_', array( self::CACHE_KEY, $key ) ); } - } diff --git a/modules/ppcp-api-client/src/Helper/OrderTransient.php b/modules/ppcp-api-client/src/Helper/OrderTransient.php index efe980928..c802cf331 100644 --- a/modules/ppcp-api-client/src/Helper/OrderTransient.php +++ b/modules/ppcp-api-client/src/Helper/OrderTransient.php @@ -156,5 +156,4 @@ class OrderTransient { } return implode( '_', array( self::CACHE_KEY . $order->id() ) ); } - } diff --git a/modules/ppcp-api-client/src/Helper/PartnerAttribution.php b/modules/ppcp-api-client/src/Helper/PartnerAttribution.php index 35e1cfc4a..740d18fdd 100644 --- a/modules/ppcp-api-client/src/Helper/PartnerAttribution.php +++ b/modules/ppcp-api-client/src/Helper/PartnerAttribution.php @@ -63,7 +63,7 @@ class PartnerAttribution { * @param string $installation_path The installation path used to determine the BN Code. * @param bool $force_update Whether to force an update of the BN code if it already exists. */ - public function initialize_bn_code( string $installation_path, bool $force_update = false ) : void { + public function initialize_bn_code( string $installation_path, bool $force_update = false ): void { $selected_bn_code = $this->bn_codes[ $installation_path ] ?? ''; if ( ! $selected_bn_code ) { return; @@ -82,7 +82,7 @@ class PartnerAttribution { * * @return string The stored BN Code, or the default value if no path is detected. */ - public function get_bn_code() : string { + public function get_bn_code(): string { $bn_code = (string) ( get_option( $this->bn_code_option_name, $this->default_bn_code ) ?? $this->default_bn_code ); if ( ! in_array( $bn_code, $this->bn_codes, true ) ) { diff --git a/modules/ppcp-api-client/src/Helper/ProductStatus.php b/modules/ppcp-api-client/src/Helper/ProductStatus.php index 0c29db33d..9f2e2e096 100644 --- a/modules/ppcp-api-client/src/Helper/ProductStatus.php +++ b/modules/ppcp-api-client/src/Helper/ProductStatus.php @@ -93,7 +93,7 @@ abstract class ProductStatus { * @throws RuntimeException When the check failed. * @throws NotFoundException When a relevant service or setting was not found. */ - abstract protected function check_local_state() : ?bool; + abstract protected function check_local_state(): ?bool; /** * Inspects the API response of the SellerStatus to determine feature eligibility. @@ -105,7 +105,7 @@ abstract class ProductStatus { * @return bool * @throws RuntimeException When the check failed. */ - abstract protected function check_active_state( SellerStatus $seller_status ) : bool; + abstract protected function check_active_state( SellerStatus $seller_status ): bool; /** * Clears the eligibility status from the local cache/DB to enforce a new @@ -114,14 +114,14 @@ abstract class ProductStatus { * @param Settings|null $settings See description in {@see self::clear()}. * @return void */ - abstract protected function clear_state( ?Settings $settings = null ) : void; + abstract protected function clear_state( ?Settings $settings = null ): void; /** * Whether the merchant has access to the feature. * * @return bool */ - public function is_active() : bool { + public function is_active(): bool { if ( null !== $this->is_eligible ) { return $this->is_eligible; } @@ -158,7 +158,7 @@ abstract class ProductStatus { * @return SellerStatus * @throws RuntimeException When the check failed. */ - protected function get_seller_status_object() : SellerStatus { + protected function get_seller_status_object(): SellerStatus { if ( null === self::$seller_status ) { // Check API failure registry to prevent multiple failed API requests. if ( $this->api_failure_registry->has_failure_in_timeframe( FailureRegistry::SELLER_STATUS_KEY, MINUTE_IN_SECONDS ) ) { @@ -177,7 +177,7 @@ abstract class ProductStatus { * * @return bool True, if we can use the merchant API endpoints. */ - public function is_onboarded() : bool { + public function is_onboarded(): bool { return $this->is_connected; } @@ -186,7 +186,7 @@ abstract class ProductStatus { * * @return bool */ - public function has_request_failure() : bool { + public function has_request_failure(): bool { return $this->has_request_failure; } @@ -199,7 +199,7 @@ abstract class ProductStatus { * @param Settings|null $settings The settings object. * @return void */ - public function clear( ?Settings $settings = null ) : void { + public function clear( ?Settings $settings = null ): void { $this->is_eligible = null; $this->has_request_failure = false; diff --git a/modules/ppcp-api-client/src/Helper/PurchaseUnitSanitizer.php b/modules/ppcp-api-client/src/Helper/PurchaseUnitSanitizer.php index b5cd133b6..a4af724a3 100644 --- a/modules/ppcp-api-client/src/Helper/PurchaseUnitSanitizer.php +++ b/modules/ppcp-api-client/src/Helper/PurchaseUnitSanitizer.php @@ -393,5 +393,4 @@ class PurchaseUnitSanitizer { public function set_last_message( string $message ): void { $this->last_message = $message; } - } diff --git a/modules/ppcp-api-client/src/Repository/PartnerReferralsData.php b/modules/ppcp-api-client/src/Repository/PartnerReferralsData.php index 40f51326b..93467ce75 100644 --- a/modules/ppcp-api-client/src/Repository/PartnerReferralsData.php +++ b/modules/ppcp-api-client/src/Repository/PartnerReferralsData.php @@ -40,7 +40,7 @@ class PartnerReferralsData { * * @return string */ - public function nonce() : string { + public function nonce(): string { return 'a1233wtergfsdt4365tzrshgfbaewa36AGa1233wtergfsdt4365tzrshgfbaewa36AG'; } @@ -59,7 +59,7 @@ class PartnerReferralsData { string $onboarding_token = '', ?bool $use_subscriptions = null, bool $use_card_payments = true - ) : array { + ): array { $in_acdc_country = $this->dcc_applies->for_country_currency(); if ( ! $products ) { diff --git a/modules/ppcp-applepay/services.php b/modules/ppcp-applepay/services.php index add3c14c3..4f832480b 100644 --- a/modules/ppcp-applepay/services.php +++ b/modules/ppcp-applepay/services.php @@ -33,11 +33,11 @@ return array( $apm_applies = $container->get( 'applepay.helpers.apm-applies' ); assert( $apm_applies instanceof ApmApplies ); - return static function () use ( $apm_applies ) : bool { + return static function () use ( $apm_applies ): bool { return $apm_applies->for_country() && $apm_applies->for_currency() && $apm_applies->for_merchant(); }; }, - 'applepay.helpers.apm-applies' => static function ( ContainerInterface $container ) : ApmApplies { + 'applepay.helpers.apm-applies' => static function ( ContainerInterface $container ): ApmApplies { return new ApmApplies( $container->get( 'applepay.supported-countries' ), $container->get( 'applepay.supported-currencies' ), @@ -45,7 +45,7 @@ return array( $container->get( 'api.shop.country' ) ); }, - 'applepay.status-cache' => static function( ContainerInterface $container ): Cache { + 'applepay.status-cache' => static function ( ContainerInterface $container ): Cache { return new Cache( 'ppcp-paypal-apple-status-cache' ); }, @@ -82,7 +82,7 @@ return array( }, 'applepay.apple-product-status' => SingletonDecorator::make( - static function( ContainerInterface $container ): AppleProductStatus { + static function ( ContainerInterface $container ): AppleProductStatus { return new AppleProductStatus( $container->get( 'wcgateway.settings' ), $container->get( 'api.endpoint.partners' ), @@ -169,7 +169,7 @@ return array( /** * The list of which countries can be used for ApplePay. */ - 'applepay.supported-countries' => static function ( ContainerInterface $container ) : array { + 'applepay.supported-countries' => static function ( ContainerInterface $container ): array { /** * Returns which countries can be used for ApplePay. */ @@ -225,7 +225,7 @@ return array( /** * The list of which currencies can be used for ApplePay. */ - 'applepay.supported-currencies' => static function ( ContainerInterface $container ) : array { + 'applepay.supported-currencies' => static function ( ContainerInterface $container ): array { /** * Returns which currencies can be used for ApplePay. */ diff --git a/modules/ppcp-applepay/src/ApplePayGateway.php b/modules/ppcp-applepay/src/ApplePayGateway.php index f7b1d2959..b84f0f414 100644 --- a/modules/ppcp-applepay/src/ApplePayGateway.php +++ b/modules/ppcp-applepay/src/ApplePayGateway.php @@ -171,7 +171,7 @@ class ApplePayGateway extends WC_Payment_Gateway { * * @return array */ - public function process_payment( $order_id ) : array { + public function process_payment( $order_id ): array { $wc_order = wc_get_order( $order_id ); if ( ! is_a( $wc_order, WC_Order::class ) ) { return $this->handle_payment_failure( @@ -234,7 +234,7 @@ class ApplePayGateway extends WC_Payment_Gateway { * * @return boolean True or false based on success, or a WP_Error object. */ - public function process_refund( $order_id, $amount = null, $reason = '' ) : bool { + public function process_refund( $order_id, $amount = null, $reason = '' ): bool { $order = wc_get_order( $order_id ); if ( ! is_a( $order, WC_Order::class ) ) { return false; @@ -250,7 +250,7 @@ class ApplePayGateway extends WC_Payment_Gateway { * * @return string */ - public function get_transaction_url( $order ) : string { + public function get_transaction_url( $order ): string { $this->view_transaction_url = $this->transaction_url_provider->get_transaction_url_base( $order ); return parent::get_transaction_url( $order ); diff --git a/modules/ppcp-applepay/src/ApplepayModule.php b/modules/ppcp-applepay/src/ApplepayModule.php index f02aabc29..49f70bfe6 100644 --- a/modules/ppcp-applepay/src/ApplepayModule.php +++ b/modules/ppcp-applepay/src/ApplepayModule.php @@ -56,7 +56,7 @@ class ApplepayModule implements ServiceModule, ExtendingModule, ExecutableModule // Clears product status when appropriate. add_action( 'woocommerce_paypal_payments_clear_apm_product_status', - function( ?Settings $settings = null ) use ( $c ): void { + function ( ?Settings $settings = null ) use ( $c ): void { $apm_status = $c->get( 'applepay.apple-product-status' ); assert( $apm_status instanceof AppleProductStatus ); $apm_status->clear( $settings ); @@ -174,7 +174,7 @@ class ApplepayModule implements ServiceModule, ExtendingModule, ExecutableModule add_filter( 'woocommerce_paypal_payments_selected_button_locations', - function( array $locations, string $setting_name ): array { + function ( array $locations, string $setting_name ): array { $gateway = WC()->payment_gateways()->payment_gateways()[ ApplePayGateway::ID ] ?? ''; if ( $gateway && $gateway->enabled === 'yes' && $setting_name === 'smart_button_locations' ) { $locations[] = 'checkout'; @@ -188,7 +188,7 @@ class ApplepayModule implements ServiceModule, ExtendingModule, ExecutableModule add_filter( 'woocommerce_paypal_payments_rest_common_merchant_features', - function( array $features ) use ( $c ): array { + function ( array $features ) use ( $c ): array { $product_status = $c->get( 'applepay.apple-product-status' ); assert( $product_status instanceof AppleProductStatus ); @@ -204,7 +204,7 @@ class ApplepayModule implements ServiceModule, ExtendingModule, ExecutableModule add_filter( 'ppcp_create_order_request_body_data', - static function ( array $data, string $payment_method, array $request ) use ( $c ) : array { + static function ( array $data, string $payment_method, array $request ) use ( $c ): array { if ( $payment_method !== ApplePayGateway::ID ) { return $data; @@ -294,7 +294,7 @@ class ApplepayModule implements ServiceModule, ExtendingModule, ExecutableModule add_action( 'woocommerce_blocks_payment_method_type_registration', - function( PaymentMethodRegistry $payment_method_registry ) use ( $c ): void { + function ( PaymentMethodRegistry $payment_method_registry ) use ( $c ): void { $payment_method_registry->register( $c->get( 'applepay.blocks-payment-method' ) ); } ); @@ -329,7 +329,7 @@ class ApplepayModule implements ServiceModule, ExtendingModule, ExecutableModule // Adds ApplePay component to the backend button preview settings. add_action( 'woocommerce_paypal_payments_admin_gateway_settings', - function( array $settings ) use ( $c ): array { + function ( array $settings ) use ( $c ): array { if ( is_array( $settings['components'] ) ) { $settings['components'][] = 'applepay'; } @@ -412,7 +412,7 @@ class ApplepayModule implements ServiceModule, ExtendingModule, ExecutableModule * @param bool $is_sandbox The environment for this merchant. * @return string */ - public function validation_string( bool $is_sandbox ) : string { + public function validation_string( bool $is_sandbox ): string { $sandbox_string = $this->sandbox_validation_string(); $live_string = $this->live_validation_string(); return $is_sandbox ? $sandbox_string : $live_string; diff --git a/modules/ppcp-applepay/src/Assets/ApplePayButton.php b/modules/ppcp-applepay/src/Assets/ApplePayButton.php index 045c234cb..47c39842c 100644 --- a/modules/ppcp-applepay/src/Assets/ApplePayButton.php +++ b/modules/ppcp-applepay/src/Assets/ApplePayButton.php @@ -26,7 +26,8 @@ use WooCommerce\PayPalCommerce\Button\Helper\ContextTrait; * Class ApplePayButton */ class ApplePayButton implements ButtonInterface { - use RequestHandlerTrait, ContextTrait; + use RequestHandlerTrait; + use ContextTrait; /** * The settings. @@ -222,7 +223,6 @@ class ApplePayButton implements ButtonInterface { return $options . '
  • '; - } /** @@ -445,7 +445,7 @@ class ApplePayButton implements ButtonInterface { } else { add_filter( 'woocommerce_payment_successful_result', - function ( array $result ) use ( $cart, $cart_item_key ) : array { + function ( array $result ) use ( $cart, $cart_item_key ): array { $this->clear_current_cart( $cart, $cart_item_key ); $this->reload_cart( $cart ); return $result; @@ -917,7 +917,7 @@ class ApplePayButton implements ButtonInterface { add_filter( 'woocommerce_paypal_payments_sdk_components_hook', - function( array $components ) { + function ( array $components ) { $components[] = 'applepay'; return $components; } diff --git a/modules/ppcp-applepay/src/Assets/ApplePayDataObjectHttp.php b/modules/ppcp-applepay/src/Assets/ApplePayDataObjectHttp.php index dad4993d5..bc028feb9 100644 --- a/modules/ppcp-applepay/src/Assets/ApplePayDataObjectHttp.php +++ b/modules/ppcp-applepay/src/Assets/ApplePayDataObjectHttp.php @@ -361,7 +361,6 @@ class ApplePayDataObjectHttp { } $this->$key = $value; } - } /** @@ -509,7 +508,7 @@ class ApplePayDataObjectHttp { * @param array $data The data. * @return void */ - protected function update_simplified_contact( array $data ) : void { + protected function update_simplified_contact( array $data ): void { $simplified_contact_info = array_map( 'sanitize_text_field', $data ); $this->simplified_contact = $this->simplified_address( $simplified_contact_info @@ -727,7 +726,7 @@ class ApplePayDataObjectHttp { * * @return bool */ - public function is_nonce_valid():bool { + public function is_nonce_valid(): bool { $nonce = filter_input( INPUT_POST, 'woocommerce-process-checkout-nonce', FILTER_SANITIZE_SPECIAL_CHARS ); if ( ! $nonce ) { return false; diff --git a/modules/ppcp-applepay/src/Assets/AppleProductStatus.php b/modules/ppcp-applepay/src/Assets/AppleProductStatus.php index 2ffa6fbf6..096be051d 100644 --- a/modules/ppcp-applepay/src/Assets/AppleProductStatus.php +++ b/modules/ppcp-applepay/src/Assets/AppleProductStatus.php @@ -54,7 +54,7 @@ class AppleProductStatus extends ProductStatus { } /** {@inheritDoc} */ - protected function check_local_state() : ?bool { + protected function check_local_state(): ?bool { $status_override = apply_filters( 'woocommerce_paypal_payments_apple_pay_product_status', null ); if ( null !== $status_override ) { return $status_override; @@ -68,7 +68,7 @@ class AppleProductStatus extends ProductStatus { } /** {@inheritDoc} */ - protected function check_active_state( SellerStatus $seller_status ) : bool { + protected function check_active_state( SellerStatus $seller_status ): bool { // Check the seller status for the intended capability. $has_capability = false; foreach ( $seller_status->products() as $product ) { @@ -101,7 +101,7 @@ class AppleProductStatus extends ProductStatus { } /** {@inheritDoc} */ - protected function clear_state( ?Settings $settings = null ) : void { + protected function clear_state( ?Settings $settings = null ): void { if ( null === $settings ) { $settings = $this->settings; } diff --git a/modules/ppcp-applepay/src/Assets/DataToAppleButtonScripts.php b/modules/ppcp-applepay/src/Assets/DataToAppleButtonScripts.php index 52663a4f0..b08d18348 100644 --- a/modules/ppcp-applepay/src/Assets/DataToAppleButtonScripts.php +++ b/modules/ppcp-applepay/src/Assets/DataToAppleButtonScripts.php @@ -49,7 +49,7 @@ class DataToAppleButtonScripts { * * @return array */ - public function apple_pay_script_data() : array { + public function apple_pay_script_data(): array { if ( is_product() ) { return $this->data_for_product_page(); } @@ -62,7 +62,7 @@ class DataToAppleButtonScripts { * * @return array */ - public function apple_pay_script_data_for_admin() : array { + public function apple_pay_script_data_for_admin(): array { return $this->data_for_admin_page(); } @@ -73,7 +73,7 @@ class DataToAppleButtonScripts { * * @return array */ - private function get_apple_pay_data( array $product = array() ) : array { + private function get_apple_pay_data( array $product = array() ): array { // true: Use Apple Pay as distinct gateway. // false: integrate it with the smart buttons. $available_gateways = WC()->payment_gateways->get_available_payment_gateways(); @@ -132,7 +132,7 @@ class DataToAppleButtonScripts { * * @return bool */ - protected function check_if_need_shipping( WC_Product $product ) : bool { + protected function check_if_need_shipping( WC_Product $product ): bool { if ( ! wc_shipping_enabled() || 0 === wc_get_shipping_method_count( @@ -154,7 +154,7 @@ class DataToAppleButtonScripts { * * @return array */ - protected function data_for_product_page() : array { + protected function data_for_product_page(): array { $product = wc_get_product( get_the_id() ); if ( ! $product ) { return array(); @@ -185,7 +185,7 @@ class DataToAppleButtonScripts { * * @return array */ - protected function data_for_cart_page() : array { + protected function data_for_cart_page(): array { $cart = WC()->cart; if ( ! $cart ) { return array(); @@ -206,7 +206,7 @@ class DataToAppleButtonScripts { * * @return array */ - protected function data_for_admin_page() : array { + protected function data_for_admin_page(): array { $data = $this->get_apple_pay_data( array( 'needShipping' => false, diff --git a/modules/ppcp-applepay/src/Helper/ApmApplies.php b/modules/ppcp-applepay/src/Helper/ApmApplies.php index 332ce7015..933634e9c 100644 --- a/modules/ppcp-applepay/src/Helper/ApmApplies.php +++ b/modules/ppcp-applepay/src/Helper/ApmApplies.php @@ -89,7 +89,7 @@ class ApmApplies { * * @return bool */ - public function for_merchant() : bool { + public function for_merchant(): bool { return apply_filters( 'woocommerce_paypal_payments_is_eligible_for_applepay', true diff --git a/modules/ppcp-applepay/src/Helper/AvailabilityNotice.php b/modules/ppcp-applepay/src/Helper/AvailabilityNotice.php index bbdcde159..1f7adead2 100644 --- a/modules/ppcp-applepay/src/Helper/AvailabilityNotice.php +++ b/modules/ppcp-applepay/src/Helper/AvailabilityNotice.php @@ -141,7 +141,6 @@ class AvailabilityNotice { if ( ! $this->is_merchant_validated ) { $this->add_merchant_not_validated_notice(); } - } /** @@ -287,5 +286,4 @@ class AvailabilityNotice { } ); } - } diff --git a/modules/ppcp-axo-block/module.php b/modules/ppcp-axo-block/module.php index a8321fea1..5d7f0cc15 100644 --- a/modules/ppcp-axo-block/module.php +++ b/modules/ppcp-axo-block/module.php @@ -9,6 +9,6 @@ declare( strict_types = 1 ); namespace WooCommerce\PayPalCommerce\AxoBlock; -return static function () : AxoBlockModule { +return static function (): AxoBlockModule { return new AxoBlockModule(); }; diff --git a/modules/ppcp-axo-block/services.php b/modules/ppcp-axo-block/services.php index 91bd5d63f..89dde7d54 100644 --- a/modules/ppcp-axo-block/services.php +++ b/modules/ppcp-axo-block/services.php @@ -14,13 +14,13 @@ use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface; return array( // If AXO Block is configured and onboarded. - 'axoblock.available' => static function ( ContainerInterface $container ) : bool { + 'axoblock.available' => static function ( ContainerInterface $container ): bool { return true; }, - 'axoblock.url' => static function ( ContainerInterface $container ) : string { + 'axoblock.url' => static function ( ContainerInterface $container ): string { return plugins_url( '/modules/ppcp-axo-block/', $container->get( 'ppcp.path-to-plugin-main-file' ) ); }, - 'axoblock.method' => static function ( ContainerInterface $container ) : AxoBlockPaymentMethod { + 'axoblock.method' => static function ( ContainerInterface $container ): AxoBlockPaymentMethod { return new AxoBlockPaymentMethod( $container->get( 'axoblock.url' ), $container->get( 'ppcp.asset-version' ), diff --git a/modules/ppcp-axo-block/src/AxoBlockModule.php b/modules/ppcp-axo-block/src/AxoBlockModule.php index e830784b6..a9ba06497 100644 --- a/modules/ppcp-axo-block/src/AxoBlockModule.php +++ b/modules/ppcp-axo-block/src/AxoBlockModule.php @@ -74,7 +74,7 @@ class AxoBlockModule implements ServiceModule, ExtendingModule, ExecutableModule */ add_filter( 'woocommerce_paypal_payments_sdk_components_hook', - function( $components ) use ( $c ) { + function ( $components ) use ( $c ) { if ( ! $c->has( 'axo.available' ) || ! $c->get( 'axo.available' ) ) { return $components; } @@ -87,7 +87,7 @@ class AxoBlockModule implements ServiceModule, ExtendingModule, ExecutableModule add_action( 'woocommerce_blocks_payment_method_type_registration', - function( PaymentMethodRegistry $payment_method_registry ) use ( $c ): void { + function ( PaymentMethodRegistry $payment_method_registry ) use ( $c ): void { /* * Only register the method if we are not in the admin or the customer is not logged in. */ diff --git a/modules/ppcp-axo-block/src/AxoBlockPaymentMethod.php b/modules/ppcp-axo-block/src/AxoBlockPaymentMethod.php index fb23730b2..5637bdd77 100644 --- a/modules/ppcp-axo-block/src/AxoBlockPaymentMethod.php +++ b/modules/ppcp-axo-block/src/AxoBlockPaymentMethod.php @@ -109,16 +109,16 @@ class AxoBlockPaymentMethod extends AbstractPaymentMethodType { * @param array $supported_country_card_type_matrix The supported country card type matrix for Axo. */ public function __construct( - string $module_url, - string $version, - WC_Payment_Gateway $gateway, - $smart_button, - Settings $settings, - CardPaymentsConfiguration $dcc_configuration, - Environment $environment, - string $wcgateway_module_url, - array $payment_method_selected_map, - array $supported_country_card_type_matrix + string $module_url, + string $version, + WC_Payment_Gateway $gateway, + $smart_button, + Settings $settings, + CardPaymentsConfiguration $dcc_configuration, + Environment $environment, + string $wcgateway_module_url, + array $payment_method_selected_map, + array $supported_country_card_type_matrix ) { $this->name = AxoGateway::ID; $this->module_url = $module_url; @@ -141,14 +141,14 @@ class AxoBlockPaymentMethod extends AbstractPaymentMethodType { /** * {@inheritDoc} */ - public function is_active() : bool { + public function is_active(): bool { return $this->gateway->is_available(); } /** * {@inheritDoc} */ - public function get_payment_method_script_handles() : array { + public function get_payment_method_script_handles(): array { $script_path = 'assets/js/index.js'; $script_asset_path = trailingslashit( $this->module_url ) . 'assets/js/index.asset.php'; $script_asset = file_exists( $script_asset_path ) @@ -199,7 +199,7 @@ class AxoBlockPaymentMethod extends AbstractPaymentMethodType { * * @return array */ - private function script_data() : array { + private function script_data(): array { if ( is_admin() ) { return array(); } diff --git a/modules/ppcp-axo/extensions.php b/modules/ppcp-axo/extensions.php index a834dcb0d..4eea59d0e 100644 --- a/modules/ppcp-axo/extensions.php +++ b/modules/ppcp-axo/extensions.php @@ -18,7 +18,7 @@ return array( 'wcgateway.settings.fields' => function ( array $fields, ContainerInterface $container ): array { - $insert_after = function( array $array, string $key, array $new ): array { + $insert_after = function ( array $array, string $key, array $new ): array { $keys = array_keys( $array ); $index = array_search( $key, $keys, true ); $pos = false === $index ? count( $array ) : $index + 1; diff --git a/modules/ppcp-axo/services.php b/modules/ppcp-axo/services.php index cfe8e325f..4fd2702c1 100644 --- a/modules/ppcp-axo/services.php +++ b/modules/ppcp-axo/services.php @@ -34,11 +34,11 @@ return array( $axo_applies = $container->get( 'axo.service.axo-applies' ); assert( $axo_applies instanceof AxoApplies ); - return static function () use ( $axo_applies ) : bool { + return static function () use ( $axo_applies ): bool { return $axo_applies->for_country_currency() && $axo_applies->for_merchant(); }; }, - 'axo.service.axo-applies' => static function ( ContainerInterface $container ) : AxoApplies { + 'axo.service.axo-applies' => static function ( ContainerInterface $container ): AxoApplies { return new AxoApplies( $container->get( 'axo.supported-country-currency-matrix' ), $container->get( 'api.shop.currency.getter' ), @@ -48,7 +48,7 @@ return array( ); }, - 'axo.helpers.compatibility-checker' => static function ( ContainerInterface $container ) : CompatibilityChecker { + 'axo.helpers.compatibility-checker' => static function ( ContainerInterface $container ): CompatibilityChecker { return new CompatibilityChecker( $container->get( 'axo.fastlane-incompatible-plugin-names' ), $container->get( 'wcgateway.configuration.card-configuration' ) @@ -154,7 +154,7 @@ return array( /** * The matrix which countries and currency combinations can be used for AXO. */ - 'axo.supported-country-currency-matrix' => static function ( ContainerInterface $container ) : array { + 'axo.supported-country-currency-matrix' => static function ( ContainerInterface $container ): array { $matrix = array( 'US' => array( 'AUD', @@ -185,7 +185,7 @@ return array( /** * The matrix which countries and card type combinations can be used for AXO. */ - 'axo.supported-country-card-type-matrix' => static function ( ContainerInterface $container ) : array { + 'axo.supported-country-card-type-matrix' => static function ( ContainerInterface $container ): array { $matrix = array( 'US' => array( 'VISA', @@ -226,42 +226,42 @@ return array( $matrix ); }, - 'axo.settings-conflict-notice' => static function ( ContainerInterface $container ) : string { + 'axo.settings-conflict-notice' => static function ( ContainerInterface $container ): string { $compatibility_checker = $container->get( 'axo.helpers.compatibility-checker' ); assert( $compatibility_checker instanceof CompatibilityChecker ); return $compatibility_checker->generate_settings_conflict_notice(); }, - 'axo.checkout-config-notice' => static function ( ContainerInterface $container ) : string { + 'axo.checkout-config-notice' => static function ( ContainerInterface $container ): string { $compatibility_checker = $container->get( 'axo.helpers.compatibility-checker' ); assert( $compatibility_checker instanceof CompatibilityChecker ); return $compatibility_checker->generate_checkout_notice(); }, - 'axo.checkout-config-notice.raw' => static function ( ContainerInterface $container ) : string { + 'axo.checkout-config-notice.raw' => static function ( ContainerInterface $container ): string { $compatibility_checker = $container->get( 'axo.helpers.compatibility-checker' ); assert( $compatibility_checker instanceof CompatibilityChecker ); return $compatibility_checker->generate_checkout_notice( true ); }, - 'axo.incompatible-plugins-notice' => static function ( ContainerInterface $container ) : string { + 'axo.incompatible-plugins-notice' => static function ( ContainerInterface $container ): string { $settings_notice_generator = $container->get( 'axo.helpers.compatibility-checker' ); assert( $settings_notice_generator instanceof CompatibilityChecker ); return $settings_notice_generator->generate_incompatible_plugins_notice(); }, - 'axo.incompatible-plugins-notice.raw' => static function ( ContainerInterface $container ) : string { + 'axo.incompatible-plugins-notice.raw' => static function ( ContainerInterface $container ): string { $settings_notice_generator = $container->get( 'axo.helpers.compatibility-checker' ); assert( $settings_notice_generator instanceof CompatibilityChecker ); return $settings_notice_generator->generate_incompatible_plugins_notice( true ); }, - 'axo.smart-button-location-notice' => static function ( ContainerInterface $container ) : string { + 'axo.smart-button-location-notice' => static function ( ContainerInterface $container ): string { $dcc_configuration = $container->get( 'wcgateway.configuration.card-configuration' ); assert( $dcc_configuration instanceof CardPaymentsConfiguration ); @@ -310,7 +310,7 @@ return array( * * @returns array */ - 'axo.fastlane-incompatible-plugins' => static function () : array { + 'axo.fastlane-incompatible-plugins' => static function (): array { /** * Filters the list of Fastlane incompatible plugins. */ @@ -365,12 +365,12 @@ return array( ); }, - 'axo.fastlane-incompatible-plugin-names' => static function ( ContainerInterface $container ) : array { + 'axo.fastlane-incompatible-plugin-names' => static function ( ContainerInterface $container ): array { $incompatible_plugins = $container->get( 'axo.fastlane-incompatible-plugins' ); $active_plugins_list = array_filter( $incompatible_plugins, - function( array $plugin ): bool { + function ( array $plugin ): bool { return (bool) $plugin['is_active']; } ); @@ -395,10 +395,10 @@ return array( } $shipping_zones = \WC_Shipping_Zones::get_zones(); - $get_zone_locations = fn( \WC_Shipping_Zone $zone): array => + $get_zone_locations = fn( \WC_Shipping_Zone $zone ): array => ! empty( $zone->get_shipping_methods( true ) ) ? array_map( - fn( object $location): string => $location->code, + fn( object $location ): string => $location->code, $zone->get_zone_locations() ) : array(); @@ -408,7 +408,7 @@ return array( ...array_map( $get_zone_locations, array_map( - fn( $zone): \WC_Shipping_Zone => + fn( $zone ): \WC_Shipping_Zone => $zone instanceof \WC_Shipping_Zone ? $zone : new \WC_Shipping_Zone( $zone['id'] ), $shipping_zones ) diff --git a/modules/ppcp-axo/src/Assets/AxoManager.php b/modules/ppcp-axo/src/Assets/AxoManager.php index d577033cc..ec2dfb7d6 100644 --- a/modules/ppcp-axo/src/Assets/AxoManager.php +++ b/modules/ppcp-axo/src/Assets/AxoManager.php @@ -190,7 +190,7 @@ class AxoManager { 'email' => 'render', ), // The amount is not available when setting the insights data, so we need to merge it here. - 'insights' => ( function( array $data ): array { + 'insights' => ( function ( array $data ): array { $data['amount']['value'] = WC()->cart->get_total( 'numeric' ); return $data; } )( $this->insights_data ), 'allowed_cards' => $this->supported_country_card_type_matrix, @@ -270,5 +270,4 @@ class AxoManager { esc_html( $label ) ); } - } diff --git a/modules/ppcp-axo/src/AxoModule.php b/modules/ppcp-axo/src/AxoModule.php index 8a031df9b..c781883c8 100644 --- a/modules/ppcp-axo/src/AxoModule.php +++ b/modules/ppcp-axo/src/AxoModule.php @@ -168,7 +168,7 @@ class AxoModule implements ServiceModule, ExtendingModule, ExecutableModule { $listener->filter_settings( $dcc_configuration->use_fastlane(), 'smart_button_locations', - function( array $existing_setting_value ) { + function ( array $existing_setting_value ) { $axo_forced_locations = array( 'cart-block', 'cart' ); return array_unique( array_merge( $existing_setting_value, $axo_forced_locations ) ); } @@ -248,7 +248,7 @@ class AxoModule implements ServiceModule, ExtendingModule, ExecutableModule { */ add_filter( 'woocommerce_paypal_payments_sdk_components_hook', - function( $components ) use ( $c ) { + function ( $components ) use ( $c ) { $dcc_configuration = $c->get( 'wcgateway.configuration.card-configuration' ); assert( $dcc_configuration instanceof CardPaymentsConfiguration ); diff --git a/modules/ppcp-axo/src/Gateway/AxoGateway.php b/modules/ppcp-axo/src/Gateway/AxoGateway.php index 0322431a9..c1d5e27d8 100644 --- a/modules/ppcp-axo/src/Gateway/AxoGateway.php +++ b/modules/ppcp-axo/src/Gateway/AxoGateway.php @@ -40,7 +40,9 @@ use DomainException; * Class AXOGateway. */ class AxoGateway extends WC_Payment_Gateway { - use OrderMetaTrait, GatewaySettingsRendererTrait, ProcessPaymentTrait; + use OrderMetaTrait; + use GatewaySettingsRendererTrait; + use ProcessPaymentTrait; const ID = 'ppcp-axo-gateway'; @@ -351,7 +353,7 @@ class AxoGateway extends WC_Payment_Gateway { * * @return array */ - protected function process_3ds_return( WC_Order $wc_order, string $token ) : array { + protected function process_3ds_return( WC_Order $wc_order, string $token ): array { try { $paypal_order = $this->order_endpoint->order( $token ); @@ -424,7 +426,7 @@ class AxoGateway extends WC_Payment_Gateway { * @param Order $order The PayPal order. * @return string The payer action URL or an empty string if not found. */ - private function get_payer_action_url( Order $order ) : string { + private function get_payer_action_url( Order $order ): string { $links = $order->links(); if ( ! $links ) { @@ -448,7 +450,7 @@ class AxoGateway extends WC_Payment_Gateway { * * @return Order The PayPal order. */ - protected function create_paypal_order( WC_Order $wc_order, string $payment_token ) : Order { + protected function create_paypal_order( WC_Order $wc_order, string $payment_token ): Order { $purchase_unit = $this->purchase_unit_factory->from_wc_order( $wc_order ); $shipping_preference = $this->shipping_preference_factory->from_state( @@ -559,7 +561,7 @@ class AxoGateway extends WC_Payment_Gateway { * * @return string */ - public function get_transaction_url( $order ) : string { + public function get_transaction_url( $order ): string { $this->view_transaction_url = $this->transaction_url_provider->get_transaction_url_base( $order ); return parent::get_transaction_url( $order ); @@ -593,7 +595,7 @@ class AxoGateway extends WC_Payment_Gateway { * * @return SettingsRenderer */ - protected function settings_renderer() : SettingsRenderer { + protected function settings_renderer(): SettingsRenderer { return $this->settings_renderer; } } diff --git a/modules/ppcp-axo/src/Helper/CompatibilityChecker.php b/modules/ppcp-axo/src/Helper/CompatibilityChecker.php index 9d27781db..d6ecf135a 100644 --- a/modules/ppcp-axo/src/Helper/CompatibilityChecker.php +++ b/modules/ppcp-axo/src/Helper/CompatibilityChecker.php @@ -65,7 +65,7 @@ class CompatibilityChecker { * * @return bool Whether the checkout uses Elementor. */ - protected function has_elementor_checkout() : bool { + protected function has_elementor_checkout(): bool { if ( $this->checkout_compatibility['has_elementor_checkout'] === null ) { $this->checkout_compatibility['has_elementor_checkout'] = CartCheckoutDetector::has_elementor_checkout(); } @@ -78,7 +78,7 @@ class CompatibilityChecker { * * @return bool Whether the checkout uses classic checkout. */ - protected function has_classic_checkout() : bool { + protected function has_classic_checkout(): bool { if ( $this->checkout_compatibility['has_classic_checkout'] === null ) { $this->checkout_compatibility['has_classic_checkout'] = CartCheckoutDetector::has_classic_checkout(); } @@ -91,7 +91,7 @@ class CompatibilityChecker { * * @return bool Whether the checkout uses block checkout. */ - protected function has_block_checkout() : bool { + protected function has_block_checkout(): bool { if ( $this->checkout_compatibility['has_block_checkout'] === null ) { $this->checkout_compatibility['has_block_checkout'] = CartCheckoutDetector::has_block_checkout(); } @@ -109,7 +109,7 @@ class CompatibilityChecker { * * @return string The full HTML code of the notification, or an empty string, or raw message. */ - private function render_notice( string $message, bool $is_error = false, bool $raw_message = false ) : string { + private function render_notice( string $message, bool $is_error = false, bool $raw_message = false ): string { if ( ! $message ) { return ''; } @@ -131,7 +131,7 @@ class CompatibilityChecker { * * @return bool Whether the setup is compatible. */ - public function is_fastlane_compatible() : bool { + public function is_fastlane_compatible(): bool { // Check for incompatible plugins. if ( ! empty( $this->incompatible_plugin_names ) ) { return false; @@ -156,7 +156,7 @@ class CompatibilityChecker { * @param bool $raw_message Whether to return raw message without HTML wrappers. * @return string */ - public function generate_checkout_notice( bool $raw_message = false ) : string { + public function generate_checkout_notice( bool $raw_message = false ): string { $notice_content = ''; // Check for checkout incompatibilities. @@ -204,7 +204,7 @@ class CompatibilityChecker { * @param bool $raw_message Whether to return raw message without HTML wrappers. * @return string */ - public function generate_incompatible_plugins_notice( bool $raw_message = false ) : string { + public function generate_incompatible_plugins_notice( bool $raw_message = false ): string { if ( empty( $this->incompatible_plugin_names ) ) { return ''; } @@ -229,7 +229,7 @@ class CompatibilityChecker { * @param bool $raw_message Whether to return raw message without HTML wrappers. * @return string */ - public function generate_settings_conflict_notice( bool $raw_message = false ) : string { + public function generate_settings_conflict_notice( bool $raw_message = false ): string { if ( $this->dcc_configuration->is_enabled() ) { return ''; } diff --git a/modules/ppcp-axo/src/Helper/PropertiesDictionary.php b/modules/ppcp-axo/src/Helper/PropertiesDictionary.php index 2b8659bd8..3df642cf7 100644 --- a/modules/ppcp-axo/src/Helper/PropertiesDictionary.php +++ b/modules/ppcp-axo/src/Helper/PropertiesDictionary.php @@ -25,5 +25,4 @@ class PropertiesDictionary { 'no' => __( 'No', 'woocommerce-paypal-payments' ), ); } - } diff --git a/modules/ppcp-axo/src/Service/AxoApplies.php b/modules/ppcp-axo/src/Service/AxoApplies.php index 83996c1f6..74fd9893f 100644 --- a/modules/ppcp-axo/src/Service/AxoApplies.php +++ b/modules/ppcp-axo/src/Service/AxoApplies.php @@ -80,7 +80,7 @@ class AxoApplies { * * @return bool */ - public function for_merchant() : bool { + public function for_merchant(): bool { return apply_filters( 'woocommerce_paypal_payments_is_eligible_for_axo', true @@ -94,11 +94,11 @@ class AxoApplies { */ public function should_render_fastlane(): bool { return ! is_user_logged_in() - && CartCheckoutDetector::has_classic_checkout() - && $this->dcc_configuration->use_fastlane() - && ! $this->is_excluded_endpoint() - && is_checkout() - && ! $this->subscription_helper->cart_contains_subscription(); + && CartCheckoutDetector::has_classic_checkout() + && $this->dcc_configuration->use_fastlane() + && ! $this->is_excluded_endpoint() + && is_checkout() + && ! $this->subscription_helper->cart_contains_subscription(); } /** diff --git a/modules/ppcp-blocks/extensions.php b/modules/ppcp-blocks/extensions.php index 134dda6a7..369cddc93 100644 --- a/modules/ppcp-blocks/extensions.php +++ b/modules/ppcp-blocks/extensions.php @@ -29,7 +29,7 @@ return array( }, 'wcgateway.settings.fields' => function ( array $fields, ContainerInterface $container ): array { - $insert_after = function( array $array, string $key, array $new ): array { + $insert_after = function ( array $array, string $key, array $new ): array { $keys = array_keys( $array ); $index = array_search( $key, $keys, true ); $pos = false === $index ? count( $array ) : $index + 1; diff --git a/modules/ppcp-blocks/services.php b/modules/ppcp-blocks/services.php index df2d68bde..e44f17490 100644 --- a/modules/ppcp-blocks/services.php +++ b/modules/ppcp-blocks/services.php @@ -40,7 +40,7 @@ return array( $container->get( 'wcgateway.all-funding-sources' ), ); }, - 'blocks.advanced-card-method' => static function( ContainerInterface $container ): AdvancedCardPaymentMethod { + 'blocks.advanced-card-method' => static function ( ContainerInterface $container ): AdvancedCardPaymentMethod { return new AdvancedCardPaymentMethod( $container->get( 'blocks.url' ), $container->get( 'ppcp.asset-version' ), @@ -69,7 +69,7 @@ return array( ); }, - 'blocks.add-place-order-method' => function ( ContainerInterface $container ) : bool { + 'blocks.add-place-order-method' => function ( ContainerInterface $container ): bool { /** * Whether to create a non-express method with the standard "Place order" button redirecting to PayPal. */ diff --git a/modules/ppcp-blocks/src/BlocksModule.php b/modules/ppcp-blocks/src/BlocksModule.php index 28dbf5a04..973c5e8b6 100644 --- a/modules/ppcp-blocks/src/BlocksModule.php +++ b/modules/ppcp-blocks/src/BlocksModule.php @@ -68,7 +68,7 @@ class BlocksModule implements ServiceModule, ExtendingModule, ExecutableModule { add_action( 'woocommerce_blocks_payment_method_type_registration', - function( PaymentMethodRegistry $payment_method_registry ) use ( $c ): void { + function ( PaymentMethodRegistry $payment_method_registry ) use ( $c ): void { $payment_method_registry->register( $c->get( 'blocks.method' ) ); $settings = $c->get( 'wcgateway.settings' ); @@ -80,7 +80,7 @@ class BlocksModule implements ServiceModule, ExtendingModule, ExecutableModule { woocommerce_store_api_register_payment_requirements( array( - 'data_callback' => function() use ( $c ): array { + 'data_callback' => function () use ( $c ): array { $smart_button = $c->get( 'button.smart-button' ); assert( $smart_button instanceof SmartButtonInterface ); @@ -143,7 +143,7 @@ class BlocksModule implements ServiceModule, ExtendingModule, ExecutableModule { add_filter( 'woocommerce_paypal_payments_sdk_components_hook', - function( array $components, string $context ) { + function ( array $components, string $context ) { if ( str_ends_with( $context, '-block' ) ) { $components[] = 'buttons'; } diff --git a/modules/ppcp-button/services.php b/modules/ppcp-button/services.php index 0f02028ef..7902cc780 100644 --- a/modules/ppcp-button/services.php +++ b/modules/ppcp-button/services.php @@ -246,7 +246,7 @@ return array( $logger ); }, - 'button.helper.early-order-handler' => static function ( ContainerInterface $container ) : EarlyOrderHandler { + 'button.helper.early-order-handler' => static function ( ContainerInterface $container ): EarlyOrderHandler { return new EarlyOrderHandler( $container->get( 'settings.flag.is-connected' ), $container->get( 'wcgateway.order-processor' ), @@ -279,7 +279,7 @@ return array( $logger ); }, - 'button.endpoint.approve-subscription' => static function( ContainerInterface $container ): ApproveSubscriptionEndpoint { + 'button.endpoint.approve-subscription' => static function ( ContainerInterface $container ): ApproveSubscriptionEndpoint { return new ApproveSubscriptionEndpoint( $container->get( 'button.request-data' ), $container->get( 'api.endpoint.order' ), @@ -301,7 +301,7 @@ return array( $container->get( 'woocommerce.logger.woocommerce' ) ); }, - 'button.endpoint.data-client-id' => static function( ContainerInterface $container ) : DataClientIdEndpoint { + 'button.endpoint.data-client-id' => static function ( ContainerInterface $container ): DataClientIdEndpoint { $request_data = $container->get( 'button.request-data' ); $identity_token = $container->get( 'api.endpoint.identity-token' ); $logger = $container->get( 'woocommerce.logger.woocommerce' ); @@ -311,7 +311,7 @@ return array( $logger ); }, - 'button.endpoint.vault-paypal' => static function( ContainerInterface $container ) : StartPayPalVaultingEndpoint { + 'button.endpoint.vault-paypal' => static function ( ContainerInterface $container ): StartPayPalVaultingEndpoint { return new StartPayPalVaultingEndpoint( $container->get( 'button.request-data' ), $container->get( 'api.endpoint.payment-token' ), diff --git a/modules/ppcp-button/src/Assets/SmartButton.php b/modules/ppcp-button/src/Assets/SmartButton.php index 0eb3ce360..1759aa176 100644 --- a/modules/ppcp-button/src/Assets/SmartButton.php +++ b/modules/ppcp-button/src/Assets/SmartButton.php @@ -63,7 +63,8 @@ use WooCommerce\PayPalCommerce\WcGateway\Helper\CardPaymentsConfiguration; */ class SmartButton implements SmartButtonInterface { - use FreeTrialHandlerTrait, ContextTrait; + use FreeTrialHandlerTrait; + use ContextTrait; /** * The Settings status helper. @@ -438,7 +439,7 @@ class SmartButton implements SmartButtonInterface { $subscription_helper = $this->subscription_helper; add_filter( 'woocommerce_credit_card_form_fields', - function ( array $default_fields, $id ) use ( $subscription_helper ) : array { + function ( array $default_fields, $id ) use ( $subscription_helper ): array { if ( CreditCardGateway::ID === $id && is_user_logged_in() @@ -671,7 +672,7 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages $enabled_on_cart = $this->settings_status->is_smart_button_enabled_for_location( 'cart' ); add_action( $this->proceed_to_checkout_button_renderer_hook(), - function() use ( $enabled_on_cart ) { + function () use ( $enabled_on_cart ) { if ( ! is_cart() || ! $enabled_on_cart || $this->is_free_trial_cart() || $this->is_cart_price_total_zero() || isset( reset( WC()->cart->cart_contents )['subscription_switch'] ) ) { return; } @@ -700,7 +701,7 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages /** * Determines whether the button component should be loaded. */ - public function should_load_buttons() : bool { + public function should_load_buttons(): bool { $pcp_gateway_enabled = $this->settings->has( 'enabled' ) && $this->settings->get( 'enabled' ); if ( ! $pcp_gateway_enabled ) { return false; @@ -726,7 +727,7 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages /** * Determines whether the Pay Later messages component should be loaded. */ - public function should_load_messages() : bool { + public function should_load_messages(): bool { $pcp_gateway_enabled = $this->settings->has( 'enabled' ) && $this->settings->get( 'enabled' ); if ( ! $pcp_gateway_enabled ) { return false; @@ -768,7 +769,7 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages /** * Whether DCC fields can be rendered. */ - public function can_render_dcc() : bool { + public function can_render_dcc(): bool { return $this->dcc_configuration->is_acdc_enabled() && in_array( $this->context(), @@ -1142,7 +1143,7 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages * * @return bool True, if any cart item requires shipping. */ - private function need_shipping() : bool { + private function need_shipping(): bool { /** * Cart instance; might be null, esp. in customizer or in Block Editor. * @@ -1599,7 +1600,7 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages * * @return array */ - private function bn_codes() : array { + private function bn_codes(): array { $bn_code = $this->partner_attribution->get_bn_code(); @@ -1910,7 +1911,7 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages * @psalm-suppress RedundantConditionGivenDocblockType */ protected function is_cart_price_total_zero(): bool { - // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison + // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual return WC()->cart && WC()->cart->get_total( 'numeric' ) == 0; } @@ -2045,7 +2046,6 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages public function is_pay_later_button_enabled_for_location( string $location, array $context_data = array() ): bool { return $this->is_pay_later_filter_enabled_for_location( $location, $context_data ) && $this->settings_status->is_pay_later_button_enabled_for_location( $location ); - } /** @@ -2178,7 +2178,6 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages }, 11 ); - } /** diff --git a/modules/ppcp-button/src/Endpoint/ApproveOrderEndpoint.php b/modules/ppcp-button/src/Endpoint/ApproveOrderEndpoint.php index f4ff90218..038e7bbbb 100644 --- a/modules/ppcp-button/src/Endpoint/ApproveOrderEndpoint.php +++ b/modules/ppcp-button/src/Endpoint/ApproveOrderEndpoint.php @@ -159,7 +159,7 @@ class ApproveOrderEndpoint implements EndpointInterface { * * @return string */ - public static function nonce() : string { + public static function nonce(): string { return self::ENDPOINT; } @@ -169,7 +169,7 @@ class ApproveOrderEndpoint implements EndpointInterface { * @return bool * @throws RuntimeException When order not found or handling failed. */ - public function handle_request() : bool { + public function handle_request(): bool { try { $data = $this->request_data->read_request( self::nonce() ); if ( ! isset( $data['order_id'] ) ) { @@ -266,7 +266,7 @@ class ApproveOrderEndpoint implements EndpointInterface { * * @return void */ - protected function toggle_final_review_enabled_setting() : void { + protected function toggle_final_review_enabled_setting(): void { // TODO new-ux: This flag must also be updated in the new settings. $final_review_enabled_setting = $this->settings->has( 'blocks_final_review_enabled' ) && $this->settings->get( 'blocks_final_review_enabled' ); $this->settings->set( 'blocks_final_review_enabled', ! $final_review_enabled_setting ); @@ -285,7 +285,7 @@ class ApproveOrderEndpoint implements EndpointInterface { * @param Order $order The PayPal order to inspect. * @throws RuntimeException When the 3DS check was rejected. */ - protected function verify_three_d_secure( Order $order ) : void { + protected function verify_three_d_secure( Order $order ): void { $payment_source = $order->payment_source(); if ( ! $payment_source ) { diff --git a/modules/ppcp-button/src/Endpoint/CreateOrderEndpoint.php b/modules/ppcp-button/src/Endpoint/CreateOrderEndpoint.php index 818c22a4b..cd8b6c594 100644 --- a/modules/ppcp-button/src/Endpoint/CreateOrderEndpoint.php +++ b/modules/ppcp-button/src/Endpoint/CreateOrderEndpoint.php @@ -353,7 +353,7 @@ class CreateOrderEndpoint implements EndpointInterface { if ( ! $this->early_order_handler->should_create_early_order() || $this->registration_needed - || isset( $data['createaccount'] ) && '1' === $data['createaccount'] ) { + || ( isset( $data['createaccount'] ) && '1' === $data['createaccount'] ) ) { wp_send_json_success( $this->make_response( $order ) ); } diff --git a/modules/ppcp-button/src/Endpoint/SimulateCartEndpoint.php b/modules/ppcp-button/src/Endpoint/SimulateCartEndpoint.php index a96302e65..ffa02f49b 100644 --- a/modules/ppcp-button/src/Endpoint/SimulateCartEndpoint.php +++ b/modules/ppcp-button/src/Endpoint/SimulateCartEndpoint.php @@ -172,14 +172,11 @@ class SimulateCartEndpoint extends AbstractCartEndpoint { // Removes shutdown actions to prevent persisting session, transients and save cookies. remove_all_actions( 'shutdown' ); unset( WC()->cart ); - } else { + } elseif ( null !== $this->real_cart ) { // Restores cart, may lead to race conditions. - if ( null !== $this->real_cart ) { - WC()->cart = $this->real_cart; - } + WC()->cart = $this->real_cart; } unset( $this->cart ); } - } diff --git a/modules/ppcp-button/src/Helper/CartProductsHelper.php b/modules/ppcp-button/src/Helper/CartProductsHelper.php index 804c26598..71e6d177b 100644 --- a/modules/ppcp-button/src/Helper/CartProductsHelper.php +++ b/modules/ppcp-button/src/Helper/CartProductsHelper.php @@ -281,5 +281,4 @@ class CartProductsHelper { public function cart_item_keys(): array { return $this->cart_item_keys; } - } diff --git a/modules/ppcp-button/src/Helper/DisabledFundingSources.php b/modules/ppcp-button/src/Helper/DisabledFundingSources.php index 2d44cbd5c..a1b3b6927 100644 --- a/modules/ppcp-button/src/Helper/DisabledFundingSources.php +++ b/modules/ppcp-button/src/Helper/DisabledFundingSources.php @@ -71,7 +71,7 @@ class DisabledFundingSources { * @param string $context The context. * @return string[] List of disabled sources */ - public function sources( string $context ) : array { + public function sources( string $context ): array { $block_contexts = array( 'checkout-block', 'cart-block' ); $flags = array( 'context' => $context, @@ -104,7 +104,7 @@ class DisabledFundingSources { * * @return array */ - private function get_sources_from_settings() : array { + private function get_sources_from_settings(): array { try { // Settings field present in the legacy UI. $disabled_funding = $this->settings->get( 'disable_funding' ); @@ -133,7 +133,7 @@ class DisabledFundingSources { * * @return array */ - private function get_sources_for_free_trial() : array { + private function get_sources_for_free_trial(): array { // Disable all sources. $disable_funding = array_keys( $this->all_funding_sources ); @@ -154,7 +154,7 @@ class DisabledFundingSources { * @param array $disable_funding The current disabled funding sources. * @return array */ - private function apply_context_rules( array $disable_funding ) : array { + private function apply_context_rules( array $disable_funding ): array { if ( 'MX' === $this->merchant_country && $this->dcc_configuration->is_bcdc_enabled() && CartCheckoutDetector::has_classic_checkout() && is_checkout() ) { return $disable_funding; } @@ -173,7 +173,7 @@ class DisabledFundingSources { * @param array $disable_funding The current disabled funding sources. * @return array */ - private function apply_block_checkout_rules( array $disable_funding ) : array { + private function apply_block_checkout_rules( array $disable_funding ): array { /** * Block checkout only supports the following funding methods: * - PayPal @@ -196,7 +196,7 @@ class DisabledFundingSources { * @param array $flags Decision flags. * @return string[] */ - private function sanitize_and_filter_sources( array $disable_funding, array $flags ) : array { + private function sanitize_and_filter_sources( array $disable_funding, array $flags ): array { /** * Filters the final list of disabled funding sources. * diff --git a/modules/ppcp-button/src/Helper/ThreeDSecure.php b/modules/ppcp-button/src/Helper/ThreeDSecure.php index 1c694dc06..fd144f0df 100644 --- a/modules/ppcp-button/src/Helper/ThreeDSecure.php +++ b/modules/ppcp-button/src/Helper/ThreeDSecure.php @@ -61,7 +61,7 @@ class ThreeDSecure { * * @return int */ - public function proceed_with_order( Order $order ) : int { + public function proceed_with_order( Order $order ): int { do_action( 'woocommerce_paypal_payments_three_d_secure_before_check', $order ); @@ -120,7 +120,7 @@ class ThreeDSecure { * @param Order $order The PayPal Order object. * @return int */ - public function return_decision( int $decision, Order $order ) : int { + public function return_decision( int $decision, Order $order ): int { $decision = apply_filters( 'woocommerce_paypal_payments_three_d_secure_decision', $decision, $order ); do_action( 'woocommerce_paypal_payments_three_d_secure_after_check', $order, $decision ); @@ -134,7 +134,7 @@ class ThreeDSecure { * * @return int */ - private function no_liability_shift( AuthResult $result ) : int { + private function no_liability_shift( AuthResult $result ): int { $enrollment = $result->enrollment_status(); $authentication = $result->authentication_result(); diff --git a/modules/ppcp-button/src/Validation/CheckoutFormValidator.php b/modules/ppcp-button/src/Validation/CheckoutFormValidator.php index 6a1f9486d..4bd8b2833 100644 --- a/modules/ppcp-button/src/Validation/CheckoutFormValidator.php +++ b/modules/ppcp-button/src/Validation/CheckoutFormValidator.php @@ -93,7 +93,7 @@ class CheckoutFormValidator extends WC_Checkout { } // Some plugins call wc_add_notice directly. - // We should retrieve such notices, and also clear them to avoid duplicates later. + // We should retrieve such notices, and also clear them to avoid duplicates later. // TODO: Normally WC converts the messages from validate_checkout into notices, // maybe we should do the same for consistency, but it requires lots of changes in the way we handle/output errors. $messages = array_merge( diff --git a/modules/ppcp-card-fields/services.php b/modules/ppcp-card-fields/services.php index 4933ce193..539cb1beb 100644 --- a/modules/ppcp-card-fields/services.php +++ b/modules/ppcp-card-fields/services.php @@ -24,17 +24,17 @@ return array( $save_payment_methods_applies = $container->get( 'card-fields.helpers.save-payment-methods-applies' ); assert( $save_payment_methods_applies instanceof CardFieldsApplies ); - return static function () use ( $save_payment_methods_applies ) : bool { + return static function () use ( $save_payment_methods_applies ): bool { return $save_payment_methods_applies->for_country() && $save_payment_methods_applies->for_merchant(); }; }, - 'card-fields.helpers.save-payment-methods-applies' => static function ( ContainerInterface $container ) : CardFieldsApplies { + 'card-fields.helpers.save-payment-methods-applies' => static function ( ContainerInterface $container ): CardFieldsApplies { return new CardFieldsApplies( $container->get( 'card-fields.supported-country-matrix' ), $container->get( 'api.shop.country' ) ); }, - 'card-fields.supported-country-matrix' => static function ( ContainerInterface $container ) : array { + 'card-fields.supported-country-matrix' => static function ( ContainerInterface $container ): array { return apply_filters( 'woocommerce_paypal_payments_card_fields_supported_country_matrix', array( @@ -82,7 +82,7 @@ return array( ) ); }, - 'card-fields.service.card-capture-validator' => static function ( ContainerInterface $container ) : CardCaptureValidator { + 'card-fields.service.card-capture-validator' => static function ( ContainerInterface $container ): CardCaptureValidator { return new CardCaptureValidator(); }, ); diff --git a/modules/ppcp-card-fields/src/CardFieldsModule.php b/modules/ppcp-card-fields/src/CardFieldsModule.php index 2acf19dd7..4f391620b 100644 --- a/modules/ppcp-card-fields/src/CardFieldsModule.php +++ b/modules/ppcp-card-fields/src/CardFieldsModule.php @@ -53,7 +53,7 @@ class CardFieldsModule implements ServiceModule, ExtendingModule, ExecutableModu add_filter( 'woocommerce_paypal_payments_sdk_components_hook', - static function( array $components ) use ( $c ) { + static function ( array $components ) use ( $c ) { $dcc_config = $c->get( 'wcgateway.configuration.card-configuration' ); assert( $dcc_config instanceof CardPaymentsConfiguration ); @@ -104,7 +104,7 @@ class CardFieldsModule implements ServiceModule, ExtendingModule, ExecutableModu * @psalm-suppress MissingClosureReturnType * @psalm-suppress MissingClosureParamType */ - function( $default_fields, $id ) use ( $c ) { + function ( $default_fields, $id ) use ( $c ) { if ( ! $c->get( 'wcgateway.configuration.card-configuration' )->is_enabled() ) { return $default_fields; } @@ -139,7 +139,7 @@ class CardFieldsModule implements ServiceModule, ExtendingModule, ExecutableModu add_filter( 'ppcp_create_order_request_body_data', - function( array $data, string $payment_method ) use ( $c ): array { + function ( array $data, string $payment_method ) use ( $c ): array { if ( ! $c->get( 'wcgateway.configuration.card-configuration' )->is_enabled() ) { return $data; } @@ -187,7 +187,7 @@ class CardFieldsModule implements ServiceModule, ExtendingModule, ExecutableModu // Validates if an order with card payment source can be captured. add_action( 'woocommerce_paypal_payments_before_capture_order', - function( Order $order ) use ( $c ) { + function ( Order $order ) use ( $c ) { $validator = $c->get( 'card-fields.service.card-capture-validator' ); assert( $validator instanceof CardCaptureValidator ); diff --git a/modules/ppcp-card-fields/src/Helper/CardFieldsApplies.php b/modules/ppcp-card-fields/src/Helper/CardFieldsApplies.php index ceb2ddddb..62f76a043 100644 --- a/modules/ppcp-card-fields/src/Helper/CardFieldsApplies.php +++ b/modules/ppcp-card-fields/src/Helper/CardFieldsApplies.php @@ -57,7 +57,7 @@ class CardFieldsApplies { * * @return bool */ - public function for_merchant() : bool { + public function for_merchant(): bool { return apply_filters( 'woocommerce_paypal_payments_is_eligible_for_card_fields', true diff --git a/modules/ppcp-compat/services.php b/modules/ppcp-compat/services.php index fa59051ff..7098a6249 100644 --- a/modules/ppcp-compat/services.php +++ b/modules/ppcp-compat/services.php @@ -21,7 +21,7 @@ use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface; return array( - 'compat.ppec.mock-gateway' => static function( $container ) { + 'compat.ppec.mock-gateway' => static function ( $container ) { $settings = $container->get( 'wcgateway.settings' ); $title = $settings->has( 'title' ) ? $settings->get( 'title' ) : __( 'PayPal', 'woocommerce-paypal-payments' ); $title = sprintf( @@ -40,13 +40,13 @@ return array( return new PPEC\SubscriptionsHandler( $ppcp_renewal_handler, $gateway ); }, - 'compat.ppec.settings_importer' => static function( ContainerInterface $container ) : PPEC\SettingsImporter { + 'compat.ppec.settings_importer' => static function ( ContainerInterface $container ): PPEC\SettingsImporter { $settings = $container->get( 'wcgateway.settings' ); return new PPEC\SettingsImporter( $settings ); }, - 'compat.plugin-script-names' => static function( ContainerInterface $container ) : array { + 'compat.plugin-script-names' => static function ( ContainerInterface $container ): array { return array( 'ppcp-smart-button', 'ppcp-oxxo', @@ -61,7 +61,7 @@ return array( ); }, - 'compat.plugin-script-file-names' => static function( ContainerInterface $container ) : array { + 'compat.plugin-script-file-names' => static function ( ContainerInterface $container ): array { return array( 'button.js', 'gateway-settings.js', @@ -104,7 +104,7 @@ return array( return plugins_url( '/modules/ppcp-compat/', $container->get( 'ppcp.path-to-plugin-main-file' ) ); }, - 'compat.assets' => function( ContainerInterface $container ) : CompatAssets { + 'compat.assets' => function ( ContainerInterface $container ): CompatAssets { return new CompatAssets( $container->get( 'compat.module.url' ), $container->get( 'ppcp.asset-version' ), @@ -120,7 +120,7 @@ return array( * * @returns SettingsMap[] */ - 'compat.setting.new-to-old-map' => static function( ContainerInterface $container ) : array { + 'compat.setting.new-to-old-map' => static function ( ContainerInterface $container ): array { $are_new_settings_enabled = $container->get( 'wcgateway.settings.admin-settings-enabled' ); if ( ! $are_new_settings_enabled ) { return array(); @@ -184,7 +184,7 @@ return array( ), ); }, - 'compat.settings.settings_map_helper' => static function( ContainerInterface $container ) : SettingsMapHelper { + 'compat.settings.settings_map_helper' => static function ( ContainerInterface $container ): SettingsMapHelper { return new SettingsMapHelper( $container->get( 'compat.setting.new-to-old-map' ), $container->get( 'compat.settings.styling_map_helper' ), @@ -195,19 +195,19 @@ return array( $container->get( 'wcgateway.settings.admin-settings-enabled' ) ); }, - 'compat.settings.styling_map_helper' => static function() : StylingSettingsMapHelper { + 'compat.settings.styling_map_helper' => static function (): StylingSettingsMapHelper { return new StylingSettingsMapHelper(); }, - 'compat.settings.settings_tab_map_helper' => static function() : SettingsTabMapHelper { + 'compat.settings.settings_tab_map_helper' => static function (): SettingsTabMapHelper { return new SettingsTabMapHelper(); }, - 'compat.settings.subscription_map_helper' => static function( ContainerInterface $container ) : SubscriptionSettingsMapHelper { + 'compat.settings.subscription_map_helper' => static function ( ContainerInterface $container ): SubscriptionSettingsMapHelper { return new SubscriptionSettingsMapHelper( $container->get( 'wc-subscriptions.helper' ) ); }, - 'compat.settings.general_map_helper' => static function() : GeneralSettingsMapHelper { + 'compat.settings.general_map_helper' => static function (): GeneralSettingsMapHelper { return new GeneralSettingsMapHelper(); }, - 'compat.settings.payment_methods_map_helper' => static function() : PaymentMethodSettingsMapHelper { + 'compat.settings.payment_methods_map_helper' => static function (): PaymentMethodSettingsMapHelper { return new PaymentMethodSettingsMapHelper(); }, ); diff --git a/modules/ppcp-compat/src/CompatModule.php b/modules/ppcp-compat/src/CompatModule.php index 56f784f04..85f2ff27e 100644 --- a/modules/ppcp-compat/src/CompatModule.php +++ b/modules/ppcp-compat/src/CompatModule.php @@ -55,7 +55,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule { add_action( 'woocommerce_init', - function() use ( $c ) { + function () use ( $c ) { $this->initialize_ppec_compat_layer( $c ); $this->initialize_tracking_compat_layer( $c ); } @@ -63,7 +63,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule { add_action( 'init', - function() use ( $c ) { + function () use ( $c ) { $asset_loader = $c->get( 'compat.assets' ); assert( $asset_loader instanceof CompatAssets ); @@ -117,7 +117,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule { */ add_action( 'woocommerce_paypal_payments_gateway_migrate_on_update', - static function() use ( $c ) { + static function () use ( $c ) { if ( ! apply_filters( // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 'woocommerce.feature-flags.woocommerce_paypal_payments.paylater_messaging_force_enabled', @@ -176,7 +176,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule { // Inbox note inviting merchant to disable PayPal Express Checkout. add_action( 'woocommerce_init', - function() { + function () { if ( is_admin() && is_callable( array( WC(), 'is_wc_admin_active' ) ) && WC()->is_wc_admin_active() && class_exists( 'Automattic\WooCommerce\Admin\Notes\Notes' ) ) { PPEC\DeactivateNote::init(); } @@ -377,7 +377,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule { protected function fix_page_builders(): void { add_action( 'init', - function() { + function () { if ( $this->is_block_theme_active() || $this->is_elementor_pro_active() @@ -386,7 +386,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule { ) { add_filter( 'woocommerce_paypal_payments_single_product_renderer_hook', - function(): string { + function (): string { return 'woocommerce_after_add_to_cart_form'; }, 5 @@ -443,7 +443,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule { protected function set_elementor_checkout_context(): void { add_action( 'wp', - function() { + function () { $page_id = get_the_ID(); if ( ! is_numeric( $page_id ) || ! CartCheckoutDetector::has_elementor_checkout( (int) $page_id ) ) { return; @@ -473,7 +473,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule { // Siteground SG Optimize. add_filter( 'sgo_js_minify_exclude', - function( array $scripts ) use ( $ppcp_script_names ) { + function ( array $scripts ) use ( $ppcp_script_names ) { return array_merge( $scripts, $ppcp_script_names ); } ); @@ -481,7 +481,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule { // LiteSpeed Cache. add_filter( 'litespeed_optimize_js_excludes', - function( array $excluded_js ) use ( $ppcp_script_file_names ) { + function ( array $excluded_js ) use ( $ppcp_script_file_names ) { return array_merge( $excluded_js, $ppcp_script_file_names ); } ); @@ -498,7 +498,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule { * @return bool Whether to do tag minification. * @psalm-suppress MissingClosureParamType */ - function( bool $do_tag_minification, string $script_tag, $file ) { + function ( bool $do_tag_minification, string $script_tag, $file ) { if ( $file && strpos( $file, 'ppcp' ) !== false ) { return false; } @@ -517,7 +517,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule { protected function initialize_nyp_compat_layer(): void { add_filter( 'woocommerce_paypal_payments_shipping_callback_cart_line_item_total', - static function( string $total, array $cart_item ) { + static function ( string $total, array $cart_item ) { if ( ! isset( $cart_item['nyp'] ) ) { return $total; } @@ -596,7 +596,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule { * @param ContainerInterface $container DI container instance. * @return void */ - protected function legacy_ui_card_payment_mapping( ContainerInterface $container ) : void { + protected function legacy_ui_card_payment_mapping( ContainerInterface $container ): void { $new_ui = $container->get( 'wcgateway.settings.admin-settings-enabled' ); if ( $new_ui ) { return; @@ -604,7 +604,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule { add_filter( 'woocommerce_paypal_payments_is_acdc_active', - static function ( bool $is_acdc ) use ( $container ) : bool { + static function ( bool $is_acdc ) use ( $container ): bool { $settings = $container->get( 'wcgateway.settings' ); assert( $settings instanceof Settings ); diff --git a/modules/ppcp-compat/src/PPEC/DeactivateNote.php b/modules/ppcp-compat/src/PPEC/DeactivateNote.php index 5fb3aad8f..232a266da 100644 --- a/modules/ppcp-compat/src/PPEC/DeactivateNote.php +++ b/modules/ppcp-compat/src/PPEC/DeactivateNote.php @@ -116,5 +116,4 @@ class DeactivateNote { $note->save(); } } - } diff --git a/modules/ppcp-compat/src/PPEC/MockGateway.php b/modules/ppcp-compat/src/PPEC/MockGateway.php index cc070c048..278e14787 100644 --- a/modules/ppcp-compat/src/PPEC/MockGateway.php +++ b/modules/ppcp-compat/src/PPEC/MockGateway.php @@ -45,5 +45,4 @@ class MockGateway extends \WC_Payment_Gateway { // Hide mock gateway, except on admin. return is_admin(); } - } diff --git a/modules/ppcp-compat/src/PPEC/PPECHelper.php b/modules/ppcp-compat/src/PPEC/PPECHelper.php index c74aac61d..bad0d2577 100644 --- a/modules/ppcp-compat/src/PPEC/PPECHelper.php +++ b/modules/ppcp-compat/src/PPEC/PPECHelper.php @@ -117,5 +117,4 @@ class PPECHelper { && self::site_has_ppec_subscriptions() && apply_filters( 'woocommerce_paypal_payments_process_legacy_subscriptions', true ); } - } diff --git a/modules/ppcp-compat/src/PPEC/SettingsImporter.php b/modules/ppcp-compat/src/PPEC/SettingsImporter.php index 7d87de968..103473241 100644 --- a/modules/ppcp-compat/src/PPEC/SettingsImporter.php +++ b/modules/ppcp-compat/src/PPEC/SettingsImporter.php @@ -231,5 +231,4 @@ class SettingsImporter { return $result; } - } diff --git a/modules/ppcp-compat/src/Settings/SettingsMapHelper.php b/modules/ppcp-compat/src/Settings/SettingsMapHelper.php index 263ac45cb..2a64ad536 100644 --- a/modules/ppcp-compat/src/Settings/SettingsMapHelper.php +++ b/modules/ppcp-compat/src/Settings/SettingsMapHelper.php @@ -125,7 +125,7 @@ class SettingsMapHelper { * @param SettingsMap[] $settings_map The settings map to validate. * @throws RuntimeException When an old key has multiple mappings. */ - protected function validate_settings_map( array $settings_map ) : void { + protected function validate_settings_map( array $settings_map ): void { $seen_keys = array(); foreach ( $settings_map as $settings_map_instance ) { @@ -172,7 +172,7 @@ class SettingsMapHelper { * * @return bool True if the key exists in the new settings, false otherwise. */ - public function has_mapped_key( string $old_key ) : bool { + public function has_mapped_key( string $old_key ): bool { if ( ! $this->new_settings_module_enabled ) { return false; } @@ -228,7 +228,7 @@ class SettingsMapHelper { * * @return void */ - protected function ensure_map_initialized() : void { + protected function ensure_map_initialized(): void { if ( $this->key_to_model === null ) { $this->initialize_key_map(); } @@ -242,7 +242,7 @@ class SettingsMapHelper { * * @return void */ - protected function initialize_key_map() : void { + protected function initialize_key_map(): void { $this->key_to_model = array(); foreach ( $this->settings_map as $settings_map_instance ) { @@ -264,7 +264,7 @@ class SettingsMapHelper { * * @return AbstractDataModel|null */ - protected function get_payment_settings_model() : ?AbstractDataModel { + protected function get_payment_settings_model(): ?AbstractDataModel { foreach ( $this->settings_map as $settings_map_instance ) { if ( $settings_map_instance->get_model() instanceof PaymentSettings ) { return $settings_map_instance->get_model(); diff --git a/modules/ppcp-googlepay/extensions.php b/modules/ppcp-googlepay/extensions.php index 20b19510c..0ec4f0f16 100644 --- a/modules/ppcp-googlepay/extensions.php +++ b/modules/ppcp-googlepay/extensions.php @@ -31,7 +31,7 @@ return array( $is_available = $container->get( 'googlepay.available' ); $is_referral = $container->get( 'googlepay.is_referral' ); - $insert_after = function( array $array, string $key, array $new ): array { + $insert_after = function ( array $array, string $key, array $new ): array { $keys = array_keys( $array ); $index = array_search( $key, $keys, true ); $pos = false === $index ? count( $array ) : $index + 1; diff --git a/modules/ppcp-googlepay/services.php b/modules/ppcp-googlepay/services.php index ea968b4d9..b52fa82ed 100644 --- a/modules/ppcp-googlepay/services.php +++ b/modules/ppcp-googlepay/services.php @@ -33,11 +33,11 @@ return array( $apm_applies = $container->get( 'googlepay.helpers.apm-applies' ); assert( $apm_applies instanceof ApmApplies ); - return static function () use ( $apm_applies ) : bool { + return static function () use ( $apm_applies ): bool { return $apm_applies->for_country() && $apm_applies->for_currency() && $apm_applies->for_merchant(); }; }, - 'googlepay.helpers.apm-applies' => static function ( ContainerInterface $container ) : ApmApplies { + 'googlepay.helpers.apm-applies' => static function ( ContainerInterface $container ): ApmApplies { return new ApmApplies( $container->get( 'googlepay.supported-countries' ), $container->get( 'googlepay.supported-currencies' ), @@ -76,7 +76,7 @@ return array( }, 'googlepay.helpers.apm-product-status' => SingletonDecorator::make( - static function( ContainerInterface $container ): ApmProductStatus { + static function ( ContainerInterface $container ): ApmProductStatus { return new ApmProductStatus( $container->get( 'wcgateway.settings' ), $container->get( 'api.endpoint.partners' ), @@ -89,7 +89,7 @@ return array( /** * The list of which countries can be used for GooglePay. */ - 'googlepay.supported-countries' => static function ( ContainerInterface $container ) : array { + 'googlepay.supported-countries' => static function ( ContainerInterface $container ): array { /** * Returns which countries can be used for GooglePay. */ @@ -145,7 +145,7 @@ return array( /** * The list of which currencies can be used for GooglePay. */ - 'googlepay.supported-currencies' => static function ( ContainerInterface $container ) : array { + 'googlepay.supported-currencies' => static function ( ContainerInterface $container ): array { /** * Returns which currencies can be used for GooglePay. */ diff --git a/modules/ppcp-googlepay/src/Assets/Button.php b/modules/ppcp-googlepay/src/Assets/Button.php index f7517da57..a2d777438 100644 --- a/modules/ppcp-googlepay/src/Assets/Button.php +++ b/modules/ppcp-googlepay/src/Assets/Button.php @@ -275,7 +275,7 @@ class Button implements ButtonInterface { */ add_filter( 'woocommerce_paypal_payments_sdk_components_hook', - function( $components ) { + function ( $components ) { $components[] = 'googlepay'; return $components; } @@ -369,7 +369,7 @@ class Button implements ButtonInterface { * * @return void */ - protected function hide_gateway_until_eligible() : void { + protected function hide_gateway_until_eligible(): void { ?>