Qual: Fix or ignore functions.lib.php phan notices (#29344)

* Fix: LogHandler parent class, implements interface & provides $code

* Fix: functions.lib phan notices

* Fix phan notifications

* Match expected DebugBar signature - rename getRenderer

* Call the correct renderer method for the DebugBar

* Use correct key type to access array

* Ignore notices

* Update functions.lib.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
MDW
2024-04-14 04:46:33 +02:00
committed by GitHub
parent c13cafab68
commit da9fd874bc
9 changed files with 179 additions and 119 deletions

View File

@@ -765,6 +765,7 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null
global $object;
'@phan-var-force CommonObject $object'; // Suppose it's a CommonObject for analysis, but other objects have the $fields field as well
if (is_object($object) && isset($object->fields[$paramname]['default'])) {
// @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset
$out = $object->fields[$paramname]['default'];
}
}
@@ -1416,6 +1417,7 @@ function dol_get_object_properties($obj, $properties = [])
* @param int $native 0=Full isolation method, 1=Native PHP method, 2=Full isolation method keeping only scalar and array properties (recommended)
* @return T Clone object
* @see https://php.net/manual/language.oop5.cloning.php
* @phan-suppress PhanTypeExpectedObjectPropAccess
*/
function dol_clone($object, $native = 0)
{
@@ -2711,9 +2713,9 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
} else {
$width = 14;
$cssclass = 'photorefcenter';
$picto = $object->picto;
$picto = $object->picto; // @phan-suppress-current-line PhanUndeclaredProperty
$prefix = 'object_';
if ($object->element == 'project' && !$object->public) {
if ($object->element == 'project' && !$object->public) { // @phan-suppress-current-line PhanUndeclaredProperty
$picto = 'project'; // instead of projectpub
}
if (strpos($picto, 'fontawesome_') !== false) {
@@ -2773,6 +2775,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
$morehtmlstatus .= $object->getLibStatut(4);
}
} elseif ($object->element == 'facturerec') {
'@phan-var-force FactureRec $object';
if ($object->frequency == 0) {
$morehtmlstatus .= $object->getLibStatut(2);
} else {
@@ -2808,6 +2811,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
// Add alias for thirdparty
if (!empty($object->name_alias)) {
'@phan-var-force Societe $object';
$morehtmlref .= '<div class="refidno opacitymedium">'.dol_escape_htmltag($object->name_alias).'</div>';
}
@@ -3616,7 +3620,7 @@ function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64,
/**
* Get array of social network dictionary
*
* @return array Array of Social Networks Dictionary
* @return array<string,array{rowid:int,label:string,url:string,icon:string,active:int}> Array of Social Networks Dictionary
*/
function getArrayOfSocialNetworks()
{
@@ -3646,7 +3650,6 @@ function getArrayOfSocialNetworks()
}
dol_setcache($cachekey, $socialnetworks); // If setting cache fails, this is not a problem, so we do not test result.
}
return $socialnetworks;
}
@@ -3657,7 +3660,7 @@ function getArrayOfSocialNetworks()
* @param int $cid Id of contact if known
* @param int $socid Id of third party if known
* @param string $type 'skype','facebook',...
* @param array $dictsocialnetworks List of socialnetworks availables
* @param array<string,array{rowid:int,label:string,url:string,icon:string,active:int}> $dictsocialnetworks List of socialnetworks available
* @return string HTML Link
*/
function dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetworks = array())
@@ -3744,7 +3747,7 @@ function dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetwor
* @param string $profID Value of profID to format
* @param string $profIDtype Type of profID to format ('1', '2', '3', '4', '5', '6' or 'VAT')
* @param string $countrycode Country code to use for formatting
* @param int $addcpButton Add button to copy to clipboard (1 => show only on hoover ; 2 => always display )
* @param int<0,2> $addcpButton Add button to copy to clipboard (1 => show only on hoover ; 2 => always display )
* @return string Formatted profID
*/
function dol_print_profids($profID, $profIDtype, $countrycode = '', $addcpButton = 1)
@@ -6608,7 +6611,7 @@ function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round
if (($forceunitoutput == 'no' && $dimension < 1 / 10000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -6)) {
$dimension *= 1000000;
$unit = $unit - 6;
$unit -= 6;
} elseif (($forceunitoutput == 'no' && $dimension < 1 / 10 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -3)) {
$dimension *= 1000;
$unit -= 3;
@@ -6835,11 +6838,11 @@ function get_localtax_by_third($local)
* Get tax (VAT) main information from Id.
* You can also call getLocalTaxesFromRate() after to get only localtax fields.
*
* @param int|string $vatrate VAT ID or Rate. Value can be value or the string with code into parenthesis or rowid if $firstparamisid is 1. Example: '8.5' or '8.5 (8.5NPR)' or 123.
* @param Societe $buyer Company object
* @param Societe $seller Company object
* @param int $firstparamisid 1 if first param is id into table (use this if you can)
* @return array array('rowid'=> , 'code'=> ...)
* @param int|string $vatrate VAT ID or Rate. Value can be value or the string with code into parenthesis or rowid if $firstparamisid is 1. Example: '8.5' or '8.5 (8.5NPR)' or 123.
* @param Societe $buyer Company object
* @param Societe $seller Company object
* @param int<0,1> $firstparamisid 1 if first param is id into table (use this if you can)
* @return array{}|array{rowid:int,code:string,rate:float,localtax1:float,localtax1_type:string,localtax2:float,localtax2_type:string,npr:float,accountancy_code_sell:string,accountacy_code_buy:string} array('rowid'=> , 'code'=> ...)
* @see getLocalTaxesFromRate()
*/
function getTaxesFromId($vatrate, $buyer = null, $seller = null, $firstparamisid = 1)
@@ -6879,16 +6882,16 @@ function getTaxesFromId($vatrate, $buyer = null, $seller = null, $firstparamisid
$obj = $db->fetch_object($resql);
if ($obj) {
return array(
'rowid' => $obj->rowid,
'code' => $obj->code,
'rate' => $obj->rate,
'localtax1' => $obj->localtax1,
'localtax1_type' => $obj->localtax1_type,
'localtax2' => $obj->localtax2,
'localtax2_type' => $obj->localtax2_type,
'npr' => $obj->npr,
'accountancy_code_sell' => $obj->accountancy_code_sell,
'accountancy_code_buy' => $obj->accountancy_code_buy
'rowid' => $obj->rowid,
'code' => $obj->code,
'rate' => $obj->rate,
'localtax1' => $obj->localtax1,
'localtax1_type' => $obj->localtax1_type,
'localtax2' => $obj->localtax2,
'localtax2_type' => $obj->localtax2_type,
'npr' => $obj->npr,
'accountancy_code_sell' => $obj->accountancy_code_sell,
'accountancy_code_buy' => $obj->accountancy_code_buy
);
} else {
return array();
@@ -7645,7 +7648,7 @@ function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto =
* @param int $removeclassattribute 1=Remove the class attribute from tags
* @param int $cleanalsojavascript Remove also occurrence of 'javascript:'.
* @param int $allowiframe Allow iframe tags.
* @param array $allowed_tags List of allowed tags to replace the default list
* @param string[] $allowed_tags List of allowed tags to replace the default list
* @param int $allowlink Allow "link" tags.
* @return string String cleaned
*
@@ -7714,11 +7717,12 @@ function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1,
* Note: Complementary to dol_string_onlythesehtmltags().
* This method is used for example by dol_htmlwithnojs() when option MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES is set to 1.
*
* @param string $stringtoclean String to clean
* @param array $allowed_attributes Array of tags not allowed
* @param string $stringtoclean String to clean
* @param string[] $allowed_attributes Array of tags not allowed
* @return string String cleaned
*
* @see dol_escape_htmltag() strip_tags() dol_string_nohtmltag() dol_string_onlythesehtmltags() dol_string_neverthesehtmltags()
* @phan-suppress PhanUndeclaredProperty
*/
function dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes = null)
{
@@ -7752,7 +7756,7 @@ function dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes
//var_dump($attrs->item($ii));
if (!empty($attrs->item($ii)->name)) {
if (! in_array($attrs->item($ii)->name, $allowed_attributes)) {
// Delete attribute if not into allowed_attributes
// Delete attribute if not into allowed_attributes @phan-suppress-next-line PhanUndeclaredMethod
$els->item($i)->removeAttribute($attrs->item($ii)->name);
} elseif (in_array($attrs->item($ii)->name, array('style'))) {
// If attribute is 'style'
@@ -8406,6 +8410,7 @@ function dol_concatdesc($text1, $text2, $forxml = false, $invert = false)
* @param string[]|null $include Array of family keys we want to include. For example array('system', 'mycompany', 'object', 'objectamount', 'date', 'user', ...)
* @return array<string,string> Array of substitutions
* @see setSubstitFromObject()
* @phan-suppress PhanTypeArraySuspiciousNullable,PhanTypePossiblyInvalidDimOffset,PhanUndeclaredProperty
*/
function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $object = null, $include = null)
{
@@ -8575,10 +8580,11 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$substitutionarray['__SHIPPINGMETHOD__'] = 'Shipping method';
}
if (isModEnabled("reception") && (!is_object($object) || $object->element == 'reception')) {
$substitutionarray['__RECEPTIONTRACKNUM__'] = 'Shippin tracking number of shipment';
$substitutionarray['__RECEPTIONTRACKNUM__'] = 'Shipping tracking number of shipment';
$substitutionarray['__RECEPTIONTRACKNUMURL__'] = 'Shipping tracking url';
}
} else {
'@phan-var-force Adherent|Delivery $object';
$substitutionarray['__ID__'] = $object->id;
$substitutionarray['__REF__'] = $object->ref;
$substitutionarray['__NEWREF__'] = $object->newref;
@@ -8608,6 +8614,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$substitutionarray['__EXPIRATION_DATE__'] = (isset($object->fin_validite) ? dol_print_date($object->fin_validite, 'daytext') : '');
if (is_object($object) && ($object->element == 'adherent' || $object->element == 'member') && $object->id > 0) {
'@phan-var-force Adherent $object';
$birthday = (empty($object->birth) ? '' : dol_print_date($object->birth, 'day'));
$substitutionarray['__MEMBER_ID__'] = (isset($object->id) ? $object->id : '');
@@ -8643,6 +8650,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
}
if (is_object($object) && $object->element == 'societe') {
'@phan-var-force Societe $object';
$substitutionarray['__THIRDPARTY_ID__'] = (is_object($object) ? $object->id : '');
$substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object) ? $object->name : '');
$substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object) ? $object->name_alias : '');
@@ -8691,17 +8699,20 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
}
if (is_object($object) && $object->element == 'recruitmentcandidature') {
'@phan-var-force RecruitmentCandidature $object';
$substitutionarray['__CANDIDATE_FULLNAME__'] = $object->getFullName($outputlangs);
$substitutionarray['__CANDIDATE_FIRSTNAME__'] = isset($object->firstname) ? $object->firstname : '';
$substitutionarray['__CANDIDATE_LASTNAME__'] = isset($object->lastname) ? $object->lastname : '';
}
if (is_object($object) && $object->element == 'conferenceorboothattendee') {
'@phan-var-force ConferenceOrBoothAttendee $object';
$substitutionarray['__ATTENDEE_FULLNAME__'] = $object->getFullName($outputlangs);
$substitutionarray['__ATTENDEE_FIRSTNAME__'] = isset($object->firstname) ? $object->firstname : '';
$substitutionarray['__ATTENDEE_LASTNAME__'] = isset($object->lastname) ? $object->lastname : '';
}
if (is_object($object) && $object->element == 'project') {
'@phan-var-force Project $object';
$substitutionarray['__PROJECT_ID__'] = $object->id;
$substitutionarray['__PROJECT_REF__'] = $object->ref;
$substitutionarray['__PROJECT_NAME__'] = $object->title;
@@ -8734,19 +8745,23 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
}
if (is_object($object) && $object->element == 'facture') {
'@phan-var-force Facture $object';
$substitutionarray['__INVOICE_SITUATION_NUMBER__'] = isset($object->situation_counter) ? $object->situation_counter : '';
}
if (is_object($object) && $object->element == 'shipping') {
'@phan-var-force Expedition $object';
$substitutionarray['__SHIPPINGTRACKNUM__'] = $object->tracking_number;
$substitutionarray['__SHIPPINGTRACKNUMURL__'] = $object->tracking_url;
$substitutionarray['__SHIPPINGMETHOD__'] = $object->shipping_method;
}
if (is_object($object) && $object->element == 'reception') {
'@phan-var-force Reception $object';
$substitutionarray['__RECEPTIONTRACKNUM__'] = $object->tracking_number;
$substitutionarray['__RECEPTIONTRACKNUMURL__'] = $object->tracking_url;
}
if (is_object($object) && $object->element == 'contrat' && $object->id > 0 && is_array($object->lines)) {
'@phan-var-force Contrat $object';
$dateplannedstart = '';
$datenextexpiration = '';
foreach ($object->lines as $line) {
@@ -8764,6 +8779,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
}
// add substitution variables for ticket
if (is_object($object) && $object->element == 'ticket') {
'@phan-var-force Ticket $object';
$substitutionarray['__TICKET_TRACKID__'] = $object->track_id;
$substitutionarray['__TICKET_SUBJECT__'] = $object->subject;
$substitutionarray['__TICKET_TYPE__'] = $object->type_code;
@@ -8887,38 +8903,47 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
}
if (is_object($object) && $object->element == 'propal') {
'@phan-var-force Propal $object';
$substitutionarray['__URL_PROPOSAL__'] = DOL_MAIN_URL_ROOT."/comm/propal/card.php?id=".$object->id;
require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php';
$substitutionarray['__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0, 'proposal', $object->ref, 1, $object);
}
if (is_object($object) && $object->element == 'commande') {
'@phan-var-force Commande $object';
$substitutionarray['__URL_ORDER__'] = DOL_MAIN_URL_ROOT."/commande/card.php?id=".$object->id;
}
if (is_object($object) && $object->element == 'facture') {
'@phan-var-force Facture $object';
$substitutionarray['__URL_INVOICE__'] = DOL_MAIN_URL_ROOT."/compta/facture/card.php?id=".$object->id;
}
if (is_object($object) && $object->element == 'contrat') {
'@phan-var-force Contrat $object';
$substitutionarray['__URL_CONTRACT__'] = DOL_MAIN_URL_ROOT."/contrat/card.php?id=".$object->id;
require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php';
$substitutionarray['__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0, 'contract', $object->ref, 1, $object);
}
if (is_object($object) && $object->element == 'fichinter') {
'@phan-var-force Fichinter $object';
$substitutionarray['__URL_FICHINTER__'] = DOL_MAIN_URL_ROOT."/fichinter/card.php?id=".$object->id;
require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php';
$substitutionarray['__ONLINE_SIGN_FICHINTER_URL__'] = getOnlineSignatureUrl(0, 'fichinter', $object->ref, 1, $object);
}
if (is_object($object) && $object->element == 'supplier_proposal') {
'@phan-var-force SupplierProposal $object';
$substitutionarray['__URL_SUPPLIER_PROPOSAL__'] = DOL_MAIN_URL_ROOT."/supplier_proposal/card.php?id=".$object->id;
}
if (is_object($object) && $object->element == 'invoice_supplier') {
'@phan-var-force FactureFournisseur $object';
$substitutionarray['__URL_SUPPLIER_INVOICE__'] = DOL_MAIN_URL_ROOT."/fourn/facture/card.php?id=".$object->id;
}
if (is_object($object) && $object->element == 'shipping') {
'@phan-var-force Expedition $object';
$substitutionarray['__URL_SHIPMENT__'] = DOL_MAIN_URL_ROOT."/expedition/card.php?id=".$object->id;
}
}
if (is_object($object) && $object->element == 'action') {
'@phan-var-force ActionComm $object';
$substitutionarray['__EVENT_LABEL__'] = $object->label;
$substitutionarray['__EVENT_TYPE__'] = $outputlangs->trans("Action".$object->type_code);
$substitutionarray['__EVENT_DATE__'] = dol_print_date($object->datep, 'day', 'auto', $outputlangs);
@@ -8927,6 +8952,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
}
}
if ((empty($exclude) || !in_array('objectamount', $exclude)) && (empty($include) || in_array('objectamount', $include))) {
'@phan-var-force Facture|FactureRec $object';
include_once DOL_DOCUMENT_ROOT.'/core/lib/functionsnumtoword.lib.php';
$substitutionarray['__DATE_YMD__'] = is_object($object) ? (isset($object->date) ? dol_print_date($object->date, 'day', 0, $outputlangs) : null) : '';
@@ -9215,10 +9241,13 @@ function make_substitutions($text, $substitutionarray, $outputlangs = null, $con
if (method_exists($class, $method)) {
if (!isset($memory_object_list[$class]['list'][$id])) {
$tmpobj = new $class($db);
// @phan-suppress-next-line PhanPluginUnknownObjectMethodCall
$valuetouseforsubstitution = $tmpobj->$method($id, $key_to_substitute);
$memory_object_list[$class]['list'][$id] = $tmpobj;
} else {
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
$tmpobj = $memory_object_list[$class]['list'][$id];
// @phan-suppress-next-line PhanPluginUnknownObjectMethodCall
$valuetouseforsubstitution = $tmpobj->$method($id, $key_to_substitute, true);
}
@@ -9656,7 +9685,7 @@ function dol_htmloutput_mesg($mesgstring = '', $mesgarray = array(), $style = 'o
*
* @param string $mesgstring Error message
* @param string[] $mesgarray Error messages array
* @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify)
* @param int<0,1> $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify)
* @return void
*
* @see dol_print_error()
@@ -9674,11 +9703,11 @@ function dol_htmloutput_errors($mesgstring = '', $mesgarray = array(), $keepembe
* @param array<string|int,mixed> $array Array to sort (array of array('key1'=>val1,'key2'=>val2,'key3'...) or array of objects)
* @param string $index Key in array to use for sorting criteria
* @param string $order Sort order ('asc' or 'desc')
* @param int $natsort If values are strings (I said value not type): 0=Use alphabetical order, 1=use "natural" sort (natsort)
* @param int<0,1> $natsort If values are strings (I said value not type): 0=Use alphabetical order, 1=use "natural" sort (natsort)
* If values are numeric (I said value not type): 0=Use numeric order (even if type is string) so use a "natural" sort, 1=use "natural" sort too (same than 0), -1=Force alphabetical order
* @param int $case_sensitive 1=sort is case sensitive, 0=not case sensitive
* @param int $keepindex If 0 and index key of array to sort is a numeric, then index will be rewritten. If 1 or index key is not numeric, key for index is kept after sorting.
* @return array Return the sorted array (the source array is not modified !)
* @param int<0,1> $case_sensitive 1=sort is case sensitive, 0=not case sensitive
* @param int<0,1> $keepindex If 0 and index key of array to sort is a numeric, then index will be rewritten. If 1 or index key is not numeric, key for index is kept after sorting.
* @return array<string|int,mixed> Return the sorted array (the source array is not modified !)
*/
function dol_sort_array(&$array, $index, $order = 'asc', $natsort = 0, $case_sensitive = 0, $keepindex = 0)
{
@@ -9693,6 +9722,7 @@ function dol_sort_array(&$array, $index, $order = 'asc', $natsort = 0, $case_sen
if (is_object($array[$key])) {
$temp[$key] = empty($array[$key]->$index) ? 0 : $array[$key]->$index;
} else {
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
$temp[$key] = empty($array[$key][$index]) ? 0 : $array[$key][$index];
}
if ($natsort == -1) {
@@ -9897,7 +9927,7 @@ function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid =
*
* @param string $var Variable
* @param string $regextext Text that must be a valid regex string
* @param int $matchrule 1=Test if start with, 0=Test if equal
* @param int<0,1> $matchrule 1=Test if start with, 0=Test if equal
* @return boolean|string True or False, text if bad usage.
*/
function isStringVarMatching($var, $regextext, $matchrule = 1)
@@ -9945,12 +9975,12 @@ function verifCond($strToEvaluate, $onlysimplestring = '1')
* Replace eval function to add more security.
* This function is called by verifCond() or trans() and transnoentitiesnoconv().
*
* @param string $s String to evaluate
* @param int $returnvalue 0=No return (deprecated, used to execute eval($a=something)). 1=Value of eval is returned (used to eval($something)).
* @param int $hideerrors 1=Hide errors
* @param string $onlysimplestring '0' (deprecated, do not use it anymore)=Accept all chars,
* '1' (most common use)=Accept only simple string with char 'a-z0-9\s^$_+-.*>&|=!?():"\',/@';',
* '2' (used for example for the compute property of extrafields)=Accept also '[]'
* @param string $s String to evaluate
* @param int<0,1> $returnvalue 0=No return (deprecated, used to execute eval($a=something)). 1=Value of eval is returned (used to eval($something)).
* @param int<0,1> $hideerrors 1=Hide errors
* @param string $onlysimplestring '0' (deprecated, do not use it anymore)=Accept all chars,
* '1' (most common use)=Accept only simple string with char 'a-z0-9\s^$_+-.*>&|=!?():"\',/@';',
* '2' (used for example for the compute property of extrafields)=Accept also '[]'
* @return void|string Nothing or return result of eval (even if type can be int, it is safer to assume string and find all potential typing issues as abs(dol_eval(...)).
* @see verifCond()
* @phan-suppress PhanPluginUnsafeEval
@@ -10147,9 +10177,9 @@ function dol_validElement($element)
/**
* Return img flag of country for a language code or country code.
*
* @param string $codelang Language code ('en_IN', 'fr_CA', ...) or ISO Country code on 2 characters in uppercase ('IN', 'FR')
* @param string $moreatt Add more attribute on img tag (For example 'style="float: right"' or 'class="saturatemedium"')
* @param int $notitlealt No title alt
* @param string $codelang Language code ('en_IN', 'fr_CA', ...) or ISO Country code on 2 characters in uppercase ('IN', 'FR')
* @param string $moreatt Add more attribute on img tag (For example 'style="float: right"' or 'class="saturatemedium"')
* @param int<0,1> $notitlealt No title alt
* @return string HTML img string with flag.
*/
function picto_from_langcode($codelang, $moreatt = '', $notitlealt = 0)
@@ -10201,7 +10231,7 @@ function picto_from_langcode($codelang, $moreatt = '', $notitlealt = 0)
* Return null if not found.
*
* @param string $countrycode Country code like 'US', 'FR', 'CA', 'ES', 'IN', 'MX', ...
* @return string|null Value of locale like 'en_US', 'fr_FR', ... or null if not found
* @return ?string Value of locale like 'en_US', 'fr_FR', ... or null if not found
*/
function getLanguageCodeFromCountryCode($countrycode)
{
@@ -10421,7 +10451,7 @@ function getLanguageCodeFromCountryCode($countrycode)
}
}
} else {
dol_syslog("Warning Exention php-intl is not available", LOG_WARNING);
dol_syslog("Warning Extension php-intl is not available", LOG_WARNING);
}
return null;
@@ -10522,6 +10552,7 @@ function complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type,
$obj = new $classtoload($db);
$function = $labeltemp[3];
if ($obj && $function && method_exists($obj, $function)) {
// @phan-suppress-next-line PhanPluginUnknownObjectMethodCall
$nbrec = $obj->$function($object->id, $obj);
if (!empty($nbrec)) {
$label .= '<span class="badge marginleftonlyshort">'.$nbrec.'</span>';
@@ -10798,10 +10829,13 @@ function printCommonFooter($zone = 'private')
// Add DebugBar data
if ($user->hasRight('debugbar', 'read') && $debugbar instanceof DebugBar\DebugBar) {
$debugbar['time']->stopMeasure('pageaftermaster');
if (isset($debugbar['time'])) {
// @phan-suppress-next-line PhanPluginUnknownObjectMethodCall
$debugbar['time']->stopMeasure('pageaftermaster');
}
print '<!-- Output debugbar data -->'."\n";
$renderer = $debugbar->getRenderer();
print $debugbar->getRenderer()->render();
$renderer = $debugbar->getJavascriptRenderer();
print $renderer->render();
} elseif (count($conf->logbuffer)) { // If there is some logs in buffer to show
print "\n";
print "<!-- Start of log output\n";
@@ -10817,12 +10851,12 @@ function printCommonFooter($zone = 'private')
/**
* Split a string with 2 keys into key array.
* For example: "A=1;B=2;C=2" is exploded into array('A'=>1,'B'=>2,'C'=>3)
* For example: "A=1;B=2;C=2" is exploded into array('A'=>'1','B'=>'2','C'=>'3')
*
* @param string|null $string String to explode
* @param ?string $string String to explode
* @param string $delimiter Delimiter between each couple of data. Example: ';' or '[\n;]+' or '(\n\r|\r|\n|;)'
* @param string $kv Delimiter between key and value
* @return array Array of data exploded
* @return array<string,string> Array of data exploded
*/
function dolExplodeIntoArray($string, $delimiter = ';', $kv = '=')
{
@@ -11079,7 +11113,7 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0)
/**
* Return string with full Url. The file qualified is the one defined by relative path in $object->last_main_doc
*
* @param Object $object Object
* @param CommonObject $object Object
* @return string Url string
*/
function showDirectDownloadLink($object)
@@ -11155,9 +11189,9 @@ function getImageFileNameForSize($file, $extName, $extImgTarget = '')
*
* @param string $modulepart propal, facture, facture_fourn, ...
* @param string $relativepath Relative path of docs.
* @param int $alldata Return array with all components (1 is recommended, then use a simple a href link with the class, target and mime attribute added. 'documentpreview' css class is handled by jquery code into main.inc.php)
* @param int<0,1> $alldata Return array with all components (1 is recommended, then use a simple a href link with the class, target and mime attribute added. 'documentpreview' css class is handled by jquery code into main.inc.php)
* @param string $param More param on http links
* @return string|array Output string with href link or array with all components of link
* @return string|array{}|array{target:string,css:string,url:string,mime:string} Output string with href link or array with all components of link
*/
function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata = 0, $param = '')
{
@@ -11223,7 +11257,7 @@ function ajax_autoselect($htmlname, $addlink = '', $textonlink = 'Link')
* Return if a file is qualified for preview
*
* @param string $file Filename we looking for information
* @return int 1 If allowed, 0 otherwise
* @return int<0,1> 1 If allowed, 0 otherwise
* @see dol_mimetype(), image_format_supported() from images.lib.php
*/
function dolIsAllowedForPreview($file)
@@ -11255,7 +11289,7 @@ function dolIsAllowedForPreview($file)
*
* @param string $file Filename we looking for MIME type
* @param string $default Default mime type if extension not found in known list
* @param int $mode 0=Return full mime, 1=otherwise short mime string, 2=image for mime type, 3=source language, 4=css of font fa
* @param int<0,4> $mode 0=Return full mime, 1=otherwise short mime string, 2=image for mime type, 3=source language, 4=css of font fa
* @return string Return a mime type family (text/xxx, application/xxx, image/xxx, audio, video, archive)
* @see dolIsAllowedForPreview(), image_format_supported() from images.lib.php
*/
@@ -11618,7 +11652,7 @@ function getDictionaryValue($tablename, $field, $id, $checkentity = false, $rowi
* Return true if the color is light
*
* @param string $stringcolor String with hex (FFFFFF) or comma RGB ('255,255,255')
* @return int -1 : Error with argument passed |0 : color is dark | 1 : color is light
* @return int<-1,1> -1 : Error with argument passed |0 : color is dark | 1 : color is light
*/
function colorIsLight($stringcolor)
{
@@ -11650,10 +11684,10 @@ function colorIsLight($stringcolor)
/**
* Function to test if an entry is enabled or not
*
* @param string $type_user 0=We test for internal user, 1=We test for external user
* @param array $menuentry Array for feature entry to test
* @param array $listofmodulesforexternal Array with list of modules allowed to external users
* @return int 0=Hide, 1=Show, 2=Show gray
* @param int<0,1> $type_user 0=We test for internal user, 1=We test for external user
* @param array{enabled:int<0,1>,module:string,perms:string} $menuentry Array for feature entry to test
* @param string[] $listofmodulesforexternal Array with list of modules allowed to external users
* @return int<0,2> 0=Hide, 1=Show, 2=Show gray
*/
function isVisibleToUserType($type_user, &$menuentry, &$listofmodulesforexternal)
{
@@ -11692,9 +11726,9 @@ function isVisibleToUserType($type_user, &$menuentry, &$listofmodulesforexternal
/**
* Round to next multiple.
*
* @param double $n Number to round up
* @param integer $x Multiple. For example 60 to round up to nearest exact minute for a date with seconds.
* @return integer Value rounded.
* @param float $n Number to round up
* @param int $x Multiple. For example 60 to round up to nearest exact minute for a date with seconds.
* @return int Value rounded.
*/
function roundUpToNextMultiple($n, $x = 5)
{
@@ -11708,9 +11742,9 @@ function roundUpToNextMultiple($n, $x = 5)
* @param string $label label of badge no html : use in alt attribute for accessibility
* @param string $html optional : label of badge with html
* @param string $type type of badge : Primary Secondary Success Danger Warning Info Light Dark status0 status1 status2 status3 status4 status5 status6 status7 status8 status9
* @param string $mode default '' , 'pill', 'dot'
* @param ''|'pill'|'dot' $mode Default '' , 'pill', 'dot'
* @param string $url the url for link
* @param array $params various params for future : recommended rather than adding more function arguments. array('attr'=>array('title'=>'abc'))
* @param array<string,mixed> $params Various params for future : recommended rather than adding more function arguments. array('attr'=>array('title'=>'abc'))
* @return string Html badge
*/
function dolGetBadge($label, $html = '', $type = 'primary', $mode = '', $url = '', $params = array())
@@ -11768,14 +11802,14 @@ function dolGetBadge($label, $html = '', $type = 'primary', $mode = '', $url = '
/**
* Output the badge of a status.
*
* @param string $statusLabel Label of badge no html : use in alt attribute for accessibility
* @param string $statusLabelShort Short label of badge no html
* @param string $html Optional : label of badge with html
* @param string $statusType status0 status1 status2 status3 status4 status5 status6 status7 status8 status9 : image name or badge name
* @param int $displayMode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto
* @param string $url The url for link
* @param array $params Various params. Example: array('tooltip'=>'no|...', 'badgeParams'=>...)
* @return string Html status string
* @param string $statusLabel Label of badge no html : use in alt attribute for accessibility
* @param string $statusLabelShort Short label of badge no html
* @param string $html Optional : label of badge with html
* @param string $statusType status0 status1 status2 status3 status4 status5 status6 status7 status8 status9 : image name or badge name
* @param int<0,6> $displayMode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto
* @param string $url The url for link
* @param array<string,mixed> $params Various params. Example: array('tooltip'=>'no|...', 'badgeParams'=>...)
* @return string Html status string
*/
function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $statusType = 'status0', $displayMode = 0, $url = '', $params = array())
{
@@ -11878,7 +11912,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st
* @param string $id Attribute id of action button. Example 'action-delete'. This can be used for full ajax confirm if this code is reused into the ->formconfirm() method.
* @param int|boolean $userRight User action right
* // phpcs:disable
* @param array $params = [ // Various params for future : recommended rather than adding more function arguments
* @param array<string,mixed> $params = [ // Various params for future : recommended rather than adding more function arguments
* 'attr' => [ // to add or override button attributes
* 'xxxxx' => '', // your xxxxx attribute you want
* 'class' => 'reposition', // to add more css class to the button class attribute
@@ -12099,8 +12133,8 @@ function getFieldErrorIcon($fieldValidationErrorMsg)
* @param string $iconClass class for icon element (Example: 'fa fa-file')
* @param string $url the url for link
* @param string $id attribute id of button
* @param int $status 0 no user rights, 1 active, 2 current action or selected, -1 Feature Disabled, -2 disable Other reason use param $helpText as tooltip help
* @param array $params various params for future : recommended rather than adding more function arguments
* @param int<-2,2> $status 0 no user rights, 1 active, 2 current action or selected, -1 Feature Disabled, -2 disable Other reason use param $helpText as tooltip help
* @param array<string,mixed> $params various params for future : recommended rather than adding more function arguments
* @return string html button
*/
function dolGetButtonTitle($label, $helpText = '', $iconClass = 'fa fa-file', $url = '', $id = '', $status = 1, $params = array())
@@ -12538,9 +12572,9 @@ function getElementProperties($elementType)
* @param int $element_id Element id (Use this or element_id but not both)
* @param string $element_type Element type ('module' or 'myobject@mymodule' or 'mymodule_myobject')
* @param string $element_ref Element ref (Use this or element_id but not both)
* @param int $useCache if you want to store object in cache or get it from cache 0 => no use cache , 1 use cache, 2 force reload cache
* @param int<0,2> $useCache if you want to store object in cache or get it from cache 0 => no use cache , 1 use cache, 2 force reload cache
* @param int $maxCacheByType number of object in cache for this element type
* @return int|object object || 0 || <0 if error
* @return int<-1,0>|object object || 0 || <0 if error
* @see getElementProperties()
*/
function fetchObjectByElement($element_id, $element_type, $element_ref = '', $useCache = 0, $maxCacheByType = 10)
@@ -12815,8 +12849,8 @@ function addSummaryTableLine($tableColumnCount, $num, $nbofloop = 0, $total = 0,
* Return a file on output using a low memory. It can return very large files with no need of memory.
* WARNING: This close output buffers.
*
* @param string $fullpath_original_file_osencoded Full path of file to return.
* @param int $method -1 automatic, 0=readfile, 1=fread, 2=stream_copy_to_stream
* @param string $fullpath_original_file_osencoded Full path of file to return.
* @param int<-1,2> $method -1 automatic, 0=readfile, 1=fread, 2=stream_copy_to_stream
* @return void
*/
function readfileLowMemory($fullpath_original_file_osencoded, $method = -1)
@@ -12860,10 +12894,10 @@ function readfileLowMemory($fullpath_original_file_osencoded, $method = -1)
* Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
* Code that handle the click is inside core/js/lib_foot.js.php.
*
* @param string $valuetocopy The value to print
* @param int $showonlyonhover Show the copy-paste button only on hover
* @param string $texttoshow Replace the value to show with this text. Use 'none' to show no text (only the copy-paste picto)
* @return string The string to print for the button
* @param string $valuetocopy The value to print
* @param int<0,1> $showonlyonhover Show the copy-paste button only on hover
* @param string $texttoshow Replace the value to show with this text. Use 'none' to show no text (only the copy-paste picto)
* @return string The string to print for the button
*/
function showValueWithClipboardCPButton($valuetocopy, $showonlyonhover = 1, $texttoshow = '')
{
@@ -12913,9 +12947,9 @@ function jsonOrUnserialize($stringtodecode)
* ccc must not contains ( or )
* Example: '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')'
* @param string $errorstr Error message string
* @param int $noand 1=Do not add the AND before the condition string.
* @param int $nopar 1=Do not add the parenthesis around the final condition string.
* @param int $noerror 1=If search criteria is not valid, does not return an error string but invalidate the SQL
* @param int<0,1> $noand 1=Do not add the AND before the condition string.
* @param int<0,1> $nopar 1=Do not add the parenthesis around the final condition string.
* @param int<0,1> $noerror 1=If search criteria is not valid, does not return an error string but invalidate the SQL
* @return string Return forged SQL string
* @see dolSqlDateFilter()
* @see natural_search()
@@ -14079,15 +14113,15 @@ function buildParamDate($prefix, $timestamp = null, $hourTime = '', $gm = 'auto'
* The function also supports executing additional hooks for customized handling of error pages.
*
* @param string $message Custom error message to display. If empty, a default "Record Not Found" message is shown.
* @param int $printheader Determines if the page header should be printed (1 = yes, 0 = no).
* @param int $printfooter Determines if the page footer should be printed (1 = yes, 0 = no).
* @param int $showonlymessage If set to 1, only the error message is displayed without any additional information or hooks.
* @param int<0,1> $printheader Determines if the page header should be printed (1 = yes, 0 = no).
* @param int<0,1> $printfooter Determines if the page footer should be printed (1 = yes, 0 = no).
* @param int<0,1> $showonlymessage If set to 1, only the error message is displayed without any additional information or hooks.
* @param mixed $params Optional parameters to pass to hooks for further processing or customization.
* @global object $conf Dolibarr configuration object (global)
* @global object $db Database connection object (global)
* @global object $user Current user object (global)
* @global Conf $conf Dolibarr configuration object (global)
* @global DoliDB $db Database connection object (global)
* @global User $user Current user object (global)
* @global Translate $langs Language translation object, initialized within the function if not already.
* @global object $hookmanager Hook manager object, initialized within the function if not already for executing hooks.
* @global HookManager $hookmanager Hook manager object, initialized within the function if not already for executing hooks.
* @global string $action Current action, can be modified by hooks.
* @global object $object Current object, can be modified by hooks.
* @return void This function terminates script execution after outputting the error page.