Skip to content

Commit

Permalink
Update PHPCS config
Browse files Browse the repository at this point in the history
  • Loading branch information
brezocordero authored Jul 26, 2024
2 parents 5a5d954 + 7d0c805 commit 455a270
Show file tree
Hide file tree
Showing 28 changed files with 55 additions and 68 deletions.
2 changes: 0 additions & 2 deletions includes/API/Catalog/Product_Group/Products/Read/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,4 @@ public static function get_rate_limit_id() {

return 'ads_management';
}


}
2 changes: 0 additions & 2 deletions includes/API/Catalog/Product_Group/Products/Read/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,4 @@ public function get_ids() {

return $product_item_ids;
}


}
2 changes: 0 additions & 2 deletions includes/API/Catalog/Product_Item/Find/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,4 @@ public function get_params() {

return array( 'fields' => 'id,product_group{id}' );
}


}
2 changes: 0 additions & 2 deletions includes/API/Catalog/Send_Item_Updates/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,4 @@ public function get_data() {
'item_type' => 'PRODUCT_ITEM',
);
}


}
4 changes: 2 additions & 2 deletions includes/API/FBE/Configuration/Read/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Response extends API\Response {
* @return boolean
*/
public function is_ig_shopping_enabled(): bool {
return ! ! $this->response_data['ig_shopping']['enabled'] ?? false;
return (bool) $this->response_data['ig_shopping']['enabled'] ?? false;
}

/**
Expand All @@ -27,6 +27,6 @@ public function is_ig_shopping_enabled(): bool {
* @return boolean
*/
public function is_ig_cta_enabled(): bool {
return ! ! $this->response_data['ig_cta']['enabled'];
return (bool) $this->response_data['ig_cta']['enabled'];
}
}
2 changes: 0 additions & 2 deletions includes/API/FBE/Configuration/Update/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,4 @@ public function set_plugin_version( string $plugin_version ) {
),
);
}


}
2 changes: 0 additions & 2 deletions includes/API/Pixel/Events/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,4 @@ public function get_data() {
*/
return apply_filters( 'wc_facebook_api_pixel_event_request_data', $data, $this );
}


}
2 changes: 1 addition & 1 deletion includes/API/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function get_retry_count() {
* @since 2.1.0
*/
public function mark_retry() {
$this->retry_count++;
++$this->retry_count;
}


Expand Down
2 changes: 0 additions & 2 deletions includes/API/Traits/Idempotent_Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,4 @@ public function get_idempotency_key() {

return $this->idempotency_key;
}


}
2 changes: 0 additions & 2 deletions includes/API/Traits/Rate_Limited_Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,4 @@ public function get_rate_limit_estimated_time_to_regain_access( $headers ) {

return ! empty( $usage_data['estimated_time_to_regain_access'] ) ? (int) $usage_data['estimated_time_to_regain_access'] : null;
}


}
9 changes: 4 additions & 5 deletions includes/Admin/Enhanced_Catalog_Attribute_Fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,20 @@ private function extract_attribute( &$attributes, $key ) {
public function render( $category_id ) {
$all_attributes = $this->category_handler->get_attributes_with_fallback_to_parent_category( $category_id );
$all_attributes_with_values = array_map(
function( $attribute ) use ( $category_id ) {
function ( $attribute ) use ( $category_id ) {
return array_merge( $attribute, array( 'value' => $this->get_value( $attribute['key'], $category_id ) ) );
},
$all_attributes
);
$recommended_attributes = array_filter(
$all_attributes_with_values,
function( $attr ) {
function ( $attr ) {
return $attr['recommended'];
}
);
$optional_attributes = array_filter(
$all_attributes_with_values,
function( $attr ) {
function ( $attr ) {
return ! $attr['recommended'];
}
);
Expand All @@ -117,7 +117,7 @@ function( $attr ) {
$this->extract_attribute( $optional_attributes, 'size' ),
$this->extract_attribute( $optional_attributes, 'gender' ),
),
function( $attr ) {
function ( $attr ) {
return ! is_null( $attr );
}
);
Expand Down Expand Up @@ -266,7 +266,6 @@ private function render_field( $attr_id, $attribute ) {
// string
$this->render_text_field( $attr_id, $attribute, $placeholder );
}

}

private function render_select_field( $attr_id, $attribute ) {
Expand Down
4 changes: 2 additions & 2 deletions includes/Admin/Notes/SettingsMoved.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

defined( 'ABSPATH' ) || exit;

use \Automattic\WooCommerce\Admin\Notes\Note;
use \Automattic\WooCommerce\Admin\Notes\NoteTraits;
use Automattic\WooCommerce\Admin\Notes\Note;
use Automattic\WooCommerce\Admin\Notes\NoteTraits;

/**
* SettingsMoved class.
Expand Down
16 changes: 7 additions & 9 deletions includes/Admin/Product_Categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ public function render_edit_enhanced_catalog_attributes_field( \WP_Term $term, $

if (
empty( $category_id ) ||
$category_handler->is_category( $category_id ) &&
$category_handler->is_root_category( $category_id )
( $category_handler->is_category( $category_id ) &&
$category_handler->is_root_category( $category_id ) )
) {
// show nothing
?>
Expand Down Expand Up @@ -314,8 +314,8 @@ public function render_add_enhanced_catalog_attributes_field( $category_id ) {

if (
empty( $category_id ) ||
$category_handler->is_category( $category_id ) &&
$category_handler->is_root_category( $category_id )
( $category_handler->is_category( $category_id ) &&
$category_handler->is_root_category( $category_id ) )
) {
// show nothing
return;
Expand Down Expand Up @@ -377,7 +377,7 @@ public function save_google_product_category_and_enhanced_attributes( $term_id,
$google_product_category_id = wc_clean( Helper::get_posted_value( self::FIELD_GOOGLE_PRODUCT_CATEGORY_ID ) );

\WooCommerce\Facebook\Product_Categories::update_google_product_category_id( $term_id, $google_product_category_id );
$this->save_enhanced_catalog_attributes( $term_id, $tt_id, $taxonomy );
$this->save_enhanced_catalog_attributes( $term_id );

$term = get_term( $term_id, $taxonomy );

Expand Down Expand Up @@ -423,11 +423,9 @@ public function save_google_product_category_and_enhanced_attributes( $term_id,
*
* @since 2.1.0
*
* @param int $term_id term ID.
* @param int $tt_id term taxonomy ID.
* @param string $taxonomy Taxonomy slug.
* @param int $term_id term ID.
*/
public function save_enhanced_catalog_attributes( $term_id, $tt_id, $taxonomy ) {
public function save_enhanced_catalog_attributes( $term_id ) {
$enhanced_catalog_attributes = \WooCommerce\Facebook\Products::get_enhanced_catalog_attributes_from_request();

foreach ( $enhanced_catalog_attributes as $key => $value ) {
Expand Down
11 changes: 8 additions & 3 deletions includes/Admin/Product_Sets.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ public function category_field_on_edit( $term ) {
* @param int $term_id Term ID.
* @param int $tt_id Term taxonomy ID.
*/
public function save_custom_field( $term_id, $tt_id ) {
public function save_custom_field( $term_id, $tt_id ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
$wc_product_cats = empty( $_POST[ $this->categories_field ] ) ? '' : wc_clean( wp_unslash( $_POST[ $this->categories_field ] ) ); //phpcs:ignore
if ( ! empty( $wc_product_cats ) ) {
$wc_product_cats = array_map(
function( $item ) {
function ( $item ) {
return absint( $item );
},
$wc_product_cats
Expand Down Expand Up @@ -149,7 +149,12 @@ protected function get_field_label() {
*/
protected function get_field( $term_id = '' ) {
$saved_items = get_term_meta( $term_id, $this->categories_field, true );
$product_cats = get_terms( 'product_cat', array( 'hide_empty' => 0 ) );
$product_cats = get_terms(
array(
'taxonomy' => 'product_cat',
'hide_empty' => false,
)
);
?>
<div class="select2 updating-message"><p></p></div>
<select
Expand Down
8 changes: 4 additions & 4 deletions includes/Admin/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public static function render_enhanced_catalog_attributes_fields( $category_id,
);
if (
empty( $category_id ) ||
$category_handler->is_category( $category_id ) &&
$category_handler->is_root_category( $category_id )
( $category_handler->is_category( $category_id ) &&
$category_handler->is_root_category( $category_id ) )
) {
// show nothing
return;
Expand Down Expand Up @@ -170,7 +170,7 @@ private static function filter_available_product_attribute_names( \WC_Product $p
*/
public static function get_available_product_attribute_names( \WC_Product $product ) {
return array_map(
function( $attribute ) use ( $product ) {
function ( $attribute ) use ( $product ) {
return wc_attribute_label( $attribute->get_name(), $product );
},
Products_Handler::get_available_product_attributes( $product )
Expand Down Expand Up @@ -210,7 +210,7 @@ public static function render_commerce_fields( \WC_Product $product ) {
<div id="variable-product-not-ready-notice" style="display:none;">
<p>
<?php
echo sprintf(
printf(
/* translators: Placeholders %1$s - strong opening tag, %2$s - strong closing tag */
esc_html__( 'To sell this product on Instagram, at least one variation must be synced to Facebook. You can control variation sync on the %1$sVariations%2$s tab with the %1$sFacebook Sync%2$s setting.', 'facebook-for-woocommerce' ),
'<strong>',
Expand Down
6 changes: 4 additions & 2 deletions includes/Admin/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ private function connect_to_enhanced_admin( $screen_id ) {
$crumbs = array(
__( 'Facebook for WooCommerce', 'facebook-for-woocommerce' ),
);
//phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( ! empty( $_GET['tab'] ) ) {
//phpcs:ignore WordPress.Security.NonceVerification.Recommended
switch ( $_GET['tab'] ) {
case Connection::ID:
$crumbs[] = __( 'Connection', 'facebook-for-woocommerce' );
Expand Down Expand Up @@ -302,7 +304,7 @@ public function get_screens() {
// ensure no bogus values are added via filter
$screens = array_filter(
$screens,
function( $value ) {
function ( $value ) {
return $value instanceof Abstract_Settings_Screen;
}
);
Expand Down Expand Up @@ -362,7 +364,7 @@ private function register_woo_nav_menu_items() {
'order' => $order,
)
);
$order++;
++$order;
}
}
}
1 change: 0 additions & 1 deletion includes/ExternalVersionUpdate/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,4 @@ public function send_new_version_to_facebook_server() {
return false;
}
}

}
1 change: 1 addition & 0 deletions includes/Framework/Api/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ public function set_tls_1_2_request( $handle, $r, $url ) {
if ( ! Helper::str_starts_with( $url, 'https://' ) ) {
return;
}
//phpcs:ignore: WordPress.WP.AlternativeFunctions.curl_curl_setopt
curl_setopt( $handle, CURLOPT_SSLVERSION, 6 );
}

Expand Down
1 change: 0 additions & 1 deletion includes/Framework/Api/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ public function to_string();
* @return string the request, safe for logging/displaying
*/
public function to_string_safe();

}
4 changes: 2 additions & 2 deletions includes/Framework/Utilities/BackgroundJobHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,8 @@ public function process_job( $job, $items_per_batch = null ) {
// process the item
$this->process_item( $item, $job );

$processed++;
$job->progress++;
++$processed;
++$job->progress;

// update job progress
$job = $this->update_job( $job );
Expand Down
1 change: 0 additions & 1 deletion includes/Jobs/CleanupSkyvergeFrameworkJobOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,4 @@ public function clean_up_old_completed_options() {
LIMIT 500"
);
}

}
5 changes: 2 additions & 3 deletions includes/Jobs/DeleteProductsFromFBCatalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
*/
class DeleteProductsFromFBCatalog extends AbstractChainedJob {

use BatchQueryOffset, LoggingTrait;
use BatchQueryOffset;
use LoggingTrait;

/**
* Called before starting the job.
Expand Down Expand Up @@ -57,7 +58,6 @@ protected function get_items_for_batch( int $batch_number, array $args ): array
);

return array_map( 'intval', $products );

}

/**
Expand Down Expand Up @@ -125,5 +125,4 @@ public function get_plugin_name(): string {
public function get_batch_size(): int {
return 25;
}

}
5 changes: 2 additions & 3 deletions includes/Jobs/ResetAllProductsFBSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
*/
class ResetAllProductsFBSettings extends AbstractChainedJob {

use BatchQueryOffset, LoggingTrait;
use BatchQueryOffset;
use LoggingTrait;

/**
* Called before starting the job.
Expand Down Expand Up @@ -57,7 +58,6 @@ protected function get_items_for_batch( int $batch_number, array $args ): array
);

return array_map( 'intval', $products );

}

/**
Expand Down Expand Up @@ -116,5 +116,4 @@ public function get_plugin_name(): string {
public function get_batch_size(): int {
return 25;
}

}
5 changes: 1 addition & 4 deletions includes/ProductSync/ProductValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,8 @@ protected function validate_product_sync_field() {

// Variable product has no variations with sync enabled so it shouldn't be synced.
throw $invalid_exception;
} else {
if ( 'no' === $this->product->get_meta( self::SYNC_ENABLED_META_KEY ) ) {
} elseif ( 'no' === $this->product->get_meta( self::SYNC_ENABLED_META_KEY ) ) {
throw $invalid_exception;
}
}
}

Expand Down Expand Up @@ -443,5 +441,4 @@ protected function validate_variation_structure() {
throw new ProductInvalidException( __( 'Too many attributes selected for product. Use 4 or less.', 'facebook-for-woocommerce' ) );
}
}

}
4 changes: 2 additions & 2 deletions includes/Products/Sync/Background.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ public function process_items( $job, $data, $items_per_batch = null ) {
facebook_for_woocommerce()->log( "Background sync error: {$e->getMessage()}" );
}

$processed++;
$job->progress++;
++$processed;
++$job->progress;
// update job progress
$job = $this->update_job( $job );
// job limits reached
Expand Down
Loading

0 comments on commit 455a270

Please sign in to comment.