Merge pull request #3607 from woocommerce/PCP-5180-fix-php-8-compatibility-issues-dynamic-properties-and-phpcs-configuration-phpcs
Some checks are pending
CI / PHP 7.4 (push) Waiting to run
CI / PHP 8.0 (push) Waiting to run
CI / PHP 8.1 (push) Waiting to run
CI / PHP 8.2 (push) Waiting to run
CI / PHP 8.3 (push) Waiting to run
CI / PHP 8.4 (push) Waiting to run
PR Playground Demo / prepare_version (push) Waiting to run
PR Playground Demo / build_plugin (push) Blocked by required conditions
PR Playground Demo / create_archive (push) Blocked by required conditions
PR Playground Demo / Comment on PR with Playground details (push) Blocked by required conditions

Refactor PHPCS configuration to be compatible to PHP8 (5180)
This commit is contained in:
Emili Castells 2025-08-25 09:21:27 +02:00 committed by GitHub
commit 46eeeb0b36
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
231 changed files with 1298 additions and 1091 deletions

View file

@ -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",

302
composer.lock generated
View file

@ -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"
},

View file

@ -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();
}
}
);

View file

@ -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 ) {

View file

@ -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'] ?? '' ),

View file

@ -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(

View file

@ -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(

View file

@ -26,5 +26,5 @@ interface RendererInterface {
*
* @return void
*/
public function enqueue_admin() : void;
public function enqueue_admin(): void;
}

View file

@ -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();

View file

@ -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(

View file

@ -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 ) {

View file

@ -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';

View file

@ -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;
}
}

View file

@ -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(

View file

@ -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(

View file

@ -348,7 +348,7 @@ class WebhookEndpoint {
if ( isset( $expected_headers[ $key ] ) ) {
$expected_headers[ $key ] = $header;
}
};
}
foreach ( $expected_headers as $key => $value ) {
if ( ! empty( $value ) ) {

View file

@ -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;
}

View file

@ -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(),

View file

@ -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;
}

View file

@ -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(),

View file

@ -124,5 +124,4 @@ class PaymentToken {
)
);
}
}

View file

@ -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(),

View file

@ -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(),

View file

@ -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(),
);

View file

@ -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()

View file

@ -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(),
);
}
}

View file

@ -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(),
);
}
}

View file

@ -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;
}

View file

@ -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 )

View file

@ -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' );
/**

View file

@ -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

View file

@ -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;
}
)

View file

@ -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',

View file

@ -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() ) );
}
}

View file

@ -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 )

View file

@ -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 : ''

View file

@ -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.

View file

@ -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;
}

View file

@ -90,5 +90,4 @@ class FailureRegistry {
private function cache_key( string $key ): string {
return implode( '_', array( self::CACHE_KEY, $key ) );
}
}

View file

@ -156,5 +156,4 @@ class OrderTransient {
}
return implode( '_', array( self::CACHE_KEY . $order->id() ) );
}
}

View file

@ -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 ) ) {

View file

@ -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;

View file

@ -393,5 +393,4 @@ class PurchaseUnitSanitizer {
public function set_last_message( string $message ): void {
$this->last_message = $message;
}
}

View file

@ -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 ) {

View file

@ -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.
*/

View file

@ -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 );

View file

@ -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;

View file

@ -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 . '<li><label><input type="checkbox" id="ppcp-onboarding-apple" ' . $checked . ' data-onboarding-option="ppcp-onboarding-apple"> ' .
__( 'Onboard with ApplePay', 'woocommerce-paypal-payments' ) . '
</label></li>';
}
/**
@ -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;
}

View file

@ -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;

View file

@ -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;
}

View file

@ -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,

View file

@ -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

View file

@ -141,7 +141,6 @@ class AvailabilityNotice {
if ( ! $this->is_merchant_validated ) {
$this->add_merchant_not_validated_notice();
}
}
/**
@ -287,5 +286,4 @@ class AvailabilityNotice {
}
);
}
}

View file

@ -9,6 +9,6 @@ declare( strict_types = 1 );
namespace WooCommerce\PayPalCommerce\AxoBlock;
return static function () : AxoBlockModule {
return static function (): AxoBlockModule {
return new AxoBlockModule();
};

View file

@ -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' ),

View file

@ -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.
*/

