Skip to content

Commit

Permalink
phpcs fixes for variable naming, params, etc
Browse files Browse the repository at this point in the history
FILE: includes/Handlers/Product/Woo_SOR.php
-----------------------------------------------------------------------------------------------
FOUND 14 ERRORS AND 0 WARNINGS AFFECTING 14 LINES
-----------------------------------------------------------------------------------------------
  87 | ERROR | Using short ternaries is not allowed as they are rarely used correctly (Universal.Operators.DisallowShortTernary.Found)
 113 | ERROR | The parameter "array( 'hide_empty' => false )" at position #2 of get_terms() has been deprecated since WordPress version 4.5.0. Instead do not pass the parameter. (WordPress.WP.DeprecatedParameters.Get_termsParam2Found)
 142 | ERROR | Variable "$CatalogItemOptionForItem" is not in valid snake_case format, try "$catalog_item_option_for_item" (WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase)
 143 | ERROR | Variable "$CatalogItemOptionForItem" is not in valid snake_case format, try "$catalog_item_option_for_item" (WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase)
 144 | ERROR | Variable "$CatalogItemOptionForItem" is not in valid snake_case format, try "$catalog_item_option_for_item" (WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase)
 348 | ERROR | Variable "$CatalogItemOptionValueForItemVariation" is not in valid snake_case format, try "$catalog_item_option_value_for_item_variation" (WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase)
 349 | ERROR | Variable "$CatalogItemOptionValueForItemVariation" is not in valid snake_case format, try "$catalog_item_option_value_for_item_variation" (WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase)
 350 | ERROR | Variable "$CatalogItemOptionValueForItemVariation" is not in valid snake_case format, try "$catalog_item_option_value_for_item_variation" (WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase)
 352 | ERROR | Variable "$CatalogItemOptionValueForItemVariation" is not in valid snake_case format, try "$catalog_item_option_value_for_item_variation" (WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase)
 357 | ERROR | The parameter "array( 'hide_empty' => false )" at position #2 of get_terms() has been deprecated since WordPress version 4.5.0. Instead do not pass the parameter. (WordPress.WP.DeprecatedParameters.Get_termsParam2Found)
 378 | ERROR | Variable "$CatalogItemOptionValueForItemVariation" is not in valid snake_case format, try "$catalog_item_option_value_for_item_variation" (WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase)
 379 | ERROR | Variable "$CatalogItemOptionValueForItemVariation" is not in valid snake_case format, try "$catalog_item_option_value_for_item_variation" (WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase)
 380 | ERROR | Variable "$CatalogItemOptionValueForItemVariation" is not in valid snake_case format, try "$catalog_item_option_value_for_item_variation" (WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase)
 382 | ERROR | Variable "$CatalogItemOptionValueForItemVariation" is not in valid snake_case format, try "$catalog_item_option_value_for_item_variation" (WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase)
-----------------------------------------------------------------------------------------------
  • Loading branch information
faisal-alvi committed Nov 13, 2024
1 parent 83f0b20 commit d194709
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions includes/Handlers/Product/Woo_SOR.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static function update_catalog_item( CatalogObject $catalog_object, \WC_P
$attributes = $product->get_attributes();

$product_variation_ids = $product->get_children();
$catalog_variations = $item_data->getVariations() ?: array();
$catalog_variations = $item_data->getVariations() ? $item_data->getVariations() : array();

// if dealing with a variable product, try and match the variations
if ( $product->is_type( 'variable' ) ) {
Expand All @@ -110,7 +110,7 @@ public static function update_catalog_item( CatalogObject $catalog_object, \WC_P
// Check if its a taxonomy-based attribute.
$attribute_option_values = array();
if ( taxonomy_exists( $attribute_id ) ) {
$terms = get_terms( $attribute_id, array( 'hide_empty' => false ) );
$terms = get_terms( $attribute_id );
$attribute_option_values = wp_list_pluck( $terms, 'name' );
} else {
$attribute_option_values = $attribute->get_options();
Expand Down Expand Up @@ -139,9 +139,9 @@ public static function update_catalog_item( CatalogObject $catalog_object, \WC_P
$product_options = array();

foreach ( $options_ids as $option_id ) {
$CatalogItemOptionForItem = new \Square\Models\CatalogItemOptionForItem();
$CatalogItemOptionForItem->setItemOptionId( $option_id );
$product_options[] = $CatalogItemOptionForItem;
$item_option = new \Square\Models\CatalogItemOptionForItem();
$item_option->setItemOptionId( $option_id );
$product_options[] = $item_option;
}

$catalog_object->getItemData()->setItemOptions( $product_options );
Expand Down Expand Up @@ -345,16 +345,16 @@ public static function update_catalog_variation( CatalogObject $catalog_object,
}

if ( $option_id && $option_value_id ) {
$CatalogItemOptionValueForItemVariation = new \Square\Models\CatalogItemOptionValueForItemVariation();
$CatalogItemOptionValueForItemVariation->setItemOptionId( $option_id );
$CatalogItemOptionValueForItemVariation->setItemOptionValueId( $option_value_id );
$option_value_object = new \Square\Models\CatalogItemOptionValueForItemVariation();
$option_value_object->setItemOptionId( $option_id );
$option_value_object->setItemOptionValueId( $option_value_id );

$variation_item_values[] = $CatalogItemOptionValueForItemVariation;
$variation_item_values[] = $option_value_object;
} else {

if ( $taxonomy_exists ) {
// Get all attribute terms from Woo taxonomy.
$attribute_option_values = get_terms( $attribute_id, array( 'hide_empty' => false ) );
$attribute_option_values = get_terms( $attribute_id );
$attribute_option_values = wp_list_pluck( $attribute_option_values, 'name' );
} else {
// Get all attribute values from the parent product.
Expand All @@ -375,11 +375,11 @@ public static function update_catalog_variation( CatalogObject $catalog_object,
}
}

$CatalogItemOptionValueForItemVariation = new \Square\Models\CatalogItemOptionValueForItemVariation();
$CatalogItemOptionValueForItemVariation->setItemOptionId( $option_id );
$CatalogItemOptionValueForItemVariation->setItemOptionValueId( $option_value_id );
$option_value_object = new \Square\Models\CatalogItemOptionValueForItemVariation();
$option_value_object->setItemOptionId( $option_id );
$option_value_object->setItemOptionValueId( $option_value_id );

$variation_item_values[] = $CatalogItemOptionValueForItemVariation;
$variation_item_values[] = $option_value_object;
}
}

Expand Down

0 comments on commit d194709

Please sign in to comment.