Clean code

This commit is contained in:
Laurent Destailleur 2022-12-31 17:08:10 +01:00
parent 65a2093cd1
commit 57358b618b
45 changed files with 20 additions and 93 deletions

View File

@ -44,8 +44,6 @@ abstract class ModeleAction extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'action'; $type = 'action';
$list = array(); $list = array();

View File

@ -84,8 +84,6 @@ abstract class ModelePDFAsset extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'asset'; $type = 'asset';
$list = array(); $list = array();

View File

@ -48,8 +48,6 @@ abstract class ModeleBankAccountDoc extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'bankaccount'; $type = 'bankaccount';
$list = array(); $list = array();

View File

@ -50,8 +50,6 @@ abstract class ModelePDFBom extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'bom'; $type = 'bom';
$list = array(); $list = array();

View File

@ -146,8 +146,6 @@ abstract class ModeleChequeReceipts extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'chequereceipt'; $type = 'chequereceipt';
$list = array(); $list = array();

View File

@ -51,8 +51,6 @@ abstract class ModelePDFCommandes extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'order'; $type = 'order';
$list = array(); $list = array();

View File

@ -54,8 +54,6 @@ abstract class ModelePDFContract extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'contract'; $type = 'contract';
$list = array(); $list = array();

View File

@ -52,8 +52,6 @@ abstract class ModelePDFDeliveryOrder extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'delivery'; $type = 'delivery';
$list = array(); $list = array();

View File

@ -50,8 +50,6 @@ abstract class ModeleDon extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'donation'; $type = 'donation';
$list = array(); $list = array();

View File

@ -53,8 +53,6 @@ abstract class ModelePdfExpedition extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'shipping'; $type = 'shipping';
$list = array(); $list = array();

View File

@ -75,8 +75,6 @@ abstract class ModeleExpenseReport extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'expensereport'; $type = 'expensereport';
$list = array(); $list = array();

View File

