Qual: Fix phan/phpstan notices in class files (part 3) (#31578)

* fix phpstan in conf class (#31630)

* fix phpstan

* fix phan

* Fix merge

* Qual: Avoid notification with typing hint

* Qual: Fix notices link.class

* Qual: Fix notices link..socialneetworkmanager.class and DoliDb->DoliDB

* Qual: Fix notices for link..utils.class

* Qual: Fix notices for db classes

* Update translate.class.php

* Update translate.class.php

---------

Co-authored-by: Frédéric FRANCE <frederic34@users.noreply.github.com>
Co-authored-by: Laurent Destailleur <eldy@users.sourceforge.net>
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
MDW 2024-10-29 22:44:47 +01:00 committed by GitHub
parent 37adda54b3
commit b91c99b18a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
26 changed files with 229 additions and 217 deletions

View File

@ -10,15 +10,15 @@
return [
// # Issue statistics:
// PhanUndeclaredProperty : 560+ occurrences
// PhanPossiblyUndeclaredGlobalVariable : 550+ occurrences
// PhanPluginUnknownPropertyType : 420+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 360+ occurrences
// PhanPossiblyUndeclaredGlobalVariable : 540+ occurrences
// PhanPluginUnknownPropertyType : 410+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 350+ occurrences
// PhanUndeclaredGlobalVariable : 350+ occurrences
// PhanPluginUnknownArrayMethodReturnType : 280+ occurrences
// PhanPluginUnknownArrayMethodParamType : 190+ occurrences
// PhanPossiblyUndeclaredVariable : 190+ occurrences
// PhanPluginUnknownArrayMethodReturnType : 230+ occurrences
// PhanPossiblyUndeclaredVariable : 180+ occurrences
// PhanPluginUnknownArrayMethodParamType : 160+ occurrences
// PhanTypeMismatchProperty : 160+ occurrences
// PhanPluginUnknownArrayFunctionParamType : 95+ occurrences
// PhanPluginUnknownArrayFunctionParamType : 90+ occurrences
// PhanPluginUndeclaredVariableIsset : 65+ occurrences
// PhanTypeMismatchArgumentNullableInternal : 60+ occurrences
// PhanPluginUnknownArrayFunctionReturnType : 50+ occurrences
@ -26,8 +26,8 @@ return [
// PhanPluginEmptyStatementIf : 45+ occurrences
// PhanTypeExpectedObjectPropAccess : 40+ occurrences
// PhanTypeInvalidDimOffset : 35+ occurrences
// PhanPluginUnknownArrayPropertyType : 30+ occurrences
// PhanTypeMismatchDimFetch : 30+ occurrences
// PhanPluginUnknownArrayPropertyType : 20+ occurrences
// PhanPluginUnknownObjectMethodCall : 15+ occurrences
// PhanUndeclaredConstant : 15+ occurrences
// PhanEmptyForeach : 10+ occurrences
@ -37,9 +37,9 @@ return [
// PhanUndeclaredMethod : 10+ occurrences
// PhanPluginSuspiciousParamPosition : 9 occurrences
// PhanPluginBothLiteralsBinaryOp : 8 occurrences
// PhanPluginConstantVariableNull : 8 occurrences
// PhanPossiblyNullTypeMismatchProperty : 8 occurrences
// PhanPluginDuplicateExpressionBinaryOp : 7 occurrences
// PhanPluginConstantVariableNull : 6 occurrences
// PhanParamTooMany : 5 occurrences
// PhanPluginDuplicateArrayKey : 4 occurrences
// PhanEmptyFQSENInClasslike : 3 occurrences
@ -48,6 +48,7 @@ return [
// PhanAccessMethodProtected : 1 occurrence
// PhanParamTooFew : 1 occurrence
// PhanTypeConversionFromArray : 1 occurrence
// PhanTypeMismatchReturn : 1 occurrence
// Currently, file_suppressions and directory_suppressions are the only supported suppressions
'file_suppressions' => [
@ -57,7 +58,6 @@ return [
'htdocs/adherents/type.php' => ['PhanTypeMismatchProperty'],
'htdocs/admin/agenda_other.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/admin/defaultvalues.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/admin/fckeditor.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/api/class/api_access.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanUndeclaredProperty'],
'htdocs/api/class/api_documents.class.php' => ['PhanPluginDuplicateExpressionBinaryOp', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable'],
'htdocs/api/class/api_login.class.php' => ['PhanPluginUnknownArrayMethodReturnType'],
@ -205,7 +205,6 @@ return [
'htdocs/contrat/services_list.php' => ['PhanEmptyForeach', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/core/actions_addupdatedelete.inc.php' => ['PhanPluginBothLiteralsBinaryOp', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'],
'htdocs/core/actions_comments.inc.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/core/actions_extrafields.inc.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/core/actions_lineupdown.inc.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'],
'htdocs/core/actions_linkedfiles.inc.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'],
'htdocs/core/actions_massactions.inc.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
@ -254,23 +253,12 @@ return [
'htdocs/core/class/html.formcompany.class.php' => ['PhanUndeclaredProperty'],
'htdocs/core/class/html.formfile.class.php' => ['PhanUndeclaredProperty'],
'htdocs/core/class/html.formmail.class.php' => ['PhanUndeclaredProperty'],
'htdocs/core/class/ldap.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownArrayPropertyType', 'PhanPossiblyUndeclaredVariable'],
'htdocs/core/class/link.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType'],
'htdocs/core/class/notify.class.php' => ['PhanUndeclaredProperty'],
'htdocs/core/class/openid.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType'],
'htdocs/core/class/reddithandler.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'],
'htdocs/core/class/smtps.class.php' => ['PhanTypeConversionFromArray'],
'htdocs/core/class/socialnetworkmanager.class.php' => ['PhanPluginUnknownArrayMethodParamType'],
'htdocs/core/class/stats.class.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchDimFetch'],
'htdocs/core/class/timespent.class.php' => ['PhanUndeclaredMethod', 'PhanUndeclaredProperty'],
'htdocs/core/class/translate.class.php' => ['PhanPluginEmptyStatementIf', 'PhanPluginUnknownArrayPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal'],
'htdocs/core/class/utils.class.php' => ['PhanPluginConstantVariableNull', 'PhanPossiblyUndeclaredVariable'],
'htdocs/core/customreports.php' => ['PhanPluginEmptyStatementIf', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetchNullable'],
'htdocs/core/datepicker.php' => ['PhanTypeInvalidDimOffset'],
'htdocs/core/db/Database.interface.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'],
'htdocs/core/db/mysqli.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeComparisonFromArray'],
'htdocs/core/db/pgsql.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeComparisonFromArray', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/core/db/sqlite3.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeComparisonFromArray', 'PhanUndeclaredProperty'],
'htdocs/core/db/sqlite3.class.php' => ['PhanTypeMismatchReturn'],
'htdocs/core/extrafieldsinimport.inc.php' => ['PhanTypeMismatchArgumentNullableInternal'],
'htdocs/core/filemanagerdol/connectors/php/connector.lib.php' => ['PhanPluginConstantVariableNull', 'PhanPluginUnknownArrayFunctionParamType', 'PhanTypeInvalidDimOffset'],
'htdocs/core/lib/accounting.lib.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType'],
@ -419,7 +407,6 @@ return [
'htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php' => ['PhanPluginUnknownArrayMethodReturnType'],
'htdocs/debugbar/class/DataCollector/DolTimeDataCollector.php' => ['PhanPluginUnknownArrayMethodReturnType'],
'htdocs/debugbar/class/DataCollector/DolibarrCollector.php' => ['PhanPluginUnknownArrayMethodReturnType'],
'htdocs/debugbar/class/TraceableDB.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownArrayPropertyType'],
'htdocs/delivery/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'],
'htdocs/delivery/class/delivery.class.php' => ['PhanUndeclaredProperty'],
'htdocs/delivery/tpl/linkedobjectblock.tpl.php' => ['PhanUndeclaredProperty'],
@ -511,7 +498,7 @@ return [
'htdocs/holiday/card_group.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'],
'htdocs/holiday/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'],
'htdocs/holiday/view_log.php' => ['PhanTypeMismatchDimFetch'],
'htdocs/hrm/admin/admin_hrm.php' => ['PhanEmptyForeach', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/hrm/admin/admin_hrm.php' => ['PhanEmptyForeach'],
'htdocs/hrm/class/evaluation.class.php' => ['PhanUndeclaredProperty'],
'htdocs/hrm/class/evaluationdet.class.php' => ['PhanUndeclaredProperty'],
'htdocs/hrm/class/job.class.php' => ['PhanUndeclaredProperty'],
@ -532,7 +519,7 @@ return [
'htdocs/imports/emptyexample.php' => ['PhanRedefineFunction', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/imports/import.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/install/check.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal'],
'htdocs/install/fileconf.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal'],
'htdocs/install/fileconf.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/install/inc.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanRedefineFunction'],
'htdocs/install/index.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/install/repair.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable'],
@ -567,7 +554,7 @@ return [
'htdocs/mrp/tpl/linkedobjectblock.tpl.php' => ['PhanUndeclaredProperty'],
'htdocs/mrp/tpl/originproductline.tpl.php' => ['PhanUndeclaredProperty'],
'htdocs/multicurrency/class/api_multicurrencies.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/multicurrency/class/multicurrency.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/multicurrency/class/multicurrency.class.php' => ['PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/opcachepreload.php' => ['PhanEmptyForeach'],
'htdocs/opensurvey/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/opensurvey/class/opensurveysondage.class.php' => ['PhanPluginUnknownPropertyType', 'PhanTypeMismatchProperty'],

View File

@ -1176,6 +1176,7 @@ class BonPrelevement extends CommonObject
while ($i < $num) {
$row = $this->db->fetch_row($resql); // TODO Replace with fetch_object()
'@phan-var-force array<int<0,12>,string> $row';
$factures[$i] = $row; // All fields
if ($row[7] == 0) {
@ -1247,7 +1248,7 @@ class BonPrelevement extends CommonObject
//dol_syslog(__METHOD__."::RIB is ok", LOG_DEBUG);
} else {
if ($type != 'bank-transfer') {
$tmpsoc->id = $fac[2];
$tmpsoc->id = (int) $fac[2];
$tmpsoc->name = $fac[8];
$invoice_url = "<a href='" . DOL_URL_ROOT . '/compta/facture/card.php?facid=' . $fac[0] . "'>" . $fac[9] . "</a>";
$this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for invoice " . $invoice_url . " for thirdparty " . $tmpsoc->getNomUrl(0);
@ -1255,7 +1256,7 @@ class BonPrelevement extends CommonObject
$error++;
}
if ($type == 'bank-transfer' && $sourcetype != 'salary') {
$tmpsoc->id = $fac[2];
$tmpsoc->id = (int) $fac[2];
$tmpsoc->name = $fac[8];
$invoice_url = "<a href='" . DOL_URL_ROOT . '/fourn/facture/card.php?facid=' . $fac[0] . "'>" . $fac[9] . "</a>";
$this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for invoice " . $invoice_url . " for thirdparty " . $tmpsoc->getNomUrl(0);
@ -1263,7 +1264,7 @@ class BonPrelevement extends CommonObject
$error++;
}
if ($type == 'bank-transfer' && $sourcetype == 'salary') {
$tmpuser->id = $fac[2];
$tmpuser->id = (int) $fac[2];
$tmpuser->firstname = $fac[8];
$salary_url = "<a href='" . DOL_URL_ROOT . '/salaries/card.php?id=' . $fac[0] . "'>" . $fac[0] . "</a>";
$this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for salary " . $salary_url . " for employee " . $tmpuser->getNomUrl(0);

View File

@ -47,7 +47,7 @@ class Ldap
public $errors = array();
/**
* @var array Servers (IP addresses or hostnames)
* @var string[] Servers (IP addresses or hostnames)
*/
public $server = array();
@ -224,7 +224,7 @@ class Ldap
public $mobile;
/**
* @var array UserAccountControl Flags
* @var array<int,string> UserAccountControl Flags
*/
public $uacf;
@ -505,7 +505,7 @@ class Ldap
*
* @param string $bindDn DN
* @param string $pass Password
* @return boolean true or false
* @return bool true or false
*/
public function bindauth($bindDn, $pass)
{
@ -522,7 +522,7 @@ class Ldap
/**
* Unbind of LDAP server (close connection).
*
* @return boolean true or false
* @return bool true or false
* @see close()
*/
public function unbind()
@ -567,7 +567,7 @@ class Ldap
* Set LDAP protocol version.
* LDAP_OPT_PROTOCOL_VERSION is a constant equal to 3
*
* @return boolean if set LDAP option OK: true, if KO: false
* @return bool if set LDAP option OK: true, if KO: false
*/
public function setVersion()
{
@ -577,7 +577,7 @@ class Ldap
/**
* Set LDAP size limit.
*
* @return boolean if set LDAP option OK: true, if KO: false
* @return bool if set LDAP option OK: true, if KO: false
*/
public function setSizeLimit()
{
@ -588,7 +588,7 @@ class Ldap
* Set LDAP referrals.
* LDAP_OPT_REFERRALS is a constant equal to ?
*
* @return boolean if set LDAP option OK: true, if KO: false
* @return bool if set LDAP option OK: true, if KO: false
*/
public function setReferrals()
{
@ -601,9 +601,9 @@ class Ldap
* LDAP object connect and bind must have been done
*
* @param string $dn DN entry key
* @param array $info Attributes array
* @param array<string,string[]> $info Attributes array
* @param User $user Object user that create
* @return int if KO: <0 || if OK: >0
* @return int<-3,-1>|int<1,1> if KO: <0 || if OK: >0
*/
public function add($dn, $info, $user)
{
@ -649,9 +649,9 @@ class Ldap
* LDAP object connect and bind must have been done
*
* @param string $dn DN entry key
* @param array $info Attributes array
* @param array<string,string[]> $info Attributes array
* @param User $user Object user that modify
* @return int if KO: <0 || if OK: >0
* @return int<-3,-1>|int<1,1> if KO: <0 || if OK: >0
*/
public function modify($dn, $info, $user)
{
@ -709,7 +709,7 @@ class Ldap
* @param string $newparent New parent (ou=xxx,dc=aaa,dc=bbb)
* @param User $user Object user that modify
* @param bool $deleteoldrdn If true the old RDN value(s) is removed, else the old RDN value(s) is retained as non-distinguished values of the entry.
* @return int if KO: <0 || if OK: >0
* @return int<-3,-1>|int<1,1> if KO: <0 || if OK: >0
*/
public function rename($dn, $newrdn, $newparent, $user, $deleteoldrdn = true)
{
@ -748,12 +748,12 @@ class Ldap
* LDAP object connect and bind must have been done
*
* @param string $dn DN entry key
* @param array $info Attributes array
* @param array<string,string[]> $info Attributes array
* @param User $user Object user that update
* @param string $olddn Old DN entry key (before update)
* @param string $newrdn New RDN entry key (uid=qqq) (for ldap_rename)
* @param string $newparent New parent (ou=xxx,dc=aaa,dc=bbb) (for ldap_rename)
* @return int if KO: <0 || if OK: >0
* @return int<-3,-1>|int<1,1> if KO: <0 || if OK: >0
*/
public function update($dn, $info, $user, $olddn, $newrdn = '', $newparent = '')
{
@ -803,7 +803,7 @@ class Ldap
* LDAP object connect and bind must have been done
*
* @param string $dn DN entry key
* @return int if KO: <0 || if OK: >0
* @return int<-3,-1>|int<1,1> if KO: <0 || if OK: >0
*/
public function delete($dn)
{
@ -835,7 +835,7 @@ class Ldap
*
* @see dump_content renamed
* @param string $dn DN entry key
* @param array $info Attributes array
* @param array<string,string[]> $info Attributes array
* @return string Content of file
*/
public function dumpContent($dn, $info)
@ -871,8 +871,8 @@ class Ldap
* Dump an LDAP message to ldapinput.in file
*
* @param string $dn DN entry key
* @param array $info Attributes array
* @return int if KO: <0 || if OK: >0
* @param array<string,string[]> $info Attributes array
* @return int<-1,-1>|int<1,1> if KO: <0 || if OK: >0
*/
public function dump($dn, $info)
{
@ -905,7 +905,7 @@ class Ldap
* @param string $host Server host or address
* @param int $port Server port (default 389)
* @param int $timeout Timeout in second (default 1s)
* @return boolean true or false
* @return bool true or false
*/
public function serverPing($host, $port = 389, $timeout = 1)
{
@ -950,9 +950,9 @@ class Ldap
* LDAP object connect and bind must have been done
*
* @param string $dn DN entry key
* @param array $info Attributes array
* @param array<string,string|string[]> $info Attributes array
* @param User $user Object user that create
* @return int if KO: <0 || if OK: >0
* @return int<-3,-1>|int<1,1> if KO: <0 || if OK: >0
*/
public function addAttribute($dn, $info, $user)
{
@ -996,9 +996,9 @@ class Ldap
* LDAP object connect and bind must have been done
*
* @param string $dn DN entry key
* @param array $info Attributes array
* @param array<string,string|string[]> $info Attributes array
* @param User $user Object user that create
* @return int if KO: <0 || if OK: >0
* @return int<-3,-1>|int<1,1> if KO: <0 || if OK: >0
*/
public function updateAttribute($dn, $info, $user)
{
@ -1042,9 +1042,9 @@ class Ldap
* LDAP object connect and bind must have been done
*
* @param string $dn DN entry key
* @param array $info Attributes array
* @param array<string,string|string[]> $info Attributes array
* @param User $user Object user that create
* @return int if KO: <0 || if OK: >0
* @return int<-3,-1>|int<1,1> if KO: <0 || if OK: >0
*/
public function deleteAttribute($dn, $info, $user)
{
@ -1086,11 +1086,11 @@ class Ldap
/**
* Returns an array containing attributes and values for first record
*
* array{count:int,0..max:string,string:array}
* array{count:int,0..max:string|mixed[],string:array}
*
* @param string $dn DN entry key
* @param string $filter Filter
* @return int|array<'count'|int|string,int|string|array> if KO: <=0 || if OK: array
* @return int<-3,0>|array<'count'|int,int|mixed[]> if KO: <=0 || if OK: array
*/
public function getAttribute($dn, $filter)
{
@ -1131,7 +1131,7 @@ class Ldap
*
* @param string $filterrecord Record
* @param string $attribute Attributes
* @return array|boolean
* @return array<string|int,int|string>|false
*/
public function getAttributeValues($filterrecord, $attribute)
{
@ -1296,6 +1296,7 @@ class Ldap
}
$i = 0;
$entry = null;
$searchDN = $this->people;
while ($i <= 2) {
@ -1360,7 +1361,7 @@ class Ldap
*
* @param string $checkDn Search DN (Ex: ou=users,cn=my-domain,cn=com)
* @param string $filter Search filter (ex: (sn=name_person) )
* @return array|int Array with answers (lowercase key - value)
* @return array<int|string,int|string|mixed[]>|int<-1,-1> Array with answers (lowercase key - value)
*/
public function search($checkDn, $filter)
{
@ -1492,7 +1493,7 @@ class Ldap
* UserAccountControl Flags to more human understandable form...
*
* @param string $uacf UACF
* @return array
* @return array<int,string>
*/
public function parseUACF($uacf)
{

View File

@ -238,13 +238,13 @@ class Link extends CommonObject
/**
* Loads all links from database
*
* @param array $links array of Link objects to fill
* @param Link[] $links array of Link objects to fill
* @param string $objecttype type of the associated object in dolibarr
* @param int $objectid id of the associated object in dolibarr
* @param string $sortfield field used to sort
* @param string $sortorder sort order
* @return int 1 if ok, 0 if no records, -1 if error
**/
* @param ?string $sortfield field used to sort
* @param ?string $sortorder sort order
* @return int<-1,1> 1 if ok, 0 if no records, -1 if error
*/
public function fetchAll(&$links, $objecttype, $objectid, $sortfield = null, $sortorder = null)
{
global $conf;

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -26,9 +27,21 @@
*/
class SimpleOpenID
{
/**
* @var string
*/
public $openid_url_identity;
/**
* @var array{openid_server?:string,trust_root?:string,cancel?:string,approved?:string}
*/
public $URLs = array();
/**
* @var array{}|array{0:string,1:string}
*/
public $error = array();
/**
* @var array{required:string[],optional:string[]}
*/
public $fields = array(
'required' => array(),
'optional' => array(),
@ -100,7 +113,7 @@ class SimpleOpenID
/**
* SetRequiredFields
*
* @param string|array $a Server
* @param string|string[] $a Server
* @return void
*/
public function SetRequiredFields($a)
@ -117,7 +130,7 @@ class SimpleOpenID
/**
* SetOptionalFields
*
* @param string|array $a Server
* @param string|string[] $a Server
* @return void
*/
public function SetOptionalFields($a)
@ -178,7 +191,7 @@ class SimpleOpenID
/**
* SetOpenIDServer
*
* @return array
* @return array{code:string,description:string}
*/
public function GetError()
{
@ -226,7 +239,7 @@ class SimpleOpenID
* splitResponse
*
* @param string $response Server
* @return array
* @return array<string,string>
*/
public function splitResponse($response)
{
@ -274,7 +287,7 @@ class SimpleOpenID
/**
* array2url
*
* @param array $arr An array
* @param array<string,string> $arr An array
* @return false|string false if KO, string of url if OK
*/
public function array2url($arr)
@ -329,7 +342,7 @@ class SimpleOpenID
* HTML2OpenIDServer
*
* @param string $content Content
* @return array Array of servers
* @return array{0:string[],1:string[]} Array of servers
*/
public function HTML2OpenIDServer($content)
{

View File

@ -78,7 +78,7 @@ class RedditHandler
/**
* Constructor to initialize RedditHandler.
*
* @param array $authParams Array containing 'client_id', 'client_secret', 'username', and 'password'.
* @param array{client_id?:string,client_secret?:string,username?:string,password?:string,name_app?:string} $authParams Array containing 'client_id', 'client_secret', 'username', and 'password'.
*/
public function __construct(array $authParams)
{
@ -134,8 +134,8 @@ class RedditHandler
* @param int $maxNb Maximum number of posts to retrieve (default is 5).
* @param int $cacheDelay Number of seconds to use cached data (0 to disable caching).
* @param string $cacheDir Directory to store cached data.
* @param array $authParams Authentication parameters (not used in this context).
* @return array|false Array of posts if successful, false otherwise.
* @param array{client_id?:string,client_secret?:string,username?:string,password?:string,name_app?:string} $authParams Authentication parameters (not used in this context).
* @return array<array{id:string,content:string,created_at:string,url:string,author_name?:string,author_avatar?:string,media_url?:string}|array{}>|false Array of posts if successful, false otherwise.
*/
public function fetch($urlAPI, $maxNb = 5, $cacheDelay = 60, $cacheDir = '', $authParams = [])
{
@ -205,8 +205,8 @@ class RedditHandler
/**
* Normalize the data fetched from the Reddit API.
*
* @param array $postData Data of a single post.
* @return array Normalized post data.
* @param array{id?:string,title?:string,created?:string,permalink?:string,thumbnail?:string} $postData Data of a single post.
* @return array{}|array{id:string,content:string,created_at:string,url:string,media_url:string} Normalized post data.
*/
public function normalizeData($postData)
{

View File

@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/mastodonhandler.class.php';
class SocialNetworkManager
{
/**
* @var DoliDb Database handler
* @var DoliDB Database handler
*/
public $db;
@ -46,7 +46,7 @@ class SocialNetworkManager
private $handler;
/**
* @var String Error code (or message)
* @var string Error code (or message)
*/
public $error = '';
@ -58,8 +58,8 @@ class SocialNetworkManager
/**
* Constructor
*
* @param string $platform name of social network
* @param array $authParams other parameters
* @param string $platform name of social network
* @param array{username?:string,password?:string,name_app?:string,client_id?:string,client_secret?:string,redirect_uri?:string,access_token?:string} $authParams other parameters
*/
public function __construct($platform, $authParams = [])
{
@ -69,7 +69,7 @@ class SocialNetworkManager
/**
* Initialize the social network needed
* @param array $authParams other parameters
* @param array{username?:string,password?:string,name_app?:string,client_id?:string,client_secret?:string,redirect_uri?:string,access_token?:string} $authParams other parameters
* @return void new instance if founded
*/
private function initializeHandler($authParams)
@ -89,7 +89,7 @@ class SocialNetworkManager
* @param int $maxNb Maximum number of posts to retrieve (default is 5).
* @param int $cacheDelay Number of seconds to use cached data (0 to disable caching).
* @param string $cacheDir Directory to store cached data.
* @param array $authParams Authentication parameters
* @param array{username?:string,password?:string,name_app?:string,client_id?:string,client_secret?:string,redirect_uri?:string,access_token?:string} $authParams Authentication parameters
* @return bool Status code: false if error, array if success.
*/
public function fetchPosts($urlAPI, $maxNb = 5, $cacheDelay = 60, $cacheDir = '', $authParams = [])

View File

@ -41,9 +41,9 @@ abstract class Stats
protected $lastfetchdate = array();
/**
* @var string cachefilesuffix
* @var string Suffix to add to name of cache file (to avoid file name conflicts)
*/
public $cachefilesuffix = ''; // Suffix to add to name of cache file (to avoid file name conflicts)
public $cachefilesuffix = '';
/**
* @var string To store the FROM part of the main table of the SQL request
@ -125,6 +125,7 @@ abstract class Stats
$nowgmt = dol_now();
$foundintocache = 0;
$filedate = -1;
if ($cachedelay > 0) {
$filedate = dol_filemtime($newpathofdestfile);
if ($filedate >= ($nowgmt - $cachedelay)) {
@ -226,6 +227,7 @@ abstract class Stats
$nowgmt = dol_now();
$foundintocache = 0;
$filedate = -1;
if ($cachedelay > 0) {
$filedate = dol_filemtime($newpathofdestfile);
if ($filedate >= ($nowgmt - $cachedelay)) {
@ -258,7 +260,7 @@ abstract class Stats
$year = $startyear;
while ($year <= $endyear) {
// floor(($i + $sm) / 12)) is 0 if we are after the month start $sm and same year, become 1 when we reach january of next year
$data[$i][] = $datay[$year - (1 - floor(($i + $sm) / 12)) + ($sm == 0 ? 1 : 0)][($i + $sm) % 12][1]; // set yval for x=i
$data[$i][] = $datay[$year - (1 - (int) floor(($i + $sm) / 12)) + ($sm == 0 ? 1 : 0)][($i + $sm) % 12][1]; // set yval for x=i
$year++;
}
}
@ -350,6 +352,7 @@ abstract class Stats
$nowgmt = dol_now();
$foundintocache = 0;
$filedate = -1;
if ($cachedelay > 0) {
$filedate = dol_filemtime($newpathofdestfile);
if ($filedate >= ($nowgmt - $cachedelay)) {

View File

@ -52,22 +52,22 @@ class Translate
/**
* @var array Array of all translations key=>value
* @var array<string,string> Array of all translations key=>value
*/
public $tab_translate = array();
/**
* @var array Array to store result after loading each language file
* @var array<string,int<1,2>> Array to store result after loading each language file
*/
private $_tab_loaded = array();
/**
* @var array Cache for labels returned by getLabelFromKey method
* @var array<string,array<string,string>> Cache for labels returned by getLabelFromKey method
*/
public $cache_labels = array();
/**
* @var array Cache to store currency symbols
* @var array<string,array{label:string,unicode:string}> Cache to store currency symbols
*/
public $cache_currencies = array();
@ -281,8 +281,8 @@ class Translate
// Search if a module directory name is provided into lang file name
$regs = array();
if (preg_match('/^([^@]+)@([^@]+)$/i', $domain, $regs)) {
$newdomain = $regs[1];
$modulename = $regs[2];
$newdomain = (string) $regs[1];
$modulename = (string) $regs[2];
}
// Check cache
@ -353,9 +353,7 @@ class Translate
if (!$found) {
if ($fp = @fopen($file_lang, "rt")) {
if ($usecachekey) {
// $tabtranslatedomain = array(); // To save lang content in cache
}
// $tabtranslatedomain = array(); // To save lang content in cache when enabled (commented because initial = argument to function)
/**
* Read each lines until a '=' (with any combination of spaces around it)
@ -502,7 +500,7 @@ class Translate
return 0;
}
$this->_tab_loaded[$newdomain] = 1; // We want to be sure this function is called once only for domain 'database'
$this->_tab_loaded[$newdomain] = 2; // Preset the load as loaded and make sure this function is called once only for $newdomain='database'
$fileread = 0;
$langofdir = $this->defaultlang;
@ -551,9 +549,7 @@ class Translate
if ($resql) {
$num = $db->num_rows($resql);
if ($num) {
if ($usecachekey) {
$tabtranslatedomain = array(); // To save lang content in cache
}
$tabtranslatedomain = array(); // To save lang content in cache (when enabled)
$i = 0;
while ($i < $num) { // Ex: Need 225ms for all fgets on all lang file for Third party page. Same speed than file_get_contents
@ -596,10 +592,6 @@ class Translate
$this->_tab_loaded[$newdomain] = 1; // Set domain file as loaded
}
if (empty($this->_tab_loaded[$newdomain])) {
$this->_tab_loaded[$newdomain] = 2; // Mark this case as not found (no lines found for language)
}
return 1;
}
@ -947,8 +939,8 @@ class Translate
* Return if a filename $filename exists for current language (or alternate language)
*
* @param string $filename Language filename to search
* @param integer $searchalt Search also alternate language file
* @return boolean true if exists and readable
* @param int $searchalt Search also alternate language file
* @return bool true if exists and readable
*/
public function file_exists($filename, $searchalt = 0)
{
@ -960,12 +952,13 @@ class Translate
}
if ($searchalt) {
$filenamealt = null;
// Test si fichier dans repertoire de la langue alternative
if ($this->defaultlang != "en_US") {
$filenamealt = $searchdir . "/langs/en_US/" . $filename;
}
//else $filenamealt = $searchdir."/langs/fr_FR/".$filename;
if (is_readable(dol_osencode($filenamealt))) {
if ($filenamealt !== null && is_readable(dol_osencode($filenamealt))) {
return true;
}
}
@ -1068,7 +1061,7 @@ class Translate
if ($resql) {
$obj = $db->fetch_object($resql);
if ($obj) {
$this->cache_labels[$tablename][$key] = $obj->label;
$this->cache_labels[$tablename][$key] = (string) $obj->label;
} else {
$this->cache_labels[$tablename][$key] = $key;
}
@ -1117,7 +1110,7 @@ class Translate
if (function_exists("mb_convert_encoding")) {
$this->loadCacheCurrencies($forceloadall ? '' : $currency_code);
if (isset($this->cache_currencies[$currency_code]) && !empty($this->cache_currencies[$currency_code]['unicode']) && is_array($this->cache_currencies[$currency_code]['unicode'])) {
if (isset($this->cache_currencies[$currency_code]) && !empty($this->cache_currencies[$currency_code]['unicode']) && is_array($this->cache_currencies[$currency_code]['unicode'])) { // @phan-suppress-current-line PhanTypeMismatchProperty
foreach ($this->cache_currencies[$currency_code]['unicode'] as $unicode) {
$currency_sign .= mb_convert_encoding("&#" . $unicode . ";", "UTF-8", 'HTML-ENTITIES');
}
@ -1170,7 +1163,7 @@ class Translate
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]['unicode'] = (array) json_decode((empty($obj->unicode) ? '' : $obj->unicode), true);
$this->cache_currencies[$obj->code_iso]['unicode'] = (array) json_decode((empty($obj->unicode) ? '' : $obj->unicode), true); // @phan-suppress-current-line PhanTypeMismatchProperty
$label[$obj->code_iso] = $this->cache_currencies[$obj->code_iso]['label'];
}
$i++;

View File

@ -456,7 +456,7 @@ class Utils
$output_arr = array();
$retval = null;
exec($fullcommandclear, $output_arr, $retval);
exec($fullcommandclear, $output_arr, $retval); // @phan-suppress-current-line PhanPluginConstantVariableNull
// TODO Replace this exec with Utils->executeCLI() function.
// We must check that the case for $lowmemorydump works too...
//$utils = new Utils($db);
@ -751,7 +751,7 @@ class Utils
if ($execmethod == 1) {
$retval = null;
exec($command, $output_arr, $retval);
exec($command, $output_arr, $retval); // @phan-suppress-current-line PhanPluginConstantVariableNull
$result = $retval;
if ($retval != 0) {
$langs->load("errors");
@ -1304,8 +1304,10 @@ class Utils
global $dolibarr_main_url_root;
$filepath = '';
$filesize = -1;
$output = '';
$error = 0;
$mimetype = '';
if (!empty($from)) {
$from = dol_escape_htmltag($from);
@ -1371,6 +1373,7 @@ class Utils
$error++;
}
$mailfile = null;
if (!$error) {
include_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, '', '', 0, -1);
@ -1381,7 +1384,8 @@ class Utils
}
$result = false;
if (!$error) {
$output = '';
if (!$error && $mailfile !== null) {
$result = $mailfile->sendfile();
if (!$result) {
$error++;

View File

@ -47,11 +47,11 @@ interface Database
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return datas as an array
* Return data as an array
* @TODO deprecate this. Use fetch_object() so you can access a field with its name instead of using an index of position of field.
*
* @param mysqli_result|resource|SQLite3Result $resultset Resultset of request
* @return array Array
* @return array<string|int,mixed>|null|int<0,0> Array
*/
public function fetch_row($resultset);
// phpcs:enable
@ -61,9 +61,10 @@ interface Database
* Function to use to build INSERT, UPDATE or WHERE predica
*
* @param int $param Date TMS to convert
* @param 'gmt'|'tzserver' $gm 'gmt'=Input information are GMT values, 'tzserver'=Local to server TZ
* @return string Date in a string YYYYMMDDHHMMSS
*/
public function idate($param);
public function idate($param, $gm = 'tzserver');
/**
* Return last error code
@ -98,7 +99,7 @@ interface Database
/**
* Return version of database server into an array
*
* @return array Version array
* @return string[] Version array
*/
public function getVersionArray();
@ -135,7 +136,7 @@ interface Database
*
* @param string $database Name of database
* @param string $table Name of table filter ('xxx%')
* @return array List of tables in an array
* @return string[] of tables in an array
*/
public function DDLListTables($database, $table = '');
// phpcs:enable
@ -146,7 +147,7 @@ interface Database
*
* @param string $database Name of database
* @param string $table Name of table filter ('xxx%')
* @return array List of tables in an array
* @return array<array{0:string,1:string}> List of tables in an array
*/
public function DDLListTablesFull($database, $table = '');
// phpcs:enable
@ -177,10 +178,10 @@ interface Database
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return datas as an array
* Return data as an array
*
* @param mysqli_result|resource|SQLite3Result $resultset Resultset of request
* @return array|null|false Result with row
* @return array<int|string,mixed>|null|false Result with row
*/
public function fetch_array($resultset);
// phpcs:enable
@ -280,16 +281,16 @@ interface Database
/**
* Return value of server parameters
*
* @param string $filter Filter list on a particular value
* @return array Array of key-values (key=>value)
* @param string $filter Filter list on a particular value
* @return array<string,string> Array of key-values (key=>value)
*/
public function getServerParametersValues($filter = '');
/**
* Return value of server status
*
* @param string $filter Filter list on a particular value
* @return array Array of key-values (key=>value)
* @param string $filter Filter list on a particular value
* @return array<string,string> Array of key-values (key=>value)
*/
public function getServerStatusValues($filter = '');
@ -340,9 +341,9 @@ interface Database
* @param array<string,array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int<-2,5>|string,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array<int|string,string>,comment?:string,validate?:int<0,1>}> $fields Associative table [field name][table of descriptions]
* @param string $primary_key Name of the field that will be the primary key
* @param string $type Type of the table
* @param array $unique_keys Associative array Name of fields that will be unique key => value
* @param array $fulltext_keys Field name table that will be indexed in fulltext
* @param array $keys Table of key fields names => value
* @param ?array<string,mixed> $unique_keys Associative array Name of fields that will be unique key => value
* @param string[] $fulltext_keys Field name table that will be indexed in fulltext
* @param string[] $keys Table of key fields names => value
* @return int Return integer <0 if KO, >=0 if OK
*/
public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null);
@ -361,7 +362,7 @@ interface Database
/**
* Return list of available charset that can be used to store data in database
*
* @return array List of Charset
* @return ?array<int,array{charset:string,description:string}> List of Charset
*/
public function getListOfCharacterSet();
@ -404,7 +405,7 @@ interface Database
/**
* Return list of available collation that can be used for database
*
* @return array List of Collation
* @return ?array<int,array{collation:string}> List of Collation
*/
public function getListOfCollation();
@ -456,7 +457,7 @@ interface Database
* List information of columns into a table.
*
* @param string $table Name of table
* @return array Array with information on table
* @return array<array<string,mixed>> Array with information on table
*/
public function DDLInfoTable($table);
// phpcs:enable

View File

@ -153,7 +153,7 @@ abstract class DoliDB implements Database
* Function to use to build INSERT, UPDATE or WHERE predica
*
* @param int $param Date TMS to convert
* @param mixed $gm 'gmt'=Input information are GMT values, 'tzserver'=Local to server TZ
* @param 'gmt'|'tzserver' $gm 'gmt'=Input information are GMT values, 'tzserver'=Local to server TZ
* @return string Date in a string YYYY-MM-DD HH:MM:SS
*/
public function idate($param, $gm = 'tzserver')
@ -417,7 +417,7 @@ abstract class DoliDB implements Database
* just means this function is not what you need. Do not use it.
*
* @param string $sql The sql query string. Must end with "... LIMIT x"
* @return bool|array Result
* @return false|Object[] Result
*/
public function getRows($sql)
{

View File

@ -414,10 +414,10 @@ class DoliDBMysqli extends DoliDB
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return datas as an array
* Return data as an array
*
* @param mysqli_result $resultset Resultset of request
* @return array|null Array or null if KO or end of cursor
* @return array<int|string,mixed>|null|false Array or null if KO or end of cursor
*/
public function fetch_array($resultset)
{
@ -431,10 +431,10 @@ class DoliDBMysqli extends DoliDB
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return datas as an array
* Return data as an array
*
* @param mysqli_result $resultset Resultset of request
* @return array|null|int Array or null if KO or end of cursor or 0 if resultset is bool
* @return array<int,mixed>|null|int<0,0> Array or null if KO or end of cursor or 0 if resultset is bool
*/
public function fetch_row($resultset)
{
@ -734,7 +734,7 @@ class DoliDBMysqli extends DoliDB
*
* @param string $database Name of database
* @param string $table Name of table filter ('xxx%')
* @return array List of tables in an array
* @return string[] List of tables in an array
*/
public function DDLListTables($database, $table = '')
{
@ -766,7 +766,7 @@ class DoliDBMysqli extends DoliDB
*
* @param string $database Name of database
* @param string $table Name of table filter ('xxx%')
* @return array List of tables in an array
* @return array<array{0:string,1:string}> List of tables in an array
*/
public function DDLListTablesFull($database, $table = '')
{
@ -794,10 +794,10 @@ class DoliDBMysqli extends DoliDB
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* List information of columns into a table.
* List information of columns in a table.
*
* @param string $table Name of table
* @return array Tableau des information des champs de la table
* @return array<array<mixed>> Table with information of columns in the table
*/
public function DDLInfoTable($table)
{
@ -826,9 +826,9 @@ class DoliDBMysqli extends DoliDB
* @param array<string,array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int<-2,5>|string,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array<int|string,string>,comment?:string,validate?:int<0,1>}> $fields Tableau associatif [nom champ][tableau des descriptions]
* @param string $primary_key Nom du champ qui sera la clef primaire
* @param string $type Type de la table
* @param array $unique_keys Tableau associatifs Nom de champs qui seront clef unique => valeur
* @param array $fulltext_keys Tableau des Nom de champs qui seront indexes en fulltext
* @param array $keys Tableau des champs cles noms => valeur
* @param ?array<string,mixed> $unique_keys Tableau associatifs Nom de champs qui seront clef unique => valeur
* @param string[] $fulltext_keys Tableau des Nom de champs qui seront indexes en fulltext
* @param array<string,mixed> $keys Tableau des champs cles noms => valeur
* @return int Return integer <0 if KO, >=0 if OK
*/
public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null)
@ -899,7 +899,7 @@ class DoliDBMysqli extends DoliDB
}
}
$sql .= implode(', ', $sqlfields);
if ($unique_keys != "") {
if (!is_array($unique_keys) && $unique_keys != "") {
$sql .= ",".implode(',', $sqluq);
}
if (is_array($keys)) {
@ -1142,7 +1142,7 @@ class DoliDBMysqli extends DoliDB
/**
* Return list of available charset that can be used to store data in database
*
* @return array|null List of Charset
* @return ?array<int,array{charset:string,description:string}> List of Charset
*/
public function getListOfCharacterSet()
{
@ -1185,7 +1185,7 @@ class DoliDBMysqli extends DoliDB
/**
* Return list of available collation that can be used for database
*
* @return array|null Liste of Collation
* @return ?array<int,array{collation:string}> List of Collations
*/
public function getListOfCollation()
{
@ -1244,8 +1244,8 @@ class DoliDBMysqli extends DoliDB
/**
* Return value of server parameters
*
* @param string $filter Filter list on a particular value
* @return array Array of key-values (key=>value)
* @param string $filter Filter list on a particular value
* @return array<string,string> Array of key-values (key=>value)
*/
public function getServerParametersValues($filter = '')
{
@ -1268,8 +1268,8 @@ class DoliDBMysqli extends DoliDB
/**
* Return value of server status (current indicators on memory, cache...)
*
* @param string $filter Filter list on a particular value
* @return array Array of key-values (key=>value)
* @param string $filter Filter list on a particular value
* @return array<string,string> Array of key-values (key=>value)
*/
public function getServerStatusValues($filter = '')
{

View File

@ -56,7 +56,7 @@ class DoliDBPgsql extends DoliDB
*/
public $unescapeslashquot = false;
/**
* @var boolean $standard_conforming_string Set this to true if postgres accept only standard encoding of string using '' and not \'
* @var boolean $standard_conforming_strings Set this to true if postgres accept only standard encoding of string using '' and not \'
*/
public $standard_conforming_strings = false;
@ -606,7 +606,7 @@ class DoliDBPgsql extends DoliDB
* Return datas as an array
*
* @param resource $resultset Resultset of request
* @return false|array Array
* @return array<int|string,mixed>|null|false Array or null if KO or end of cursor
*/
public function fetch_array($resultset)
{
@ -623,7 +623,7 @@ class DoliDBPgsql extends DoliDB
* Return datas as an array
*
* @param resource $resultset Resultset of request
* @return false|array Array
* @return array<int,mixed>|null|int<0,0> Array or null if KO or end of cursor or 0 if resultset is bool
*/
public function fetch_row($resultset)
{
@ -632,7 +632,7 @@ class DoliDBPgsql extends DoliDB
if (!is_resource($resultset) && !is_object($resultset)) {
$resultset = $this->_results;
}
return pg_fetch_row($resultset);
return pg_fetch_row($resultset); // @phan-suppress-current-line PhanTypeMismatchArgumentProbablyReal
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@ -964,7 +964,7 @@ class DoliDBPgsql extends DoliDB
*
* @param string $database Name of database
* @param string $table Name of table filter ('xxx%')
* @return array List of tables in an array
* @return string[] List of tables in an array
*/
public function DDLListTables($database, $table = '')
{
@ -979,7 +979,7 @@ class DoliDBPgsql extends DoliDB
}
$result = pg_query($this->db, "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'".$escapedlike." ORDER BY table_name");
if ($result) {
while ($row = $this->fetch_row($result)) {
while ($row = $this->fetch_row($result)) { // @phan-suppress-current-line PhanTypeMismatchArgumentProbablyReal
$listtables[] = $row[0];
}
}
@ -992,7 +992,7 @@ class DoliDBPgsql extends DoliDB
*
* @param string $database Name of database
* @param string $table Name of table filter ('xxx%')
* @return array List of tables in an array
* @return array<array{0:string,1:string}> List of tables in an array
*/
public function DDLListTablesFull($database, $table = '')
{
@ -1007,7 +1007,7 @@ class DoliDBPgsql extends DoliDB
}
$result = pg_query($this->db, "SELECT table_name, table_type FROM information_schema.tables WHERE table_schema = 'public'".$escapedlike." ORDER BY table_name");
if ($result) {
while ($row = $this->fetch_row($result)) {
while ($row = $this->fetch_row($result)) { // @phan-suppress-current-line PhanTypeMismatchArgumentProbablyReal
$listtables[] = $row;
}
}
@ -1016,10 +1016,10 @@ class DoliDBPgsql extends DoliDB
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* List information of columns into a table.
* List information of columns in a table.
*
* @param string $table Name of table
* @return array Array with information on table
* @return array<array<mixed>> Table with information of columns in the table
*/
public function DDLInfoTable($table)
{
@ -1060,9 +1060,9 @@ class DoliDBPgsql extends DoliDB
* @param array<string,array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int<-2,5>|string,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array<int|string,string>,comment?:string,validate?:int<0,1>}> $fields Tableau associatif [nom champ][tableau des descriptions]
* @param string $primary_key Nom du champ qui sera la clef primaire
* @param string $type Type de la table
* @param array $unique_keys Tableau associatifs Nom de champs qui seront clef unique => valeur
* @param array $fulltext_keys Tableau des Nom de champs qui seront indexes en fulltext
* @param array $keys Tableau des champs cles noms => valeur
* @param ?array<string,mixed> $unique_keys Tableau associatifs Nom de champs qui seront clef unique => valeur
* @param string[] $fulltext_keys Tableau des Nom de champs qui seront indexes en fulltext
* @param array<string,mixed> $keys Tableau des champs cles noms => valeur
* @return int Return integer <0 if KO, >=0 if OK
*/
public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null)
@ -1347,7 +1347,7 @@ class DoliDBPgsql extends DoliDB
/**
* Return list of available charset that can be used to store data in database
*
* @return array|null List of Charset
* @return ?array<int,array{charset:string,description:string}> List of Charset
*/
public function getListOfCharacterSet()
{
@ -1386,7 +1386,7 @@ class DoliDBPgsql extends DoliDB
/**
* Return list of available collation that can be used for database
*
* @return array|null Liste of Collation
* @return ?array<int,array{collation:string}> List of Collations
*/
public function getListOfCollation()
{
@ -1459,8 +1459,8 @@ class DoliDBPgsql extends DoliDB
/**
* Return value of server parameters
*
* @param string $filter Filter list on a particular value
* @return array Array of key-values (key=>value)
* @param string $filter Filter list on a particular value
* @return array<string,string> Array of key-values (key=>value)
*/
public function getServerParametersValues($filter = '')
{
@ -1483,8 +1483,8 @@ class DoliDBPgsql extends DoliDB
/**
* Return value of server status
*
* @param string $filter Filter list on a particular value
* @return array Array of key-values (key=>value)
* @param string $filter Filter list on a particular value
* @return array<string,string> Array of key-values (key=>value)
*/
public function getServerStatusValues($filter = '')
{

View File

@ -539,7 +539,7 @@ class DoliDBSqlite3 extends DoliDB
* Return datas as an array
*
* @param SQLite3Result $resultset Resultset of request
* @return false|array Array or false if KO or end of cursor
* @return array<int|string,mixed>|null|false Array or null if KO or end of cursor
*/
public function fetch_array($resultset)
{
@ -558,7 +558,7 @@ class DoliDBSqlite3 extends DoliDB
* Return datas as an array
*
* @param SQLite3Result $resultset Resultset of request
* @return false|array Array or false if KO or end of cursor
* @return array<int,mixed>|null|int<0,0> Array or null if KO or end of cursor or 0 if resultset is bool
*/
public function fetch_row($resultset)
{
@ -571,7 +571,7 @@ class DoliDBSqlite3 extends DoliDB
return $resultset->fetchArray(SQLITE3_NUM);
} else {
// si le curseur est un boolean on retourne la valeur 0
return false;
return 0;
}
}
@ -591,7 +591,9 @@ class DoliDBSqlite3 extends DoliDB
if (!is_object($resultset)) {
$resultset = $this->_results;
}
// Ignore Phan - queryString is added as dynamic property @phan-suppress-next-line PhanUndeclaredProperty
if (preg_match("/^SELECT/i", $resultset->queryString)) {
// Ignore Phan - queryString is added as dynamic property @phan-suppress-next-line PhanUndeclaredProperty
return $this->db->querySingle("SELECT count(*) FROM (".$resultset->queryString.") q");
}
return 0;
@ -872,7 +874,7 @@ class DoliDBSqlite3 extends DoliDB
*
* @param string $database Name of database
* @param string $table Name of table filter ('xxx%')
* @return array List of tables in an array
* @return string[] List of tables in an array
*/
public function DDLListTables($database, $table = '')
{
@ -904,7 +906,7 @@ class DoliDBSqlite3 extends DoliDB
*
* @param string $database Name of database
* @param string $table Name of table filter ('xxx%')
* @return array List of tables in an array
* @return array<array{0:string,1:string}> List of tables in an array
*/
public function DDLListTablesFull($database, $table = '')
{
@ -935,7 +937,8 @@ class DoliDBSqlite3 extends DoliDB
* List information of columns into a table.
*
* @param string $table Name of table
* @return array Tableau des information des champs de la table
* @return array<array<mixed>> Table with information of columns in the table
* TODO modify for sqlite
*/
public function DDLInfoTable($table)
@ -965,9 +968,9 @@ class DoliDBSqlite3 extends DoliDB
* @param array<string,array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int<-2,5>|string,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array<int|string,string>,comment?:string,validate?:int<0,1>,value?:string,attribute?:string,null?:string,extra?:string}> $fields Tableau associatif [nom champ][tableau des descriptions]
* @param string $primary_key Nom du champ qui sera la clef primaire
* @param string $type Type de la table
* @param array $unique_keys Tableau associatifs Nom de champs qui seront clef unique => valeur
* @param array $fulltext_keys Tableau des Nom de champs qui seront indexes en fulltext
* @param array $keys Tableau des champs cles noms => valeur
* @param ?array<string,mixed> $unique_keys Tableau associatifs Nom de champs qui seront clef unique => valeur
* @param string[] $fulltext_keys Tableau des Nom de champs qui seront indexes en fulltext
* @param array<string,mixed> $keys Tableau des champs cles noms => valeur
* @return int Return integer <0 if KO, >=0 if OK
*/
public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null)
@ -1016,8 +1019,11 @@ class DoliDBSqlite3 extends DoliDB
}
if ($primary_key != "") {
$pk = "PRIMARY KEY(".$this->sanitize($primary_key).")";
} else {
$pk = "";
}
if (is_array($unique_keys)) {
$i = 0;
foreach ($unique_keys as $key => $value) {
@ -1245,7 +1251,7 @@ class DoliDBSqlite3 extends DoliDB
/**
* Return list of available charset that can be used to store data in database
*
* @return array List of Charset
* @return ?array<int,array{charset:string,description:string}> List of Charset
*/
public function getListOfCharacterSet()
{
@ -1269,7 +1275,7 @@ class DoliDBSqlite3 extends DoliDB
/**
* Return list of available collation that can be used for database
*
* @return array List of Collation
* @return ?array<int,array{collation:string}> List of Collation
*/
public function getListOfCollation()
{
@ -1321,8 +1327,8 @@ class DoliDBSqlite3 extends DoliDB
/**
* Return value of server parameters
*
* @param string $filter Filter list on a particular value
* @return array Array of key-values (key=>value)
* @param string $filter Filter list on a particular value
* @return array<string,string> Array of key-values (key=>value)
*/
public function getServerParametersValues($filter = '')
{
@ -1369,7 +1375,7 @@ class DoliDBSqlite3 extends DoliDB
* Return value of server status
*
* @param string $filter Filter list on a particular value
* @return array Array of key-values (key=>value)
* @return array<string,string> Array of key-values (key=>value)
*/
public function getServerStatusValues($filter = '')
{

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2023 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -65,7 +66,7 @@ class DolQueryCollector extends DataCollector implements Renderable, AssetProvid
$queries[] = array(
'sql' => $query['sql'],
'duration' => $query['duration'],
'duration_str' => round($query['duration'] * 1000, 2),
'duration_str' => round((float) $query['duration'] * 1000, 2),
'memory' => $query['memory_usage'],
'is_success' => $query['is_success'],
'error_code' => $query['error_code'],

View File

@ -37,7 +37,7 @@ class TraceableDB extends DoliDB
*/
public $db; // cannot be protected because of parent declaration
/**
* @var array Queries array
* @var array<array<string,null|true|string>> Queries array
*/
public $queries;
/**
@ -90,8 +90,8 @@ class TraceableDB extends DoliDB
/**
* Return datas as an array
*
* @param resource $resultset Resultset of request
* @return array Array
* @param resource $resultset Resultset of request
* @return array<int,mixed>|null|int<0,0> Array
*/
public function fetch_row($resultset)
{
@ -104,7 +104,7 @@ class TraceableDB extends DoliDB
* Function to use to build INSERT, UPDATE or WHERE predica
*
* @param int $param Date TMS to convert
* @param mixed $gm 'gmt'=Input information are GMT values, 'tzserver'=Local to server TZ
* @param 'gmt'|'tzserver' $gm 'gmt'=Input information are GMT values, 'tzserver'=Local to server TZ
* @return string Date in a string YYYY-MM-DD HH:MM:SS
*/
public function idate($param, $gm = 'tzserver')
@ -152,7 +152,7 @@ class TraceableDB extends DoliDB
/**
* Return version of database server into an array
*
* @return array Version array
* @return string[] Version array
*/
public function getVersionArray()
{
@ -200,7 +200,7 @@ class TraceableDB extends DoliDB
*
* @param string $database Name of database
* @param string $table Name of table filter ('xxx%')
* @return array List of tables in an array
* @return string[] List of tables in an array
*/
public function DDLListTables($database, $table = '')
{
@ -212,7 +212,7 @@ class TraceableDB extends DoliDB
*
* @param string $database Name of database
* @param string $table Name of table filter ('xxx%')
* @return array List of tables in an array
* @return array<array{0:string,1:string}> List of tables in an array
*/
public function DDLListTablesFull($database, $table = '')
{
@ -257,7 +257,7 @@ class TraceableDB extends DoliDB
* Return datas as an array
*
* @param resource $resultset Resultset of request
* @return array Array
* @return array<int|string,mixed>|null|false Result with row
*/
public function fetch_array($resultset)
{
@ -419,8 +419,8 @@ class TraceableDB extends DoliDB
/**
* Return value of server parameters
*
* @param string $filter Filter list on a particular value
* @return array Array of key-values (key=>value)
* @param string $filter Filter list on a particular value
* @return array<string,string> Array of key-values (key=>value)
*/
public function getServerParametersValues($filter = '')
{
@ -430,8 +430,8 @@ class TraceableDB extends DoliDB
/**
* Return value of server status
*
* @param string $filter Filter list on a particular value
* @return array Array of key-values (key=>value)
* @param string $filter Filter list on a particular value
* @return array<string,string> Array of key-values (key=>value)
*/
public function getServerStatusValues($filter = '')
{
@ -499,9 +499,9 @@ class TraceableDB extends DoliDB
* @param array<string,array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int<-2,5>|string,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array<int|string,string>,comment?:string,validate?:int<0,1>}> $fields Associative table [field name][table of descriptions]
* @param string $primary_key Nom du champ qui sera la clef primaire
* @param string $type Type de la table
* @param array $unique_keys Tableau associatifs Nom de champs qui seront clef unique => valeur
* @param array $fulltext_keys Tableau des Nom de champs qui seront indexes en fulltext
* @param array $keys Tableau des champs cles noms => valeur
* @param ?array<string,mixed> $unique_keys Tableau associatifs Nom de champs qui seront clef unique => valeur
* @param string[] $fulltext_keys Tableau des Nom de champs qui seront indexes en fulltext
* @param string[] $keys Tableau des champs cles noms => valeur
* @return int Return integer <0 if KO, >=0 if OK
*/
public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null)
@ -523,7 +523,7 @@ class TraceableDB extends DoliDB
/**
* Return list of available charset that can be used to store data in database
*
* @return array List of Charset
* @return ?array<int,array{charset:string,description:string}> List of Charset
*/
public function getListOfCharacterSet()
{
@ -572,7 +572,7 @@ class TraceableDB extends DoliDB
/**
* Return list of available collation that can be used for database
*
* @return array List of Collation
* @return ?array<int,array{collation:string}> List of Collation
*/
public function getListOfCollation()
{
@ -668,8 +668,8 @@ class TraceableDB extends DoliDB
/**
* List information of columns into a table.
*
* @param string $table Name of table
* @return array Array with information on table
* @param string $table Name of table
* @return array<array<string,mixed>> Array with information on table
*/
public function DDLInfoTable($table)
{

View File

@ -376,8 +376,8 @@ if (!empty($force_install_noedit)) {
$option .= ' '.$langs->trans("VersionExperimental");
} elseif ($type == 'sqlite3') {
$option .= ' '.$langs->trans("VersionExperimental");
} elseif (!function_exists($testfunction)) {
// No available
} elseif ($testfunction === null || !function_exists($testfunction)) {
// None available
$option .= ' - '.$langs->trans("FunctionNotAvailableInThisPHP");
}
$option .= '</option>';

View File

@ -183,7 +183,7 @@ class MultiCurrency extends CommonObject
* Load object in memory from the database
*
* @param int $id Id object
* @param string $code code
* @param ?string $code code
* @return int Return integer <0 if KO, 0 if not found, >0 if OK
*/
public function fetch($id, $code = null)
@ -519,12 +519,12 @@ class MultiCurrency extends CommonObject
/**
* Get id and rate of currency from code
*
* @param DoliDB $dbs Object db
* @param string $code Code value search
* @param integer|string $date_document Date from document (propal, order, invoice, ...)
* @param DoliDB $dbs Object db
* @param string $code Code value search
* @param int|string $date_document Date from document (propal, order, invoice, ...)
*
* @return array [0] => id currency
* [1] => rate
* @return array{0:int,1:float} [0] => id currency
* [1] => rate
*/
public static function getIdAndTxFromCode($dbs, $code, $date_document = '')
{

View File

@ -32,14 +32,14 @@ require_once __DIR__ . '/webPortalTheme.class.php';
class Context
{
/**
* @var Context Singleton
* @var ?Context Singleton
* @access private
* @static
*/
private static $_instance = null;
/**
* @var DoliDb $db Database handler
* @var DoliDB $db Database handler
*/
public $db;

View File

@ -149,7 +149,7 @@ class WebPortalInvoice extends Facture
/**
* Constructor
*
* @param DoliDb $db Database handler
* @param DoliDB $db Database handler
*/
public function __construct(DoliDB $db)
{

View File

@ -192,7 +192,7 @@ class WebPortalMember extends Adherent
/**
* Constructor
*
* @param DoliDb $db Database handler
* @param DoliDB $db Database handler
*/
public function __construct(DoliDB $db)
{

View File

@ -145,7 +145,7 @@ class WebPortalOrder extends Commande
/**
* Constructor
*
* @param DoliDb $db Database handler
* @param DoliDB $db Database handler
*/
public function __construct(DoliDB $db)
{

View File

@ -159,7 +159,7 @@ class WebPortalPartnership extends Partnership
/**
* Constructor
*
* @param DoliDb $db Database handler
* @param DoliDB $db Database handler
*/
public function __construct(DoliDB $db)
{

View File

@ -145,7 +145,7 @@ class WebPortalPropal extends Propal
/**
* Constructor
*
* @param DoliDb $db Database handler
* @param DoliDB $db Database handler
*/
public function __construct(DoliDB $db)
{

View File

@ -68,6 +68,8 @@ parameters:
- '#Sprain\\SwissQrBill\\#'
- '#(?:Constructor of class (?:(?:ModeleBox|box_accountancy_last_manual_entri)es|box_(?:ac(?:countancy_suspense_account|ti(?:ons(?:_future)?|vity))|b(?:irthdays(?:_members)?|o(?:(?:okmark|m)s))|c(?:(?:lient|o(?:m(?:(?:mand|pt)e)|nt(?:r?act)))s|ustomers_outstanding_bill_reached)|dolibarr_state_board|f(?:actures(?:_(?:fourn(?:_imp)?|imp))?|icheinter|ournisseurs|unnel_of_prospection)|g(?:oodcustomers|raph_(?:invoices_(?:per(?:month|year)|supplier_permonth)|n(?:b_ticket(?:_last_x_days|s_type)|ew_vs_close_ticket)|orders_(?:(?:supplier_)?permonth)|pro(?:duct_distribution|pales_permonth)|ticket_by_severity))|last(?:_(?:(?:modified_)?knowledgerecord|(?:modified_)?ticket)|login)|m(?:embers_(?:by_t(?:ags|ype)|last_(?:modified|subscriptions)|subscriptions_by_year)|os)|pro(?:duits(?:_alerte_stock)?|ject(?:_opportunities)?|pales|spect)|s(?:(?:cheduled_job|ervices_contract)s|ervices_expired|(?:hipment|upplier_order)s|upplier_orders_awaiting_reception)|task|validated_projects))) has an unused parameter \$param\.#'
- '#(?:Constructor of class DoliDB(?:Mysqli|Pgsql|Sqlite3)) has an unused parameter \$type\.#'
- '#Method DoliDBSqlite3::getListOfCollation\(\) should return array<int, array\{collation: string\}>\|null but returns array\{array\{charset: .UTF-8., description: .UTF-8.\}\}#'
- '#(?:Constructor of class DolEditor) has an unused parameter \$toolbarlocation\.#'
- '#Dead catch - Exception is never thrown in the try block#'