Skip to content

Commit

Permalink
Update phpcs and related sniffs (#8415)
Browse files Browse the repository at this point in the history
  • Loading branch information
reykjalin authored Mar 22, 2024
1 parent 61cce82 commit bc8ae14
Show file tree
Hide file tree
Showing 151 changed files with 763 additions and 620 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"require-dev": {
"composer/installers": "1.10.0",
"phpunit/phpunit": "9.5.14",
"woocommerce/woocommerce-sniffs": "0.1.0",
"woocommerce/woocommerce-sniffs": "1.0.0",
"woocommerce/action-scheduler": "3.1.6",
"kalessil/production-dependencies-guard": "dev-master",
"vimeo/psalm": "4.13.1",
Expand All @@ -44,7 +44,7 @@
"automattic/jetpack-changelogger": "3.3.2",
"spatie/phpunit-watcher": "1.23",
"woocommerce/qit-cli": "0.4.0",
"slevomat/coding-standard": "8.0.0",
"slevomat/coding-standard": "8.15.0",
"dg/bypass-finals": "1.5.1"
},
"scripts": {
Expand Down
792 changes: 512 additions & 280 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion includes/admin/class-wc-payments-admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function display_test_mode_notice() {
<p>
<b><?php esc_html_e( 'Test mode active: ', 'woocommerce-payments' ); ?></b>
<?php
echo sprintf(
printf(
/* translators: %s: WooPayments */
esc_html__( "All transactions are simulated. Customers can't make real purchases through %s.", 'woocommerce-payments' ),
'WooPayments'
Expand Down
6 changes: 3 additions & 3 deletions includes/admin/class-wc-payments-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function display_not_supported_currency_notice() {
<?php esc_html( ' ' . get_woocommerce_currency() ); ?>
</b>
<?php
echo sprintf(
printf(
/* translators: %s: WooPayments*/
esc_html__( 'The selected currency is not available for the country set in your %s account.', 'woocommerce-payments' ),
'WooPayments'
Expand Down Expand Up @@ -1219,7 +1219,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 @@ -1249,7 +1249,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
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,4 @@ public function get_loans() {
$request->assign_hook( 'wcpay_get_loans_request' );
return $request->handle_rest_request();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -277,5 +277,4 @@ public function get_item_schema() {
],
];
}

}
6 changes: 2 additions & 4 deletions includes/admin/class-wc-rest-payments-files-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public function register_routes() {
'permission_callback' => [],
]
);

}

/**
Expand Down Expand Up @@ -118,7 +117,7 @@ public function get_file( WP_REST_Request $request ) {
*/
add_filter(
'rest_pre_serve_request',
function ( bool $served, WP_HTTP_Response $response ) : bool {
function ( bool $served, WP_HTTP_Response $response ): bool {
echo $response->get_data(); // @codingStandardsIgnoreLine
return true;
},
Expand All @@ -134,7 +133,6 @@ function ( bool $served, WP_HTTP_Response $response ) : bool {
'Content-Disposition' => 'inline',
]
);

}

/**
Expand Down Expand Up @@ -191,7 +189,7 @@ public function get_file_content( WP_REST_Request $request ) {
*
* @return WP_Error
*/
private function file_error_response( WP_Error $error ) : WP_Error {
private function file_error_response( WP_Error $error ): WP_Error {
$error_status_code = 'resource_missing' === $error->get_error_code() ? WP_Http::NOT_FOUND : WP_Http::INTERNAL_SERVER_ERROR;
return new WP_Error(
$error->get_error_code(),
Expand Down
4 changes: 2 additions & 2 deletions includes/admin/class-wc-rest-payments-orders-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ public function create_terminal_intent( $request ) {
* @return array|null
* @throws \Exception
*/
public function get_terminal_intent_payment_method( $request, array $default_value = [ Payment_Method::CARD_PRESENT ] ) :array {
public function get_terminal_intent_payment_method( $request, array $default_value = [ Payment_Method::CARD_PRESENT ] ): array {
$payment_methods = $request->get_param( 'payment_methods' );
if ( null === $payment_methods ) {
return $default_value;
Expand Down Expand Up @@ -446,7 +446,7 @@ public function get_terminal_intent_payment_method( $request, array $default_val
* @return string|null
* @throws \Exception
*/
public function get_terminal_intent_capture_method( $request, string $default_value = 'manual' ) : string {
public function get_terminal_intent_capture_method( $request, string $default_value = 'manual' ): string {
$capture_method = $request->get_param( 'capture_method' );
if ( null === $capture_method ) {
return $default_value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,4 @@ public function get_payment_intent( $request ) {

return $this->forward_request( 'get_intent', [ $payment_intent_id ] );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,4 @@ public function prepare_item_for_response( $item, $request ) {

return rest_ensure_response( $prepared_item );
}


}
1 change: 0 additions & 1 deletion includes/admin/class-wc-rest-user-exists-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,3 @@ public function user_exists( WP_REST_Request $request ): WP_REST_Response {
);
}
}

1 change: 0 additions & 1 deletion includes/admin/class-wc-rest-woopay-session-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,3 @@ private function is_request_from_woopay(): bool {
return isset( $_SERVER['HTTP_USER_AGENT'] ) && 'WooPay' === $_SERVER['HTTP_USER_AGENT'];
}
}

5 changes: 2 additions & 3 deletions includes/admin/tasks/class-wc-payments-task-disputes.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ public function get_additional_info() {
),
count( (array) $this->disputes_due_within_7d )
);

}

/**
Expand Down Expand Up @@ -325,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 @@ -338,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
2 changes: 1 addition & 1 deletion includes/class-duplicate-payment-prevention-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function check_payment_intent_attached_to_order_succeeded( WC_Order $orde
} catch ( Exception $e ) {
Logger::error( 'Failed to fetch attached payment intent: ' . $e );
return;
};
}

if ( ! $intent->is_authorized() ) {
return;
Expand Down
1 change: 0 additions & 1 deletion includes/class-experimental-abtest.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,3 @@ protected function request_variation( $test_name ) {
return $get;
}
}

6 changes: 3 additions & 3 deletions includes/class-wc-payment-gateway-wcpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -1999,7 +1999,7 @@ public function get_payment_method_to_use_for_intent() {
* @param Payment_Information $payment_information Payment information object for transaction.
* @return array List of payment methods.
*/
public function get_payment_method_types( $payment_information ) : array {
public function get_payment_method_types( $payment_information ): array {
$requested_payment_method = sanitize_text_field( wp_unslash( $_POST['payment_method'] ?? '' ) ); // phpcs:ignore WordPress.Security.NonceVerification
$token = $payment_information->get_payment_token();

Expand Down Expand Up @@ -3813,7 +3813,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 @@ -4300,7 +4300,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
28 changes: 14 additions & 14 deletions includes/class-wc-payments-account.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ public function get_account_status_data(): array {
*
* @return string Account statement descriptor.
*/
public function get_statement_descriptor() : string {
public function get_statement_descriptor(): string {
$account = $this->get_cached_account_data();
return ! empty( $account ) && isset( $account['statement_descriptor'] ) ? $account['statement_descriptor'] : '';
}
Expand All @@ -325,7 +325,7 @@ public function get_statement_descriptor() : string {
*
* @return string Account statement descriptor.
*/
public function get_statement_descriptor_kanji() : string {
public function get_statement_descriptor_kanji(): string {
$account = $this->get_cached_account_data();
return ! empty( $account ) && isset( $account['statement_descriptor_kanji'] ) ? $account['statement_descriptor_kanji'] : '';
}
Expand All @@ -335,7 +335,7 @@ public function get_statement_descriptor_kanji() : string {
*
* @return string Account statement descriptor.
*/
public function get_statement_descriptor_kana() : string {
public function get_statement_descriptor_kana(): string {
$account = $this->get_cached_account_data();
return ! empty( $account ) && isset( $account['statement_descriptor_kana'] ) ? $account['statement_descriptor_kana'] : '';
}
Expand All @@ -345,7 +345,7 @@ public function get_statement_descriptor_kana() : string {
*
* @return string Business profile name.
*/
public function get_business_name() : string {
public function get_business_name(): string {
$account = $this->get_cached_account_data();
return isset( $account['business_profile']['name'] ) ? $account['business_profile']['name'] : '';
}
Expand All @@ -355,7 +355,7 @@ public function get_business_name() : string {
*
* @return string Business profile url.
*/
public function get_business_url() : string {
public function get_business_url(): string {
$account = $this->get_cached_account_data();
return isset( $account['business_profile']['url'] ) ? $account['business_profile']['url'] : '';
}
Expand All @@ -365,7 +365,7 @@ public function get_business_url() : string {
*
* @return array Business profile support address.
*/
public function get_business_support_address() : array {
public function get_business_support_address(): array {
$account = $this->get_cached_account_data();
return isset( $account['business_profile']['support_address'] ) ? $account['business_profile']['support_address'] : [];
}
Expand All @@ -375,7 +375,7 @@ public function get_business_support_address() : array {
*
* @return string Business profile support email.
*/
public function get_business_support_email() : string {
public function get_business_support_email(): string {
$account = $this->get_cached_account_data();
return isset( $account['business_profile']['support_email'] ) ? $account['business_profile']['support_email'] : '';
}
Expand All @@ -385,7 +385,7 @@ public function get_business_support_email() : string {
*
* @return string Business profile support phone.
*/
public function get_business_support_phone() : string {
public function get_business_support_phone(): string {
$account = $this->get_cached_account_data();
return isset( $account['business_profile']['support_phone'] ) ? $account['business_profile']['support_phone'] : '';
}
Expand All @@ -395,7 +395,7 @@ public function get_business_support_phone() : string {
*
* @return string branding logo.
*/
public function get_branding_logo() : string {
public function get_branding_logo(): string {
$account = $this->get_cached_account_data();
return isset( $account['branding']['logo'] ) ? $account['branding']['logo'] : '';
}
Expand All @@ -405,7 +405,7 @@ public function get_branding_logo() : string {
*
* @return string branding icon.
*/
public function get_branding_icon() : string {
public function get_branding_icon(): string {
$account = $this->get_cached_account_data();
return isset( $account['branding']['icon'] ) ? $account['branding']['icon'] : '';
}
Expand All @@ -415,7 +415,7 @@ public function get_branding_icon() : string {
*
* @return string branding primary color.
*/
public function get_branding_primary_color() : string {
public function get_branding_primary_color(): string {
$account = $this->get_cached_account_data();
return isset( $account['branding']['primary_color'] ) ? $account['branding']['primary_color'] : '';
}
Expand All @@ -425,7 +425,7 @@ public function get_branding_primary_color() : string {
*
* @return string branding secondary color.
*/
public function get_branding_secondary_color() : string {
public function get_branding_secondary_color(): string {
$account = $this->get_cached_account_data();
return isset( $account['branding']['secondary_color'] ) ? $account['branding']['secondary_color'] : '';
}
Expand Down 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
3 changes: 2 additions & 1 deletion includes/class-wc-payments-action-scheduler-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class WC_Payments_Action_Scheduler_Service {
* @param WC_Payments_Order_Service $order_service - Order Service.
*/
public function __construct(
WC_Payments_API_Client $payments_api_client, WC_Payments_Order_Service $order_service
WC_Payments_API_Client $payments_api_client,
WC_Payments_Order_Service $order_service
) {
$this->payments_api_client = $payments_api_client;
$this->order_service = $order_service;
Expand Down
3 changes: 1 addition & 2 deletions includes/class-wc-payments-captured-event-note.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,6 @@ private function format_fx(
self::format_exchange_rate( $exchange_rate, $to_currency ),
WC_Payments_Utils::format_explicit_currency( $to_display_amount, $to_currency, false )
);

}

/**
Expand All @@ -410,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
3 changes: 1 addition & 2 deletions includes/class-wc-payments-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,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 Expand Up @@ -448,5 +448,4 @@ public function set_gateway( $payment_method_id ) {
$this->gateway = $this->gateway->wc_payments_get_payment_gateway_by_id( $payment_method_id );
}
}

}
Loading

0 comments on commit bc8ae14

Please sign in to comment.