Clean dead code

This commit is contained in:
Laurent Destailleur 2020-11-28 14:47:39 +01:00
parent 41984f9934
commit 59b445a103
13 changed files with 21 additions and 89 deletions

View File

@ -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'

View File

@ -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');
}

View File

@ -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
*

View File

@ -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].'<br>';
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].'<br>';
if not in lines {
$this->add_product($value[1], $value[0]);
}
}
}
**/
}

View File

@ -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

View File

@ -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';

View File

@ -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();

View File

@ -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

View File

@ -286,8 +286,6 @@ class CommandeFournisseur extends CommonOrder
public function __construct($db)
{
$this->db = $db;
$this->products = array();
}

View File

@ -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();
}
/**

View File

@ -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();

View File

@ -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');
}

View File

@ -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
*