Fix phpcs

This commit is contained in:
Emili Castells Guasch 2024-08-21 16:33:44 +02:00
parent dd990ca44a
commit 2e524b53ea
6 changed files with 61 additions and 62 deletions

View file

@ -23,42 +23,42 @@ return array(
dirname( realpath( __FILE__ ), 3 ) . '/woocommerce-paypal-payments.php' dirname( realpath( __FILE__ ), 3 ) . '/woocommerce-paypal-payments.php'
); );
}, },
'ppcp-local-apms.payment-methods' => static function( ContainerInterface $container): array { 'ppcp-local-apms.payment-methods' => static function( ContainerInterface $container ): array {
return array( return array(
'bancontact' => array( 'bancontact' => array(
'id' => BancontactGateway::ID, 'id' => BancontactGateway::ID,
'countries' => array('BE',), 'countries' => array( 'BE' ),
'currencies' => array('EUR',), 'currencies' => array( 'EUR' ),
), ),
'blik' => array( 'blik' => array(
'id' => BlikGateway::ID, 'id' => BlikGateway::ID,
'countries' => array('PL',), 'countries' => array( 'PL' ),
'currencies' => array('PLN',), 'currencies' => array( 'PLN' ),
), ),
'eps' => array( 'eps' => array(
'id' => EPSGateway::ID, 'id' => EPSGateway::ID,
'countries' => array('AT',), 'countries' => array( 'AT' ),
'currencies' => array('EUR',), 'currencies' => array( 'EUR' ),
), ),
'ideal' => array( 'ideal' => array(
'id' => IDealGateway::ID, 'id' => IDealGateway::ID,
'countries' => array('NL',), 'countries' => array( 'NL' ),
'currencies' => array('EUR',), 'currencies' => array( 'EUR' ),
), ),
'mybank' => array( 'mybank' => array(
'id' => MyBankGateway::ID, 'id' => MyBankGateway::ID,
'countries' => array('IT',), 'countries' => array( 'IT' ),
'currencies' => array('EUR',), 'currencies' => array( 'EUR' ),
), ),
'p24' => array( 'p24' => array(
'id' => P24Gateway::ID, 'id' => P24Gateway::ID,
'countries' => array('PL',), 'countries' => array( 'PL' ),
'currencies' => array('EUR', 'PLN',), 'currencies' => array( 'EUR', 'PLN' ),
), ),
'trustly' => array( 'trustly' => array(
'id' => TrustlyGateway::ID, 'id' => TrustlyGateway::ID,
'countries' => array('AT', 'DE', 'DK', 'EE', 'ES', 'FI', 'GB', 'LT', 'LV', 'NL', 'NO', 'SE',), 'countries' => array( 'AT', 'DE', 'DK', 'EE', 'ES', 'FI', 'GB', 'LT', 'LV', 'NL', 'NO', 'SE' ),
'currencies' => array('EUR', 'DKK', 'SEK', 'GBP', 'NOK',), 'currencies' => array( 'EUR', 'DKK', 'SEK', 'GBP', 'NOK' ),
), ),
); );
}, },
@ -86,7 +86,7 @@ return array(
$container->get( 'wcgateway.transaction-url-provider' ) $container->get( 'wcgateway.transaction-url-provider' )
); );
}, },
'ppcp-local-apms.ideal.wc-gateway' => static function ( ContainerInterface $container ): IDealGateway { 'ppcp-local-apms.ideal.wc-gateway' => static function ( ContainerInterface $container ): IDealGateway {
return new IDealGateway( return new IDealGateway(
$container->get( 'api.endpoint.orders' ), $container->get( 'api.endpoint.orders' ),
$container->get( 'api.factory.purchase-unit' ), $container->get( 'api.factory.purchase-unit' ),
@ -94,7 +94,7 @@ return array(
$container->get( 'wcgateway.transaction-url-provider' ) $container->get( 'wcgateway.transaction-url-provider' )
); );
}, },
'ppcp-local-apms.mybank.wc-gateway' => static function ( ContainerInterface $container ): MyBankGateway { 'ppcp-local-apms.mybank.wc-gateway' => static function ( ContainerInterface $container ): MyBankGateway {
return new MyBankGateway( return new MyBankGateway(
$container->get( 'api.endpoint.orders' ), $container->get( 'api.endpoint.orders' ),
$container->get( 'api.factory.purchase-unit' ), $container->get( 'api.factory.purchase-unit' ),
@ -110,7 +110,7 @@ return array(
$container->get( 'wcgateway.transaction-url-provider' ) $container->get( 'wcgateway.transaction-url-provider' )
); );
}, },
'ppcp-local-apms.trustly.wc-gateway' => static function ( ContainerInterface $container ): TrustlyGateway { 'ppcp-local-apms.trustly.wc-gateway' => static function ( ContainerInterface $container ): TrustlyGateway {
return new TrustlyGateway( return new TrustlyGateway(
$container->get( 'api.endpoint.orders' ), $container->get( 'api.endpoint.orders' ),
$container->get( 'api.factory.purchase-unit' ), $container->get( 'api.factory.purchase-unit' ),
@ -139,14 +139,14 @@ return array(
$container->get( 'ppcp-local-apms.eps.wc-gateway' ) $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( return new IDealPaymentMethod(
$container->get( 'ppcp-local-apms.url' ), $container->get( 'ppcp-local-apms.url' ),
$container->get( 'ppcp.asset-version' ), $container->get( 'ppcp.asset-version' ),
$container->get( 'ppcp-local-apms.ideal.wc-gateway' ) $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( return new MyBankPaymentMethod(
$container->get( 'ppcp-local-apms.url' ), $container->get( 'ppcp-local-apms.url' ),
$container->get( 'ppcp.asset-version' ), $container->get( 'ppcp.asset-version' ),
@ -160,7 +160,7 @@ return array(
$container->get( 'ppcp-local-apms.p24.wc-gateway' ) $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( return new TrustlyPaymentMethod(
$container->get( 'ppcp-local-apms.url' ), $container->get( 'ppcp-local-apms.url' ),
$container->get( 'ppcp.asset-version' ), $container->get( 'ppcp.asset-version' ),

View file

@ -136,11 +136,10 @@ class IDealGateway extends WC_Payment_Gateway {
$payment_source = array( $payment_source = array(
'country_code' => $wc_order->get_billing_country(), 'country_code' => $wc_order->get_billing_country(),
'name' => $wc_order->get_billing_first_name() . ' ' . $wc_order->get_billing_last_name(), 'name' => $wc_order->get_billing_first_name() . ' ' . $wc_order->get_billing_last_name(),
); );
// TODO get "bic" from gateway settings. // TODO get "bic" from gateway settings.
$request_body = array( $request_body = array(
'intent' => 'CAPTURE', 'intent' => 'CAPTURE',
'payment_source' => array( 'payment_source' => array(

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* iDeal payment method. * IDeal payment method.
* *
* @package WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods * @package WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods
*/ */
@ -31,7 +31,7 @@ class IDealPaymentMethod extends AbstractPaymentMethodType {
private $version; private $version;
/** /**
* iDeal WC gateway. * IDeal WC gateway.
* *
* @var IDealGateway * @var IDealGateway
*/ */
@ -40,8 +40,8 @@ class IDealPaymentMethod extends AbstractPaymentMethodType {
/** /**
* IDealPaymentMethod constructor. * IDealPaymentMethod constructor.
* *
* @param string $module_url The URL of this module. * @param string $module_url The URL of this module.
* @param string $version The assets version. * @param string $version The assets version.
* @param IDealGateway $gateway IDeal WC gateway. * @param IDealGateway $gateway IDeal WC gateway.
*/ */
public function __construct( public function __construct(

View file

@ -47,9 +47,9 @@ class LocalAlternativePaymentMethodsModule implements ModuleInterface {
return $methods; return $methods;
} }
$payment_methods = $c->get('ppcp-local-apms.payment-methods'); $payment_methods = $c->get( 'ppcp-local-apms.payment-methods' );
foreach ($payment_methods as $key => $value) { foreach ( $payment_methods as $key => $value ) {
$methods[] = $c->get( 'ppcp-local-apms.' . $key . '.wc-gateway' ); $methods[] = $c->get( 'ppcp-local-apms.' . $key . '.wc-gateway' );
} }
return $methods; return $methods;
@ -72,11 +72,11 @@ class LocalAlternativePaymentMethodsModule implements ModuleInterface {
$customer_country = WC()->customer->get_billing_country() ?: WC()->customer->get_shipping_country(); $customer_country = WC()->customer->get_billing_country() ?: WC()->customer->get_shipping_country();
$site_currency = get_woocommerce_currency(); $site_currency = get_woocommerce_currency();
$payment_methods = $c->get('ppcp-local-apms.payment-methods'); $payment_methods = $c->get( 'ppcp-local-apms.payment-methods' );
foreach ($payment_methods as $payment_method) { foreach ( $payment_methods as $payment_method ) {
if ( if (
! in_array($customer_country, $payment_method['countries'], true) ! in_array( $customer_country, $payment_method['countries'], true )
|| ! in_array($site_currency, $payment_method['currencies'], true) || ! in_array( $site_currency, $payment_method['currencies'], true )
) { ) {
unset( $methods[ $payment_method['id'] ] ); unset( $methods[ $payment_method['id'] ] );
} }
@ -90,8 +90,8 @@ class LocalAlternativePaymentMethodsModule implements ModuleInterface {
add_action( add_action(
'woocommerce_blocks_payment_method_type_registration', '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'); $payment_methods = $c->get( 'ppcp-local-apms.payment-methods' );
foreach ($payment_methods as $key => $value) { foreach ( $payment_methods as $key => $value ) {
$payment_method_registry->register( $c->get( 'ppcp-local-apms.' . $key . '.payment-method' ) ); $payment_method_registry->register( $c->get( 'ppcp-local-apms.' . $key . '.payment-method' ) );
} }
} }
@ -99,8 +99,8 @@ class LocalAlternativePaymentMethodsModule implements ModuleInterface {
add_filter( add_filter(
'woocommerce_paypal_payments_localized_script_data', 'woocommerce_paypal_payments_localized_script_data',
function ( array $data ) use ($c) { function ( array $data ) use ( $c ) {
$payment_methods = $c->get('ppcp-local-apms.payment-methods'); $payment_methods = $c->get( 'ppcp-local-apms.payment-methods' );
$default_disable_funding = $data['url_params']['disable-funding'] ?? ''; $default_disable_funding = $data['url_params']['disable-funding'] ?? '';
$disable_funding = array_merge( array_keys( $payment_methods ), array_filter( explode( ',', $default_disable_funding ) ) ); $disable_funding = array_merge( array_keys( $payment_methods ), array_filter( explode( ',', $default_disable_funding ) ) );
@ -117,7 +117,7 @@ class LocalAlternativePaymentMethodsModule implements ModuleInterface {
* *
* @psalm-suppress MissingClosureParamType * @psalm-suppress MissingClosureParamType
*/ */
function( $order_id ) use($c) { function( $order_id ) use ( $c ) {
$order = wc_get_order( $order_id ); $order = wc_get_order( $order_id );
if ( ! $order instanceof WC_Order ) { if ( ! $order instanceof WC_Order ) {
return; return;
@ -128,9 +128,9 @@ class LocalAlternativePaymentMethodsModule implements ModuleInterface {
$order_key = wc_clean( wp_unslash( $_GET['key'] ?? '' ) ); $order_key = wc_clean( wp_unslash( $_GET['key'] ?? '' ) );
// phpcs:enable // phpcs:enable
$payment_methods = $c->get('ppcp-local-apms.payment-methods'); $payment_methods = $c->get( 'ppcp-local-apms.payment-methods' );
if ( if (
! $this->is_local_apm($order->get_payment_method(), $payment_methods) ! $this->is_local_apm( $order->get_payment_method(), $payment_methods )
|| ! $cancelled || ! $cancelled
|| $order->get_order_key() !== $order_key || $order->get_order_key() !== $order_key
) { ) {
@ -152,12 +152,12 @@ class LocalAlternativePaymentMethodsModule implements ModuleInterface {
* Check if given payment method is a local APM. * Check if given payment method is a local APM.
* *
* @param string $selected_payment_method Selected payment method. * @param string $selected_payment_method Selected payment method.
* @param array $payment_methods Available local APMs. * @param array $payment_methods Available local APMs.
* @return bool * @return bool
*/ */
private function is_local_apm(string $selected_payment_method, array $payment_methods): bool { private function is_local_apm( string $selected_payment_method, array $payment_methods ): bool {
foreach ($payment_methods as $payment_method) { foreach ( $payment_methods as $payment_method ) {
if($payment_method['id'] === $selected_payment_method) { if ( $payment_method['id'] === $selected_payment_method ) {
return true; return true;
} }
} }

View file

@ -40,8 +40,8 @@ class MyBankPaymentMethod extends AbstractPaymentMethodType {
/** /**
* MyBankPaymentMethod constructor. * MyBankPaymentMethod constructor.
* *
* @param string $module_url The URL of this module. * @param string $module_url The URL of this module.
* @param string $version The assets version. * @param string $version The assets version.
* @param MyBankGateway $gateway MyBank WC gateway. * @param MyBankGateway $gateway MyBank WC gateway.
*/ */
public function __construct( public function __construct(

View file

@ -40,8 +40,8 @@ class TrustlyPaymentMethod extends AbstractPaymentMethodType {
/** /**
* TrustlyPaymentMethod constructor. * TrustlyPaymentMethod constructor.
* *
* @param string $module_url The URL of this module. * @param string $module_url The URL of this module.
* @param string $version The assets version. * @param string $version The assets version.
* @param TrustlyGateway $gateway Trustly WC gateway. * @param TrustlyGateway $gateway Trustly WC gateway.
*/ */
public function __construct( public function __construct(