View file

@ -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();
}

View file

@ -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;

View file

@ -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<array{name: string, is_active: bool}>
*/
'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
)

View file

@ -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 )
);
}
}

View file

@ -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 );

View file

@ -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;
}
}

View file

@ -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 '';
}

View file

@ -25,5 +25,4 @@ class PropertiesDictionary {
'no' => __( 'No', 'woocommerce-paypal-payments' ),
);
}
}

View file

@ -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();
}
/**

View file

@ -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;

View file

@ -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.
*/

View file

@ -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';
}

View file

@ -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' ),

View file

@ -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
);
}
/**

View file

@ -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 ) {

View file

@ -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 ) );
}

View file

@ -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 );
}
}

View file

@ -281,5 +281,4 @@ class CartProductsHelper {
public function cart_item_keys(): array {
return $this->cart_item_keys;
}
}

View file

@ -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.
*

View file

@ -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();

View file

@ -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(

View file

@ -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();
},
);

View file

@ -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 );

View file

@ -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

View file

@ -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();
},
);

View file

@ -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 );

View file

@ -116,5 +116,4 @@ class DeactivateNote {
$note->save();
}
}
}

View file

@ -45,5 +45,4 @@ class MockGateway extends \WC_Payment_Gateway {
// Hide mock gateway, except on admin.
return is_admin();
}
}

View file

@ -117,5 +117,4 @@ class PPECHelper {
&& self::site_has_ppec_subscriptions()
&& apply_filters( 'woocommerce_paypal_payments_process_legacy_subscriptions', true );
}
}

View file

@ -231,5 +231,4 @@ class SettingsImporter {
return $result;
}
}

View file

@ -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();

View file

@ -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;

View file

@ -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.
*/

View file

@ -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 {
?>
<style data-hide-gateway='<?php echo esc_attr( GooglePayGateway::ID ); ?>'>
.wc_payment_method.payment_method_ppcp-googlepay {

View file

@ -219,5 +219,4 @@ class UpdatePaymentDataEndpoint {
WC()->session->set( 'chosen_shipping_methods', array( $rate_id ) );
}
}
}

View file

