forked from Wavyzz/dolibarr
Clean code
This commit is contained in:
@@ -30,11 +30,11 @@ require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/iUs
|
||||
require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/Resources.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/Defaults.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/RestException.php';
|
||||
use \Luracast\Restler\iAuthenticate;
|
||||
use \Luracast\Restler\iUseAuthentication;
|
||||
use \Luracast\Restler\Resources;
|
||||
use \Luracast\Restler\Defaults;
|
||||
use \Luracast\Restler\RestException;
|
||||
use Luracast\Restler\iAuthenticate;
|
||||
use Luracast\Restler\iUseAuthentication;
|
||||
use Luracast\Restler\Resources;
|
||||
use Luracast\Restler\Defaults;
|
||||
use Luracast\Restler\RestException;
|
||||
|
||||
/**
|
||||
* Dolibarr API access class
|
||||
|
||||
@@ -1350,7 +1350,7 @@ class CMailFile
|
||||
/**
|
||||
* Build a css style (mode = all) into this->styleCSS and this->bodyCSS
|
||||
*
|
||||
* @return string
|
||||
* @return void
|
||||
*/
|
||||
public function buildCSS()
|
||||
{
|
||||
|
||||
@@ -1536,7 +1536,7 @@ abstract class CommonDocGenerator
|
||||
* get column status from column key
|
||||
*
|
||||
* @param string $colKey the column key
|
||||
* @return float width in mm
|
||||
* @return boolean true if column on
|
||||
*/
|
||||
public function getColumnStatus($colKey)
|
||||
{
|
||||
|
||||
@@ -148,7 +148,7 @@ class HookManager
|
||||
* @param array $parameters Array of parameters
|
||||
* @param Object $object Object to use hooks on
|
||||
* @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...)
|
||||
* @return mixed For 'addreplace' hooks (doActions, formConfirm, formObjectOptions, pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop/replace standard actions, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller.
|
||||
* @return int For 'addreplace' hooks (doActions, formConfirm, formObjectOptions, pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop/replace standard actions, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller.
|
||||
* For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0 if we want to keep standard actions, >0 uf we want to stop/replace standard actions (at least one > 0 and replacement will be done), <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller.
|
||||
* All types can also return some values into an array ->results that will be finaly merged into this->resArray for caller.
|
||||
* $this->error or this->errors are also defined by class called by this function if error.
|
||||
|
||||
@@ -53,6 +53,11 @@ class Lessc
|
||||
public $importDisabled = false;
|
||||
public $importDir = '';
|
||||
|
||||
public $scope;
|
||||
public $formatter;
|
||||
public $env;
|
||||
public $count;
|
||||
|
||||
protected $numberPrecision = null;
|
||||
|
||||
protected $allParsedFiles = array();
|
||||
|
||||
@@ -667,7 +667,7 @@ class RssParser
|
||||
|
||||
|
||||
/**
|
||||
* To concat 2 string with no warning if an operand is not defined
|
||||
* To concat 2 strings with no warning if an operand is not defined
|
||||
*
|
||||
* @param string $str1 Str1
|
||||
* @param string $str2 Str2
|
||||
|
||||
@@ -75,7 +75,7 @@ if ("Notification" in window) {
|
||||
/* Check if permission ok */
|
||||
if (Notification.permission !== "granted") {
|
||||
console.log("Ask Notification.permission");
|
||||
Notification.requestPermission()
|
||||
Notification.requestPermission();
|
||||
}
|
||||
|
||||
/* Launch timer */
|
||||
|
||||
@@ -72,12 +72,9 @@ function regexEvent(objet,evt,type)
|
||||
// ((charCode>=96) && (charCode<=105)) || //numpad
|
||||
return true;
|
||||
|
||||
}else
|
||||
{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -735,7 +735,7 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null
|
||||
$qualified = 1;
|
||||
}
|
||||
|
||||
if ($qualified) {
|
||||
if ($qualified && isset($user->default_values[$relativepathstring]['filters'][$defkey][$paramname])) {
|
||||
// We must keep $_POST and $_GET here
|
||||
if (isset($_POST['sall']) || isset($_POST['search_all']) || isset($_GET['sall']) || isset($_GET['search_all'])) {
|
||||
// We made a search from quick search menu, do we still use default filter ?
|
||||
@@ -1390,7 +1390,7 @@ function dol_string_unaccent($str)
|
||||
|
||||
if (utf8_check($str)) {
|
||||
if (extension_loaded('intl') && !empty($conf->global->MAIN_UNACCENT_USE_TRANSLITERATOR)) {
|
||||
$transliterator = \Transliterator::createFromRules(':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', \Transliterator::FORWARD);
|
||||
$transliterator = Transliterator::createFromRules(':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', Transliterator::FORWARD);
|
||||
return $transliterator->transliterate($str);
|
||||
}
|
||||
// See http://www.utf8-chartable.de/
|
||||
|
||||
@@ -621,7 +621,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
|
||||
}
|
||||
|
||||
// Before PHP8, img was a resource, With PHP8, it is a GdImage
|
||||
if (!is_resource($img) && !($img instanceof \GdImage)) {
|
||||
if (!is_resource($img) && !($img instanceof GdImage)) {
|
||||
dol_syslog('Failed to detect type of image. We found infoImg[2]='.$infoImg[2], LOG_WARNING);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ function pdf_getEncryption($pathoffile)
|
||||
$content = file_get_contents($pathoffile);
|
||||
|
||||
//ob_start();
|
||||
@($parser = new \TCPDF_PARSER(ltrim($content)));
|
||||
@($parser = new TCPDF_PARSER(ltrim($content)));
|
||||
list($xref, $data) = $parser->getParsedData();
|
||||
unset($parser);
|
||||
//ob_end_clean();
|
||||
|
||||
@@ -51,7 +51,7 @@ class ImportCsv extends ModeleImports
|
||||
public $errors = array();
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
* @var string Code of driver
|
||||
*/
|
||||
public $id;
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class ImportXlsx extends ModeleImports
|
||||
public $errors = array();
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
* @var string Code of driver
|
||||
*/
|
||||
public $id;
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class ModeleImports
|
||||
public $error = '';
|
||||
|
||||
/**
|
||||
* @var int id of driver
|
||||
* @var string Code of driver
|
||||
*/
|
||||
public $id;
|
||||
|
||||
@@ -129,7 +129,7 @@ class ModeleImports
|
||||
/**
|
||||
* getDriverId
|
||||
*
|
||||
* @return string Id
|
||||
* @return int Id
|
||||
*/
|
||||
public function getDriverId()
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* \ingroup debugbar
|
||||
*/
|
||||
|
||||
use \DebugBar\DataCollector\ConfigCollector;
|
||||
use DebugBar\DataCollector\ConfigCollector;
|
||||
|
||||
/**
|
||||
* DolConfigCollector class
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* \ingroup debugbar
|
||||
*/
|
||||
|
||||
use \DebugBar\DataCollector\ExceptionsCollector;
|
||||
use DebugBar\DataCollector\ExceptionsCollector;
|
||||
|
||||
/**
|
||||
* DolExceptionsCollector class
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* \ingroup debugbar
|
||||
*/
|
||||
|
||||
use \DebugBar\DataCollector\MemoryCollector;
|
||||
use DebugBar\DataCollector\MemoryCollector;
|
||||
|
||||
/**
|
||||
* DolMemoryCollector class
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* \ingroup debugbar
|
||||
*/
|
||||
|
||||
use \DebugBar\DataCollector\MessagesCollector;
|
||||
use DebugBar\DataCollector\MessagesCollector;
|
||||
|
||||
/**
|
||||
* DolMessagesCollector class
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* \ingroup debugbar
|
||||
*/
|
||||
|
||||
use \DebugBar\DataCollector\RequestDataCollector;
|
||||
use DebugBar\DataCollector\RequestDataCollector;
|
||||
|
||||
/**
|
||||
* DolRequestDataCollector class
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* \ingroup debugbar
|
||||
*/
|
||||
|
||||
use \DebugBar\DataCollector\TimeDataCollector;
|
||||
use DebugBar\DataCollector\TimeDataCollector;
|
||||
|
||||
/**
|
||||
* DolTimeDataCollector class
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
dol_include_once('/debugbar/class/autoloader.php');
|
||||
|
||||
use \DebugBar\DebugBar;
|
||||
use DebugBar\DebugBar;
|
||||
|
||||
dol_include_once('/debugbar/class/DataCollector/DolMessagesCollector.php');
|
||||
dol_include_once('/debugbar/class/DataCollector/DolRequestDataCollector.php');
|
||||
|
||||
@@ -74,6 +74,11 @@ class Don extends CommonObject
|
||||
*/
|
||||
public $amount;
|
||||
|
||||
/**
|
||||
* @var integer Thirdparty ID
|
||||
*/
|
||||
public $socid;
|
||||
|
||||
/**
|
||||
* @var string Thirdparty name
|
||||
*/
|
||||
|
||||
@@ -2337,7 +2337,7 @@ if ($action == 'create') {
|
||||
|
||||
if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
|
||||
print '<td class="fk_c_exp_tax_cat">';
|
||||
$params = array('fk_expense' => $object->id, 'fk_expense_det' => $line->id, 'date' => $line->dates);
|
||||
$params = array('fk_expense' => $object->id, 'fk_expense_det' => $line->id, 'date' => $line->date);
|
||||
print $form->selectExpenseCategories($line->fk_c_exp_tax_cat, 'fk_c_exp_tax_cat', 1, array(), 'fk_c_type_fees', $userauthor->default_c_exp_tax_cat, $params);
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
@@ -35,7 +35,18 @@ class Export
|
||||
*/
|
||||
public $db;
|
||||
|
||||
/**
|
||||
* @var string Last error message
|
||||
*/
|
||||
public $error;
|
||||
/**
|
||||
* @var string Last error code
|
||||
*/
|
||||
public $errno;
|
||||
/**
|
||||
* @var string Error messages
|
||||
*/
|
||||
public $errors;
|
||||
|
||||
public $array_export_code = array(); // Tableau de "idmodule_numexportprofile"
|
||||
public $array_export_code_for_sort = array(); // Tableau de "idmodule_numexportprofile"
|
||||
|
||||
@@ -29,6 +29,21 @@
|
||||
*/
|
||||
class Import
|
||||
{
|
||||
/**
|
||||
* @var DoliDB Database handler.
|
||||
*/
|
||||
public $db;
|
||||
|
||||
/**
|
||||
* @var string Error code (or message)
|
||||
*/
|
||||
public $error = '';
|
||||
|
||||
/**
|
||||
* @var string[] Error codes (or messages)
|
||||
*/
|
||||
public $errors = array();
|
||||
|
||||
public $array_import_module;
|
||||
public $array_import_perms;
|
||||
public $array_import_icon;
|
||||
@@ -45,16 +60,6 @@ class Import
|
||||
public $array_import_convertvalue;
|
||||
public $array_import_run_sql_after;
|
||||
|
||||
/**
|
||||
* @var string Error code (or message)
|
||||
*/
|
||||
public $error = '';
|
||||
|
||||
/**
|
||||
* @var string[] Error codes (or messages)
|
||||
*/
|
||||
public $errors = array();
|
||||
|
||||
// To store import templates
|
||||
public $id;
|
||||
public $hexa; // List of fields in the export profile
|
||||
|
||||
@@ -2864,11 +2864,11 @@ if (!empty($module) && $module != 'initmodule' && $module != 'deletemodule') {
|
||||
dol_include_once($fullpathdirtodescriptor);
|
||||
|
||||
$class = 'mod'.$module;
|
||||
} catch (Throwable $e) { // This is called in PHP 7 only. Never called with PHP 5.6
|
||||
} catch (Throwable $e) { // This is called in PHP 7 only (includes Error and Exception). Never called with PHP 5.6-.
|
||||
$loadclasserrormessage = $e->getMessage()."<br>\n";
|
||||
$loadclasserrormessage .= 'File: '.$e->getFile()."<br>\n";
|
||||
$loadclasserrormessage .= 'Line: '.$e->getLine()."<br>\n";
|
||||
} catch (Exception $e) {
|
||||
} catch (Exception $e) { // This is called in PHP 5.6- because not already trapped by previous case in PHP 5.6-.
|
||||
$loadclasserrormessage = $e->getMessage()."<br>\n";
|
||||
$loadclasserrormessage .= 'File: '.$e->getFile()."<br>\n";
|
||||
$loadclasserrormessage .= 'Line: '.$e->getLine()."<br>\n";
|
||||
|
||||
@@ -122,10 +122,10 @@ $error = 0;
|
||||
|
||||
try {
|
||||
$event = \Stripe\Webhook::constructEvent($payload, $sig_header, $endpoint_secret);
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
} catch (UnexpectedValueException $e) {
|
||||
// Invalid payload
|
||||
httponly_accessforbidden('Invalid payload', 400);
|
||||
} catch (\Stripe\Error\SignatureVerification $e) {
|
||||
} catch (\Stripe\Exception\SignatureVerificationException $e) {
|
||||
httponly_accessforbidden('Invalid signature', 400);
|
||||
} catch (Exception $e) {
|
||||
httponly_accessforbidden('Error '.$e->getMessage(), 400);
|
||||
|
||||
@@ -622,8 +622,7 @@ class Thirdparties extends DolibarrApi
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
* @param int $page Page number
|
||||
*
|
||||
* @return mixed
|
||||
* @return array|void
|
||||
*
|
||||
* @url GET {id}/categories
|
||||
*/
|
||||
@@ -640,17 +639,17 @@ class Thirdparties extends DolibarrApi
|
||||
|
||||
$categories = new Categorie($this->db);
|
||||
|
||||
$result = $categories->getListForItem($id, 'customer', $sortfield, $sortorder, $limit, $page);
|
||||
$arrayofcateg = $categories->getListForItem($id, 'customer', $sortfield, $sortorder, $limit, $page);
|
||||
|
||||
if (is_numeric($result) && $result < 0) {
|
||||
if (is_numeric($arrayofcateg) && $arrayofcateg < 0) {
|
||||
throw new RestException(503, 'Error when retrieve category list : '.$categories->error);
|
||||
}
|
||||
|
||||
if (is_numeric($result) && $result == 0) { // To fix a return of 0 instead of empty array of method getListForItem
|
||||
if (is_numeric($arrayofcateg) && $arrayofcateg == 0) { // To fix a return of 0 instead of empty array of method getListForItem
|
||||
return array();
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $arrayofcateg;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -245,18 +245,18 @@ function PrintCategories(first) {
|
||||
|
||||
function MoreCategories(moreorless) {
|
||||
console.log("MoreCategories moreorless="+moreorless+" pagecategories="+pagecategories);
|
||||
if (moreorless=="more") {
|
||||
if (moreorless == "more") {
|
||||
$('#catimg15').animate({opacity: '0.5'}, 1);
|
||||
$('#catimg15').animate({opacity: '1'}, 100);
|
||||
pagecategories=pagecategories+1;
|
||||
}
|
||||
if (moreorless=="less") {
|
||||
if (moreorless == "less") {
|
||||
$('#catimg14').animate({opacity: '0.5'}, 1);
|
||||
$('#catimg14').animate({opacity: '1'}, 100);
|
||||
if (pagecategories==0) return; //Return if no less pages
|
||||
pagecategories=pagecategories-1;
|
||||
}
|
||||
if (typeof (categories[<?php echo ($MAXCATEG - 2); ?> * pagecategories] && moreorless=="more") == "undefined"){ // Return if no more pages
|
||||
if (typeof (categories[<?php echo ($MAXCATEG - 2); ?> * pagecategories] && moreorless == "more") == "undefined") { // Return if no more pages
|
||||
pagecategories=pagecategories-1;
|
||||
return;
|
||||
}
|
||||
|
||||
10
qodana.yaml
10
qodana.yaml
@@ -16,6 +16,7 @@ exclude:
|
||||
- htdocs/includes
|
||||
- htdocs/install/doctemplates
|
||||
- htdocs/modulebuilder/template/test/phpunit/functionnal
|
||||
- htdocs/theme/common/fontawesome-5
|
||||
- name: PhpIssetCanBeReplacedWithCoalesceInspection
|
||||
- name: PhpRedundantOptionalArgumentInspection
|
||||
- name: PhpLanguageLevelInspection
|
||||
@@ -84,3 +85,12 @@ exclude:
|
||||
- name: PhpPointlessBooleanExpressionInConditionInspection
|
||||
- name: PhpUndefinedMethodInspection
|
||||
- name: PhpDuplicateCatchBodyInspection
|
||||
- name: PhpDefineCanBeReplacedWithConstInspection
|
||||
- name: PhpMissingParamTypeInspection
|
||||
- name: PhpMissingReturnTypeInspection
|
||||
- name: CommaExpressionJS
|
||||
- name: JSTypeOfValues
|
||||
- name: PhpRedundantVariableDocTypeInspection
|
||||
- name: PhpUnhandledExceptionInspection
|
||||
- name: JSIgnoredPromiseFromCall
|
||||
|
||||
Reference in New Issue
Block a user