mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Qual: Fix phan issues related to getNextValue() notices (#30747)
* Qual: 🛟 Fix reference to $db with $this->db
# Qual: reference to $db with $this->db
$db was undeclared, use $this->db.
* Fix suspected issue with environment max size and md5sum working on limited files
* Qual: Fix LDAP typing
* Qual: Fix some phan typing related to getNextValue()
# Qual: Fix some phan typing related to getNextValue()
This fixes a few typings in relation to getNextValue().
* Update phan baseline
* PHPDoc: set arguments as nullable (+update array types)
* Improve PHPDoc
* Force toselect type to int[]
* Enable all phan notices on actions_massactions.inc.php
* Test was wrong, can not count when it's not an array
* Update baseline
* Remove ignore for notice that no longer exists
* Update baseline
* Fix format argument
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
parent
a8367a6cd8
commit
c496e84916
|
|
@ -235,7 +235,7 @@ return [
|
|||
'htdocs/comm/mailing/index.php' => ['PhanUndeclaredProperty'],
|
||||
'htdocs/comm/propal/card.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
|
||||
'htdocs/comm/propal/class/api_proposals.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/comm/propal/class/propal.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType'],
|
||||
'htdocs/comm/propal/class/propal.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType'],
|
||||
'htdocs/comm/propal/class/propalestats.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType'],
|
||||
'htdocs/comm/propal/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'],
|
||||
'htdocs/comm/propal/stats/index.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
|
||||
|
|
@ -303,13 +303,13 @@ return [
|
|||
'htdocs/compta/paiement/cheque/class/remisecheque.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanUndeclaredMethod'],
|
||||
'htdocs/compta/paiement/cheque/list.php' => ['PhanUndeclaredGlobalVariable'],
|
||||
'htdocs/compta/paiement/class/cpaiement.class.php' => ['PhanPluginUnknownPropertyType'],
|
||||
'htdocs/compta/paiement/class/paiement.class.php' => ['PhanEmptyForeach', 'PhanPluginEmptyStatementIf', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/compta/paiement/class/paiement.class.php' => ['PhanEmptyForeach', 'PhanPluginEmptyStatementIf', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/compta/paiement/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredGlobalVariable'],
|
||||
'htdocs/compta/paiement_charge.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/compta/paiement_vat.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/compta/payment_vat/card.php' => ['PhanUndeclaredGlobalVariable'],
|
||||
'htdocs/compta/prelevement/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/compta/prelevement/class/bonprelevement.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchProperty'],
|
||||
'htdocs/compta/prelevement/class/bonprelevement.class.php' => ['PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchProperty'],
|
||||
'htdocs/compta/prelevement/class/rejetprelevement.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchProperty'],
|
||||
'htdocs/compta/prelevement/create.php' => ['PhanPluginSuspiciousParamPosition', 'PhanPossiblyUndeclaredGlobalVariable'],
|
||||
'htdocs/compta/prelevement/demandes.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
|
||||
|
|
@ -521,7 +521,7 @@ return [
|
|||
'htdocs/core/lib/images.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal'],
|
||||
'htdocs/core/lib/import.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'],
|
||||
'htdocs/core/lib/invoice.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'],
|
||||
'htdocs/core/lib/invoice2.lib.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/core/lib/invoice2.lib.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPossiblyUndeclaredVariable'],
|
||||
'htdocs/core/lib/ldap.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'],
|
||||
'htdocs/core/lib/loan.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'],
|
||||
'htdocs/core/lib/mailmanspip.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'],
|
||||
|
|
@ -567,7 +567,7 @@ return [
|
|||
'htdocs/core/modules/barcode/doc/phpbarcode.modules.php' => ['PhanPossiblyNullTypeMismatchProperty', 'PhanPossiblyUndeclaredVariable'],
|
||||
'htdocs/core/modules/barcode/mod_barcode_product_standard.php' => ['PhanPluginUnknownPropertyType'],
|
||||
'htdocs/core/modules/barcode/modules_barcode.class.php' => ['PhanPluginUnknownPropertyType'],
|
||||
'htdocs/core/modules/bom/mod_bom_advanced.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
|
||||
'htdocs/core/modules/bom/mod_bom_advanced.php' => ['PhanUndeclaredProperty'],
|
||||
'htdocs/core/modules/cheque/doc/pdf_blochet.class.php' => ['PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/core/modules/cheque/modules_chequereceipts.php' => ['PhanPluginUnknownObjectMethodCall'],
|
||||
'htdocs/core/modules/commande/doc/pdf_einstein.modules.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
|
||||
|
|
@ -1004,7 +1004,7 @@ return [
|
|||
'htdocs/projet/class/projectstats.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable'],
|
||||
'htdocs/projet/class/task.class.php' => ['PhanPluginEmptyStatementIf', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/projet/class/taskstats.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType'],
|
||||
'htdocs/projet/contact.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeComparisonFromArray', 'PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/projet/contact.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeComparisonFromArray', 'PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/projet/element.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
|
||||
'htdocs/projet/ganttchart.inc.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'],
|
||||
'htdocs/projet/ganttview.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ $arraylistofpdfformat = array(
|
|||
|
||||
$s = $langs->trans("LibraryToBuildPDF")."<br>";
|
||||
$i = 0;
|
||||
$pdf = pdf_getInstance('A4');
|
||||
$pdf = pdf_getInstance(array(210, 297));
|
||||
if (class_exists('FPDF') && !class_exists('TCPDF')) {
|
||||
if ($i) {
|
||||
$s .= ' + ';
|
||||
|
|
|
|||
|
|
@ -3643,7 +3643,8 @@ class Propal extends CommonObject
|
|||
}
|
||||
|
||||
$obj = new $classname();
|
||||
$numref = "";
|
||||
'@phan-var-force ModeleNumRefPropales $obj';
|
||||
|
||||
$numref = $obj->getNextValue($soc, $this);
|
||||
|
||||
if ($numref != "") {
|
||||
|
|
|
|||
|
|
@ -449,6 +449,8 @@ class Commande extends CommonOrder
|
|||
}
|
||||
|
||||
$obj = new $classname();
|
||||
'@phan-var-force ModeleNumRefCommandes $obj';
|
||||
|
||||
$numref = $obj->getNextValue($soc, $this);
|
||||
|
||||
if ($numref != "") {
|
||||
|
|
|
|||
|
|
@ -1212,7 +1212,8 @@ class Paiement extends CommonObject
|
|||
}
|
||||
|
||||
$obj = new $classname();
|
||||
$numref = "";
|
||||
'@phan-var-force ModeleNumRefPayments $obj';
|
||||
|
||||
$numref = $obj->getNextValue($soc, $this);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -79,9 +79,9 @@ function pdf_admin_prepare_head()
|
|||
/**
|
||||
* Return array with format properties of default PDF format
|
||||
*
|
||||
* @param Translate|null $outputlangs Output lang to use to autodetect output format if we need 'auto' detection
|
||||
* @param string $mode 'setup' = Use setup, 'auto' = Force autodetection whatever is setup
|
||||
* @return array Array('width'=>w,'height'=>h,'unit'=>u);
|
||||
* @param ?Translate $outputlangs Output lang to use to autodetect output format if we need 'auto' detection
|
||||
* @param 'setup'|'auto' $mode 'setup' = Use setup, 'auto' = Force autodetection whatever is setup
|
||||
* @return array{width:float|int,height:float|int,unit:string} Array('width'=>w,'height'=>h,'unit'=>u);
|
||||
*/
|
||||
function pdf_getFormat(Translate $outputlangs = null, $mode = 'setup')
|
||||
{
|
||||
|
|
@ -120,9 +120,9 @@ function pdf_getFormat(Translate $outputlangs = null, $mode = 'setup')
|
|||
/**
|
||||
* Return a PDF instance object. We create a FPDI instance that instantiate TCPDF.
|
||||
*
|
||||
* @param string $format Array(width,height). Keep empty to use default setup.
|
||||
* @param array{float|int,float|int}|array{}|'' $format Array(width,height). Keep empty to use default setup.
|
||||
* @param string $metric Unit of format ('mm')
|
||||
* @param string $pagetype 'P' or 'l'
|
||||
* @param 'P'|'l' $pagetype 'P' or 'l'
|
||||
* @return TCPDF|TCPDI PDF object
|
||||
*/
|
||||
function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P')
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ class mod_bom_advanced extends ModeleNumRefBoms
|
|||
$old_code_type = $mysoc->typent_code;
|
||||
$mysoc->code_client = 'CCCCCCCCCC';
|
||||
$mysoc->typent_code = 'TTTTTTTTTT';
|
||||
$numExample = $this->getNextValue($mysoc, '');
|
||||
$numExample = $this->getNextValue($mysoc, null);
|
||||
$mysoc->code_client = $old_code_client;
|
||||
$mysoc->typent_code = $old_code_type;
|
||||
|
||||
|
|
@ -120,9 +120,9 @@ class mod_bom_advanced extends ModeleNumRefBoms
|
|||
/**
|
||||
* Return next free value
|
||||
*
|
||||
* @param Product $objprod Object product
|
||||
* @param Bom $object Object we need next value for
|
||||
* @return string|int Next value if OK, 0 if KO
|
||||
* @param Product $objprod Object product
|
||||
* @param ?Bom $object Object we need next value for
|
||||
* @return string|int<-1,0> Next value if OK, 0 if KO
|
||||
*/
|
||||
public function getNextValue($objprod, $object)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ class mod_bom_standard extends ModeleNumRefBoms
|
|||
/**
|
||||
* Return next free value
|
||||
*
|
||||
* @param Product $objprod Object product
|
||||
* @param Bom $object Object we need next value for
|
||||
* @return string|int<-1,-1> Next value if OK, -1 if KO
|
||||
* @param Product $objprod Object product
|
||||
* @param ?Bom $object Object we need next value for
|
||||
* @return string|int<-1,0> Next value if OK, 0 if KO
|
||||
*/
|
||||
public function getNextValue($objprod, $object)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -88,9 +88,9 @@ abstract class ModeleNumRefBoms extends CommonNumRefGenerator
|
|||
/**
|
||||
* Return next free value
|
||||
*
|
||||
* @param Product $objprod Object product
|
||||
* @param Bom $object Object we need next value for
|
||||
* @return string|int<-1,-1> Next value if OK, -1 if KO
|
||||
* @param Product $objprod Object product
|
||||
* @param ?Bom $object Object we need next value for
|
||||
* @return string|int<-1,0> Next value if OK, 0 if KO
|
||||
*/
|
||||
abstract public function getNextValue($objprod, $object);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,9 +160,9 @@ class mod_facture_mars extends ModeleNumRefFactures
|
|||
* Return next value not used or last value used
|
||||
*
|
||||
* @param Societe $objsoc Object third party
|
||||
* @param Facture $invoice Object invoice
|
||||
* @param ?Facture $invoice Object invoice
|
||||
* @param string $mode 'next' for next value or 'last' for last value
|
||||
* @return string|int<-1,1> Value if OK, <=0 if KO
|
||||
* @return string|int<-1,0> Value if OK, <=0 if KO
|
||||
*/
|
||||
public function getNextValue($objsoc, $invoice, $mode = 'next')
|
||||
{
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ class mod_facture_mercure extends ModeleNumRefFactures
|
|||
$old_code_type = $mysoc->typent_code;
|
||||
$mysoc->code_client = 'CCCCCCCCCC';
|
||||
$mysoc->typent_code = 'TTTTTTTTTT';
|
||||
$numExample = $this->getNextValue($mysoc, '');
|
||||
$numExample = $this->getNextValue($mysoc, null);
|
||||
$mysoc->code_client = $old_code_client;
|
||||
$mysoc->typent_code = $old_code_type;
|
||||
|
||||
|
|
@ -139,9 +139,9 @@ class mod_facture_mercure extends ModeleNumRefFactures
|
|||
* Return next value not used or last value used
|
||||
*
|
||||
* @param Societe $objsoc Object third party
|
||||
* @param Facture $invoice Object invoice
|
||||
* @param ?Facture $invoice Object invoice
|
||||
* @param string $mode 'next' for next value or 'last' for last value
|
||||
* @return string|int<-1,1> Value if OK, <=0 if KO
|
||||
* @return string|int<-1,0> Value if OK, <=0 if KO
|
||||
*/
|
||||
public function getNextValue($objsoc, $invoice, $mode = 'next')
|
||||
{
|
||||
|
|
|
|||
|
|
@ -201,9 +201,9 @@ class mod_facture_terre extends ModeleNumRefFactures
|
|||
* ALTER TABLE llx_facture ADD INDEX calculated_numrefonly_idx (calculated_numrefonly);
|
||||
*
|
||||
* @param Societe $objsoc Object third party
|
||||
* @param Facture $invoice Object invoice
|
||||
* @param ?Facture $invoice Object invoice
|
||||
* @param string $mode 'next' for next value or 'last' for last value
|
||||
* @return string|int<-1,1> Value if OK, <=0 if KO
|
||||
* @return string|int<-1,0> Value if OK, <=0 if KO
|
||||
*/
|
||||
public function getNextValue($objsoc, $invoice, $mode = 'next')
|
||||
{
|
||||
|
|
|
|||
|
|
@ -272,9 +272,9 @@ abstract class ModeleNumRefFactures extends CommonNumRefGenerator
|
|||
* Return next value not used or last value used
|
||||
*
|
||||
* @param Societe $objsoc Object third party
|
||||
* @param Facture $invoice Object invoice
|
||||
* @param ?Facture $invoice Object invoice
|
||||
* @param string $mode 'next' for next value or 'last' for last value
|
||||
* @return string|int<-1,1> Value if OK, <=0 if KO
|
||||
* @return string|int<-1,0> Value if OK, <=0 if KO
|
||||
*/
|
||||
abstract public function getNextValue($objsoc, $invoice, $mode = 'next');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,10 @@
|
|||
// $object = Object fetched;
|
||||
// $sendto
|
||||
// $withmaindocfilemail
|
||||
'@phan-var-force CommonObject $objecttmp';
|
||||
'
|
||||
@phan-var-force CommonObject $objecttmp
|
||||
@phan-var-force int[] $toselect
|
||||
';
|
||||
|
||||
if (!empty($sall) || !empty($search_all)) {
|
||||
$search_all = empty($sall) ? $search_all : $sall;
|
||||
|
|
|
|||
|
|
@ -1041,8 +1041,8 @@ class Task extends CommonObjectLine
|
|||
* Return list of tasks for all projects or for one particular project
|
||||
* Sort order is on project, then on position of task, and last on start date of first level task
|
||||
*
|
||||
* @param User $usert Object user to limit tasks affected to a particular user
|
||||
* @param User $userp Object user to limit projects of a particular user and public projects
|
||||
* @param ?User $usert Object user to limit tasks affected to a particular user
|
||||
* @param ?User $userp Object user to limit projects of a particular user and public projects
|
||||
* @param int $projectid Project id
|
||||
* @param int $socid Third party id
|
||||
* @param int $mode 0=Return list of tasks and their projects, 1=Return projects and tasks if exists
|
||||
|
|
@ -1053,12 +1053,12 @@ class Task extends CommonObjectLine
|
|||
* @param int $filterontaskuser Filter on user assigned to task
|
||||
* @param ?Extrafields $extrafields Show additional column from project or task
|
||||
* @param int $includebilltime Calculate also the time to bill and billed
|
||||
* @param array $search_array_options Array of search filters. Not Used yet.
|
||||
* @param array<string,string> $search_array_options Array of search filters. Not Used yet.
|
||||
* @param int $loadextras Fetch all Extrafields on each project and task
|
||||
* @param int $loadRoleMode 1= will test Roles on task; 0 used in delete project action
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @return array|string Array of tasks
|
||||
* @return Task[]|string Array of tasks
|
||||
*/
|
||||
public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields = null, $includebilltime = 0, $search_array_options = array(), $loadextras = 0, $loadRoleMode = 1, $sortfield = '', $sortorder = '')
|
||||
{
|
||||
|
|
|
|||
|
|
@ -105,7 +105,8 @@ if (empty($reshook)) {
|
|||
foreach ($task_array as $task) {
|
||||
$task_already_affected = false;
|
||||
$personsLinked = $task->liste_contact(-1, $source);
|
||||
if (!is_array($personsLinked) && count($personsLinked) < 0) {
|
||||
if (!is_array($personsLinked)) {
|
||||
// When liste_contact() does not return an array, it's an error.
|
||||
setEventMessage($object->error, 'errors');
|
||||
} else {
|
||||
foreach ($personsLinked as $person) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user