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

@@ -10,21 +10,21 @@
return [ return [
// # Issue statistics: // # Issue statistics:
// PhanPluginUnknownPropertyType : 2250+ occurrences // PhanPluginUnknownPropertyType : 2250+ occurrences
// PhanTypePossiblyInvalidDimOffset : 1560+ occurrences // PhanTypePossiblyInvalidDimOffset : 1550+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 1450+ occurrences // PhanTypeMismatchArgumentProbablyReal : 1450+ occurrences
// PhanPossiblyUndeclaredGlobalVariable : 1400+ occurrences // PhanPossiblyUndeclaredGlobalVariable : 1400+ occurrences
// PhanPluginUnknownObjectMethodCall : 1050+ occurrences // PhanPluginUnknownObjectMethodCall : 1040+ occurrences
// PhanUndeclaredProperty : 940+ occurrences // PhanUndeclaredProperty : 840+ occurrences
// PhanPluginUnknownArrayMethodParamType : 780+ occurrences // PhanPluginUnknownArrayMethodParamType : 780+ occurrences
// PhanUndeclaredGlobalVariable : 730+ occurrences // PhanUndeclaredGlobalVariable : 730+ occurrences
// PhanPluginUnknownArrayMethodReturnType : 620+ occurrences // PhanPluginUnknownArrayMethodReturnType : 620+ occurrences
// PhanPossiblyUndeclaredVariable : 420+ occurrences // PhanPossiblyUndeclaredVariable : 420+ occurrences
// PhanTypeArraySuspiciousNullable : 360+ occurrences // PhanTypeArraySuspiciousNullable : 340+ occurrences
// PhanTypeMismatchProperty : 300+ occurrences // PhanTypeMismatchProperty : 300+ occurrences
// PhanPluginDuplicateExpressionAssignmentOperation : 280+ occurrences // PhanPluginDuplicateExpressionAssignmentOperation : 280+ occurrences
// PhanPluginUnknownArrayFunctionReturnType : 230+ occurrences // PhanPluginUnknownArrayFunctionReturnType : 230+ occurrences
// PhanTypeObjectUnsetDeclaredProperty : 230+ occurrences // PhanTypeObjectUnsetDeclaredProperty : 230+ occurrences
// PhanPluginUnknownArrayFunctionParamType : 190+ occurrences // PhanPluginUnknownArrayFunctionParamType : 180+ occurrences
// PhanTypeMismatchArgumentNullableInternal : 180+ occurrences // PhanTypeMismatchArgumentNullableInternal : 180+ occurrences
// PhanTypeInvalidDimOffset : 170+ occurrences // PhanTypeInvalidDimOffset : 170+ occurrences
// PhanTypeExpectedObjectPropAccess : 150+ occurrences // PhanTypeExpectedObjectPropAccess : 150+ occurrences
@@ -53,10 +53,10 @@ return [
// PhanInvalidFQSENInClasslike : 4 occurrences // PhanInvalidFQSENInClasslike : 4 occurrences
// PhanParamTooMany : 4 occurrences // PhanParamTooMany : 4 occurrences
// PhanTypeConversionFromArray : 3 occurrences // PhanTypeConversionFromArray : 3 occurrences
// PhanNoopStringLiteral : 2 occurrences
// PhanTypeComparisonToArray : 2 occurrences // PhanTypeComparisonToArray : 2 occurrences
// PhanAccessMethodProtected : 1 occurrence // PhanAccessMethodProtected : 1 occurrence
// PhanAccessPropertyStaticAsNonStatic : 1 occurrence // PhanAccessPropertyStaticAsNonStatic : 1 occurrence
// PhanNoopStringLiteral : 1 occurrence
// PhanPluginWhitespaceTrailing : 1 occurrence // PhanPluginWhitespaceTrailing : 1 occurrence
// PhanTypeArraySuspiciousNull : 1 occurrence // PhanTypeArraySuspiciousNull : 1 occurrence
// PhanTypeMismatchReturn : 1 occurrence // PhanTypeMismatchReturn : 1 occurrence
@@ -172,7 +172,7 @@ return [
'htdocs/admin/supplier_order.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredMethod'], 'htdocs/admin/supplier_order.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredMethod'],
'htdocs/admin/supplier_payment.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod'], 'htdocs/admin/supplier_payment.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod'],
'htdocs/admin/supplier_proposal.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], 'htdocs/admin/supplier_proposal.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'],
'htdocs/admin/syslog.php' => ['PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredMethod'], 'htdocs/admin/syslog.php' => ['PhanTypeMismatchArgumentNullableInternal'],
'htdocs/admin/system/constall.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/admin/system/constall.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/admin/system/database-tables.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/admin/system/database-tables.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/admin/system/dbtable.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeArraySuspiciousNullable'], 'htdocs/admin/system/dbtable.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeArraySuspiciousNullable'],
@@ -613,7 +613,6 @@ return [
'htdocs/core/lib/fiscalyear.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], 'htdocs/core/lib/fiscalyear.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'],
'htdocs/core/lib/fourn.lib.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanPluginUnknownArrayFunctionReturnType'], 'htdocs/core/lib/fourn.lib.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanPluginUnknownArrayFunctionReturnType'],
'htdocs/core/lib/ftp.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal'], 'htdocs/core/lib/ftp.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal'],
'htdocs/core/lib/functions.lib.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanTypeArraySuspiciousNullable', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypePossiblyInvalidDimOffset', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'],
'htdocs/core/lib/functions2.lib.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypePossiblyInvalidDimOffset'], 'htdocs/core/lib/functions2.lib.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypePossiblyInvalidDimOffset'],
'htdocs/core/lib/functions_ch.lib.php' => ['PhanTypeMismatchDimFetch'], 'htdocs/core/lib/functions_ch.lib.php' => ['PhanTypeMismatchDimFetch'],
'htdocs/core/lib/functionsnumtoword.lib.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanPossiblyUndeclaredVariable', 'PhanTypeInvalidLeftOperandOfNumericOp'], 'htdocs/core/lib/functionsnumtoword.lib.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanPossiblyUndeclaredVariable', 'PhanTypeInvalidLeftOperandOfNumericOp'],

