Skip to content

Commit

Permalink
Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into d…
Browse files Browse the repository at this point in the history
…evelop
  • Loading branch information
eldy committed Dec 18, 2024
2 parents f35c011 + f3c028c commit 5a88a40
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-18-autolabel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
configuration-path: .github/changed-lines-count-labeler.yml
continue-on-error: true
continue-on-error: true
60 changes: 18 additions & 42 deletions build/phpstan/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ parameters:
path: ../../htdocs/accountancy/class/accountingaccount.class.php

-
message: '#^Call to function array_key_exists\(\) with ''error'' and array\{ref\: mixed, label\: mixed, acquisition_value_ht\: mixed, depreciation\: non\-empty\-array\<int\|string, array\{date\: mixed, ref\: mixed, lines\: non\-empty\-array\<int\|string, mixed\>\}\>, disposal\?\: array\{date\: mixed, amount\: mixed, subject_to_vat\: bool\}\} will always evaluate to false\.$#'
message: '#^Call to function array_key_exists\(\) with ''error'' and array\{ref\: mixed, label\: mixed, acquisition_value_ht\: mixed, depreciation\: non\-empty\-array\<array\{date\: mixed, ref\: mixed, lines\: non\-empty\-array\<mixed\>\}\>, disposal\?\: array\{date\: mixed, amount\: mixed, subject_to_vat\: bool\}\} will always evaluate to false\.$#'
identifier: function.impossibleType
count: 1
path: ../../htdocs/accountancy/class/accountingjournal.class.php
Expand Down Expand Up @@ -625,7 +625,7 @@ parameters:
path: ../../htdocs/accountancy/class/lettering.class.php

-
message: '#^Parameter \#1 \$link_by_element of method Lettering\:\:getGroupElements\(\) expects array\<array\<string, int\>\>, array\<int\|string, array\<string, string\>\> given\.$#'
message: '#^Parameter \#1 \$link_by_element of method Lettering\:\:getGroupElements\(\) expects array\<array\<string, int\>\>, array\<array\<string, string\>\> given\.$#'
identifier: argument.type
count: 1
path: ../../htdocs/accountancy/class/lettering.class.php
Expand Down Expand Up @@ -894,10 +894,16 @@ parameters:
count: 1
path: ../../htdocs/adherents/card.php

-
message: '#^Call to function is_array\(\) with array will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: ../../htdocs/adherents/class/adherent.class.php

-
message: '#^Call to function is_array\(\) with array\<mixed\> will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 2
count: 1
path: ../../htdocs/adherents/class/adherent.class.php

-
Expand Down Expand Up @@ -3343,7 +3349,7 @@ parameters:
path: ../../htdocs/categories/class/categorie.class.php

-
message: '#^Method Categorie\:\:get_full_arbo\(\) should return \-1\|array\<int, array\{rowid\: int, id\: int, fk_parent\: int, label\: string, description\: string, color\: string, position\: string, visible\: int, \.\.\.\}\> but returns array\<int\|string, array\{rowid\: mixed, id\: mixed, fk_parent\: mixed, label\: mixed, description\: mixed, color\: mixed, position\: mixed, visible\: mixed, \.\.\.\}\>\.$#'
message: '#^Method Categorie\:\:get_full_arbo\(\) should return \-1\|array\<int, array\{rowid\: int, id\: int, fk_parent\: int, label\: string, description\: string, color\: string, position\: string, visible\: int, \.\.\.\}\> but returns array\<array\{rowid\: mixed, id\: mixed, fk_parent\: mixed, label\: mixed, description\: mixed, color\: mixed, position\: mixed, visible\: mixed, \.\.\.\}\>\.$#'
identifier: return.type
count: 1
path: ../../htdocs/categories/class/categorie.class.php
Expand All @@ -3361,7 +3367,7 @@ parameters:
path: ../../htdocs/categories/class/categorie.class.php

-
message: '#^Property Categorie\:\:\$cats \(array\<int, array\{rowid\: int, id\: int, fk_parent\: int, label\: string, description\: string, color\: string, position\: string, visible\: int, \.\.\.\}\>\) does not accept array\<int\|string, array\{rowid\: mixed, id\: mixed, fk_parent\: mixed, label\: mixed, description\: mixed, color\: mixed, position\: mixed, visible\: mixed, \.\.\.\}\>\.$#'
message: '#^Property Categorie\:\:\$cats \(array\<int, array\{rowid\: int, id\: int, fk_parent\: int, label\: string, description\: string, color\: string, position\: string, visible\: int, \.\.\.\}\>\) does not accept array\<array\{rowid\: mixed, id\: mixed, fk_parent\: mixed, label\: mixed, description\: mixed, color\: mixed, position\: mixed, visible\: mixed, \.\.\.\}\>\.$#'
identifier: assign.propertyType
count: 2
path: ../../htdocs/categories/class/categorie.class.php
Expand Down Expand Up @@ -5311,7 +5317,7 @@ parameters:
path: ../../htdocs/compta/cashcontrol/class/cashcontrol.class.php

-
message: '#^Call to function is_array\(\) with non\-empty\-array\<int\|string, \(float\|int\)\> will always evaluate to true\.$#'
message: '#^Call to function is_array\(\) with non\-empty\-array\<\(float\|int\)\> will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: ../../htdocs/compta/cashcontrol/report.php
Expand Down Expand Up @@ -6601,7 +6607,7 @@ parameters:
path: ../../htdocs/compta/resultat/index.php

-
message: '#^Call to function is_array\(\) with non\-empty\-array\<int\|string, array\{NP\: mixed, N\?\: \(float\|int\), M\?\: non\-empty\-array\<0\|1\|2\|3\|4\|5\|6\|7\|8\|9\|10\|11, mixed\>\}\> will always evaluate to true\.$#'
message: '#^Call to function is_array\(\) with non\-empty\-array\<array\{NP\: mixed, N\?\: \(float\|int\), M\?\: non\-empty\-array\<0\|1\|2\|3\|4\|5\|6\|7\|8\|9\|10\|11, mixed\>\}\> will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: ../../htdocs/compta/resultat/result.php
Expand Down Expand Up @@ -7969,7 +7975,7 @@ parameters:
path: ../../htdocs/core/actions_linkedfiles.inc.php

-
message: '#^Call to function is_array\(\) with non\-empty\-array\<int\|string, array\{paths\: array\{mixed\}, names\: array\{string\}, mimes\: array\{mixed\}\}\> will always evaluate to true\.$#'
message: '#^Call to function is_array\(\) with non\-empty\-array\<array\{paths\: array\{mixed\}, names\: array\{string\}, mimes\: array\{mixed\}\}\> will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: ../../htdocs/core/actions_massactions.inc.php
Expand Down Expand Up @@ -10537,7 +10543,7 @@ parameters:
path: ../../htdocs/core/class/notify.class.php

-
message: '#^Call to function is_array\(\) with non\-empty\-array\<int\|string, string\> will always evaluate to true\.$#'
message: '#^Call to function is_array\(\) with non\-empty\-array\<string\> will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: ../../htdocs/core/class/openid.class.php
Expand Down Expand Up @@ -13597,7 +13603,7 @@ parameters:
path: ../../htdocs/core/modules/hrm/mod_evaluation_standard.php

-
message: '#^Call to function is_array\(\) with non\-empty\-array will always evaluate to true\.$#'
message: '#^Call to function is_array\(\) with non\-empty\-list\<string\|null\> will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: ../../htdocs/core/modules/import/import_csv.modules.php
Expand Down Expand Up @@ -23299,7 +23305,7 @@ parameters:
path: ../../htdocs/master.inc.php

-
message: '#^Call to function is_array\(\) with array\<int\|string, array\{modulenamewithcase\: mixed, moduledescriptorrelpath\: string, moduledescriptorfullpath\: mixed, moduledescriptorrootpath\: mixed, moduletype\?\: ''external''\|''internal''\}\> will always evaluate to true\.$#'
message: '#^Call to function is_array\(\) with array\<array\{modulenamewithcase\: mixed, moduledescriptorrelpath\: string, moduledescriptorfullpath\: mixed, moduledescriptorrootpath\: mixed, moduletype\?\: ''external''\|''internal''\}\> will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: ../../htdocs/modulebuilder/index.php
Expand Down Expand Up @@ -30312,12 +30318,6 @@ parameters:
count: 1
path: ../../htdocs/salaries/list.php

-
message: '#^Variable \$resteapayer might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/salaries/list.php

-
message: '#^Variable \$selected might not be defined\.$#'
identifier: variable.undefined
Expand All @@ -30336,12 +30336,6 @@ parameters:
count: 2
path: ../../htdocs/salaries/paiement_salary.php

-
message: '#^Variable \$sumpaid might not be defined\.$#'
identifier: variable.undefined
count: 3
path: ../../htdocs/salaries/paiement_salary.php

-
message: '#^Negated boolean expression is always false\.$#'
identifier: booleanNot.alwaysFalse
Expand Down Expand Up @@ -30432,24 +30426,6 @@ parameters:
count: 1
path: ../../htdocs/societe/ajax/company.php

-
message: '#^Variable \$canvas might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/societe/canvas/company/tpl/card_create.tpl.php

-
message: '#^Variable \$canvas might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/societe/canvas/company/tpl/card_edit.tpl.php

-
message: '#^Variable \$canvas might not be defined\.$#'
identifier: variable.undefined
count: 2
path: ../../htdocs/societe/canvas/company/tpl/card_view.tpl.php

-
message: '#^Variable \$db might not be defined\.$#'
identifier: variable.undefined
Expand Down Expand Up @@ -30937,7 +30913,7 @@ parameters:
path: ../../htdocs/societe/notify/card.php

-
message: '#^Call to function is_array\(\) with array\<int\|string, array\{available\: mixed, currency\: mixed, pending\?\: \(array\|float\|int\)\}\> will always evaluate to true\.$#'
message: '#^Call to function is_array\(\) with array\<array\{available\: mixed, currency\: mixed, pending\?\: \(array\|float\|int\)\}\> will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: ../../htdocs/societe/paymentmodes.php
Expand Down
6 changes: 3 additions & 3 deletions dev/tools/phan/baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ return [
// PhanTypeMismatchProperty : 130+ occurrences
// PhanPluginUnknownArrayMethodParamType : 120+ occurrences
// PhanPluginUnknownPropertyType : 110+ occurrences
// PhanPossiblyUndeclaredVariable : 80+ occurrences
// PhanPossiblyUndeclaredVariable : 65+ occurrences
// PhanRedefineFunction : 45+ occurrences
// PhanTypeExpectedObjectPropAccess : 45+ occurrences
// PhanTypeMismatchArgumentNullableInternal : 40+ occurrences
Expand Down Expand Up @@ -507,7 +507,7 @@ return [
'htdocs/recruitment/admin/setup_candidatures.php' => ['PhanEmptyForeach'],
'htdocs/recruitment/class/recruitmentcandidature.class.php' => ['PhanUndeclaredProperty'],
'htdocs/recruitment/class/recruitmentjobposition.class.php' => ['PhanUndeclaredProperty'],
'htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php' => ['PhanPluginSuspiciousParamOrder', 'PhanUndeclaredProperty'],
'htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php' => ['PhanPluginSuspiciousParamOrder', 'PhanUndeclaredProperty'],
'htdocs/recruitment/index.php' => ['PhanUndeclaredGlobalVariable'],
Expand All @@ -523,7 +523,7 @@ return [
'htdocs/salaries/card.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/salaries/class/api_salaries.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'],
'htdocs/salaries/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'],
'htdocs/salaries/paiement_salary.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/salaries/paiement_salary.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/salaries/virement_request.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
'htdocs/societe/admin/societe.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod'],
'htdocs/societe/ajax/company.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
Expand Down
14 changes: 6 additions & 8 deletions htdocs/accountancy/class/bookkeeping.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class BookKeeping extends CommonObject
public $doc_date;

/**
* @var int Deadline for payment
* @var int|null|'' Deadline for payment
*/
public $date_lim_reglement;

Expand Down Expand Up @@ -2926,7 +2926,7 @@ public function closeFiscalPeriod($fiscal_period_id, $new_fiscal_period_id, $sep
$result = $this->db->query($sql);
if (!$result) {
$this->errors[] = 'Error: ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
$error++;
}
$objtmp = $this->db->fetch_object($result);
Expand All @@ -2938,7 +2938,7 @@ public function closeFiscalPeriod($fiscal_period_id, $new_fiscal_period_id, $sep

$bookkeeping->numero_compte = $obj->numero_compte;
$accountingaccount = new AccountingAccount($this->db);
$accountingaccount->fetch('', $obj->numero_compte);
$accountingaccount->fetch(0, $obj->numero_compte);
$bookkeeping->label_compte = $accountingaccount->label; // latest account label used

$bookkeeping->label_operation = $new_fiscal_period->label;
Expand All @@ -2953,8 +2953,7 @@ public function closeFiscalPeriod($fiscal_period_id, $new_fiscal_period_id, $sep

$result = $bookkeeping->create($user);
if ($result < 0) {
$this->error = $bookkeeping->error;
$this->errors = $bookkeeping->errors;
$this->setErrorsFromObject($bookkeeping);
$error++;
break;
}
Expand Down Expand Up @@ -2990,7 +2989,7 @@ public function closeFiscalPeriod($fiscal_period_id, $new_fiscal_period_id, $sep
$result = $this->db->query($sql);
if (!$result) {
$this->errors[] = 'Error: ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
$error++;
}
$objtmp = $this->db->fetch_object($result);
Expand All @@ -3015,8 +3014,7 @@ public function closeFiscalPeriod($fiscal_period_id, $new_fiscal_period_id, $sep

$result = $bookkeeping->create($user);
if ($result < 0) {
$this->error = $bookkeeping->error;
$this->errors = $bookkeeping->errors;
$this->setErrorsFromObject($bookkeeping);
$error++;
}
}
Expand Down
12 changes: 4 additions & 8 deletions htdocs/reception/class/reception.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,7 @@ public function valid($user, $notrigger = 0)

if (intval($result) < 0) {
$error++;
$this->errors[] = $mouvS->error;
$this->errors = array_merge($this->errors, $mouvS->errors);
$this->setErrorsFromObject($mouvS);
break;
}
} else {
Expand All @@ -661,8 +660,7 @@ public function valid($user, $notrigger = 0)

if (intval($result) < 0) {
$error++;
$this->errors[] = $mouvS->error;
$this->errors = array_merge($this->errors, $mouvS->errors);
$this->setErrorsFromObject($mouvS);
break;
}
}
Expand Down Expand Up @@ -809,8 +807,7 @@ public function getStatusDispatch()

$ret = $supplierorderdispatch->fetchAll('', '', 0, 0, $filter);
if ($ret < 0) {
$this->error = $supplierorderdispatch->error;
$this->errors = $supplierorderdispatch->errors;
$this->setErrorsFromObject($supplierorderdispatch);
return $ret;
} else {
// build array with quantity received by product in all supplier orders (origin)
Expand Down Expand Up @@ -895,8 +892,7 @@ public function addline($entrepot_id, $id, $qty, $array_options = [], $comment =
$supplierorderline = new CommandeFournisseurLigne($this->db);
$result = $supplierorderline->fetch($id);
if ($result <= 0) {
$this->error = $supplierorderline->error;
$this->errors = $supplierorderline->errors;
$this->setErrorsFromObject($supplierorderline);
return -1;
}

Expand Down
3 changes: 2 additions & 1 deletion htdocs/salaries/class/salary.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class Salary extends CommonObject

/**
* @var int
* @deprecated see $accountid
* @see $accountid
*/
public $fk_account;
Expand Down Expand Up @@ -154,7 +155,7 @@ class Salary extends CommonObject
const STATUS_PAID = 1;

/**
* @var string
* @var float amount remain to pay
*/
public $resteapayer;

Expand Down
6 changes: 3 additions & 3 deletions htdocs/salaries/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@
$objecttmp = new Salary($db);
$result = $objecttmp->fetch($toselectid);
if ($result > 0) {
$totalpaid = $objecttmp->getSommePaiement();
$objecttmp->resteapayer = price2num((float) $objecttmp->amount - $totalpaid, 'MT');
$totalpaid = (float) $objecttmp->getSommePaiement();
$objecttmp->resteapayer = (float) price2num((float) $objecttmp->amount - $totalpaid, 'MT');

// hook to finalize the remaining amount, considering e.g. cash discount agreements
$parameters = array('remaintopay' => $objecttmp->resteapayer);
Expand All @@ -211,7 +211,7 @@
if ($objecttmp->status == Salary::STATUS_PAID || $objecttmp->resteapayer == 0) {
$error++;
setEventMessages($langs->trans("Salary").' '.$objecttmp->ref.' : '.$langs->trans("AlreadyPaid"), $objecttmp->errors, 'errors');
} elseif ($resteapayer < 0) {
} elseif ($objecttmp->resteapayer < 0) {
$error++;
setEventMessages($langs->trans("Salary").' '.$objecttmp->ref.' : '.$langs->trans("AmountMustBePositive"), $objecttmp->errors, 'errors');
}
Expand Down
3 changes: 2 additions & 1 deletion htdocs/salaries/paiement_salary.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
llxHeader('', '', $help_url);

$salary = $object;
$sumpaid = 0.0;

// Formulaire de creation d'un paiement de charge
if ($action == 'create') {
Expand Down Expand Up @@ -214,7 +215,7 @@
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
$sumpaid = $obj->total;
$sumpaid = (float) $obj->total;
$db->free($resql);
}
/*print '<tr><td>'.$langs->trans("AlreadyPaid").'</td><td>'.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
Expand Down
7 changes: 5 additions & 2 deletions htdocs/societe/canvas/company/tpl/card_create.tpl.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2010 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2010 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
Expand All @@ -18,10 +18,13 @@
*/

/**
* @var Canvas $this
* @var Conf $conf
* @var CommonObject $this
* @var Translate $langs
* @var User $user
*
* @var string $canvas
*/
// Protection to avoid direct call of template
if (empty($conf) || !is_object($conf)) {
Expand Down
2 changes: 2 additions & 0 deletions htdocs/societe/canvas/company/tpl/card_edit.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
*/

/**
* @var Canvas $this
* @var Conf $conf
* @var CommonObject $this
* @var Translate $langs
* @var User $user
* @var string $canvas
*/
// Protection to avoid direct call of template
if (empty($conf) || !is_object($conf)) {
Expand Down
Loading

0 comments on commit 5a88a40

Please sign in to comment.