Clean phpcs

This commit is contained in:
Laurent Destailleur 2020-05-02 15:18:59 +02:00
parent 6bc7085297
commit a88ab40384
11 changed files with 71 additions and 60 deletions

View File

@ -28,7 +28,7 @@ Other licenses apply for some included dependencies. See [COPYRIGHT](https://git
If you have low technical skills and you're looking to install Dolibarr ERP/CRM in just a few clicks, you can use one of the packaged versions:
- [DoliWamp for Windows](https://wiki.dolibarr.org/index.php/Dolibarr_for_Windows_(DoliWamp)
- DoliDeb for Debian or Ubuntu
- [DoliDeb for Debian](https://wiki.dolibarr.org/index.php/Dolibarr_for_Ubuntu_or_Debian
- DoliRpm for Redhat, Fedora, OpenSuse, Mandriva or Mageia
Releases can be downloaded from [official website](https://www.dolibarr.org/).

View File

@ -67,19 +67,11 @@
</rule>
<!--
<!-- Warnings on TODO -->
<!-- Disabled: We want to keep TODO as normal
<rule ref="Generic.Commenting.Todo" />
-->
<!-- Warning if action on same line than if -->
<!--
<rule ref="Generic.ControlStructures.InlineControlStructure">
<properties>
<property name="error" value="false"/>
</properties>
</rule>
-->
<!-- PHP code MUST use only UTF-8 without BOM. -->
<rule ref="Generic.Files.ByteOrderMark"/>
@ -99,19 +91,33 @@
</properties>
</rule>
<!-- Disallow several statements on same line -->
<!-- Warning if action on same line than if -->
<!-- Disabled: We want to allow this for better code compacity and readability
<rule ref="Generic.ControlStructures.InlineControlStructure">
<properties>
<property name="error" value="false"/>
</properties>
</rule>
-->
<!-- We want to allow 'if () { ...small code... }' on same line for better code compacity and readability -->
<rule ref="Generic.Formatting.DisallowMultipleStatements">
<severity>0</severity>
</rule>
<!-- Have 2 chars padding maximum and always show as errors -->
<!--
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<properties> <property name="maxPadding" value="2"/> <property
name="ignoreMultiLine" value="true"/> </properties> </rule>
-->
<!-- Check assignement have the = align on each line. Have 20 chars padding maximum and always show as errors -->
<!-- Disabled: Report some false warning
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<properties>
<property name="maxPadding" value="20"/>
<property name="ignoreMultiLine" value="true"/>
</properties>
</rule>
-->
<rule ref="Generic.Formatting.SpaceAfterCast" />
<rule ref="Generic.Functions.CallTimePassByReference" />
@ -127,7 +133,7 @@
<!-- Tweaks to metrics -->
<rule ref="Generic.Metrics.CyclomaticComplexity">
<properties>
<property name="complexity" value="150" />
<property name="complexity" value="250" />
<property name="absoluteComplexity" value="300" />
</properties>
</rule>
@ -190,13 +196,10 @@
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.StartFile">
<severity>0</severity>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EndFile">
<severity>0</severity>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.StartFile" />
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EndFile" />
<!-- Disabled: We want to have 2 empty line as separator sometimes -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines" >
<severity>0</severity>
</rule>
@ -208,7 +211,6 @@
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration" />
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration.SpaceAfterFunction">
<severity>0</severity>
</rule>
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
<properties>

View File

@ -18,7 +18,7 @@
// Create the autoloader for Luracast
require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/AutoLoader.php';
call_user_func(function() {
call_user_func(function () {
$loader = Luracast\Restler\AutoLoader::instance();
spl_autoload_register($loader);
return $loader;

View File

@ -44,7 +44,7 @@ if (!$res) die("Include of main fails");
require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/AutoLoader.php';
call_user_func(function() {
call_user_func(function () {
$loader = Luracast\Restler\AutoLoader::instance();
spl_autoload_register($loader);
return $loader;

View File

@ -1295,7 +1295,7 @@ abstract class CommonDocGenerator
if (!empty($fields))
{
// Sort extrafields by rank
uasort($fields, function($a, $b) {
uasort($fields, function ($a, $b) {
return ($a->rank > $b->rank) ? -1 : 1;
});

View File

@ -282,7 +282,8 @@ class modEmailCollector extends DolibarrModules
$tmpresql = $this->db->query($tmpsql);
if ($tmpresql) {
if ($this->db->num_rows($tmpresql) == 0) {
$descriptionA1 = 'This collector will scan your mailbox to find emails that match some rules and create automatically a ticket (Module Ticket must be enabled) with the email informations. You can use this collector if you provide some support by email, so your ticket request will be automatically generated. If the collector Collect_Responses is also enabled, when you send an email from the ticket, you may also see answers of your customers or partners directly on the ticket view.';
$descriptionA1 = 'This collector will scan your mailbox to find emails that match some rules and create automatically a ticket (Module Ticket must be enabled) with the email informations. You can use this collector if you provide some support by email, so your ticket request will be automatically generated.';
$descriptionA1 .= ' If the collector Collect_Responses is also enabled, when you send an email from the ticket, you may also see answers of your customers or partners directly on the ticket view.';
$sqlforexampleA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)";
$sqlforexampleA1 .= " VALUES (".$conf->entity.", 'Collect_Ticket_Requets', 'Example to collect ticket requests', '".$this->db->escape($descriptionA1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".$user->id.", 0)";
$sqlforexampleA2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";
@ -319,7 +320,9 @@ class modEmailCollector extends DolibarrModules
$tmpresql = $this->db->query($tmpsql);
if ($tmpresql) {
if ($this->db->num_rows($tmpresql) == 0) {
$descriptionC1 = "This collector will scan your mailbox to find emails that match some rules and create automatically a lead (Module Project must be enabled) with the email informations. You can use this collector if you want to follow your lead using the module Project (1 lead = 1 project), so your leads will be automatically generated. If the collector Collect_Responses is also enabled, when you send an email from your leads, proposals or any other object, you may also see answers of your customers or partners directly on the application.<br>Note: With this initial example, the title of the lead is generated including the email. If the thirdparty can't be found in database (new customer), the lead will be attached to the thirdparty with ID 1.";
$descriptionC1 = "This collector will scan your mailbox to find emails that match some rules and create automatically a lead (Module Project must be enabled) with the email informations. You can use this collector if you want to follow your lead using the module Project (1 lead = 1 project), so your leads will be automatically generated.";
$descriptionC1 .= " If the collector Collect_Responses is also enabled, when you send an email from your leads, proposals or any other object, you may also see answers of your customers or partners directly on the application.<br>";
$descriptionC1 .= "Note: With this initial example, the title of the lead is generated including the email. If the thirdparty can't be found in database (new customer), the lead will be attached to the thirdparty with ID 1.";
$sqlforexampleC1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)";
$sqlforexampleC1 .= " VALUES (".$conf->entity.", 'Collect_Leads', 'Example to collect leads', '".$this->db->escape($descriptionC1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".$user->id.", 0)";
$sqlforexampleC2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";

View File

@ -82,7 +82,7 @@ $tmpDir = $conf->dav->multidir_output[$entity]; // We need root dir, not a dir t
// Authentication callback function
$authBackend = new \Sabre\DAV\Auth\Backend\BasicCallBack(function($username, $password) {
$authBackend = new \Sabre\DAV\Auth\Backend\BasicCallBack(function ($username, $password) {
global $user;
global $conf;
global $dolibarr_main_authentication, $dolibarr_auto_user;

View File

@ -4,7 +4,7 @@
* Simple autoloader, so we don't need Composer just for this.
*/
spl_autoload_register(function($class) {
spl_autoload_register(function ($class) {
if (preg_match('/^DebugBar/', $class) || preg_match('/^'.preg_quote('Psr\Log', '/').'/', $class)) {
$file = DOL_DOCUMENT_ROOT.'/includes/'.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php';
//var_dump($class.' - '.file_exists($file).' - '.$file);

View File

@ -55,11 +55,17 @@ class PaymentDonation extends CommonObject
public $fk_donation;
public $datec = '';
public $tms = '';
public $datep = '';
public $amount; // Total amount of payment
public $amounts = array(); // Array of amounts
public $amount; // Total amount of payment
public $amounts = array(); // Array of amounts
public $typepayment;
public $num_payment;
/**
@ -121,14 +127,14 @@ class PaymentDonation extends CommonObject
}
// Clean parameters
if (isset($this->fk_donation)) $this->fk_donation = (int) $this->fk_donation;
if (isset($this->amount)) $this->amount = trim($this->amount);
if (isset($this->fk_donation)) $this->fk_donation = (int) $this->fk_donation;
if (isset($this->amount)) $this->amount = trim($this->amount);
if (isset($this->fk_typepayment)) $this->fk_typepayment = trim($this->fk_typepayment);
if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment);
if (isset($this->note_public)) $this->note_public = trim($this->note_public);
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment);
if (isset($this->note_public)) $this->note_public = trim($this->note_public);
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
$totalamount = 0;
foreach ($this->amounts as $key => $value) // How payment is dispatch
@ -228,26 +234,26 @@ class PaymentDonation extends CommonObject
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->ref = $obj->rowid;
$this->id = $obj->rowid;
$this->ref = $obj->rowid;
$this->fk_donation = $obj->fk_donation;
$this->datec = $this->db->jdate($obj->datec);
$this->tms = $this->db->jdate($obj->tms);
$this->datep = $this->db->jdate($obj->datep);
$this->amount = $obj->amount;
$this->fk_donation = $obj->fk_donation;
$this->datec = $this->db->jdate($obj->datec);
$this->tms = $this->db->jdate($obj->tms);
$this->datep = $this->db->jdate($obj->datep);
$this->amount = $obj->amount;
$this->fk_typepayment = $obj->fk_typepayment;
$this->num_payment = $obj->num_payment;
$this->note_public = $obj->note_public;
$this->fk_bank = $obj->fk_bank;
$this->fk_user_creat = $obj->fk_user_creat;
$this->fk_user_modif = $obj->fk_user_modif;
$this->num_payment = $obj->num_payment;
$this->note_public = $obj->note_public;
$this->fk_bank = $obj->fk_bank;
$this->fk_user_creat = $obj->fk_user_creat;
$this->fk_user_modif = $obj->fk_user_modif;
$this->type_code = $obj->type_code;
$this->type_code = $obj->type_code;
$this->type_label = $obj->type_label;
$this->bank_account = $obj->fk_account;
$this->bank_line = $obj->fk_bank;
$this->bank_line = $obj->fk_bank;
}
$this->db->free($resql);

View File

@ -141,7 +141,7 @@ for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
$price_options[$i] = $langs->trans('SellingPrice').' '.$i;
}
$genPriceOptions = function($level) use ($price_options) {
$genPriceOptions = function ($level) use ($price_options) {
$return = array();

View File

@ -31,10 +31,10 @@ $langs->loadLangs(array("stocks", "other"));
// Get parameters
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');
$cancel = GETPOST('cancel', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');
$cancel = GETPOST('cancel', 'aZ09');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectcard'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha');