From e5e9f914e5cd8470c7da857230ba6228505255cd Mon Sep 17 00:00:00 2001 From: onhairech <47675588+oussamanhairech@users.noreply.github.com> Date: Wed, 12 Jul 2023 16:32:50 +0200 Subject: [PATCH] qodana fix 3 : missing returns (#25332) * qodana fix 3 : missing returns * removing a duplicated line --- htdocs/admin/sms.php | 7 +- .../comm/action/class/cactioncomm.class.php | 1 + .../mailing/class/advtargetemailing.class.php | 1 + htdocs/core/class/CSMSFile.class.php | 2 +- htdocs/core/class/html.formcontract.class.php | 3 +- .../class/html.formexpensereport.class.php | 18 +- htdocs/core/class/html.formfile.class.php | 1 + htdocs/core/class/rssparser.class.php | 1 + htdocs/core/class/translate.class.php | 175 ++++++++++-------- htdocs/core/lib/functions2.lib.php | 1 + htdocs/core/lib/functionsnumtoword.lib.php | 1 + htdocs/core/lib/security.lib.php | 1 + htdocs/hrm/class/skill.class.php | 2 +- 13 files changed, 119 insertions(+), 95 deletions(-) diff --git a/htdocs/admin/sms.php b/htdocs/admin/sms.php index 391ca42a6d3..554f0420d25 100644 --- a/htdocs/admin/sms.php +++ b/htdocs/admin/sms.php @@ -111,8 +111,11 @@ if ($action == 'send' && !$cancel) { $body = make_substitutions($body, $substitutionarrayfortest); require_once DOL_DOCUMENT_ROOT.'/core/class/CSMSFile.class.php'; - - $smsfile = new CSMSFile($sendto, $smsfrom, $body, $deliveryreceipt, $deferred, $priority, $class); // This define OvhSms->login, pass, session and account + try{ + $smsfile = new CSMSFile($sendto, $smsfrom, $body, $deliveryreceipt, $deferred, $priority, $class); // This define OvhSms->login, pass, session and account + } catch (Exception $e){ + setEventMessages($e->getMessage(), null, 'error'); + } $result = $smsfile->sendfile(); // This send SMS if ($result) { diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php index 5499e258964..45c78863343 100644 --- a/htdocs/comm/action/class/cactioncomm.class.php +++ b/htdocs/comm/action/class/cactioncomm.class.php @@ -341,5 +341,6 @@ class CActionComm if ($transcode != "Action".$this->code) { return $transcode; } + return -1; } } diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 7b4e06c897f..271f0d49ad3 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -516,6 +516,7 @@ class AdvanceTargetingMailing extends CommonObject $this->create($user); } } + return -1; } diff --git a/htdocs/core/class/CSMSFile.class.php b/htdocs/core/class/CSMSFile.class.php index a8dc4bfff9a..58450de4d8e 100644 --- a/htdocs/core/class/CSMSFile.class.php +++ b/htdocs/core/class/CSMSFile.class.php @@ -82,7 +82,7 @@ class CSMSFile // If ending method not defined if (empty($conf->global->MAIN_SMS_SENDMODE)) { $this->error = 'No SMS Engine defined'; - return -1; + throw new Exception('No SMS Engine defined'); } dol_syslog("CSMSFile::CSMSFile: MAIN_SMS_SENDMODE=".$conf->global->MAIN_SMS_SENDMODE." charset=".$conf->file->character_set_client." from=".$from.", to=".$to.", msg length=".strlen($msg), LOG_DEBUG); diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index f4486bfb2b5..56187336532 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -187,8 +187,9 @@ class FormContract print '
'; print ''; print ''; - $this->select_contract($socid, $selected, $htmlname, $maxlength, $showempty, $showRef); + $result = $this->select_contract($socid, $selected, $htmlname, $maxlength, $showempty, $showRef); print ''; print '
'; + return $result; } } diff --git a/htdocs/core/class/html.formexpensereport.class.php b/htdocs/core/class/html.formexpensereport.class.php index b20260acc41..8b6d45be1c5 100644 --- a/htdocs/core/class/html.formexpensereport.class.php +++ b/htdocs/core/class/html.formexpensereport.class.php @@ -65,9 +65,9 @@ class FormExpenseReport $tmpep = new ExpenseReport($this->db); - print ''; if ($useempty) { - print ''; + $html.=''; } $arrayoflabels = $tmpep->statuts; if ($useshortlabel) { @@ -75,15 +75,17 @@ class FormExpenseReport } foreach ($arrayoflabels as $key => $val) { if ($selected != '' && $selected == $key) { - print ''; + $html .= $langs->trans($val); + $html .= ''; } - print ''; - print ajax_combobox($htmlname); + $html .= ''; + $html .= ajax_combobox($htmlname); + print $html; + return $html; } /** diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 1f7055f58b0..99e5efbec52 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1958,6 +1958,7 @@ class FormFile if (!empty($addfilterfields)) { print ''; } + return count($filearray); // Fin de zone } diff --git a/htdocs/core/class/rssparser.class.php b/htdocs/core/class/rssparser.class.php index 010cb186b70..fc3a8753a59 100644 --- a/htdocs/core/class/rssparser.class.php +++ b/htdocs/core/class/rssparser.class.php @@ -679,6 +679,7 @@ class RssParser $str1 = ""; } $str1 .= $str2; + return $str1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index a3e69c61e15..99fd36110a7 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -82,9 +82,9 @@ class Translate $more = array(); $i = 0; foreach ($conf->file->dol_document_root as $dir) { - $newdir = $dir.$conf->global->MAIN_FORCELANGDIR; // For example $conf->global->MAIN_FORCELANGDIR is '/mymodule' meaning we search files into '/mymodule/langs/xx_XX' + $newdir = $dir . $conf->global->MAIN_FORCELANGDIR; // For example $conf->global->MAIN_FORCELANGDIR is '/mymodule' meaning we search files into '/mymodule/langs/xx_XX' if (!in_array($newdir, $this->dir)) { - $more['module_'.$i] = $newdir; + $more['module_' . $i] = $newdir; $i++; // We add the forced dir into the array $more. Just after, we add entries into $more to list of lang dir $this->dir. } } @@ -109,31 +109,31 @@ class Translate //print "Short code before _ : ".$langpart[0].' / Short code after _ : '.$langpart[1].'
'; if (!empty($langpart[1])) { // If it's for a codetouse that is a long code xx_YY // Array force long code from first part, even if long code is defined - $longforshort = array('ar'=>'ar_SA'); + $longforshort = array('ar' => 'ar_SA'); $longforshortexcep = array('ar_EG'); if (isset($longforshort[strtolower($langpart[0])]) && !in_array($codetouse, $longforshortexcep)) { $srclang = $longforshort[strtolower($langpart[0])]; } elseif (!is_numeric($langpart[1])) { // Second part YY may be a numeric with some Chrome browser - $srclang = strtolower($langpart[0])."_".strtoupper($langpart[1]); - $longforlong = array('no_nb'=>'nb_NO'); + $srclang = strtolower($langpart[0]) . "_" . strtoupper($langpart[1]); + $longforlong = array('no_nb' => 'nb_NO'); if (isset($longforlong[strtolower($srclang)])) { $srclang = $longforlong[strtolower($srclang)]; } } else { - $srclang = strtolower($langpart[0])."_".strtoupper($langpart[0]); + $srclang = strtolower($langpart[0]) . "_" . strtoupper($langpart[0]); } } else { // If it's for a codetouse that is a short code xx // Array to convert short lang code into long code. $longforshort = array( - 'am'=>'am_ET', 'ar'=>'ar_SA', 'bn'=>'bn_DB', 'el'=>'el_GR', 'ca'=>'ca_ES', 'cs'=>'cs_CZ', 'en'=>'en_US', 'fa'=>'fa_IR', - 'gl'=>'gl_ES', 'he'=>'he_IL', 'hi'=>'hi_IN', 'ja'=>'ja_JP', - 'ka'=>'ka_GE', 'km'=>'km_KH', 'kn'=>'kn_IN', 'ko'=>'ko_KR', 'lo'=>'lo_LA', 'nb'=>'nb_NO', 'no'=>'nb_NO', 'ne'=>'ne_NP', - 'sl'=>'sl_SI', 'sq'=>'sq_AL', 'sr'=>'sr_RS', 'sv'=>'sv_SE', 'uk'=>'uk_UA', 'vi'=>'vi_VN', 'zh'=>'zh_CN' + 'am' => 'am_ET', 'ar' => 'ar_SA', 'bn' => 'bn_DB', 'el' => 'el_GR', 'ca' => 'ca_ES', 'cs' => 'cs_CZ', 'en' => 'en_US', 'fa' => 'fa_IR', + 'gl' => 'gl_ES', 'he' => 'he_IL', 'hi' => 'hi_IN', 'ja' => 'ja_JP', + 'ka' => 'ka_GE', 'km' => 'km_KH', 'kn' => 'kn_IN', 'ko' => 'ko_KR', 'lo' => 'lo_LA', 'nb' => 'nb_NO', 'no' => 'nb_NO', 'ne' => 'ne_NP', + 'sl' => 'sl_SI', 'sq' => 'sq_AL', 'sr' => 'sr_RS', 'sv' => 'sv_SE', 'uk' => 'uk_UA', 'vi' => 'vi_VN', 'zh' => 'zh_CN' ); if (isset($longforshort[strtolower($langpart[0])])) { $srclang = $longforshort[strtolower($langpart[0])]; } elseif (!empty($langpart[0])) { - $srclang = strtolower($langpart[0])."_".strtoupper($langpart[0]); + $srclang = strtolower($langpart[0]) . "_" . strtoupper($langpart[0]); } else { $srclang = 'en_US'; } @@ -170,9 +170,16 @@ class Translate */ public function loadLangs($domains) { + $loaded = 0; foreach ($domains as $domain) { - $this->load($domain); + $result = $this->load($domain); + if ($result > 0) { + $loaded = $result; + } elseif ($result < 0) { + return $result; + } } + return $loaded; } /** @@ -204,7 +211,7 @@ class Translate // Check parameters if (empty($domain)) { - dol_print_error('', get_class($this)."::Load ErrorWrongParameters"); + dol_print_error('', get_class($this) . "::Load ErrorWrongParameters"); return -1; } if ($this->defaultlang === 'none_NONE') { @@ -229,8 +236,10 @@ class Translate } // Check cache - if (!empty($this->_tab_loaded[$newdomain]) - && ($this->_tab_loaded[$newdomain] != 2 || empty($forceloadifalreadynotfound))) { // File already loaded and found and not forced for this domain + if ( + !empty($this->_tab_loaded[$newdomain]) + && ($this->_tab_loaded[$newdomain] != 2 || empty($forceloadifalreadynotfound)) + ) { // File already loaded and found and not forced for this domain //dol_syslog("Translate::Load already loaded for newdomain=".$newdomain); return 0; } @@ -248,13 +257,13 @@ class Translate } if (empty($langofdir)) { // This may occurs when load is called without setting the language and without providing a value for forcelangdir - dol_syslog("Error: ".get_class($this)."::load was called for domain=".$domain." but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING); + dol_syslog("Error: " . get_class($this) . "::load was called for domain=" . $domain . " but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING); return -1; } foreach ($this->dir as $searchdir) { // Directory of translation files - $file_lang = $searchdir.($modulename ? '/'.$modulename : '')."/langs/".$langofdir."/".$newdomain.".lang"; + $file_lang = $searchdir . ($modulename ? '/' . $modulename : '') . "/langs/" . $langofdir . "/" . $newdomain . ".lang"; $file_lang_osencoded = dol_osencode($file_lang); $filelangexists = is_file($file_lang_osencoded); @@ -270,7 +279,7 @@ class Translate $usecachekey = ''; // Using a memcached server if (isModEnabled('memcached') && !empty($conf->global->MEMCACHED_SERVER)) { - $usecachekey = $newdomain.'_'.$langofdir.'_'.md5($file_lang); // Should not contains special chars + $usecachekey = $newdomain . '_' . $langofdir . '_' . md5($file_lang); // Should not contains special chars } elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) { // Using cache with shmop. Speed gain: 40ms - Memory overusage: 200ko (Size of session cache file) $usecachekey = $newdomain; @@ -280,7 +289,7 @@ class Translate //dol_syslog('Translate::Load we will cache result into usecachekey '.$usecachekey); //global $aaa; $aaa+=1; //print $aaa." ".$usecachekey."\n"; - require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; + require_once DOL_DOCUMENT_ROOT . '/core/lib/memory.lib.php'; $tmparray = dol_getcache($usecachekey); if (is_array($tmparray) && count($tmparray)) { $this->tab_translate += $tmparray; // Faster than array_merge($tmparray,$this->tab_translate). Note: If a value already exists into tab_translate, value into tmparaay is not added. @@ -339,7 +348,7 @@ class Translate if ($usecachekey && count($tabtranslatedomain)) { $ressetcache = dol_setcache($usecachekey, $tabtranslatedomain); if ($ressetcache < 0) { - $error = 'Failed to set cache for usecachekey='.$usecachekey.' result='.$ressetcache; + $error = 'Failed to set cache for usecachekey=' . $usecachekey . ' result=' . $ressetcache; dol_syslog($error, LOG_ERR); } } @@ -356,7 +365,7 @@ class Translate if ($alt == 0) { // This function MUST NOT contains call to syslog //dol_syslog("Translate::Load loading alternate translation file (to complete ".$this->defaultlang."/".$newdomain.".lang file)", LOG_DEBUG); - $langofdir = strtolower($langarray[0]).'_'.strtoupper($langarray[0]); + $langofdir = strtolower($langarray[0]) . '_' . strtoupper($langarray[0]); if ($langofdir == 'el_EL') { $langofdir = 'el_GR'; // main parent for el_CY is not 'el_EL' but 'el_GR' } @@ -388,7 +397,7 @@ class Translate // This part is deprecated and replaced with table llx_overwrite_trans // Kept for backward compatibility. if (empty($loadfromfileonly)) { - $overwritekey = 'MAIN_OVERWRITE_TRANS_'.$this->defaultlang; + $overwritekey = 'MAIN_OVERWRITE_TRANS_' . $this->defaultlang; if (!empty($conf->global->$overwritekey)) { // Overwrite translation with key1:newstring1,key2:newstring2 // Overwrite translation with param MAIN_OVERWRITE_TRANS_xx_XX $tmparray = explode(',', $conf->global->$overwritekey); @@ -402,8 +411,10 @@ class Translate } // Check to be sure that SeparatorDecimal differs from SeparatorThousand - if (!empty($this->tab_translate["SeparatorDecimal"]) && !empty($this->tab_translate["SeparatorThousand"]) - && $this->tab_translate["SeparatorDecimal"] == $this->tab_translate["SeparatorThousand"]) { + if ( + !empty($this->tab_translate["SeparatorDecimal"]) && !empty($this->tab_translate["SeparatorThousand"]) + && $this->tab_translate["SeparatorDecimal"] == $this->tab_translate["SeparatorThousand"] + ) { $this->tab_translate["SeparatorThousand"] = ''; } @@ -449,7 +460,7 @@ class Translate $langofdir = $this->defaultlang; if (empty($langofdir)) { // This may occurs when load is called without setting the language and without providing a value for forcelangdir - dol_syslog("Error: ".get_class($this)."::loadFromDatabase was called but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING); + dol_syslog("Error: " . get_class($this) . "::loadFromDatabase was called but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING); return -1; } @@ -460,7 +471,7 @@ class Translate $usecachekey = ''; // Using a memcached server if (isModEnabled('memcached') && !empty($conf->global->MEMCACHED_SERVER)) { - $usecachekey = $newdomain.'_'.$langofdir; // Should not contains special chars + $usecachekey = $newdomain . '_' . $langofdir; // Should not contains special chars } elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) { // Using cache with shmop. Speed gain: 40ms - Memory overusage: 200ko (Size of session cache file) $usecachekey = $newdomain; @@ -470,7 +481,7 @@ class Translate //dol_syslog('Translate::Load we will cache result into usecachekey '.$usecachekey); //global $aaa; $aaa+=1; //print $aaa." ".$usecachekey."\n"; - require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; + require_once DOL_DOCUMENT_ROOT . '/core/lib/memory.lib.php'; $tmparray = dol_getcache($usecachekey); if (is_array($tmparray) && count($tmparray)) { $this->tab_translate += $tmparray; // Faster than array_merge($tmparray,$this->tab_translate). Note: If a value already exists into tab_translate, value into tmparaay is not added. @@ -483,8 +494,8 @@ class Translate if (!$found && !empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) { // Overwrite translation with database read - $sql = "SELECT transkey, transvalue FROM ".$db->prefix()."overwrite_trans where lang='".$db->escape($this->defaultlang)."' OR lang IS NULL"; - $sql .= " AND entity IN (0, ".getEntity('overwrite_trans').")"; + $sql = "SELECT transkey, transvalue FROM " . $db->prefix() . "overwrite_trans where lang='" . $db->escape($this->defaultlang) . "' OR lang IS NULL"; + $sql .= " AND entity IN (0, " . getEntity('overwrite_trans') . ")"; $sql .= $db->order("lang", "DESC"); $resql = $db->query($sql); @@ -522,7 +533,7 @@ class Translate if ($usecachekey && count($tabtranslatedomain)) { $ressetcache = dol_setcache($usecachekey, $tabtranslatedomain); if ($ressetcache < 0) { - $error = 'Failed to set cache for usecachekey='.$usecachekey.' result='.$ressetcache; + $error = 'Failed to set cache for usecachekey=' . $usecachekey . ' result=' . $ressetcache; dol_syslog($error, LOG_ERR); } } @@ -622,12 +633,12 @@ class Translate $str = $this->tab_translate[$key]; // Make some string replacement after translation - $replacekey = 'MAIN_REPLACE_TRANS_'.$this->defaultlang; + $replacekey = 'MAIN_REPLACE_TRANS_' . $this->defaultlang; if (!empty($conf->global->$replacekey)) { // Replacement translation variable with string1:newstring1;string2:newstring2 $tmparray = explode(';', $conf->global->$replacekey); foreach ($tmparray as $tmp) { $tmparray2 = explode(':', $tmp); - $str = preg_replace('/'.preg_quote($tmparray2[0]).'/', $tmparray2[1], $str); + $str = preg_replace('/' . preg_quote($tmparray2[0]) . '/', $tmparray2[1], $str); } } @@ -712,12 +723,12 @@ class Translate $str = $this->tab_translate[$key]; // Make some string replacement after translation - $replacekey = 'MAIN_REPLACE_TRANS_'.$this->defaultlang; + $replacekey = 'MAIN_REPLACE_TRANS_' . $this->defaultlang; if (!empty($conf->global->$replacekey)) { // Replacement translation variable with string1:newstring1;string2:newstring2 $tmparray = explode(';', $conf->global->$replacekey); foreach ($tmparray as $tmp) { $tmparray2 = explode(':', $tmp); - $str = preg_replace('/'.preg_quote($tmparray2[0]).'/', $tmparray2[1], $str); + $str = preg_replace('/' . preg_quote($tmparray2[0]) . '/', $tmparray2[1], $str); } } @@ -810,7 +821,7 @@ class Translate $this->load("languages"); // We scan directory langs to detect available languages - $handle = opendir($langdir."/langs"); + $handle = opendir($langdir . "/langs"); $langs_available = array(); while ($dir = trim(readdir($handle))) { $regs = array(); @@ -818,33 +829,33 @@ class Translate // We must keep only main languages if ($mainlangonly) { $arrayofspecialmainlanguages = array( - 'en'=>'en_US', - 'am'=>'am_ET', - 'ar'=>'ar_SA', - 'bn'=>'bn_DB', - 'bs'=>'bs_BA', - 'ca'=>'ca_ES', - 'cs'=>'cs_CZ', - 'da'=>'da_DK', - 'et'=>'et_EE', - 'el'=>'el_GR', - 'eu'=>'eu_ES', - 'fa'=>'fa_IR', - 'he'=>'he_IL', - 'ka'=>'ka_GE', - 'km'=>'km_KH', - 'kn'=>'kn_IN', - 'ko'=>'ko_KR', - 'ja'=>'ja_JP', - 'lo'=>'lo_LA', - 'nb'=>'nb_NO', - 'sq'=>'sq_AL', - 'sr'=>'sr_RS', - 'sv'=>'sv_SE', - 'sl'=>'sl_SI', - 'uk'=>'uk_UA', - 'vi'=>'vi_VN', - 'zh'=>'zh_CN' + 'en' => 'en_US', + 'am' => 'am_ET', + 'ar' => 'ar_SA', + 'bn' => 'bn_DB', + 'bs' => 'bs_BA', + 'ca' => 'ca_ES', + 'cs' => 'cs_CZ', + 'da' => 'da_DK', + 'et' => 'et_EE', + 'el' => 'el_GR', + 'eu' => 'eu_ES', + 'fa' => 'fa_IR', + 'he' => 'he_IL', + 'ka' => 'ka_GE', + 'km' => 'km_KH', + 'kn' => 'kn_IN', + 'ko' => 'ko_KR', + 'ja' => 'ja_JP', + 'lo' => 'lo_LA', + 'nb' => 'nb_NO', + 'sq' => 'sq_AL', + 'sr' => 'sr_RS', + 'sv' => 'sv_SE', + 'sl' => 'sl_SI', + 'uk' => 'uk_UA', + 'vi' => 'vi_VN', + 'zh' => 'zh_CN' ); if (strtolower($regs[1]) != strtolower($regs[2]) && !in_array($dir, $arrayofspecialmainlanguages)) { continue; @@ -860,9 +871,9 @@ class Translate } if ($usecode == 1 || !empty($conf->global->MAIN_SHOW_LANGUAGE_CODE)) { - $langs_available[$dir] = $dir.': '.dol_trunc($this->trans('Language_'.$dir), $maxlength); + $langs_available[$dir] = $dir . ': ' . dol_trunc($this->trans('Language_' . $dir), $maxlength); } else { - $langs_available[$dir] = $this->trans('Language_'.$dir); + $langs_available[$dir] = $this->trans('Language_' . $dir); } if ($mainlangonly) { $langs_available[$dir] = str_replace(' (United States)', '', $langs_available[$dir]); @@ -886,14 +897,14 @@ class Translate // phpcs:enable // Test si fichier dans repertoire de la langue foreach ($this->dir as $searchdir) { - if (is_readable(dol_osencode($searchdir."/langs/".$this->defaultlang."/".$filename))) { + if (is_readable(dol_osencode($searchdir . "/langs/" . $this->defaultlang . "/" . $filename))) { return true; } if ($searchalt) { // Test si fichier dans repertoire de la langue alternative if ($this->defaultlang != "en_US") { - $filenamealt = $searchdir."/langs/en_US/".$filename; + $filenamealt = $searchdir . "/langs/en_US/" . $filename; } //else $filenamealt = $searchdir."/langs/fr_FR/".$filename; if (is_readable(dol_osencode($filenamealt))) { @@ -934,8 +945,8 @@ class Translate } $fonc = 'numberwords'; - if (file_exists($newdir.'/functions_'.$fonc.'.lib.php')) { - include_once $newdir.'/functions_'.$fonc.'.lib.php'; + if (file_exists($newdir . '/functions_' . $fonc . '.lib.php')) { + include_once $newdir . '/functions_' . $fonc . '.lib.php'; if (function_exists('numberwords_getLabelFromNumber')) { $newnumber = numberwords_getLabelFromNumber($this, $number, $isamount); break; @@ -988,13 +999,13 @@ class Translate } // Not found in loaded language file nor in cache. So we will take the label into database. - $sql = "SELECT ".$fieldlabel." as label"; - $sql .= " FROM ".$db->prefix().$tablename; - $sql .= " WHERE ".$fieldkey." = '".$db->escape($keyforselect ? $keyforselect : $key)."'"; + $sql = "SELECT " . $fieldlabel . " as label"; + $sql .= " FROM " . $db->prefix() . $tablename; + $sql .= " WHERE " . $fieldkey . " = '" . $db->escape($keyforselect ? $keyforselect : $key) . "'"; if ($filteronentity) { - $sql .= " AND entity IN (".getEntity($tablename).')'; + $sql .= " AND entity IN (" . getEntity($tablename) . ')'; } - dol_syslog(get_class($this).'::getLabelFromKey', LOG_DEBUG); + dol_syslog(get_class($this) . '::getLabelFromKey', LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); @@ -1027,9 +1038,9 @@ class Translate $symbol = $this->getCurrencySymbol($currency_code); if (in_array($currency_code, array('USD'))) { - return $symbol.$amount; + return $symbol . $amount; } else { - return $amount.$symbol; + return $amount . $symbol; } } @@ -1050,7 +1061,7 @@ class Translate if (isset($this->cache_currencies[$currency_code]) && !empty($this->cache_currencies[$currency_code]['unicode']) && is_array($this->cache_currencies[$currency_code]['unicode'])) { foreach ($this->cache_currencies[$currency_code]['unicode'] as $unicode) { - $currency_sign .= mb_convert_encoding("&#".$unicode.";", "UTF-8", 'HTML-ENTITIES'); + $currency_sign .= mb_convert_encoding("&#" . $unicode . ";", "UTF-8", 'HTML-ENTITIES'); } } } @@ -1076,14 +1087,14 @@ class Translate } $sql = "SELECT code_iso, label, unicode"; - $sql .= " FROM ".$db->prefix()."c_currencies"; + $sql .= " FROM " . $db->prefix() . "c_currencies"; $sql .= " WHERE active = 1"; if (!empty($currency_code)) { - $sql .= " AND code_iso = '".$db->escape($currency_code)."'"; + $sql .= " AND code_iso = '" . $db->escape($currency_code) . "'"; } //$sql.= " ORDER BY code_iso ASC"; // Not required, a sort is done later - dol_syslog(get_class($this).'::loadCacheCurrencies', LOG_DEBUG); + dol_syslog(get_class($this) . '::loadCacheCurrencies', LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $this->load("dict"); @@ -1100,7 +1111,7 @@ class Translate $obj = $db->fetch_object($resql); if ($obj) { // If a translation exists, we use it lese we use the default label - $this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $this->trans("Currency".$obj->code_iso) != "Currency".$obj->code_iso ? $this->trans("Currency".$obj->code_iso) : ($obj->label != '-' ? $obj->label : '')); + $this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $this->trans("Currency" . $obj->code_iso) != "Currency" . $obj->code_iso ? $this->trans("Currency" . $obj->code_iso) : ($obj->label != '-' ? $obj->label : '')); $this->cache_currencies[$obj->code_iso]['unicode'] = (array) json_decode((empty($obj->unicode) ? '' : $obj->unicode), true); $label[$obj->code_iso] = $this->cache_currencies[$obj->code_iso]['label']; } @@ -1134,8 +1145,8 @@ class Translate $substitutionarray = array(); foreach ($this->tab_translate as $code => $label) { - $substitutionarray['lang_'.$code] = $label; - $substitutionarray['__('.$code.')__'] = $label; + $substitutionarray['lang_' . $code] = $label; + $substitutionarray['__(' . $code . ')__'] = $label; } return $substitutionarray; diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 15ac87a975f..9e632b948b4 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -2376,6 +2376,7 @@ function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent) print '
We fixed '.$totalnb.' record(s). Some records may still be corrupted. New check may be required.'; return $totalnb; } + return -1; } diff --git a/htdocs/core/lib/functionsnumtoword.lib.php b/htdocs/core/lib/functionsnumtoword.lib.php index f451f7370eb..f14295ab068 100644 --- a/htdocs/core/lib/functionsnumtoword.lib.php +++ b/htdocs/core/lib/functionsnumtoword.lib.php @@ -247,6 +247,7 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number') } return $entexto; } + return -1; } /** diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 7ca7a442909..0ad5c4e80db 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -327,6 +327,7 @@ function dolGetLdapPasswordHash($password, $type = 'md5') } elseif ($type === 'clear') { return '{CLEAR}' . $password; // Just for test, plain text password is not secured ! } + return ""; } /** diff --git a/htdocs/hrm/class/skill.class.php b/htdocs/hrm/class/skill.class.php index 1f2dc77fc5e..9062bc6caa3 100644 --- a/htdocs/hrm/class/skill.class.php +++ b/htdocs/hrm/class/skill.class.php @@ -417,7 +417,7 @@ class Skill extends CommonObject $this->error = $skilldet->error; return $this->lines; } - return -1; + return []; }