Fix grouped "use" statement issues.

This commit is contained in:
Miguel Pérez Pellicer 2025-08-22 17:01:29 +02:00
parent 060a86f5c9
commit e2fb54c7a9
16 changed files with 83 additions and 60 deletions

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

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

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

@ -41,7 +41,8 @@ use function WooCommerce\PayPalCommerce\Api\ppcp_get_paypal_order;
*/
class OrderTrackingEndpoint {
use RequestTrait, TransactionIdHandlingTrait;
use RequestTrait;
use TransactionIdHandlingTrait;
const ENDPOINT = 'ppc-tracking-info';
@ -171,7 +172,7 @@ class OrderTrackingEndpoint {
*
* @throws RuntimeException If problem adding.
*/
public function add_tracking_information( ShipmentInterface $shipment, int $order_id ) : void {
public function add_tracking_information( ShipmentInterface $shipment, int $order_id ): void {
$wc_order = wc_get_order( $order_id );
if ( ! $wc_order instanceof WC_Order ) {
return;
@ -221,7 +222,7 @@ class OrderTrackingEndpoint {
*
* @throws RuntimeException If problem updating.
*/
public function update_tracking_information( ShipmentInterface $shipment, int $order_id ) : void {
public function update_tracking_information( ShipmentInterface $shipment, int $order_id ): void {
$host = trailingslashit( $this->host );
$tracker_id = $this->find_tracker_id( $shipment->capture_id(), $shipment->tracking_number() );
$url = "{$host}v1/shipping/trackers/{$tracker_id}";
@ -267,7 +268,7 @@ class OrderTrackingEndpoint {
* @return ShipmentInterface|null The tracking information.
* @throws RuntimeException If problem getting.
*/
public function get_tracking_information( int $wc_order_id, string $tracking_number ) : ?ShipmentInterface {
public function get_tracking_information( int $wc_order_id, string $tracking_number ): ?ShipmentInterface {
$wc_order = wc_get_order( $wc_order_id );
if ( ! $wc_order instanceof WC_Order ) {
return null;
@ -316,7 +317,7 @@ class OrderTrackingEndpoint {
* @return ShipmentInterface[] The list of shipments.
* @throws RuntimeException If problem getting.
*/
public function list_tracking_information( int $wc_order_id ) : ?array {
public function list_tracking_information( int $wc_order_id ): ?array {
$wc_order = wc_get_order( $wc_order_id );
if ( ! $wc_order instanceof WC_Order ) {
return array();

View file

@ -27,7 +27,8 @@ use function WooCommerce\PayPalCommerce\Api\ppcp_get_paypal_order;
*/
class WcShippingTaxIntegration implements Integration {
use TrackingAvailabilityTrait, TransactionIdHandlingTrait;
use TrackingAvailabilityTrait;
use TransactionIdHandlingTrait;
/**
* The shipment factory.
@ -74,7 +75,7 @@ class WcShippingTaxIntegration implements Integration {
add_filter(
'rest_post_dispatch',
function( WP_HTTP_Response $response, WP_REST_Server $server, WP_REST_Request $request ): WP_HTTP_Response {
function ( WP_HTTP_Response $response, WP_REST_Server $server, WP_REST_Request $request ): WP_HTTP_Response {
try {
if ( ! apply_filters( 'woocommerce_paypal_payments_sync_wc_shipping_tax', true ) ) {
return $response;
@ -122,7 +123,6 @@ class WcShippingTaxIntegration implements Integration {
10,
3
);
}
/**

View file

@ -30,7 +30,8 @@ use function WooCommerce\PayPalCommerce\Api\ppcp_get_paypal_order;
*/
class OrderTrackingModule implements ServiceModule, ExtendingModule, ExecutableModule {
use ModuleClassNameIdTrait;
use TrackingAvailabilityTrait, TransactionIdHandlingTrait;
use TrackingAvailabilityTrait;
use TransactionIdHandlingTrait;
public const PPCP_TRACKING_INFO_META_NAME = '_ppcp_paypal_tracking_info_meta_name';
@ -58,7 +59,7 @@ class OrderTrackingModule implements ServiceModule, ExtendingModule, ExecutableM
add_action(
'wc_ajax_' . OrderTrackingEndpoint::ENDPOINT,
function() use ( $c ) {
function () use ( $c ) {
$c->get( 'order-tracking.endpoint.controller' )->handle_request();
}
);
@ -68,7 +69,7 @@ class OrderTrackingModule implements ServiceModule, ExtendingModule, ExecutableM
add_action(
'init',
function() use ( $asset_loader, $c ) {
function () use ( $asset_loader, $c ) {
if ( ! $this->is_tracking_enabled( $c->get( 'api.bearer' ) ) ) {
return;
}
@ -78,7 +79,7 @@ class OrderTrackingModule implements ServiceModule, ExtendingModule, ExecutableM
);
add_action(
'init',
function() use ( $asset_loader, $c ) {
function () use ( $asset_loader, $c ) {
if ( ! $this->is_tracking_enabled( $c->get( 'api.bearer' ) ) ) {
return;
}
@ -98,7 +99,7 @@ class OrderTrackingModule implements ServiceModule, ExtendingModule, ExecutableM
*
* @psalm-suppress MissingClosureParamType
*/
function( string $post_type, $post_or_order_object ) use ( $c ) {
function ( string $post_type, $post_or_order_object ) use ( $c ) {
if ( ! $this->is_tracking_enabled( $c->get( 'api.bearer' ) ) ) {
return;
}

View file

@ -31,7 +31,10 @@ use WooCommerce\PayPalCommerce\WcGateway\Processor\TransactionIdHandlingTrait;
*/
class VaultedCreditCardHandler {
use OrderMetaTrait, TransactionIdHandlingTrait, PaymentsStatusHandlingTrait, FreeTrialHandlerTrait;
use OrderMetaTrait;
use TransactionIdHandlingTrait;
use PaymentsStatusHandlingTrait;
use FreeTrialHandlerTrait;
/**
* The subscription helper.

View file

@ -32,7 +32,8 @@ use WP_User_Query;
* @psalm-suppress MissingConstructor
*/
class VaultingModule implements ServiceModule, ExtendingModule, ExecutableModule {
use ModuleClassNameIdTrait, ContextTrait;
use ModuleClassNameIdTrait;
use ContextTrait;
/**
* Session Handler
@ -65,7 +66,7 @@ class VaultingModule implements ServiceModule, ExtendingModule, ExecutableModule
add_action(
'woocommerce_init',
function() use ( $container ) {
function () use ( $container ) {
$listener = $container->get( 'vaulting.customer-approval-listener' );
assert( $listener instanceof CustomerApprovalListener );
@ -76,7 +77,7 @@ class VaultingModule implements ServiceModule, ExtendingModule, ExecutableModule
$subscription_helper = $container->get( 'wc-subscriptions.helper' );
add_action(
'woocommerce_created_customer',
function( int $customer_id ) use ( $subscription_helper, $container ) {
function ( int $customer_id ) use ( $subscription_helper, $container ) {
if ( $container->has( 'save-payment-methods.eligible' ) && $container->get( 'save-payment-methods.eligible' ) ) {
return;
}
@ -123,7 +124,7 @@ class VaultingModule implements ServiceModule, ExtendingModule, ExecutableModule
* @psalm-suppress MissingClosureParamType
* @psalm-suppress MissingClosureReturnType
*/
function( $tokens, $customer_id, $gateway_id ) {
function ( $tokens, $customer_id, $gateway_id ) {
if ( ! is_array( $tokens ) ) {
return $tokens;
}
@ -161,7 +162,7 @@ class VaultingModule implements ServiceModule, ExtendingModule, ExecutableModule
*
* @psalm-suppress MissingClosureParamType
*/
function( $item, $payment_token ) {
function ( $item, $payment_token ) {
if ( ! is_array( $item ) || ! is_a( $payment_token, WC_Payment_Token::class ) ) {
return $item;
}
@ -189,7 +190,7 @@ class VaultingModule implements ServiceModule, ExtendingModule, ExecutableModule
add_action(
'wp',
function() use ( $container ) {
function () use ( $container ) {
if ( $container->get( 'vaulting.vault-v3-enabled' ) ) {
return;
}
@ -256,7 +257,7 @@ class VaultingModule implements ServiceModule, ExtendingModule, ExecutableModule
*/
add_action(
'pcp_migrate_payment_tokens',
function() use ( $container ) {
function () use ( $container ) {
$logger = $container->get( 'woocommerce.logger.woocommerce' );
assert( $logger instanceof LoggerInterface );
@ -266,7 +267,7 @@ class VaultingModule implements ServiceModule, ExtendingModule, ExecutableModule
add_action(
'woocommerce_paypal_payments_payment_tokens_migration',
function( int $customer_id ) use ( $container ) {
function ( int $customer_id ) use ( $container ) {
$migration = $container->get( 'vaulting.payment-tokens-migration' );
assert( $migration instanceof PaymentTokensMigration );
@ -281,7 +282,7 @@ class VaultingModule implements ServiceModule, ExtendingModule, ExecutableModule
*
* @psalm-suppress MissingClosureParamType
*/
function( $methods ) {
function ( $methods ) {
global $wp;
if ( ! is_array( $methods ) ) {

View file

@ -30,7 +30,9 @@ use WooCommerce\PayPalCommerce\WcGateway\Settings\SettingsRenderer;
*/
class CardButtonGateway extends \WC_Payment_Gateway {
use ProcessPaymentTrait, FreeTrialHandlerTrait, GatewaySettingsRendererTrait;
use ProcessPaymentTrait;
use FreeTrialHandlerTrait;
use GatewaySettingsRendererTrait;
const ID = 'ppcp-card-button-gateway';

View file

@ -42,7 +42,11 @@ use WooCommerce\PayPalCommerce\WcGateway\Helper\CardPaymentsConfiguration;
*/
class CreditCardGateway extends \WC_Payment_Gateway_CC {
use ProcessPaymentTrait, GatewaySettingsRendererTrait, TransactionIdHandlingTrait, PaymentsStatusHandlingTrait, FreeTrialHandlerTrait;
use ProcessPaymentTrait;
use GatewaySettingsRendererTrait;
use TransactionIdHandlingTrait;
use PaymentsStatusHandlingTrait;
use FreeTrialHandlerTrait;
const ID = 'ppcp-credit-card-gateway';
@ -375,7 +379,7 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
*
* @return bool
*/
public function is_available() : bool {
public function is_available(): bool {
return $this->is_enabled();
}

View file

@ -42,7 +42,12 @@ use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
*/
class PayPalGateway extends \WC_Payment_Gateway {
use ProcessPaymentTrait, FreeTrialHandlerTrait, GatewaySettingsRendererTrait, OrderMetaTrait, TransactionIdHandlingTrait, PaymentsStatusHandlingTrait;
use ProcessPaymentTrait;
use FreeTrialHandlerTrait;
use GatewaySettingsRendererTrait;
use OrderMetaTrait;
use TransactionIdHandlingTrait;
use PaymentsStatusHandlingTrait;
public const ID = 'ppcp-gateway';
public const INTENT_META_KEY = '_ppcp_paypal_intent';
@ -465,10 +470,9 @@ class PayPalGateway extends \WC_Payment_Gateway {
*
* @return bool
*/
private function is_credit_card_tab() : bool {
private function is_credit_card_tab(): bool {
return is_admin()
&& CreditCardGateway::ID === $this->page_id;
}
/**
@ -476,7 +480,7 @@ class PayPalGateway extends \WC_Payment_Gateway {
*
* @return bool
*/
private function is_pui_tab():bool {
private function is_pui_tab(): bool {
if ( 'DE' !== $this->api_shop_country ) {
return false;
}
@ -489,7 +493,7 @@ class PayPalGateway extends \WC_Payment_Gateway {
*
* @return bool true if is connection tab, otherwise false
*/
protected function is_connection_tab() : bool {
protected function is_connection_tab(): bool {
return is_admin()
&& Settings::CONNECTION_TAB_ID === $this->page_id;
}
@ -499,7 +503,7 @@ class PayPalGateway extends \WC_Payment_Gateway {
*
* @return bool true if is pay-later tab, otherwise false
*/
protected function is_pay_later_tab() : bool {
protected function is_pay_later_tab(): bool {
return is_admin()
&& Settings::PAY_LATER_TAB_ID === $this->page_id;
}
@ -509,7 +513,7 @@ class PayPalGateway extends \WC_Payment_Gateway {
*
* @return bool
*/
private function is_paypal_tab() : bool {
private function is_paypal_tab(): bool {
return ! $this->is_credit_card_tab()
&& is_admin()
&& self::ID === $this->page_id;

View file

@ -33,7 +33,8 @@ use WooCommerce\PayPalCommerce\WcGateway\Notice\AuthorizeOrderActionNotice;
*/
class AuthorizedPaymentsProcessor {
use PaymentsStatusHandlingTrait, TransactionIdHandlingTrait;
use PaymentsStatusHandlingTrait;
use TransactionIdHandlingTrait;
const SUCCESSFUL = 'SUCCESSFUL';
const ALREADY_CAPTURED = 'ALREADY_CAPTURED';
@ -474,5 +475,4 @@ class AuthorizedPaymentsProcessor {
}
);
}
}

View file

@ -38,7 +38,9 @@ use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
*/
class OrderProcessor {
use OrderMetaTrait, PaymentsStatusHandlingTrait, TransactionIdHandlingTrait;
use OrderMetaTrait;
use PaymentsStatusHandlingTrait;
use TransactionIdHandlingTrait;
/**
* The environment.

View file

@ -22,7 +22,8 @@ use WP_REST_Response;
*/
class PaymentCaptureCompleted implements RequestHandler {
use TransactionIdHandlingTrait, RequestHandlerTrait;
use TransactionIdHandlingTrait;
use RequestHandlerTrait;
/**
* The logger.

View file

@ -23,7 +23,9 @@ use WP_REST_Response;
*/
class PaymentCaptureRefunded implements RequestHandler {
use TransactionIdHandlingTrait, RefundMetaTrait, RequestHandlerTrait;
use TransactionIdHandlingTrait;
use RefundMetaTrait;
use RequestHandlerTrait;
/**
* The logger.

View file

@ -22,7 +22,9 @@ use WP_REST_Response;
*/
class PaymentSaleRefunded implements RequestHandler {
use TransactionIdHandlingTrait, RefundMetaTrait, RequestHandlerTrait;
use TransactionIdHandlingTrait;
use RefundMetaTrait;
use RequestHandlerTrait;
/**
* The logger.
@ -67,7 +69,6 @@ class PaymentSaleRefunded implements RequestHandler {
*/
public function responsible_for_request( WP_REST_Request $request ): bool {
return in_array( $request['event_type'], $this->event_types(), true );
}
/**