From 59b445a103e3c0bed637d96e9ef15274bd130b6c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 28 Nov 2020 14:47:39 +0100 Subject: [PATCH] Clean dead code --- .github/workflows/exakat.yml | 2 +- htdocs/comm/propal/card.php | 3 --- htdocs/comm/propal/class/propal.class.php | 24 +----------------- htdocs/commande/class/commande.class.php | 20 ++++++--------- htdocs/compta/facture/class/facture.class.php | 8 ------ htdocs/delivery/class/delivery.class.php | 4 +-- htdocs/expedition/class/expedition.class.php | 6 ++--- htdocs/fichinter/class/fichinter.class.php | 3 +-- .../class/fournisseur.commande.class.php | 2 -- .../fourn/class/fournisseur.facture.class.php | 6 ++--- htdocs/reception/class/reception.class.php | 5 ++-- htdocs/supplier_proposal/card.php | 2 -- .../class/supplier_proposal.class.php | 25 +------------------ 13 files changed, 21 insertions(+), 89 deletions(-) diff --git a/.github/workflows/exakat.yml b/.github/workflows/exakat.yml index 3cfc4f8ba23..e38d28397f7 100644 --- a/.github/workflows/exakat.yml +++ b/.github/workflows/exakat.yml @@ -13,5 +13,5 @@ jobs: - name: Exakat uses: docker://exakat/exakat-ga with: - ignore_rules: 'Classes/UseInstanceof,Performances/PrePostIncrement,Functions/UndefinedFunctions,Functions/WrongNumberOfArguments,Functions/WrongTypeWithCall,Variables/UndefinedVariable,Classes/DontUnsetProperties,Classes/NonPpp,Classes/StaticMethodsCalledFromObject,Classes/UseClassOperator,Functions/UsesDefaultArguments,Php/NoClassInGlobal,Php/ShouldUseCoalesce,Php/WrongTypeForNativeFunction,Structures/MergeIfThen,Structures/ElseIfElseif,Structures/RepeatedPrint,Structures/SameConditions,Structures/SwitchWithoutDefault,Structures/ShouldMakeTernary,Structures/UselessParenthesis,Structures/UseConstant' + ignore_rules: 'Classes/UseInstanceof,Performances/PrePostIncrement,Functions/UndefinedFunctions,Functions/WrongNumberOfArguments,Functions/WrongTypeWithCall,Variables/UndefinedVariable,Classes/DontUnsetProperties,Classes/NonPpp,Classes/StaticMethodsCalledFromObject,Classes/UseClassOperator,Functions/UsesDefaultArguments,Php/NoClassInGlobal,Php/ShouldUseCoalesce,Php/WrongTypeForNativeFunction,Structures/AddZero,Structures/DropElseAfterReturn,Structures/IfWithSameConditions,Structures/MergeIfThen,Structures/ElseIfElseif,Structures/RepeatedPrint,Structures/RepeatedRegex,Structures/SameConditions,Structures/SwitchWithoutDefault,Structures/ShouldMakeTernary,Structures/UselessParenthesis,Structures/UseConstant' ignore_dirs: '/htdocs/includes,/build,/dev,/doc,/scripts,/test' \ No newline at end of file diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 320b0c02e1e..90e779009de 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -366,9 +366,6 @@ if (empty($reshook)) $object->statut = Propal::STATUS_DRAFT; $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); - - // the create is done below and further more the existing create_from function is quite hilarating - //$id = $object->create_from($user); } else { setEventMessages($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), null, 'errors'); } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index bc588f430d9..e906c4163d6 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -208,7 +208,6 @@ class Propal extends CommonObject public $demand_reason_id; public $demand_reason_code; - public $products = array(); public $extraparams = array(); /** @@ -355,15 +354,13 @@ class Propal extends CommonObject $this->socid = $socid; $this->id = $propalid; - $this->products = array(); - $this->duree_validite = ((int) $conf->global->PROPALE_VALIDITY_DURATION); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Add line into array products + * Add line into array ->lines * $this->thirdparty should be loaded * * @param int $idproduct Product Id to add @@ -372,7 +369,6 @@ class Propal extends CommonObject * @return int <0 if KO, >0 if OK * * TODO Replace calls to this function by generation objet Ligne - * inserted into table $this->products */ public function add_product($idproduct, $qty, $remise_percent = 0) { @@ -1279,24 +1275,6 @@ class Propal extends CommonObject } } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Insert into DB a proposal object completely defined by its data members (ex, results from copy). - * - * @param User $user User that create - * @return int Id of the new object if ok, <0 if ko - * @see create() - */ - public function create_from($user) - { - // phpcs:enable - // i love this function because $this->products is not used in create function... - $this->products = $this->lines; - - return $this->create($user); - } - /** * Load an object from its id and create a new one in database * diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index ad3c9a10043..f2734b5b8b6 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -199,6 +199,7 @@ class Commande extends CommonOrder public $rang; public $special_code; public $source; // Order mode. How we received order (by phone, by email, ...) + public $extraparams = array(); public $linked_objects = array(); @@ -368,8 +369,6 @@ class Commande extends CommonOrder $this->remise = 0; $this->remise_percent = 0; - - $this->products = array(); } /** @@ -1690,7 +1689,6 @@ class Commande extends CommonOrder * @return void * * TODO Remplacer les appels a cette fonction par generation objet Ligne - * insere dans tableau $this->products */ public function add_product($idproduct, $qty, $remise_percent = 0.0, $date_start = '', $date_end = '') { @@ -1752,15 +1750,13 @@ class Commande extends CommonOrder $prods_arbo = $prod->get_arbo_each_prod(); if(count($prods_arbo) > 0) { - foreach($prods_arbo as $key => $value) - { - // print "id : ".$value[1].' :qty: '.$value[0].'
'; - if(! in_array($value[1],$this->products)) - $this->add_product($value[1], $value[0]); - - } - } - + foreach($prods_arbo as $key => $value) + { + // print "id : ".$value[1].' :qty: '.$value[0].'
'; + if not in lines { + $this->add_product($value[1], $value[0]); + } + } } **/ } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 23b9ff7e316..29203a48f26 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -176,11 +176,6 @@ class Facture extends CommonInvoice */ public $fk_bank; - /** - * @deprecated - */ - public $products = array(); - /** * @var FactureLigne[] */ @@ -1077,7 +1072,6 @@ class Facture extends CommonInvoice $facture->origin_id = $this->origin_id; $facture->lines = $this->lines; // Array of lines of invoice - $facture->products = $this->lines; // Tant que products encore utilise $facture->situation_counter = $this->situation_counter; $facture->situation_cycle_ref = $this->situation_cycle_ref; $facture->situation_final = $this->situation_final; @@ -1179,7 +1173,6 @@ class Facture extends CommonInvoice $object->ref_client = ''; $object->close_code = ''; $object->close_note = ''; - $object->products = $object->lines; // For backward compatibility if ($conf->global->MAIN_DONT_KEEP_NOTE_ON_CLONING == 1) { $object->note_private = ''; $object->note_public = ''; @@ -1191,7 +1184,6 @@ class Facture extends CommonInvoice if (($object->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts { unset($object->lines[$i]); - unset($object->products[$i]); // Tant que products encore utilise } // Bloc to update dates of service (month by month only if previously filled at 1d near start or end of month) // If it's a service with start and end dates diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 3c4d53f53e7..394e86fdd78 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -102,6 +102,8 @@ class Delivery extends CommonObject */ public $model_pdf; + public $lines = array(); + /** * Constructor @@ -111,8 +113,6 @@ class Delivery extends CommonObject public function __construct($db) { $this->db = $db; - $this->lines = array(); - $this->products = array(); // List of short language codes for status $this->statuts[-1] = 'StatusDeliveryCanceled'; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index a0acef35203..907b7ea9051 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -106,7 +106,6 @@ class Expedition extends CommonObject * @var int warehouse id */ public $entrepot_id; - public $lines = array(); /** * @var string Tracking number @@ -171,6 +170,9 @@ class Expedition extends CommonObject public $meths; public $listmeths; // List of carriers + public $lines = array(); + + /** * Draft status */ @@ -202,8 +204,6 @@ class Expedition extends CommonObject global $conf; $this->db = $db; - $this->lines = array(); - $this->products = array(); // List of long language codes for status $this->statuts = array(); diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index f147677647e..617da1963b8 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -176,6 +176,7 @@ class Fichinter extends CommonObject */ const STATUS_CLOSED = 3; + /** * Constructor * @@ -184,8 +185,6 @@ class Fichinter extends CommonObject public function __construct($db) { $this->db = $db; - - $this->products = array(); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 56835f03ee4..6fe473cc12f 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -286,8 +286,6 @@ class CommandeFournisseur extends CommonOrder public function __construct($db) { $this->db = $db; - - $this->products = array(); } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index f35db176b83..09c74dd5d92 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -187,6 +187,8 @@ class FactureFournisseur extends CommonInvoice public $mode_reglement_id; public $mode_reglement_code; + public $extraparams = array(); + /** * Invoice lines * @var SupplierInvoiceLine[] @@ -198,8 +200,6 @@ class FactureFournisseur extends CommonInvoice */ public $fournisseur; - public $extraparams = array(); - // Multicurrency /** * @var int ID @@ -331,8 +331,6 @@ class FactureFournisseur extends CommonInvoice public function __construct($db) { $this->db = $db; - - $this->products = array(); } /** diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index d64c3c999a7..b52cc3afe84 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -68,7 +68,6 @@ class Reception extends CommonObject public $brouillon; public $entrepot_id; - public $lines = array(); public $tracking_number; public $tracking_url; public $billed; @@ -106,6 +105,8 @@ class Reception extends CommonObject public $meths; public $listmeths; // List of carriers + public $lines = array(); + const STATUS_DRAFT = 0; const STATUS_VALIDATED = 1; @@ -121,8 +122,6 @@ class Reception extends CommonObject public function __construct($db) { $this->db = $db; - $this->lines = array(); - $this->products = array(); // List of long language codes for status $this->statuts = array(); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index b891d042e5b..893748deee7 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -272,8 +272,6 @@ if (empty($reshook)) $object->note = GETPOST('note', 'restricthtml'); $object->note_private = GETPOST('note', 'restricthtml'); $object->statut = SupplierProposal::STATUS_DRAFT; - - $id = $object->create_from($user); } else { setEventMessages($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_supplier_proposal')), null, 'errors'); } diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 914e487b594..9a6ed7e1d38 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -171,9 +171,7 @@ class SupplierProposal extends CommonObject public $remise_percent = 0; public $remise_absolue = 0; - public $products = array(); public $extraparams = array(); - public $lines = array(); public $line; @@ -237,15 +235,12 @@ class SupplierProposal extends CommonObject $this->socid = $socid; $this->id = $supplier_proposalid; - - $this->products = array(); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Add line into array products - * $this->client doit etre charge + * Add line into array ->lines * * @param int $idproduct Product Id to add * @param int $qty Quantity @@ -253,7 +248,6 @@ class SupplierProposal extends CommonObject * @return int <0 if KO, >0 if OK * * TODO Remplacer les appels a cette fonction par generation objet Ligne - * insere dans tableau $this->products */ public function add_product($idproduct, $qty, $remise_percent = 0) { @@ -1085,23 +1079,6 @@ class SupplierProposal extends CommonObject } } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Insert into DB a supplier_proposal object completely defined by its data members (ex, results from copy). - * - * @param User $user User that create - * @return int Id of the new object if ok, <0 if ko - * @see create() - */ - public function create_from($user) - { - // phpcs:enable - $this->products = $this->lines; - - return $this->create($user); - } - /** * Load an object from its id and create a new one in database *