@ -54,7 +54,7 @@ class GooglepayModule implements ServiceModule, ExtendingModule, ExecutableModul
// 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( 'googlepay.helpers.apm-product-status' );
assert( $apm_status instanceof ApmProductStatus );
$apm_status->clear( $settings );
@ -149,7 +149,7 @@ class GooglepayModule implements ServiceModule, ExtendingModule, ExecutableModul
// Registers buttons on blocks pages.
add_action(
'woocommerce_blocks_payment_method_type_registration',
function( PaymentMethodRegistry $payment_method_registry ) use ( $c, $button ): void {
function ( PaymentMethodRegistry $payment_method_registry ) use ( $c, $button ): void {
if ( SettingsModule::should_use_the_old_ui() && ! $button->is_enabled() ) {
return;
}
@ -161,7 +161,7 @@ class GooglepayModule implements ServiceModule, ExtendingModule, ExecutableModul
// Adds GooglePay 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'][] = 'googlepay';
}
@ -178,7 +178,6 @@ class GooglepayModule implements ServiceModule, ExtendingModule, ExecutableModul
$endpoint->handle_request();
}
);
},
1
);
@ -225,7 +224,7 @@ class GooglepayModule implements ServiceModule, ExtendingModule, ExecutableModul
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()[ GooglePayGateway::ID ] ?? '';
if ( $gateway && $gateway->enabled === 'yes' && $setting_name === 'smart_button_locations' ) {
$locations[] = 'checkout';
@ -255,7 +254,7 @@ class GooglepayModule implements ServiceModule, ExtendingModule, ExecutableModul
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 {
$funding_source = $request['funding_source'] ?? '';
if ( $payment_method !== GooglePayGateway::ID && $funding_source !== 'googlepay' ) {

View file

@ -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_googlepay',
true

View file

@ -54,7 +54,7 @@ class ApmProductStatus extends ProductStatus {
}
/** {@inheritDoc} */
protected function check_local_state() : ?bool {
protected function check_local_state(): ?bool {
$status_override = apply_filters( 'woocommerce_paypal_payments_google_pay_product_status', null );
if ( null !== $status_override ) {
return $status_override;
@ -68,7 +68,7 @@ class ApmProductStatus 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 ApmProductStatus 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;
}

View file

@ -153,5 +153,4 @@ class AvailabilityNotice {
}
);
}
}

View file

@ -16,7 +16,7 @@ return array(
'ppcp-local-apms.url' => static function ( ContainerInterface $container ): string {
return plugins_url( '/modules/ppcp-local-alternative-payment-methods/', $container->get( 'ppcp.path-to-plugin-main-file' ) );
},
'ppcp-local-apms.payment-methods' => static function( ContainerInterface $container ): array {
'ppcp-local-apms.payment-methods' => static function ( ContainerInterface $container ): array {
return array(
'bancontact' => array(
'id' => BancontactGateway::ID,
@ -140,56 +140,56 @@ return array(
$container->get( 'wcgateway.builder.experience-context' )
);
},
'ppcp-local-apms.bancontact.payment-method' => static function( ContainerInterface $container ): BancontactPaymentMethod {
'ppcp-local-apms.bancontact.payment-method' => static function ( ContainerInterface $container ): BancontactPaymentMethod {
return new BancontactPaymentMethod(
$container->get( 'ppcp-local-apms.url' ),
$container->get( 'ppcp.asset-version' ),
$container->get( 'ppcp-local-apms.bancontact.wc-gateway' )
);
},
'ppcp-local-apms.blik.payment-method' => static function( ContainerInterface $container ): BlikPaymentMethod {
'ppcp-local-apms.blik.payment-method' => static function ( ContainerInterface $container ): BlikPaymentMethod {
return new BlikPaymentMethod(
$container->get( 'ppcp-local-apms.url' ),
$container->get( 'ppcp.asset-version' ),
$container->get( 'ppcp-local-apms.blik.wc-gateway' )
);
},
'ppcp-local-apms.eps.payment-method' => static function( ContainerInterface $container ): EPSPaymentMethod {
'ppcp-local-apms.eps.payment-method' => static function ( ContainerInterface $container ): EPSPaymentMethod {
return new EPSPaymentMethod(
$container->get( 'ppcp-local-apms.url' ),
$container->get( 'ppcp.asset-version' ),
$container->get( 'ppcp-local-apms.eps.wc-gateway' )
);
},
'ppcp-local-apms.ideal.payment-method' => static function( ContainerInterface $container ): IDealPaymentMethod {
'ppcp-local-apms.ideal.payment-method' => static function ( ContainerInterface $container ): IDealPaymentMethod {
return new IDealPaymentMethod(
$container->get( 'ppcp-local-apms.url' ),
$container->get( 'ppcp.asset-version' ),
$container->get( 'ppcp-local-apms.ideal.wc-gateway' )
);
},
'ppcp-local-apms.mybank.payment-method' => static function( ContainerInterface $container ): MyBankPaymentMethod {
'ppcp-local-apms.mybank.payment-method' => static function ( ContainerInterface $container ): MyBankPaymentMethod {
return new MyBankPaymentMethod(
$container->get( 'ppcp-local-apms.url' ),
$container->get( 'ppcp.asset-version' ),
$container->get( 'ppcp-local-apms.mybank.wc-gateway' )
);
},
'ppcp-local-apms.p24.payment-method' => static function( ContainerInterface $container ): P24PaymentMethod {
'ppcp-local-apms.p24.payment-method' => static function ( ContainerInterface $container ): P24PaymentMethod {
return new P24PaymentMethod(
$container->get( 'ppcp-local-apms.url' ),
$container->get( 'ppcp.asset-version' ),
$container->get( 'ppcp-local-apms.p24.wc-gateway' )
);
},
'ppcp-local-apms.trustly.payment-method' => static function( ContainerInterface $container ): TrustlyPaymentMethod {
'ppcp-local-apms.trustly.payment-method' => static function ( ContainerInterface $container ): TrustlyPaymentMethod {
return new TrustlyPaymentMethod(
$container->get( 'ppcp-local-apms.url' ),
$container->get( 'ppcp.asset-version' ),
$container->get( 'ppcp-local-apms.trustly.wc-gateway' )
);
},
'ppcp-local-apms.multibanco.payment-method' => static function( ContainerInterface $container ): MultibancoPaymentMethod {
'ppcp-local-apms.multibanco.payment-method' => static function ( ContainerInterface $container ): MultibancoPaymentMethod {
return new MultibancoPaymentMethod(
$container->get( 'ppcp-local-apms.url' ),
$container->get( 'ppcp.asset-version' ),

View file

@ -28,21 +28,21 @@ class LocalAlternativePaymentMethodsModule implements ServiceModule, ExtendingMo
/**
* {@inheritDoc}
*/
public function services() : array {
public function services(): array {
return require __DIR__ . '/../services.php';
}
/**
* {@inheritDoc}
*/
public function extensions() : array {
public function extensions(): array {
return require __DIR__ . '/../extensions.php';
}
/**
* {@inheritDoc}
*/
public function run( ContainerInterface $c ) : bool {
public function run( ContainerInterface $c ): bool {
add_action( 'after_setup_theme', fn() => $this->run_with_translations( $c ) );
return true;
@ -56,7 +56,7 @@ class LocalAlternativePaymentMethodsModule implements ServiceModule, ExtendingMo
* @param ContainerInterface $c The DI container.
* @return void
*/
private function run_with_translations( ContainerInterface $c ) : void {
private function run_with_translations( ContainerInterface $c ): void {
// When Local APMs are disabled, none of the following hooks are needed.
if ( ! $this->should_add_local_apm_gateways( $c ) ) {
return;
@ -131,7 +131,7 @@ class LocalAlternativePaymentMethodsModule implements ServiceModule, ExtendingMo
*/
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_methods = $c->get( 'ppcp-local-apms.payment-methods' );
foreach ( $payment_methods as $key => $value ) {
$payment_method_registry->register( $c->get( 'ppcp-local-apms.' . $key . '.payment-method' ) );
@ -159,7 +159,7 @@ class LocalAlternativePaymentMethodsModule implements ServiceModule, ExtendingMo
*
* @psalm-suppress MissingClosureParamType
*/
function( $order_id ) use ( $c ) {
function ( $order_id ) use ( $c ) {
$order = wc_get_order( $order_id );
if ( ! $order instanceof WC_Order ) {
return;
@ -191,7 +191,7 @@ class LocalAlternativePaymentMethodsModule implements ServiceModule, ExtendingMo
add_action(
'woocommerce_paypal_payments_payment_capture_completed_webhook_handler',
function( WC_Order $wc_order, string $order_id ) use ( $c ) {
function ( WC_Order $wc_order, string $order_id ) use ( $c ) {
$payment_methods = $c->get( 'ppcp-local-apms.payment-methods' );
if (
! $this->is_local_apm( $wc_order->get_payment_method(), $payment_methods )
@ -232,7 +232,7 @@ class LocalAlternativePaymentMethodsModule implements ServiceModule, ExtendingMo
* @param ContainerInterface $container Container.
* @return bool
*/
private function should_add_local_apm_gateways( ContainerInterface $container ) : bool {
private function should_add_local_apm_gateways( ContainerInterface $container ): bool {
// APMs are only available after merchant onboarding is completed.
$is_connected = $container->get( 'settings.flag.is-connected' );
if ( ! $is_connected ) {

View file

@ -52,7 +52,7 @@ class LocalApmProductStatus extends ProductStatus {
}
/** {@inheritDoc} */
protected function check_local_state() : ?bool {
protected function check_local_state(): ?bool {
if ( $this->settings->has( self::SETTINGS_KEY ) && ( $this->settings->get( self::SETTINGS_KEY ) ) ) {
return wc_string_to_bool( $this->settings->get( self::SETTINGS_KEY ) );
}
@ -61,7 +61,7 @@ class LocalApmProductStatus extends ProductStatus {
}
/** {@inheritDoc} */
protected function check_active_state( SellerStatus $seller_status ) : bool {
protected function check_active_state( SellerStatus $seller_status ): bool {
$has_capability = false;
foreach ( $seller_status->capabilities() as $capability ) {
@ -86,7 +86,7 @@ class LocalApmProductStatus 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;
}

View file

@ -24,7 +24,7 @@ use WooCommerce\PayPalCommerce\Settings\Data\GeneralSettings;
use WooCommerce\PayPalCommerce\WcGateway\Helper\MerchantDetails;
return array(
'api.paypal-host' => function( ContainerInterface $container ) : string {
'api.paypal-host' => function ( ContainerInterface $container ): string {
$environment = $container->get( 'settings.environment' );
/**
* The current environment.
@ -35,18 +35,16 @@ return array(
return $container->get( 'api.paypal-host-sandbox' );
}
return $container->get( 'api.paypal-host-production' );
},
'api.paypal-website-url' => function( ContainerInterface $container ) : string {
'api.paypal-website-url' => function ( ContainerInterface $container ): string {
$environment = $container->get( 'settings.environment' );
assert( $environment instanceof Environment );
if ( $environment->current_environment_is( Environment::SANDBOX ) ) {
return $container->get( 'api.paypal-website-url-sandbox' );
}
return $container->get( 'api.paypal-website-url-production' );
},
'onboarding.state' => function( ContainerInterface $container ) : State {
'onboarding.state' => function ( ContainerInterface $container ): State {
$settings = $container->get( 'wcgateway.settings' );
return new State( $settings );
},
@ -55,7 +53,7 @@ return array(
* (onboarding/connected) and connection-aware environment checks.
* This is the preferred solution to check environment and connection state.
*/
'settings.connection-state' => static function ( ContainerInterface $container ) : ConnectionState {
'settings.connection-state' => static function ( ContainerInterface $container ): ConnectionState {
$state = $container->get( 'onboarding.state' );
assert( $state instanceof State );
@ -74,7 +72,7 @@ return array(
*
* @deprecated Use 'settings.connection-state' instead.
*/
'settings.flag.is-connected' => static function ( ContainerInterface $container ) : bool {
'settings.flag.is-connected' => static function ( ContainerInterface $container ): bool {
$state = $container->get( 'settings.connection-state' );
assert( $state instanceof ConnectionState );
@ -86,7 +84,7 @@ return array(
*
* @deprecated Use 'settings.connection-state' instead.
*/
'settings.flag.is-sandbox' => static function ( ContainerInterface $container ) : bool {
'settings.flag.is-sandbox' => static function ( ContainerInterface $container ): bool {
$state = $container->get( 'settings.connection-state' );
assert( $state instanceof ConnectionState );
@ -97,19 +95,19 @@ return array(
*
* @deprecated Directly use 'settings.connection-state' instead of this.
*/
'settings.environment' => function ( ContainerInterface $container ) : Environment {
'settings.environment' => function ( ContainerInterface $container ): Environment {
$state = $container->get( 'settings.connection-state' );
assert( $state instanceof ConnectionState );
return $state->get_environment();
},
'settings.merchant-details' => static function ( ContainerInterface $container ) : MerchantDetails {
'settings.merchant-details' => static function ( ContainerInterface $container ): MerchantDetails {
$woo_country = $container->get( 'api.shop.country' );
$eligibility_checks = $container->get( 'wcgateway.feature-eligibility.list' );
return new MerchantDetails( $woo_country, $woo_country, $eligibility_checks );
},
'onboarding.assets' => function( ContainerInterface $container ) : OnboardingAssets {
'onboarding.assets' => function ( ContainerInterface $container ): OnboardingAssets {
$state = $container->get( 'onboarding.state' );
$login_seller_endpoint = $container->get( 'onboarding.endpoint.login-seller' );
return new OnboardingAssets(
@ -126,7 +124,7 @@ return array(
return plugins_url( '/modules/ppcp-onboarding/', $container->get( 'ppcp.path-to-plugin-main-file' ) );
},
'onboarding.endpoint.login-seller' => static function ( ContainerInterface $container ) : LoginSellerEndpoint {
'onboarding.endpoint.login-seller' => static function ( ContainerInterface $container ): LoginSellerEndpoint {
$request_data = $container->get( 'button.request-data' );
$login_seller_production = $container->get( 'api.endpoint.login-seller-production' );
@ -146,7 +144,7 @@ return array(
new Cache( 'ppcp-client-credentials-cache' )
);
},
'onboarding.endpoint.pui' => static function( ContainerInterface $container ) : UpdateSignupLinksEndpoint {
'onboarding.endpoint.pui' => static function ( ContainerInterface $container ): UpdateSignupLinksEndpoint {
return new UpdateSignupLinksEndpoint(
$container->get( 'wcgateway.settings' ),
$container->get( 'button.request-data' ),
@ -156,7 +154,7 @@ return array(
$container->get( 'woocommerce.logger.woocommerce' )
);
},
'onboarding.signup-link-cache' => static function( ContainerInterface $container ): Cache {
'onboarding.signup-link-cache' => static function ( ContainerInterface $container ): Cache {
return new Cache( 'ppcp-paypal-signup-link' );
},
'onboarding.signup-link-ids' => static function ( ContainerInterface $container ): array {
@ -167,12 +165,12 @@ return array(
'sandbox-express_checkout',
);
},
'onboarding.render-send-only-notice' => static function( ContainerInterface $container ) {
'onboarding.render-send-only-notice' => static function ( ContainerInterface $container ) {
return new OnboardingSendOnlyNoticeRenderer(
$container->get( 'wcgateway.send-only-message' )
);
},
'onboarding.render' => static function ( ContainerInterface $container ) : OnboardingRenderer {
'onboarding.render' => static function ( ContainerInterface $container ): OnboardingRenderer {
$partner_referrals = $container->get( 'api.endpoint.partner-referrals-production' );
$partner_referrals_sandbox = $container->get( 'api.endpoint.partner-referrals-sandbox' );
$partner_referrals_data = $container->get( 'api.repository.partner-referrals-data' );
@ -188,14 +186,14 @@ return array(
$logger
);
},
'onboarding.render-options' => static function ( ContainerInterface $container ) : OnboardingOptionsRenderer {
'onboarding.render-options' => static function ( ContainerInterface $container ): OnboardingOptionsRenderer {
return new OnboardingOptionsRenderer(
$container->get( 'onboarding.url' ),
$container->get( 'api.shop.country' ),
$container->get( 'wcgateway.settings' )
);
},
'onboarding.rest' => static function( $container ) : OnboardingRESTController {
'onboarding.rest' => static function ( $container ): OnboardingRESTController {
return new OnboardingRESTController( $container );
},
);

View file

@ -175,10 +175,8 @@ class LoginSellerEndpoint implements EndpointInterface {
}
if ( $accept_cards ) {
$funding_sources = array_diff( $funding_sources, array( 'card' ) );
} else {
if ( ! in_array( 'card', $funding_sources, true ) ) {
} elseif ( ! in_array( 'card', $funding_sources, true ) ) {
$funding_sources[] = 'card';
}
}
$this->settings->set( 'disable_funding', $funding_sources );

Some files were not shown because too many files have changed in this diff Show more