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)
{
// phpcs:enable
global $conf;
$type = 'action';
$list = array();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
/**
* 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)
@ -44,7 +44,6 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac
public $libversion = array();
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* 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
* @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)."::liste_modeles");
dol_syslog(get_class($this)."::listOfAvailableExportFormat");
$dir = DOL_DOCUMENT_ROOT."/core/modules/export/";
$handle = opendir($dir);

View File

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

View File

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

View File

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

View File

@ -49,8 +49,6 @@ abstract class ModelePDFEvaluation extends CommonDocGenerator
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
global $conf;
$type = 'evaluation';
$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 integer $maxfilenamelength Max length of value to show
* @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)."::liste_modeles");
dol_syslog(get_class($this)."::listOfAvailableImportFormat");
$dir = DOL_DOCUMENT_ROOT."/core/modules/import/";
$handle = opendir($dir);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -402,7 +402,7 @@ class pdf_standard extends ModelePDFStock
// Label
$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
$valtoshow = price2num($objp->value, 'MS');

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1187,7 +1187,7 @@ if ($step == 5 && $datatoexport) {
$htmltabloflibs .= '<td class="right">'.$langs->trans("LibraryVersion").'</td>';
$htmltabloflibs .= '</tr>'."\n";
$liste = $objmodelexport->liste_modeles($db);
$liste = $objmodelexport->listOfAvailableExportFormat($db);
$listeall = $liste;
foreach ($listeall as $key => $val) {
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';
$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) {
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 $langs->trans("FileMustHaveOneOfFollowingFormat");
print '</td></tr>';
$list = $objmodelimport->liste_modeles($db);
$list = $objmodelimport->listOfAvailableImportFormat($db);
foreach ($list as $key) {
print '<tr class="oddeven">';
print '<td width="16">'.img_picto_common($key, $objmodelimport->getPictoForKey($key)).'</td>';
@ -529,7 +529,7 @@ if ($step == 3 && $datatoimport) {
$param .= '&enclosure='.urlencode($enclosure);
}
$list = $objmodelimport->liste_modeles($db);
$list = $objmodelimport->listOfAvailableImportFormat($db);
llxHeader('', $langs->trans("NewImport"), $help_url);
@ -763,7 +763,7 @@ if ($step == 4 && $datatoimport) {
//var_dump($array_match_file_to_database);
$model = $format;
$list = $objmodelimport->liste_modeles($db);
$list = $objmodelimport->listOfAvailableImportFormat($db);
if (empty($separator)) {
$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;
$list = $objmodelimport->liste_modeles($db);
$list = $objmodelimport->listOfAvailableImportFormat($db);
// Create classe to use for import
$dir = DOL_DOCUMENT_ROOT."/core/modules/import/";
@ -2010,7 +2010,7 @@ if ($step == 6 && $datatoimport) {
}
$model = $format;
$list = $objmodelimport->liste_modeles($db);
$list = $objmodelimport->listOfAvailableImportFormat($db);
$importid = GETPOST("importid", 'alphanohtml');

View File

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

View File

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