From 64508a3909568549404bcc3caa370e9dccd7a5eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 20 Apr 2024 23:45:52 +0200 Subject: [PATCH] fix phpstan (#29397) --- .../class/ProductCombination.class.php | 28 +++++++++---------- htdocs/variants/combinations.php | 11 ++++---- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 63fc85ce623..aa0558c2b8a 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -1,8 +1,9 @@ - * Copyright (C) 2018 Juanjo Menent - * Copyright (C) 2022 Open-Dsi - * Copyright (C) 2024 MDW +/* Copyright (C) 2016 Marcos García + * Copyright (C) 2018 Juanjo Menent + * Copyright (C) 2022 Open-Dsi + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -718,16 +719,16 @@ class ProductCombination * [...] * ) * - * @param User $user Object user - * @param Product $product Parent product - * @param array> $combinations Attribute and value combinations. + * @param User $user Object user + * @param Product $product Parent product + * @param array $combinations Attribute and value combinations. * @param array> $variations Price and weight variations - * @param bool|array $price_var_percent Is the price variation a relative variation? - * @param bool|float $forced_pricevar If the price variation is forced - * @param bool|float $forced_weightvar If the weight variation is forced - * @param bool|string $forced_refvar If the reference is forced - * @param string $ref_ext External reference - * @return int<-1,1> Return integer <0 KO, >0 OK + * @param bool|array $price_var_percent Is the price variation a relative variation? + * @param bool|float $forced_pricevar If the price variation is forced + * @param bool|float $forced_weightvar If the weight variation is forced + * @param bool|string $forced_refvar If the reference is forced + * @param string $ref_ext External reference + * @return int<-1,1> Return integer <0 KO, >0 OK */ public function createProductCombination(User $user, Product $product, array $combinations, array $variations, $price_var_percent = false, $forced_pricevar = false, $forced_weightvar = false, $forced_refvar = false, $ref_ext = '') { @@ -794,7 +795,6 @@ class ProductCombination $prodattrval = new ProductAttributeValue($this->db); // $combination contains list of attributes pairs key->value. Example: array('id Color'=>id Blue, 'id Size'=>id Small, 'id Option'=>id val a, ...) - //var_dump($combinations); foreach ($combinations as $currcombattr => $currcombval) { //This was checked earlier, so no need to double check $prodattr->fetch($currcombattr); diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 905e915dfbb..c54e606fa65 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -1,8 +1,8 @@ - * Copyright (C) 2017 Laurent Destailleur - * Copyright (C) 2018-2019 Frédéric France - * Copyright (C) 2022 Open-Dsi +/* Copyright (C) 2016 Marcos García + * Copyright (C) 2017 Laurent Destailleur + * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2022 Open-Dsi * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -172,7 +172,7 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST( } // Valuepair - $sanit_features[$explode[0]] = $explode[1]; + $sanit_features[(int) $explode[0]] = (int) $explode[1]; $tmp = new ProductCombination2ValuePair($db); $tmp->fk_prod_attr = (int) $explode[0]; @@ -185,7 +185,6 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST( // sanit_feature is an array with 1 (and only 1) value per attribute. // For example: Color->blue, Size->Small, Option->2 - //var_dump($sanit_features); if (!$prodcomb->fetchByProductCombination2ValuePairs($id, $sanit_features)) { $result = $prodcomb->createProductCombination($user, $object, $sanit_features, array(), $level_price_impact_percent, $level_price_impact, $weight_impact, $reference); if ($result > 0) {