Skip to content

Commit

Permalink
add space after function keyword for anonymous functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristófer R committed Mar 21, 2024
1 parent 0c288f5 commit da7ed25
Show file tree
Hide file tree
Showing 47 changed files with 108 additions and 108 deletions.
4 changes: 2 additions & 2 deletions includes/admin/class-wc-payments-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,7 @@ public function add_transactions_notification_badge() {
* @return int The number of disputes which need a response.
*/
private function get_disputes_awaiting_response_count() {
$send_callback = function() {
$send_callback = function () {
$request = Request::get( WC_Payments_API_Client::DISPUTES_API . '/status_counts' );
$request->assign_hook( 'wcpay_get_dispute_status_counts' );
return $request->send();
Expand Down Expand Up @@ -1250,7 +1250,7 @@ private function get_uncaptured_transactions_count() {
$test_mode = WC_Payments::mode()->is_test();
$cache_key = $test_mode ? DATABASE_CACHE::AUTHORIZATION_SUMMARY_KEY_TEST_MODE : DATABASE_CACHE::AUTHORIZATION_SUMMARY_KEY;

$send_callback = function() {
$send_callback = function () {
$request = Request::get( WC_Payments_API_Client::AUTHORIZATIONS_API . '/summary' );
$request->assign_hook( 'wc_pay_get_authorizations_summary' );
return $request->send();
Expand Down
4 changes: 2 additions & 2 deletions includes/admin/tasks/class-wc-payments-task-disputes.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ private function get_disputes_needing_response_within_days( $num_days ) {
private function get_disputes_needing_response() {
return $this->database_cache->get_or_add(
Database_Cache::ACTIVE_DISPUTES_KEY,
function() {
function () {
$response = $this->api_client->get_disputes(
[
'pagesize' => 50,
Expand All @@ -337,7 +337,7 @@ function() {
// sort by due_by date ascending.
usort(
$active_disputes,
function( $a, $b ) {
function ( $a, $b ) {
$a_due_by = new \DateTime( $a['due_by'] );
$b_due_by = new \DateTime( $b['due_by'] );

Expand Down
2 changes: 1 addition & 1 deletion includes/admin/tracks/tracks-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function record_tracker_events() {
// Loaded on admin_init to ensure that we are in admin and that WC_Tracks is loaded.
add_action(
'admin_init',
function() {
function () {
if ( ! class_exists( 'WC_Tracks' ) ) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions includes/class-wc-payment-gateway-wcpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -3811,7 +3811,7 @@ public function get_payment_method_ids_enabled_at_checkout( $order_id = null, $f
in_array( Link_Payment_Method::PAYMENT_METHOD_STRIPE_ID, $enabled_payment_methods, true ) ) {
$enabled_payment_methods = array_filter(
$enabled_payment_methods,
static function( $method ) {
static function ( $method ) {
return Link_Payment_Method::PAYMENT_METHOD_STRIPE_ID !== $method;
}
);
Expand Down Expand Up @@ -4268,7 +4268,7 @@ private function upe_needs_redirection( $payment_methods ) {
* @return void
*/
private function handle_afterpay_shipping_requirement( WC_Order $order, Create_And_Confirm_Intention $request ): void {
$check_if_usable = function( array $address ): bool {
$check_if_usable = function ( array $address ): bool {
return $address['country'] && $address['state'] && $address['city'] && $address['postal_code'] && $address['line1'];
};

Expand Down
4 changes: 2 additions & 2 deletions includes/class-wc-payments-account.php
Original file line number Diff line number Diff line change
Expand Up @@ -1847,7 +1847,7 @@ private function get_actioned_notes(): array {
}

// Fetch the last 10 actioned wcpay-promo admin notifications.
$add_like_clause = function( $where_clause ) {
$add_like_clause = function ( $where_clause ) {
return $where_clause . " AND name like 'wcpay-promo-%'";
};

Expand Down Expand Up @@ -2023,7 +2023,7 @@ public function get_tracking_info( $force_refresh = false ): ?array {

return $this->database_cache->get_or_add(
Database_Cache::TRACKING_INFO_KEY,
function(): array {
function (): array {
return $this->payments_api_client->get_tracking_info();
},
'is_array', // We expect an array back from the cache.
Expand Down
2 changes: 1 addition & 1 deletion includes/class-wc-payments-captured-event-note.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ private function format_exchange_rate( float $rate, string $currency ): string {
[ 'decimals' => $num_decimals ]
);

$func_remove_ending_zeros = function( $str ) {
$func_remove_ending_zeros = function ( $str ) {
return rtrim( $str, '0' );
};

Expand Down
2 changes: 1 addition & 1 deletion includes/class-wc-payments-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ public function payment_fields() {
wp_enqueue_script( 'wcpay-upe-checkout' );
add_action(
'wp_footer',
function() use ( $payment_fields ) {
function () use ( $payment_fields ) {
wp_localize_script( 'wcpay-upe-checkout', 'wcpay_upe_config', $payment_fields );
}
);
Expand Down
2 changes: 1 addition & 1 deletion includes/class-wc-payments-fraud-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ function () {
// This is OK to do since we are not accepting data entries with HTML.
return WC_Payments_Utils::array_map_recursive(
$fraud_services,
function( $value ) {
function ( $value ) {
// Only apply `sanitize_text_field()` to string values since this function will cast to string.
if ( is_string( $value ) ) {
return sanitize_text_field( $value );
Expand Down
2 changes: 1 addition & 1 deletion includes/class-wc-payments-incentives-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function fetch_connect_incentive_details(): ?array {
if ( ! empty( $results ) ) {
$incentive = array_filter(
$results,
function( array $incentive ) {
function ( array $incentive ) {
return isset( $incentive['type'] ) && 'connect_page' === $incentive['type'];
}
)[0] ?? [];
Expand Down
2 changes: 1 addition & 1 deletion includes/class-wc-payments-status.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function render_status_report_section() { ?>
$adv_fraud_settings = json_decode( wp_json_encode( $this->gateway->get_option( 'advanced_fraud_protection_settings' ) ), true );
$list = array_filter(
array_map(
function( $rule ) {
function ( $rule ) {
if ( empty( $rule['key'] ) ) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion includes/core/server/class-request.php
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ public static function traverse_class_constants( string $constant_name, bool $un
* @return array The difference between the two arrays.
*/
private function array_diff( $array1, $array2 ) {
$arr_to_json = function( $item ) {
$arr_to_json = function ( $item ) {
return is_array( $item ) ? wp_json_encode( $item ) : $item;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function add_pay_for_order_params_to_js_config() {
if ( isset( $_GET['pay_for_order'] ) && isset( $_GET['key'] ) && current_user_can( 'pay_for_order', $order_id ) ) {
add_filter(
'wcpay_payment_fields_js_config',
function( $js_config ) use ( $order ) {
function ( $js_config ) use ( $order ) {
$session = wc()->session;
$session_email = '';

Expand Down
4 changes: 2 additions & 2 deletions includes/fraud-prevention/models/class-check.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public static function list( string $operator, array $checks ) {
if ( 0 < count(
array_filter(
$checks,
function( $check ) {
function ( $check ) {
return ! ( $check instanceof Check ); }
)
) ) {
Expand Down Expand Up @@ -203,7 +203,7 @@ public function to_array() {
return [
'operator' => $this->operator,
'checks' => array_map(
function( Check $check ) {
function ( Check $check ) {
return $check->to_array();
},
$this->checks
Expand Down
10 changes: 5 additions & 5 deletions includes/multi-currency/MultiCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ public function get_cached_currencies() {

return $this->database_cache->get_or_add(
Database_Cache::CURRENCIES_KEY,
function() {
function () {
try {
$currency_data = $this->payments_api_client->get_currency_rates( strtolower( get_woocommerce_currency() ) );
return [
Expand Down Expand Up @@ -646,7 +646,7 @@ private function initialize_enabled_currencies() {
// This allows to keep the alphabetical sorting by name.
$enabled_currencies = array_filter(
$available_currencies,
function( $currency ) use ( $enabled_currency_codes ) {
function ( $currency ) use ( $enabled_currency_codes ) {
return in_array( $currency->get_code(), $enabled_currency_codes, true );
}
);
Expand Down Expand Up @@ -1405,15 +1405,15 @@ private function simulate_client_currency() {
// Simulate client currency from geolocation.
add_filter(
'wcpay_multi_currency_override_notice_currency_name',
function( $selected_currency_name ) use ( $simulation_currency_name ) {
function ( $selected_currency_name ) use ( $simulation_currency_name ) {
return $simulation_currency_name;
}
);

// Simulate client country from geolocation.
add_filter(
'wcpay_multi_currency_override_notice_country',
function( $selected_country ) use ( $simulation_country ) {
function ( $selected_country ) use ( $simulation_country ) {
return $simulation_country;
}
);
Expand Down Expand Up @@ -1497,7 +1497,7 @@ private function add_simulation_params_to_preview_urls() {
$params = $this->simulation_params;
add_filter(
'wp_footer',
function() use ( $params ) {
function () use ( $params ) {
?>
<script type="text/javascript" id="wcpay_multi_currency-simulation-script">
// Add simulation overrides to all links.
Expand Down
2 changes: 1 addition & 1 deletion includes/wc-payment-api/class-wc-payments-api-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ public function get_timeline( $id ) {
// Sort by date desc, then by type desc as specified in events_order.
usort(
$timeline['data'],
function( $a, $b ) {
function ( $a, $b ) {
$result = $b['datetime'] <=> $a['datetime'];
if ( 0 !== $result ) {
return $result;
Expand Down
4 changes: 2 additions & 2 deletions src/Internal/Service/Level3Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function get_data_from_order( int $order_id ): array {
$order_items = array_values( $order->get_items( [ 'line_item', 'fee' ] ) );
$currency = $order->get_currency();

$process_item = function( $item ) use ( $currency ) {
$process_item = function ( $item ) use ( $currency ) {
return $this->process_item( $item, $currency );
};
$items_to_send = array_map( $process_item, $order_items );
Expand Down Expand Up @@ -171,7 +171,7 @@ private function bundle_level3_data_from_items( array $items ) {
$items_count = count( $items );
$total_cost = array_sum(
array_map(
function( $cost, $qty ) {
function ( $cost, $qty ) {
return $cost * $qty;
},
array_column( $items, 'unit_cost' ),
Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Service/PaymentContextLoggerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function log_changes( PaymentContext $context ): void {
*/
private function changes_to_str( $changes ) : array {
$changes_string = array_map(
function( Change $change ) {
function ( Change $change ) {
if ( $change->get_old_value() ) {
$str = "\t\tChanged " . $change->get_key() . ' from ' . $this->value_to_string( $change->get_old_value() ) .
' to ' . $this->value_to_string( $change->get_new_value() );
Expand Down
4 changes: 2 additions & 2 deletions tests/WCPAY_UnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected function mock_wcpay_request( string $request_class, int $total_api_cal
->with(
$this->callback(
// With filters there is a chance that mock will be changed. With this code we are sure that it belongs to same class.
function( $argument ) use ( $request_class, $request ) {
function ( $argument ) use ( $request_class, $request ) {
return get_class( $request ) === get_class( $argument ) || is_subclass_of( $argument, $request_class );
}
)
Expand All @@ -92,7 +92,7 @@ function( $argument ) use ( $request_class, $request ) {
}

// An anonymous callback, which will be used once and disposed.
$fn = function( $existing_request, $class_name ) use ( &$fn, $request ) {
$fn = function ( $existing_request, $class_name ) use ( &$fn, $request ) {
if ( ! is_null( $existing_request ) ) {
return $existing_request; // Another `mock_wcpay_request` in action.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ public function test_create_customer_from_order_guest_without_customer_id() {
->method( 'create_customer_for_user' )
->with(
$this->callback(
function( $argument ) {
function ( $argument ) {
return ( $argument instanceof WP_User ) && ! $argument->ID;
}
),
Expand All @@ -917,7 +917,7 @@ function( $argument ) {
->with(
$this->equalTo( 'cus_new' ),
$this->callback(
function( $argument ) {
function ( $argument ) {
return ( $argument instanceof WP_User ) && ! $argument->ID;
}
),
Expand Down Expand Up @@ -980,7 +980,7 @@ public function test_create_customer_from_order_guest_with_customer_id() {
->with(
$this->equalTo( 'cus_guest' ),
$this->callback(
function( $argument ) {
function ( $argument ) {
return ( $argument instanceof WP_User ) && ! $argument->ID;
}
),
Expand Down Expand Up @@ -1206,7 +1206,7 @@ public function test_create_terminal_intent_success() {
->method( 'set_metadata' )
->with(
$this->callback(
function( $metadata ) {
function ( $metadata ) {
return isset( $metadata['order_number'] );
}
)
Expand All @@ -1216,7 +1216,7 @@ function( $metadata ) {
->method( 'set_payment_method_types' )
->with(
$this->callback(
function( $argument ) {
function ( $argument ) {
return is_array( $argument ) && ! empty( $argument );
}
)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function _manually_load_plugin() {
// subscriptions funtionality.
add_filter(
'pre_option__wcpay_feature_subscriptions',
function() {
function () {
return '1';
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function test_exception_will_throw_if_amount_parameter_is_changed_when_fi
$request->set_currency_code( 'usd' );
add_filter(
'cac_test_exception_will_throw_if_immutable_parameter_is_changed_when_filter_is_applied',
function() {
function () {
$new_class = new class( $this->mock_api_client, $this->mock_wc_payments_http_client) extends Create_And_Confirm_Intention {

};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function test_exception_will_throw_if_amount_parameter_is_changed_when_fi
$request->set_currency_code( 'usd' );
add_filter(
'test_exception_will_throw_if_immutable_parameter_is_changed_when_filter_is_applied',
function() {
function () {
$new_class = new class( $this->mock_api_client, $this->mock_wc_payments_http_client) extends Create_Intention {

};
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/core/server/request/test-class-core-request.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function test_extension_by_multiple_classes() {

add_filter(
$hook,
function( $request ) {
function ( $request ) {
$modified = WooPay_Request::extend( $request );
$modified->set_param_2( 2 );
return $modified;
Expand All @@ -105,7 +105,7 @@ function( $request ) {

add_filter(
$hook,
function( $request ) {
function ( $request ) {
$modified = ThirdParty_Request::extend( $request );
$modified->set_param_3( 3 );
return $modified;
Expand All @@ -114,7 +114,7 @@ function( $request ) {

add_filter(
$hook,
function( $request ) {
function ( $request ) {
$modified = Another_ThirdParty_Request::extend( $request );
$modified->set_param_4( 4 );
return $modified;
Expand Down Expand Up @@ -147,7 +147,7 @@ public function test_extension_works_with_ids() {

add_filter(
$hook,
function( $base ) {
function ( $base ) {
return Request_With_Id::extend( $base );
}
);
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/core/server/request/test-class-get-request.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function test_exception_will_throw_if_api_route_is_invalid_when_request_f
$request->set_api( WC_Payments_API_Client::DEPOSITS_API );
add_filter(
'test_exception_will_throw_if_invalid_api_route_is_set_when_filter_is_applied',
function() {
function () {
$new_class = new class( $this->mock_api_client, $this->mock_wc_payments_http_client) extends Get_Request {

};
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/core/server/request/test-trait-order-info.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function test_build_order_info_with_subscriptions() {
$mock_subscription->set_parent( $mock_order );

WC_Subscriptions::set_wcs_get_subscriptions_for_order(
function( $parent_order ) use ( $mock_subscription ) {
function ( $parent_order ) use ( $mock_subscription ) {
return [ $mock_subscription ];
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function test_it_hashes_order_info() {
$ip_country = Country_Code::UNITED_KINGDOM;
add_filter(
'woocommerce_geolocate_ip',
function() use ( $ip_country ) {
function () use ( $ip_country ) {
return $ip_country;
}
);
Expand Down
Loading

0 comments on commit da7ed25

Please sign in to comment.