@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
/** /**
* Parent class for export modules * Parent class for export modules
*/ */
class ModeleExports extends CommonDocGenerator // This class can't be abstract as there is instance propreties loaded by liste_modeles class ModeleExports extends CommonDocGenerator // This class can't be abstract as there is instance propreties loaded by listOfAvailableExportFormat
{ {
/** /**
* @var string Error code (or message) * @var string Error code (or message)
@ -44,7 +44,6 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac
public $libversion = array(); public $libversion = array();
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Load into memory list of available export format * Load into memory list of available export format
* *
@ -52,10 +51,9 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac
* @param integer $maxfilenamelength Max length of value to show * @param integer $maxfilenamelength Max length of value to show
* @return array List of templates (same content than array this->driverlabel) * @return array List of templates (same content than array this->driverlabel)
*/ */
public function liste_modeles($db, $maxfilenamelength = 0) public function listOfAvailableExportFormat($db, $maxfilenamelength = 0)
{ {
// phpcs:enable dol_syslog(get_class($this)."::listOfAvailableExportFormat");
dol_syslog(get_class($this)."::liste_modeles");
$dir = DOL_DOCUMENT_ROOT."/core/modules/export/"; $dir = DOL_DOCUMENT_ROOT."/core/modules/export/";
$handle = opendir($dir); $handle = opendir($dir);

View File

@ -61,8 +61,6 @@ abstract class ModelePDFFactures extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'invoice'; $type = 'invoice';
$list = array(); $list = array();

View File

@ -51,8 +51,6 @@ abstract class ModelePDFFicheinter extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'ficheinter'; $type = 'ficheinter';
$list = array(); $list = array();

View File

@ -55,8 +55,6 @@ abstract class ModelePDFHoliday extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'holiday'; $type = 'holiday';
$list = array(); $list = array();

View File

@ -49,8 +49,6 @@ abstract class ModelePDFEvaluation extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'evaluation'; $type = 'evaluation';
$list = array(); $list = array();

View File

@ -155,18 +155,16 @@ class ModeleImports
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Charge en memoire et renvoie la liste des modeles actifs * Load into memory list of available import format
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show * @param integer $maxfilenamelength Max length of value to show
* @return array List of templates * @return array List of templates
*/ */
public function liste_modeles($db, $maxfilenamelength = 0) public function listOfAvailableImportFormat($db, $maxfilenamelength = 0)
{ {
// phpcs:enable dol_syslog(get_class($this)."::listOfAvailableImportFormat");
dol_syslog(get_class($this)."::liste_modeles");
$dir = DOL_DOCUMENT_ROOT."/core/modules/import/"; $dir = DOL_DOCUMENT_ROOT."/core/modules/import/";
$handle = opendir($dir); $handle = opendir($dir);

View File

@ -51,8 +51,6 @@ class ModelePDFCards
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'member'; $type = 'member';
$list = array(); $list = array();

View File

@ -51,7 +51,6 @@ abstract class ModelePDFMember extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
$type = 'member'; $type = 'member';
$list = array(); $list = array();

View File

@ -85,8 +85,6 @@ abstract class ModelePDFMovement extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'movement'; $type = 'movement';
$list = array(); $list = array();

View File

@ -50,8 +50,6 @@ abstract class ModelePDFMo extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'mrp'; $type = 'mrp';
$list = array(); $list = array();

View File

@ -51,8 +51,6 @@ class ModelePDFLabels
public function liste_modeles($db, $maxfilenamelength = 0) public function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'members_labels'; $type = 'members_labels';
$list = array(); $list = array();

View File

@ -55,8 +55,6 @@ abstract class ModelePDFProductBatch extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'product_batch'; $type = 'product_batch';
$list = array(); $list = array();

View File

@ -103,8 +103,6 @@ abstract class ModelePDFProjects extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'project'; $type = 'project';
$list = array(); $list = array();

View File

@ -49,8 +49,6 @@ abstract class ModelePDFTask extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'project_task'; $type = 'project_task';
$list = array(); $list = array();

View File

@ -190,21 +190,21 @@ class doc_generic_proposal_odt extends ModelePDFPropales
if (getDolGlobalInt("MAIN_PROPAL_CHOOSE_ODT_DOCUMENT") > 0) { if (getDolGlobalInt("MAIN_PROPAL_CHOOSE_ODT_DOCUMENT") > 0) {
// Model for creation // Model for creation
$list = ModelePDFPropales::liste_modeles($this->db); $list = ModelePDFPropales::liste_modeles($this->db);
$texte .= '<table width="50%;">'; $texte .= '<table width="50%">';
$texte .= '<tr>'; $texte .= '<tr>';
$texte .= '<td width="60%;">'.$langs->trans("DefaultModelPropalCreate").'</td>'; $texte .= '<td width="60%">'.$langs->trans("DefaultModelPropalCreate").'</td>';
$texte .= '<td colspan="">'; $texte .= '<td colspan="">';
$texte .= $form->selectarray('value2', $list, $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT); $texte .= $form->selectarray('value2', $list, $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT);
$texte .= "</td></tr>"; $texte .= "</td></tr>";
$texte .= '<tr>'; $texte .= '<tr>';
$texte .= '<td width="60%;">'.$langs->trans("DefaultModelPropalToBill").'</td>'; $texte .= '<td width="60%">'.$langs->trans("DefaultModelPropalToBill").'</td>';
$texte .= '<td colspan="">'; $texte .= '<td colspan="">';
$texte .= $form->selectarray('value3', $list, $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL); $texte .= $form->selectarray('value3', $list, $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL);
$texte .= "</td></tr>"; $texte .= "</td></tr>";
$texte .= '<tr>'; $texte .= '<tr>';
$texte .= '<td width="60%;">'.$langs->trans("DefaultModelPropalClosed").'</td>'; $texte .= '<td width="60%">'.$langs->trans("DefaultModelPropalClosed").'</td>';
$texte .= '<td colspan="">'; $texte .= '<td colspan="">';
$texte .= $form->selectarray('value4', $list, $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED); $texte .= $form->selectarray('value4', $list, $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED);
$texte .= "</td></tr>"; $texte .= "</td></tr>";

View File

@ -53,8 +53,6 @@ abstract class ModelePDFPropales extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'propal'; $type = 'propal';
$list = array(); $list = array();

View File

@ -43,8 +43,6 @@ abstract class ModelePdfReception extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'reception'; $type = 'reception';
$list = array(); $list = array();

View File

@ -48,7 +48,6 @@ abstract class ModeleThirdPartyDoc extends CommonDocGenerator
public static function liste_modeles($dbs, $maxfilenamelength = 0) public static function liste_modeles($dbs, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
$type = 'company'; $type = 'company';
$list = array(); $list = array();

View File

@ -402,7 +402,7 @@ class pdf_standard extends ModelePDFStock
// Label // Label
$pdf->SetXY($this->posxlabel + 0.8, $curY); $pdf->SetXY($this->posxlabel + 0.8, $curY);
$pdf->MultiCell($this->posxqty - $this->posxlabel - 0.8, 3, dol_trunc($objp->produit, 24), 0, 'L'); $pdf->MultiCell($this->posxqty - $this->posxlabel - 0.8, 3, dol_trunc($productstatic->label, 24), 0, 'L');
// Quantity // Quantity
$valtoshow = price2num($objp->value, 'MS'); $valtoshow = price2num($objp->value, 'MS');

View File

@ -75,8 +75,6 @@ abstract class ModelePDFStock extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'stock'; $type = 'stock';
$list = array(); $list = array();

View File

@ -50,8 +50,6 @@ abstract class ModelePDFStockTransfer extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'stocktransfer'; $type = 'stocktransfer';
$list = array(); $list = array();

View File

@ -51,8 +51,6 @@ abstract class ModelePDFSuppliersInvoices extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'invoice_supplier'; $type = 'invoice_supplier';
$list = array(); $list = array();

View File

@ -54,8 +54,6 @@ abstract class ModelePDFSuppliersOrders extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'order_supplier'; $type = 'order_supplier';
$list = array(); $list = array();

View File

@ -74,8 +74,6 @@ abstract class ModelePDFSuppliersPayments extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'supplier_payment'; $type = 'supplier_payment';
$list = array(); $list = array();

View File

@ -53,8 +53,6 @@ abstract class ModelePDFSupplierProposal extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'supplier_proposal'; $type = 'supplier_proposal';
$list = array(); $list = array();

View File

@ -44,8 +44,6 @@ abstract class ModelePDFTicket extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'ticket'; $type = 'ticket';
$list = array(); $list = array();

View File

@ -55,8 +55,6 @@ abstract class ModelePDFUser extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'user'; $type = 'user';
$list = array(); $list = array();

View File

@ -55,8 +55,6 @@ abstract class ModelePDFUserGroup extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'group'; $type = 'group';
$list = array(); $list = array();

View File

@ -50,8 +50,6 @@ abstract class ModelePDFWorkstation extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf;
$type = 'workstation'; $type = 'workstation';
$list = array(); $list = array();

View File

@ -1187,7 +1187,7 @@ if ($step == 5 && $datatoexport) {
$htmltabloflibs .= '<td class="right">'.$langs->trans("LibraryVersion").'</td>'; $htmltabloflibs .= '<td class="right">'.$langs->trans("LibraryVersion").'</td>';
$htmltabloflibs .= '</tr>'."\n"; $htmltabloflibs .= '</tr>'."\n";
$liste = $objmodelexport->liste_modeles($db); $liste = $objmodelexport->listOfAvailableExportFormat($db);
$listeall = $liste; $listeall = $liste;
foreach ($listeall as $key => $val) { foreach ($listeall as $key => $val) {
if (preg_match('/__\(Disabled\)__/', $listeall[$key])) { if (preg_match('/__\(Disabled\)__/', $listeall[$key])) {

View File

@ -72,7 +72,7 @@ print '</tr>';
include_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php'; include_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php';
$model = new ModeleExports($db); $model = new ModeleExports($db);
$liste = $model->liste_modeles($db); // This is not a static method for exports because method load non static properties $liste = $model->listOfAvailableExportFormat($db); // This is not a static method for exports because method load non static properties
foreach ($liste as $key => $val) { foreach ($liste as $key => $val) {
if (preg_match('/__\(Disabled\)__/', $liste[$key])) { if (preg_match('/__\(Disabled\)__/', $liste[$key])) {

View File

@ -485,7 +485,7 @@ if ($step == 2 && $datatoimport) {
print '<tr class="liste_titre"><td colspan="5">'; print '<tr class="liste_titre"><td colspan="5">';
print $langs->trans("FileMustHaveOneOfFollowingFormat"); print $langs->trans("FileMustHaveOneOfFollowingFormat");
print '</td></tr>'; print '</td></tr>';
$list = $objmodelimport->liste_modeles($db); $list = $objmodelimport->listOfAvailableImportFormat($db);
foreach ($list as $key) { foreach ($list as $key) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td width="16">'.img_picto_common($key, $objmodelimport->getPictoForKey($key)).'</td>'; print '<td width="16">'.img_picto_common($key, $objmodelimport->getPictoForKey($key)).'</td>';
@ -529,7 +529,7 @@ if ($step == 3 && $datatoimport) {
$param .= '&enclosure='.urlencode($enclosure); $param .= '&enclosure='.urlencode($enclosure);
} }
$list = $objmodelimport->liste_modeles($db); $list = $objmodelimport->listOfAvailableImportFormat($db);
llxHeader('', $langs->trans("NewImport"), $help_url); llxHeader('', $langs->trans("NewImport"), $help_url);
@ -763,7 +763,7 @@ if ($step == 4 && $datatoimport) {
//var_dump($array_match_file_to_database); //var_dump($array_match_file_to_database);
$model = $format; $model = $format;
$list = $objmodelimport->liste_modeles($db); $list = $objmodelimport->listOfAvailableImportFormat($db);
if (empty($separator)) { if (empty($separator)) {
$separator = (empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE) ? ',' : $conf->global->IMPORT_CSV_SEPARATOR_TO_USE); $separator = (empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE) ? ',' : $conf->global->IMPORT_CSV_SEPARATOR_TO_USE);
@ -1547,7 +1547,7 @@ if ($step == 5 && $datatoimport) {
} }
$model = $format; $model = $format;
$list = $objmodelimport->liste_modeles($db); $list = $objmodelimport->listOfAvailableImportFormat($db);
// Create classe to use for import // Create classe to use for import
$dir = DOL_DOCUMENT_ROOT."/core/modules/import/"; $dir = DOL_DOCUMENT_ROOT."/core/modules/import/";
@ -2010,7 +2010,7 @@ if ($step == 6 && $datatoimport) {
} }
$model = $format; $model = $format;
$list = $objmodelimport->liste_modeles($db); $list = $objmodelimport->listOfAvailableImportFormat($db);
$importid = GETPOST("importid", 'alphanohtml'); $importid = GETPOST("importid", 'alphanohtml');

View File

@ -68,7 +68,7 @@ print '</tr>';
include_once DOL_DOCUMENT_ROOT.'/core/modules/import/modules_import.php'; include_once DOL_DOCUMENT_ROOT.'/core/modules/import/modules_import.php';
$model = new ModeleImports(); $model = new ModeleImports();
$list = $model->liste_modeles($db); $list = $model->listOfAvailableImportFormat($db);
foreach ($list as $key) { foreach ($list as $key) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';

View File

@ -72,6 +72,7 @@ exclude:
- name: PhpConditionCheckedByNextConditionInspection - name: PhpConditionCheckedByNextConditionInspection
- name: RegExpSingleCharAlternation - name: RegExpSingleCharAlternation
- name: PhpSuspiciousNameCombinationInspection - name: PhpSuspiciousNameCombinationInspection
- name: PhpObjectFieldsAreOnlyWrittenInspection
- name: PhpWriteAccessToReferencedArrayValueWithoutUnsetInspection - name: PhpWriteAccessToReferencedArrayValueWithoutUnsetInspection