diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt
index 992f00540a5..3af98b46915 100644
--- a/dev/tools/phan/baseline.txt
+++ b/dev/tools/phan/baseline.txt
@@ -10,21 +10,21 @@
return [
// # Issue statistics:
// PhanPluginUnknownPropertyType : 2250+ occurrences
- // PhanTypePossiblyInvalidDimOffset : 1560+ occurrences
+ // PhanTypePossiblyInvalidDimOffset : 1550+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 1450+ occurrences
// PhanPossiblyUndeclaredGlobalVariable : 1400+ occurrences
- // PhanPluginUnknownObjectMethodCall : 1050+ occurrences
- // PhanUndeclaredProperty : 940+ occurrences
+ // PhanPluginUnknownObjectMethodCall : 1040+ occurrences
+ // PhanUndeclaredProperty : 840+ occurrences
// PhanPluginUnknownArrayMethodParamType : 780+ occurrences
// PhanUndeclaredGlobalVariable : 730+ occurrences
// PhanPluginUnknownArrayMethodReturnType : 620+ occurrences
// PhanPossiblyUndeclaredVariable : 420+ occurrences
- // PhanTypeArraySuspiciousNullable : 360+ occurrences
+ // PhanTypeArraySuspiciousNullable : 340+ occurrences
// PhanTypeMismatchProperty : 300+ occurrences
// PhanPluginDuplicateExpressionAssignmentOperation : 280+ occurrences
// PhanPluginUnknownArrayFunctionReturnType : 230+ occurrences
// PhanTypeObjectUnsetDeclaredProperty : 230+ occurrences
- // PhanPluginUnknownArrayFunctionParamType : 190+ occurrences
+ // PhanPluginUnknownArrayFunctionParamType : 180+ occurrences
// PhanTypeMismatchArgumentNullableInternal : 180+ occurrences
// PhanTypeInvalidDimOffset : 170+ occurrences
// PhanTypeExpectedObjectPropAccess : 150+ occurrences
@@ -53,10 +53,10 @@ return [
// PhanInvalidFQSENInClasslike : 4 occurrences
// PhanParamTooMany : 4 occurrences
// PhanTypeConversionFromArray : 3 occurrences
+ // PhanNoopStringLiteral : 2 occurrences
// PhanTypeComparisonToArray : 2 occurrences
// PhanAccessMethodProtected : 1 occurrence
// PhanAccessPropertyStaticAsNonStatic : 1 occurrence
- // PhanNoopStringLiteral : 1 occurrence
// PhanPluginWhitespaceTrailing : 1 occurrence
// PhanTypeArraySuspiciousNull : 1 occurrence
// PhanTypeMismatchReturn : 1 occurrence
@@ -172,7 +172,7 @@ return [
'htdocs/admin/supplier_order.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredMethod'],
'htdocs/admin/supplier_payment.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod'],
'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/database-tables.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/admin/system/dbtable.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeArraySuspiciousNullable'],
@@ -613,7 +613,6 @@ return [
'htdocs/core/lib/fiscalyear.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'],
'htdocs/core/lib/fourn.lib.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanPluginUnknownArrayFunctionReturnType'],
'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/functions_ch.lib.php' => ['PhanTypeMismatchDimFetch'],
'htdocs/core/lib/functionsnumtoword.lib.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanPossiblyUndeclaredVariable', 'PhanTypeInvalidLeftOperandOfNumericOp'],
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 56b9de40b22..fe6a624eabb 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -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 .= '
'.dol_escape_htmltag($object->name_alias).'
';
}
@@ -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 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 $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 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 $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 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 .= ''.$nbrec.'';
@@ -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 ''."\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 "