View File

@@ -765,6 +765,7 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null
global $object; global $object;
'@phan-var-force CommonObject $object'; // Suppose it's a CommonObject for analysis, but other objects have the $fields field as well '@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'])) { if (is_object($object) && isset($object->fields[$paramname]['default'])) {
// @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset
$out = $object->fields[$paramname]['default']; $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) * @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 * @return T Clone object
* @see https://php.net/manual/language.oop5.cloning.php * @see https://php.net/manual/language.oop5.cloning.php
* @phan-suppress PhanTypeExpectedObjectPropAccess
*/ */
function dol_clone($object, $native = 0) function dol_clone($object, $native = 0)
{ {
@@ -2711,9 +2713,9 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
} else { } else {
$width = 14; $width = 14;
$cssclass = 'photorefcenter'; $cssclass = 'photorefcenter';
$picto = $object->picto; $picto = $object->picto; // @phan-suppress-current-line PhanUndeclaredProperty
$prefix = 'object_'; $prefix = 'object_';
if ($object->element == 'project' && !$object->public) { if ($object->element == 'project' && !$object->public) { // @phan-suppress-current-line PhanUndeclaredProperty
$picto = 'project'; // instead of projectpub $picto = 'project'; // instead of projectpub
} }
if (strpos($picto, 'fontawesome_') !== false) { if (strpos($picto, 'fontawesome_') !== false) {
@@ -2773,6 +2775,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
$morehtmlstatus .= $object->getLibStatut(4); $morehtmlstatus .= $object->getLibStatut(4);
} }
} elseif ($object->element == 'facturerec') { } elseif ($object->element == 'facturerec') {
'@phan-var-force FactureRec $object';
if ($object->frequency == 0) { if ($object->frequency == 0) {
$morehtmlstatus .= $object->getLibStatut(2); $morehtmlstatus .= $object->getLibStatut(2);
} else { } else {
@@ -2808,6 +2811,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
// Add alias for thirdparty // Add alias for thirdparty
if (!empty($object->name_alias)) { if (!empty($object->name_alias)) {
'@phan-var-force Societe $object';
$morehtmlref .= '<div class="refidno opacitymedium">'.dol_escape_htmltag($object->name_alias).'</div>'; $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 * 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() 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. dol_setcache($cachekey, $socialnetworks); // If setting cache fails, this is not a problem, so we do not test result.
} }
return $socialnetworks; return $socialnetworks;
} }
@@ -3657,7 +3660,7 @@ function getArrayOfSocialNetworks()
* @param int $cid Id of contact if known * @param int $cid Id of contact if known
* @param int $socid Id of third party if known * @param int $socid Id of third party if known
* @param string $type 'skype','facebook',... * @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 * @return string HTML Link
*/ */
function dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetworks = array()) 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 $profID Value of profID to format
* @param string $profIDtype Type of profID to format ('1', '2', '3', '4', '5', '6' or 'VAT') * @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 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 * @return string Formatted profID
*/ */
function dol_print_profids($profID, $profIDtype, $countrycode = '', $addcpButton = 1) 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)) { if (($forceunitoutput == 'no' && $dimension < 1 / 10000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -6)) {
$dimension *= 1000000; $dimension *= 1000000;
$unit = $unit - 6; $unit -= 6;
} elseif (($forceunitoutput == 'no' && $dimension < 1 / 10 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -3)) { } elseif (($forceunitoutput == 'no' && $dimension < 1 / 10 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -3)) {
$dimension *= 1000; $dimension *= 1000;
$unit -= 3; $unit -= 3;
@@ -6838,8 +6841,8 @@ function get_localtax_by_third($local)
* @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 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 $buyer Company object
* @param Societe $seller Company object * @param Societe $seller Company object
* @param int $firstparamisid 1 if first param is id into table (use this if you can) * @param int<0,1> $firstparamisid 1 if first param is id into table (use this if you can)
* @return array array('rowid'=> , 'code'=> ...) * @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() * @see getLocalTaxesFromRate()
*/ */
function getTaxesFromId($vatrate, $buyer = null, $seller = null, $firstparamisid = 1) function getTaxesFromId($vatrate, $buyer = null, $seller = null, $firstparamisid = 1)
@@ -7645,7 +7648,7 @@ function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto =
* @param int $removeclassattribute 1=Remove the class attribute from tags * @param int $removeclassattribute 1=Remove the class attribute from tags
* @param int $cleanalsojavascript Remove also occurrence of 'javascript:'. * @param int $cleanalsojavascript Remove also occurrence of 'javascript:'.
* @param int $allowiframe Allow iframe tags. * @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. * @param int $allowlink Allow "link" tags.
* @return string String cleaned * @return string String cleaned
* *
@@ -7715,10 +7718,11 @@ function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1,
* This method is used for example by dol_htmlwithnojs() when option MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES is set to 1. * 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 string $stringtoclean String to clean
* @param array $allowed_attributes Array of tags not allowed * @param string[] $allowed_attributes Array of tags not allowed
* @return string String cleaned * @return string String cleaned
* *
* @see dol_escape_htmltag() strip_tags() dol_string_nohtmltag() dol_string_onlythesehtmltags() dol_string_neverthesehtmltags() * @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) function dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes = null)
{ {
@@ -7752,7 +7756,7 @@ function dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes
//var_dump($attrs->item($ii)); //var_dump($attrs->item($ii));
if (!empty($attrs->item($ii)->name)) { if (!empty($attrs->item($ii)->name)) {
if (! in_array($attrs->item($ii)->name, $allowed_attributes)) { 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); $els->item($i)->removeAttribute($attrs->item($ii)->name);
} elseif (in_array($attrs->item($ii)->name, array('style'))) { } elseif (in_array($attrs->item($ii)->name, array('style'))) {
// If attribute is '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', ...) * @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 * @return array<string,string> Array of substitutions
* @see setSubstitFromObject() * @see setSubstitFromObject()
* @phan-suppress PhanTypeArraySuspiciousNullable,PhanTypePossiblyInvalidDimOffset,PhanUndeclaredProperty
*/ */
function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $object = null, $include = null) 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'; $substitutionarray['__SHIPPINGMETHOD__'] = 'Shipping method';
} }
if (isModEnabled("reception") && (!is_object($object) || $object->element == 'reception')) { 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'; $substitutionarray['__RECEPTIONTRACKNUMURL__'] = 'Shipping tracking url';
} }
} else { } else {
'@phan-var-force Adherent|Delivery $object';
$substitutionarray['__ID__'] = $object->id; $substitutionarray['__ID__'] = $object->id;
$substitutionarray['__REF__'] = $object->ref; $substitutionarray['__REF__'] = $object->ref;
$substitutionarray['__NEWREF__'] = $object->newref; $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') : ''); $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) { 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')); $birthday = (empty($object->birth) ? '' : dol_print_date($object->birth, 'day'));
$substitutionarray['__MEMBER_ID__'] = (isset($object->id) ? $object->id : ''); $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') { if (is_object($object) && $object->element == 'societe') {
'@phan-var-force Societe $object';
$substitutionarray['__THIRDPARTY_ID__'] = (is_object($object) ? $object->id : ''); $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object) ? $object->id : '');
$substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object) ? $object->name : ''); $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object) ? $object->name : '');
$substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object) ? $object->name_alias : ''); $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') { if (is_object($object) && $object->element == 'recruitmentcandidature') {
'@phan-var-force RecruitmentCandidature $object';
$substitutionarray['__CANDIDATE_FULLNAME__'] = $object->getFullName($outputlangs); $substitutionarray['__CANDIDATE_FULLNAME__'] = $object->getFullName($outputlangs);
$substitutionarray['__CANDIDATE_FIRSTNAME__'] = isset($object->firstname) ? $object->firstname : ''; $substitutionarray['__CANDIDATE_FIRSTNAME__'] = isset($object->firstname) ? $object->firstname : '';
$substitutionarray['__CANDIDATE_LASTNAME__'] = isset($object->lastname) ? $object->lastname : ''; $substitutionarray['__CANDIDATE_LASTNAME__'] = isset($object->lastname) ? $object->lastname : '';
} }
if (is_object($object) && $object->element == 'conferenceorboothattendee') { if (is_object($object) && $object->element == 'conferenceorboothattendee') {
'@phan-var-force ConferenceOrBoothAttendee $object';
$substitutionarray['__ATTENDEE_FULLNAME__'] = $object->getFullName($outputlangs); $substitutionarray['__ATTENDEE_FULLNAME__'] = $object->getFullName($outputlangs);
$substitutionarray['__ATTENDEE_FIRSTNAME__'] = isset($object->firstname) ? $object->firstname : ''; $substitutionarray['__ATTENDEE_FIRSTNAME__'] = isset($object->firstname) ? $object->firstname : '';
$substitutionarray['__ATTENDEE_LASTNAME__'] = isset($object->lastname) ? $object->lastname : ''; $substitutionarray['__ATTENDEE_LASTNAME__'] = isset($object->lastname) ? $object->lastname : '';
} }
if (is_object($object) && $object->element == 'project') { if (is_object($object) && $object->element == 'project') {
'@phan-var-force Project $object';
$substitutionarray['__PROJECT_ID__'] = $object->id; $substitutionarray['__PROJECT_ID__'] = $object->id;
$substitutionarray['__PROJECT_REF__'] = $object->ref; $substitutionarray['__PROJECT_REF__'] = $object->ref;
$substitutionarray['__PROJECT_NAME__'] = $object->title; $substitutionarray['__PROJECT_NAME__'] = $object->title;
@@ -8734,19 +8745,23 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
} }
if (is_object($object) && $object->element == 'facture') { if (is_object($object) && $object->element == 'facture') {
'@phan-var-force Facture $object';
$substitutionarray['__INVOICE_SITUATION_NUMBER__'] = isset($object->situation_counter) ? $object->situation_counter : ''; $substitutionarray['__INVOICE_SITUATION_NUMBER__'] = isset($object->situation_counter) ? $object->situation_counter : '';
} }
if (is_object($object) && $object->element == 'shipping') { if (is_object($object) && $object->element == 'shipping') {
'@phan-var-force Expedition $object';
$substitutionarray['__SHIPPINGTRACKNUM__'] = $object->tracking_number; $substitutionarray['__SHIPPINGTRACKNUM__'] = $object->tracking_number;
$substitutionarray['__SHIPPINGTRACKNUMURL__'] = $object->tracking_url; $substitutionarray['__SHIPPINGTRACKNUMURL__'] = $object->tracking_url;
$substitutionarray['__SHIPPINGMETHOD__'] = $object->shipping_method; $substitutionarray['__SHIPPINGMETHOD__'] = $object->shipping_method;
} }
if (is_object($object) && $object->element == 'reception') { if (is_object($object) && $object->element == 'reception') {
'@phan-var-force Reception $object';
$substitutionarray['__RECEPTIONTRACKNUM__'] = $object->tracking_number; $substitutionarray['__RECEPTIONTRACKNUM__'] = $object->tracking_number;
$substitutionarray['__RECEPTIONTRACKNUMURL__'] = $object->tracking_url; $substitutionarray['__RECEPTIONTRACKNUMURL__'] = $object->tracking_url;
} }
if (is_object($object) && $object->element == 'contrat' && $object->id > 0 && is_array($object->lines)) { if (is_object($object) && $object->element == 'contrat' && $object->id > 0 && is_array($object->lines)) {
'@phan-var-force Contrat $object';
$dateplannedstart = ''; $dateplannedstart = '';
$datenextexpiration = ''; $datenextexpiration = '';
foreach ($object->lines as $line) { foreach ($object->lines as $line) {
@@ -8764,6 +8779,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
} }
// add substitution variables for ticket // add substitution variables for ticket
if (is_object($object) && $object->element == 'ticket') { if (is_object($object) && $object->element == 'ticket') {
'@phan-var-force Ticket $object';
$substitutionarray['__TICKET_TRACKID__'] = $object->track_id; $substitutionarray['__TICKET_TRACKID__'] = $object->track_id;
$substitutionarray['__TICKET_SUBJECT__'] = $object->subject; $substitutionarray['__TICKET_SUBJECT__'] = $object->subject;
$substitutionarray['__TICKET_TYPE__'] = $object->type_code; $substitutionarray['__TICKET_TYPE__'] = $object->type_code;
@@ -8887,38 +8903,47 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
} }
if (is_object($object) && $object->element == 'propal') { 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; $substitutionarray['__URL_PROPOSAL__'] = DOL_MAIN_URL_ROOT."/comm/propal/card.php?id=".$object->id;
require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php';
$substitutionarray['__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0, 'proposal', $object->ref, 1, $object); $substitutionarray['__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0, 'proposal', $object->ref, 1, $object);
} }
if (is_object($object) && $object->element == 'commande') { 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; $substitutionarray['__URL_ORDER__'] = DOL_MAIN_URL_ROOT."/commande/card.php?id=".$object->id;
} }
if (is_object($object) && $object->element == 'facture') { 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; $substitutionarray['__URL_INVOICE__'] = DOL_MAIN_URL_ROOT."/compta/facture/card.php?id=".$object->id;
} }
if (is_object($object) && $object->element == 'contrat') { 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; $substitutionarray['__URL_CONTRACT__'] = DOL_MAIN_URL_ROOT."/contrat/card.php?id=".$object->id;
require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php';
$substitutionarray['__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0, 'contract', $object->ref, 1, $object); $substitutionarray['__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0, 'contract', $object->ref, 1, $object);
} }
if (is_object($object) && $object->element == 'fichinter') { 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; $substitutionarray['__URL_FICHINTER__'] = DOL_MAIN_URL_ROOT."/fichinter/card.php?id=".$object->id;
require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php';
$substitutionarray['__ONLINE_SIGN_FICHINTER_URL__'] = getOnlineSignatureUrl(0, 'fichinter', $object->ref, 1, $object); $substitutionarray['__ONLINE_SIGN_FICHINTER_URL__'] = getOnlineSignatureUrl(0, 'fichinter', $object->ref, 1, $object);
} }
if (is_object($object) && $object->element == 'supplier_proposal') { 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; $substitutionarray['__URL_SUPPLIER_PROPOSAL__'] = DOL_MAIN_URL_ROOT."/supplier_proposal/card.php?id=".$object->id;
} }
if (is_object($object) && $object->element == 'invoice_supplier') { 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; $substitutionarray['__URL_SUPPLIER_INVOICE__'] = DOL_MAIN_URL_ROOT."/fourn/facture/card.php?id=".$object->id;
} }
if (is_object($object) && $object->element == 'shipping') { 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; $substitutionarray['__URL_SHIPMENT__'] = DOL_MAIN_URL_ROOT."/expedition/card.php?id=".$object->id;
} }
} }
if (is_object($object) && $object->element == 'action') { if (is_object($object) && $object->element == 'action') {
'@phan-var-force ActionComm $object';
$substitutionarray['__EVENT_LABEL__'] = $object->label; $substitutionarray['__EVENT_LABEL__'] = $object->label;
$substitutionarray['__EVENT_TYPE__'] = $outputlangs->trans("Action".$object->type_code); $substitutionarray['__EVENT_TYPE__'] = $outputlangs->trans("Action".$object->type_code);
$substitutionarray['__EVENT_DATE__'] = dol_print_date($object->datep, 'day', 'auto', $outputlangs); $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))) { 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'; 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) : ''; $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 (method_exists($class, $method)) {
if (!isset($memory_object_list[$class]['list'][$id])) { if (!isset($memory_object_list[$class]['list'][$id])) {
$tmpobj = new $class($db); $tmpobj = new $class($db);
// @phan-suppress-next-line PhanPluginUnknownObjectMethodCall
$valuetouseforsubstitution = $tmpobj->$method($id, $key_to_substitute); $valuetouseforsubstitution = $tmpobj->$method($id, $key_to_substitute);
$memory_object_list[$class]['list'][$id] = $tmpobj; $memory_object_list[$class]['list'][$id] = $tmpobj;
} else { } else {
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
$tmpobj = $memory_object_list[$class]['list'][$id]; $tmpobj = $memory_object_list[$class]['list'][$id];
// @phan-suppress-next-line PhanPluginUnknownObjectMethodCall
$valuetouseforsubstitution = $tmpobj->$method($id, $key_to_substitute, true); $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 $mesgstring Error message
* @param string[] $mesgarray Error messages array * @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 * @return void
* *
* @see dol_print_error() * @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 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 $index Key in array to use for sorting criteria
* @param string $order Sort order ('asc' or 'desc') * @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 * 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<0,1> $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. * @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 Return the sorted array (the source array is not modified !) * @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) 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])) { if (is_object($array[$key])) {
$temp[$key] = empty($array[$key]->$index) ? 0 : $array[$key]->$index; $temp[$key] = empty($array[$key]->$index) ? 0 : $array[$key]->$index;
} else { } else {
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
$temp[$key] = empty($array[$key][$index]) ? 0 : $array[$key][$index]; $temp[$key] = empty($array[$key][$index]) ? 0 : $array[$key][$index];
} }
if ($natsort == -1) { if ($natsort == -1) {
@@ -9897,7 +9927,7 @@ function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid =
* *
* @param string $var Variable * @param string $var Variable
* @param string $regextext Text that must be a valid regex string * @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. * @return boolean|string True or False, text if bad usage.
*/ */
function isStringVarMatching($var, $regextext, $matchrule = 1) function isStringVarMatching($var, $regextext, $matchrule = 1)
@@ -9946,8 +9976,8 @@ function verifCond($strToEvaluate, $onlysimplestring = '1')
* This function is called by verifCond() or trans() and transnoentitiesnoconv(). * This function is called by verifCond() or trans() and transnoentitiesnoconv().
* *
* @param string $s String to evaluate * @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<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 $hideerrors 1=Hide errors * @param int<0,1> $hideerrors 1=Hide errors
* @param string $onlysimplestring '0' (deprecated, do not use it anymore)=Accept all chars, * @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^$_+-.*>&|=!?():"\',/@';', * '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 '[]' * '2' (used for example for the compute property of extrafields)=Accept also '[]'
@@ -10149,7 +10179,7 @@ function dol_validElement($element)
* *
* @param string $codelang Language code ('en_IN', 'fr_CA', ...) or ISO Country code on 2 characters in uppercase ('IN', 'FR') * @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 string $moreatt Add more attribute on img tag (For example 'style="float: right"' or 'class="saturatemedium"')
* @param int $notitlealt No title alt * @param int<0,1> $notitlealt No title alt
* @return string HTML img string with flag. * @return string HTML img string with flag.
*/ */
function picto_from_langcode($codelang, $moreatt = '', $notitlealt = 0) 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. * Return null if not found.
* *
* @param string $countrycode Country code like 'US', 'FR', 'CA', 'ES', 'IN', 'MX', ... * @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) function getLanguageCodeFromCountryCode($countrycode)
{ {
@@ -10421,7 +10451,7 @@ function getLanguageCodeFromCountryCode($countrycode)
} }
} }
} else { } 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; return null;
@@ -10522,6 +10552,7 @@ function complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type,
$obj = new $classtoload($db); $obj = new $classtoload($db);
$function = $labeltemp[3]; $function = $labeltemp[3];
if ($obj && $function && method_exists($obj, $function)) { if ($obj && $function && method_exists($obj, $function)) {
// @phan-suppress-next-line PhanPluginUnknownObjectMethodCall
$nbrec = $obj->$function($object->id, $obj); $nbrec = $obj->$function($object->id, $obj);
if (!empty($nbrec)) { if (!empty($nbrec)) {
$label .= '<span class="badge marginleftonlyshort">'.$nbrec.'</span>'; $label .= '<span class="badge marginleftonlyshort">'.$nbrec.'</span>';
@@ -10798,10 +10829,13 @@ function printCommonFooter($zone = 'private')
// Add DebugBar data // Add DebugBar data
if ($user->hasRight('debugbar', 'read') && $debugbar instanceof DebugBar\DebugBar) { if ($user->hasRight('debugbar', 'read') && $debugbar instanceof DebugBar\DebugBar) {
if (isset($debugbar['time'])) {
// @phan-suppress-next-line PhanPluginUnknownObjectMethodCall
$debugbar['time']->stopMeasure('pageaftermaster'); $debugbar['time']->stopMeasure('pageaftermaster');
}
print '<!-- Output debugbar data -->'."\n"; print '<!-- Output debugbar data -->'."\n";
$renderer = $debugbar->getRenderer(); $renderer = $debugbar->getJavascriptRenderer();
print $debugbar->getRenderer()->render(); print $renderer->render();
} elseif (count($conf->logbuffer)) { // If there is some logs in buffer to show } elseif (count($conf->logbuffer)) { // If there is some logs in buffer to show
print "\n"; print "\n";
print "<!-- Start of log output\n"; print "<!-- Start of log output\n";
@@ -10817,12 +10851,12 @@ function printCommonFooter($zone = 'private')
/** /**
* Split a string with 2 keys into key array. * 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 $delimiter Delimiter between each couple of data. Example: ';' or '[\n;]+' or '(\n\r|\r|\n|;)'
* @param string $kv Delimiter between key and value * @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 = '=') 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 * 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 * @return string Url string
*/ */
function showDirectDownloadLink($object) function showDirectDownloadLink($object)
@@ -11155,9 +11189,9 @@ function getImageFileNameForSize($file, $extName, $extImgTarget = '')
* *
* @param string $modulepart propal, facture, facture_fourn, ... * @param string $modulepart propal, facture, facture_fourn, ...
* @param string $relativepath Relative path of docs. * @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 * @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 = '') 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 * Return if a file is qualified for preview
* *
* @param string $file Filename we looking for information * @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 * @see dol_mimetype(), image_format_supported() from images.lib.php
*/ */
function dolIsAllowedForPreview($file) function dolIsAllowedForPreview($file)
@@ -11255,7 +11289,7 @@ function dolIsAllowedForPreview($file)
* *
* @param string $file Filename we looking for MIME type * @param string $file Filename we looking for MIME type
* @param string $default Default mime type if extension not found in known list * @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) * @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 * @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 * Return true if the color is light
* *
* @param string $stringcolor String with hex (FFFFFF) or comma RGB ('255,255,255') * @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) function colorIsLight($stringcolor)
{ {
@@ -11650,10 +11684,10 @@ function colorIsLight($stringcolor)
/** /**
* Function to test if an entry is enabled or not * 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 int<0,1> $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{enabled:int<0,1>,module:string,perms:string} $menuentry Array for feature entry to test
* @param array $listofmodulesforexternal Array with list of modules allowed to external users * @param string[] $listofmodulesforexternal Array with list of modules allowed to external users
* @return int 0=Hide, 1=Show, 2=Show gray * @return int<0,2> 0=Hide, 1=Show, 2=Show gray
*/ */
function isVisibleToUserType($type_user, &$menuentry, &$listofmodulesforexternal) function isVisibleToUserType($type_user, &$menuentry, &$listofmodulesforexternal)
{ {
@@ -11692,9 +11726,9 @@ function isVisibleToUserType($type_user, &$menuentry, &$listofmodulesforexternal
/** /**
* Round to next multiple. * Round to next multiple.
* *
* @param double $n Number to round up * @param float $n Number to round up
* @param integer $x Multiple. For example 60 to round up to nearest exact minute for a date with seconds. * @param int $x Multiple. For example 60 to round up to nearest exact minute for a date with seconds.
* @return integer Value rounded. * @return int Value rounded.
*/ */
function roundUpToNextMultiple($n, $x = 5) 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 $label label of badge no html : use in alt attribute for accessibility
* @param string $html optional : label of badge with html * @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 $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 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 * @return string Html badge
*/ */
function dolGetBadge($label, $html = '', $type = 'primary', $mode = '', $url = '', $params = array()) function dolGetBadge($label, $html = '', $type = 'primary', $mode = '', $url = '', $params = array())
@@ -11772,9 +11806,9 @@ function dolGetBadge($label, $html = '', $type = 'primary', $mode = '', $url = '
* @param string $statusLabelShort Short label of badge no html * @param string $statusLabelShort Short label of badge no html
* @param string $html Optional : label of badge with 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 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 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 string $url The url for link
* @param array $params Various params. Example: array('tooltip'=>'no|...', 'badgeParams'=>...) * @param array<string,mixed> $params Various params. Example: array('tooltip'=>'no|...', 'badgeParams'=>...)
* @return string Html status string * @return string Html status string
*/ */
function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $statusType = 'status0', $displayMode = 0, $url = '', $params = array()) 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 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 * @param int|boolean $userRight User action right
* // phpcs:disable * // 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 * 'attr' => [ // to add or override button attributes
* 'xxxxx' => '', // your xxxxx attribute you want * 'xxxxx' => '', // your xxxxx attribute you want
* 'class' => 'reposition', // to add more css class to the button class attribute * '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 $iconClass class for icon element (Example: 'fa fa-file')
* @param string $url the url for link * @param string $url the url for link
* @param string $id attribute id of button * @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 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 $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
* @return string html button * @return string html button
*/ */
function dolGetButtonTitle($label, $helpText = '', $iconClass = 'fa fa-file', $url = '', $id = '', $status = 1, $params = array()) 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 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_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 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 * @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() * @see getElementProperties()
*/ */
function fetchObjectByElement($element_id, $element_type, $element_ref = '', $useCache = 0, $maxCacheByType = 10) function fetchObjectByElement($element_id, $element_type, $element_ref = '', $useCache = 0, $maxCacheByType = 10)
@@ -12816,7 +12850,7 @@ function addSummaryTableLine($tableColumnCount, $num, $nbofloop = 0, $total = 0,
* WARNING: This close output buffers. * WARNING: This close output buffers.
* *
* @param string $fullpath_original_file_osencoded Full path of file to return. * @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 int<-1,2> $method -1 automatic, 0=readfile, 1=fread, 2=stream_copy_to_stream
* @return void * @return void
*/ */
function readfileLowMemory($fullpath_original_file_osencoded, $method = -1) function readfileLowMemory($fullpath_original_file_osencoded, $method = -1)
@@ -12861,7 +12895,7 @@ function readfileLowMemory($fullpath_original_file_osencoded, $method = -1)
* Code that handle the click is inside core/js/lib_foot.js.php. * Code that handle the click is inside core/js/lib_foot.js.php.
* *
* @param string $valuetocopy The value to print * @param string $valuetocopy The value to print
* @param int $showonlyonhover Show the copy-paste button only on hover * @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) * @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 * @return string The string to print for the button
*/ */
@@ -12913,9 +12947,9 @@ function jsonOrUnserialize($stringtodecode)
* ccc must not contains ( or ) * ccc must not contains ( or )
* Example: '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')' * Example: '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')'
* @param string $errorstr Error message string * @param string $errorstr Error message string
* @param int $noand 1=Do not add the AND before the condition string. * @param int<0,1> $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<0,1> $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> $noerror 1=If search criteria is not valid, does not return an error string but invalidate the SQL
* @return string Return forged SQL string * @return string Return forged SQL string
* @see dolSqlDateFilter() * @see dolSqlDateFilter()
* @see natural_search() * @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. * 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 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<0,1> $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<0,1> $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> $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. * @param mixed $params Optional parameters to pass to hooks for further processing or customization.
* @global object $conf Dolibarr configuration object (global) * @global Conf $conf Dolibarr configuration object (global)
* @global object $db Database connection object (global) * @global DoliDB $db Database connection object (global)
* @global object $user Current user object (global) * @global User $user Current user object (global)
* @global Translate $langs Language translation object, initialized within the function if not already. * @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 string $action Current action, can be modified by hooks.
* @global object $object Current object, 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. * @return void This function terminates script execution after outputting the error page.

View File

@@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> /* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*/ */
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -22,12 +23,17 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandlerInterface.php';
/** /**
* Parent class for log handlers * Parent class for log handlers
*/ */
class LogHandler abstract class LogHandler implements LogHandlerInterface
{ {
/**
* @var string Code for the handler
*/
public $code;
protected $ident = 0; protected $ident = 0;
/** /**
* @var string[] Array of errors messages * @var string[] Array of error messages
*/ */
public $errors = []; public $errors = [];

View File

@@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> /* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*/ */
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -79,10 +80,11 @@ interface LogHandlerInterface
public function isActive(); public function isActive();
/** /**
* Output log content * Export the message
* *
* @param array $content Content to log * @param array $content Array containing the info about the message
* @param string $suffixinfilename When output is a file, append this suffix into default log filename.
* @return void * @return void
*/ */
public function export($content); public function export($content, $suffixinfilename = '');
} }

View File

@@ -8,7 +8,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandler.php';
/** /**
* Class to manage logging to a file * Class to manage logging to a file
*/ */
class mod_syslog_file extends LogHandler implements LogHandlerInterface class mod_syslog_file extends LogHandler
{ {
public $code = 'file'; public $code = 'file';
public $lastTime = 0; public $lastTime = 0;

View File

@@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> /* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*/ */
require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandler.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandler.php';
@@ -7,7 +8,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandler.php';
/** /**
* Class to manage logging to syslog * Class to manage logging to syslog
*/ */
class mod_syslog_syslog extends LogHandler implements LogHandlerInterface class mod_syslog_syslog extends LogHandler
{ {
public $code = 'syslog'; public $code = 'syslog';
@@ -105,9 +106,10 @@ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface
* Export the message * Export the message
* *
* @param array $content Array containing the info about the message * @param array $content Array containing the info about the message
* @param string $suffixinfilename When output is a file, append this suffix into default log filename.
* @return void * @return void
*/ */
public function export($content) public function export($content, $suffixinfilename = '')
{ {
global $conf; global $conf;

View File

@@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2023 Laurent Destailleur <eldy@users.sourceforge.net> /* 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 * 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 * it under the terms of the GNU General Public License as published by
@@ -69,11 +70,16 @@ class DolibarrDebugBar extends DebugBar
/** /**
* Returns a JavascriptRenderer for this instance * Returns a JavascriptRenderer for this instance
* *
* @param string $baseUrl Base url
* @param string $basePath Base path
* @return \DebugBar\JavascriptRenderer String content * @return \DebugBar\JavascriptRenderer String content
*/ */
public function getRenderer() public function getJavascriptRenderer($baseUrl = null, $basePath = null)
{ {
$renderer = parent::getJavascriptRenderer(DOL_URL_ROOT.'/includes/maximebf/debugbar/src/DebugBar/Resources'); if ($baseUrl === null) {
$baseUrl = DOL_URL_ROOT.'/includes/maximebf/debugbar/src/DebugBar/Resources';
}
$renderer = parent::getJavascriptRenderer($baseUrl, $basePath);
$renderer->disableVendor('jquery'); // We already have jquery loaded globally by the main.inc.php $renderer->disableVendor('jquery'); // We already have jquery loaded globally by the main.inc.php
$renderer->disableVendor('fontawesome'); // We already have fontawesome loaded globally by the main.inc.php $renderer->disableVendor('fontawesome'); // We already have fontawesome loaded globally by the main.inc.php
$renderer->disableVendor('highlightjs'); // We don't need this $renderer->disableVendor('highlightjs'); // We don't need this
@@ -81,4 +87,15 @@ class DolibarrDebugBar extends DebugBar
return $renderer; return $renderer;
} }
/**
* Returns a JavascriptRenderer for this instance
*
* @return \DebugBar\JavascriptRenderer String content
* @deprecated Use getJavascriptRenderer
*/
public function getRenderer()
{
return $this->getJavascriptRenderer();
}
} }

View File

@@ -1238,10 +1238,10 @@ if ($step == 4 && $datatoimport) {
} elseif ($modetoautofillmapping == 'session' && !empty($_SESSION['dol_array_match_file_to_database_select'])) { } elseif ($modetoautofillmapping == 'session' && !empty($_SESSION['dol_array_match_file_to_database_select'])) {
$tmpselectioninsession = dolExplodeIntoArray($_SESSION['dol_array_match_file_to_database_select'], ',', '='); $tmpselectioninsession = dolExplodeIntoArray($_SESSION['dol_array_match_file_to_database_select'], ',', '=');
//var_dump($code); //var_dump($code);
if (!empty($tmpselectioninsession[($i + 1)]) && $tmpselectioninsession[($i + 1)] == $tmpcode) { if (!empty($tmpselectioninsession[(string) ($i + 1)]) && $tmpselectioninsession[(string) ($i + 1)] == $tmpcode) {
$selectforline .= ' selected'; $selectforline .= ' selected';
} }
$selectforline .= ' data-debug="'.$tmpcode.'-'.$code.'-'.$j.'-'.(!empty($tmpselectioninsession[($i + 1)]) ? $tmpselectioninsession[($i + 1)] : "").'"'; $selectforline .= ' data-debug="'.$tmpcode.'-'.$code.'-'.$j.'-'.(!empty($tmpselectioninsession[(string) ($i + 1)]) ? $tmpselectioninsession[(string) ($i + 1)] : "").'"';
} }
$selectforline .= ' data-html="'.dol_escape_htmltag($labelhtml).'"'; $selectforline .= ' data-html="'.dol_escape_htmltag($labelhtml).'"';
$selectforline .= '>'; $selectforline .= '>';

View File

@@ -443,7 +443,7 @@ if (isModEnabled('debugbar') && !GETPOST('dol_use_jmobile') && empty($_SESSION['
global $debugbar; global $debugbar;
include_once DOL_DOCUMENT_ROOT.'/debugbar/class/DebugBar.php'; include_once DOL_DOCUMENT_ROOT.'/debugbar/class/DebugBar.php';
$debugbar = new DolibarrDebugBar(); $debugbar = new DolibarrDebugBar();
$renderer = $debugbar->getRenderer(); $renderer = $debugbar->getJavascriptRenderer();
if (!getDolGlobalString('MAIN_HTML_HEADER')) { if (!getDolGlobalString('MAIN_HTML_HEADER')) {
$conf->global->MAIN_HTML_HEADER = ''; $conf->global->MAIN_HTML_HEADER = '';
} }