From aa49419e8fd289c58135d32c9c95d1d3150837cb Mon Sep 17 00:00:00 2001 From: MDW Date: Sat, 10 Aug 2024 23:21:46 +0200 Subject: [PATCH] Qual: Fix/initial type cannot be inferred (#30591) * Update baseline * Add/update phpdoc typings * Fix type for AssetDepreciationOptions as is * Fix typing for Asset->depreciation_lines * $card is used in derived classes, add it back to ActionsAdherentCardCommon * Adjust code with typing/corrections for defined types * Fix typos, code update to match typing, extra typing * Add type cast for numeric operation * Phpdoc/cast adjustments detected because of new phpdoc hints --- dev/tools/phan/baseline.txt | 24 ++-- .../class/accountingjournal.class.php | 2 +- .../accountancy/class/bookkeeping.class.php | 61 +++++++++ .../actions_adherentcard_common.class.php | 24 +++- htdocs/adherents/class/adherent.class.php | 9 ++ .../adherents/class/adherent_type.class.php | 55 ++++---- .../adherents/class/adherentstats.class.php | 18 +++ .../admin/dolistore/class/dolistore.class.php | 47 +++++-- htdocs/api/class/api_setup.class.php | 3 + htdocs/asset/class/asset.class.php | 122 +++++++++++++++--- .../class/assetdepreciationoptions.class.php | 26 +++- htdocs/asset/class/assetmodel.class.php | 42 ++++++ htdocs/asset/depreciation.php | 3 +- htdocs/blockedlog/class/blockedlog.class.php | 29 ++++- htdocs/bom/class/bom.class.php | 9 ++ htdocs/bookcal/class/availabilities.class.php | 51 ++++++++ 16 files changed, 450 insertions(+), 75 deletions(-) diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index ad1a91929d3..94b83291a3d 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -64,7 +64,7 @@ return [ 'htdocs/accountancy/class/accountancyimport.class.php' => ['PhanPluginUnknownArrayMethodParamType'], 'htdocs/accountancy/class/accountingaccount.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPossiblyUndeclaredVariable'], 'htdocs/accountancy/class/accountingjournal.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/accountancy/class/bookkeeping.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/accountancy/class/bookkeeping.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/accountancy/class/lettering.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable'], 'htdocs/accountancy/customer/list.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/accountancy/journal/bankjournal.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], @@ -76,11 +76,11 @@ return [ 'htdocs/accountancy/tpl/export_journal.tpl.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/adherents/admin/member.php' => ['PhanParamTooMany', 'PhanPluginUnknownObjectMethodCall', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanUndeclaredMethod'], 'htdocs/adherents/agenda.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/adherents/canvas/actions_adherentcard_common.class.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanTypeSuspiciousNonTraversableForeach'], + 'htdocs/adherents/canvas/actions_adherentcard_common.class.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanTypeSuspiciousNonTraversableForeach'], 'htdocs/adherents/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], - 'htdocs/adherents/class/adherent.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/adherents/class/adherent_type.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/adherents/class/adherentstats.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType'], + 'htdocs/adherents/class/adherent.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/adherents/class/adherent_type.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/adherents/class/adherentstats.class.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/adherents/class/api_members.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], 'htdocs/adherents/class/api_subscriptions.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], 'htdocs/adherents/class/subscription.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredVariable'], @@ -107,7 +107,7 @@ return [ 'htdocs/admin/delivery.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredMethod'], 'htdocs/admin/dict.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanRedefineFunction', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], - 'htdocs/admin/dolistore/class/dolistore.class.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType'], + 'htdocs/admin/dolistore/class/dolistore.class.php' => ['PhanPluginUnknownObjectMethodCall'], 'htdocs/admin/ecm.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/admin/emailcollector_card.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanUndeclaredMethod'], 'htdocs/admin/emailcollector_list.php' => ['PhanTypeMismatchArgumentProbablyReal'], @@ -178,15 +178,15 @@ return [ 'htdocs/api/class/api_access.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanUndeclaredProperty'], 'htdocs/api/class/api_documents.class.php' => ['PhanPluginDuplicateExpressionBinaryOp', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable'], 'htdocs/api/class/api_login.class.php' => ['PhanPluginUnknownArrayMethodReturnType'], - 'htdocs/api/class/api_setup.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/api/class/api_setup.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/api/class/api_status.class.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/asset/admin/setup.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod'], 'htdocs/asset/agenda.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/asset/card.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/asset/class/asset.class.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/asset/class/asset.class.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/asset/class/assetaccountancycodes.class.php' => ['PhanPluginUnknownArrayMethodReturnType'], - 'htdocs/asset/class/assetdepreciationoptions.class.php' => ['PhanPluginUnknownPropertyType', 'PhanTypeMismatchProperty'], - 'htdocs/asset/class/assetmodel.class.php' => ['PhanPluginUnknownPropertyType', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], + 'htdocs/asset/class/assetdepreciationoptions.class.php' => ['PhanTypeMismatchProperty'], + 'htdocs/asset/class/assetmodel.class.php' => ['PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], 'htdocs/asset/depreciation.php' => ['PhanPluginEmptyStatementIf'], 'htdocs/asset/disposal.php' => ['PhanPluginEmptyStatementIf'], 'htdocs/asset/document.php' => ['PhanPossiblyUndeclaredGlobalVariable'], @@ -201,13 +201,13 @@ return [ 'htdocs/blockedlog/admin/blockedlog_list.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/blockedlog/ajax/block-info.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/blockedlog/ajax/check_signature.php' => ['PhanUndeclaredGlobalVariable'], - 'htdocs/blockedlog/class/blockedlog.class.php' => ['PhanPluginUnknownPropertyType', 'PhanTypeMismatchProperty', 'PhanTypeSuspiciousNonTraversableForeach', 'PhanUndeclaredProperty'], + 'htdocs/blockedlog/class/blockedlog.class.php' => ['PhanTypeMismatchProperty', 'PhanTypeSuspiciousNonTraversableForeach', 'PhanUndeclaredProperty'], 'htdocs/bom/bom_agenda.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/bom/bom_card.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], 'htdocs/bom/bom_document.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/bom/bom_list.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/bom/class/api_boms.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], - 'htdocs/bom/class/bom.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyNullTypeMismatchProperty', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], + 'htdocs/bom/class/bom.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPossiblyNullTypeMismatchProperty', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], 'htdocs/bom/tpl/linkedobjectblock.tpl.php' => ['PhanPluginUnknownObjectMethodCall'], 'htdocs/bom/tpl/objectline_create.tpl.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/bom/tpl/objectline_edit.tpl.php' => ['PhanTypeExpectedObjectPropAccessButGotNull', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 3d55890919d..da85d8e3630 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -582,7 +582,7 @@ class AccountingJournal extends CommonObject } $lines = array(); - $lines[0][$accountancy_code_value_asset_sold] = -($element_static->acquisition_value_ht - $last_cumulative_amount_ht); + $lines[0][$accountancy_code_value_asset_sold] = -((float) $element_static->acquisition_value_ht - $last_cumulative_amount_ht); $lines[0][$accountancy_code_depreciation_asset] = -$last_cumulative_amount_ht; $lines[0][$accountancy_code_asset] = $element_static->acquisition_value_ht; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index dfb8b274c91..26ceb4868ba 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -3096,8 +3096,18 @@ class BookKeepingLine extends CommonObjectLine */ public $id; + /** + * @var ?int Date of source document + */ public $doc_date = null; + /** + * @var string Doc type + */ public $doc_type; + + /** + * @var string Doc ref + */ public $doc_ref; /** @@ -3110,13 +3120,44 @@ class BookKeepingLine extends CommonObjectLine */ public $fk_docdet; + /** + * @var string Thirdparty code + */ public $thirdparty_code; + + /** + * @var string|null Subledger account + */ public $subledger_account; + + /** + * @var string|null Subledger label + */ public $subledger_label; + + /** + * @var string doc_type + */ public $numero_compte; + + /** + * @var string label compte + */ public $label_compte; + + /** + * @var string label operation + */ public $label_operation; + + /** + * @var float FEC:Debit + */ public $debit; + + /** + * @var float FEC:Credit + */ public $credit; /** @@ -3144,7 +3185,15 @@ class BookKeepingLine extends CommonObjectLine * @var string Sens */ public $sens; + + /** + * @var ?string + */ public $lettering_code; + + /** + * @var string + */ public $date_lettering; /** @@ -3152,8 +3201,20 @@ class BookKeepingLine extends CommonObjectLine */ public $fk_user_author; + + /** + * @var string key for import + */ public $import_key; + + /** + * @var string + */ public $code_journal; + + /** + * @var string + */ public $journal_label; /** * @var int accounting transaction id diff --git a/htdocs/adherents/canvas/actions_adherentcard_common.class.php b/htdocs/adherents/canvas/actions_adherentcard_common.class.php index d4b06aa2b1f..58a9c4d7b2a 100644 --- a/htdocs/adherents/canvas/actions_adherentcard_common.class.php +++ b/htdocs/adherents/canvas/actions_adherentcard_common.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2012 Philippe Grand + * Copyright (C) 2024 MDW * * 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 @@ -32,14 +33,29 @@ abstract class ActionsAdherentCardCommon */ public $db; + /** + * @var string + */ public $dirmodule; + /** + * @var string + */ public $targetmodule; + /** + * @var string + */ public $canvas; + /** + * @var string + */ public $card; - - //! Template container + /** + * @var array Template container + */ public $tpl = array(); - //! Object container + /** + * @var Object container + */ public $object; /** @@ -57,7 +73,7 @@ abstract class ActionsAdherentCardCommon * Get object * * @param int $id Object id - * @return object Object loaded + * @return Adherent Object loaded */ public function getObject($id) { diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 12992f5717b..808ce431d92 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -106,6 +106,9 @@ class Adherent extends CommonObject */ public $civility_code; + /** + * @var int + */ public $civility; /** @@ -202,6 +205,9 @@ class Adherent extends CommonObject */ public $datem; + /** + * @var string|int + */ public $datevalid; /** @@ -239,6 +245,9 @@ class Adherent extends CommonObject */ public $user_login; + /** + * @var string|int + */ public $datefin; diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 3909b4a5e03..00dd3bb0d98 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -68,20 +68,23 @@ class AdherentType extends CommonObject */ public $morphy; + /** + * @var string + */ public $duration; /** - * type expiration + * @var int type expiration */ public $duration_value; /** - * Expiration unit + * @var string Expiration unit */ public $duration_unit; /** - * @var int Subscription required (0 or 1) + * @var int<0,1> Subscription required (0 or 1) */ public $subscription; @@ -119,7 +122,7 @@ class AdherentType extends CommonObject /** @var string Email sent after exclude */ public $mail_exclude = ''; - /** @var array Array of members */ + /** @var Adherent[] Array of members */ public $members = array(); /** @@ -502,7 +505,7 @@ class AdherentType extends CommonObject $this->morphy = $obj->morphy; $this->status = $obj->status; $this->duration = $obj->duration; - $this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1); + $this->duration_value = (int) substr($obj->duration, 0, dol_strlen($obj->duration) - 1); $this->duration_unit = substr($obj->duration, -1); $this->subscription = $obj->subscription; $this->amount = $obj->amount; @@ -534,7 +537,7 @@ class AdherentType extends CommonObject * Return list of members' type * * @param int $status Filter on status of type - * @return array List of types of members + * @return array List of types of members */ public function liste_array($status = -1) { @@ -573,7 +576,7 @@ class AdherentType extends CommonObject * Return the array of all amounts per membership type id * * @param int $status Filter on status of type - * @return array Array of membership type + * @return array Array of membership type */ public function amountByType($status = null) { @@ -609,11 +612,11 @@ class AdherentType extends CommonObject /** * Return array of Member objects for member type this->id (or all if this->id not defined) * - * @param string $excludefilter Filter to exclude. This value must not come from a user input. - * @param int $mode 0=Return array of member instance + * @param string $excludefilter Filter to exclude. This value must not come from a user input. + * @param int<0,2> $mode 0=Return array of member instance * 1=Return array of member instance without extra data * 2=Return array of members id only - * @return mixed Array of members or -1 on error + * @return Adherent[]|int<-1,-1> Array of members or -1 on error */ public function listMembersForMemberType($excludefilter = '', $mode = 0) { @@ -713,12 +716,12 @@ class AdherentType extends CommonObject /** * Return clickable name (with picto eventually) * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param int $maxlen length max label - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL + * @param int<0,2> $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $maxlen length max label + * @param int<0,1> $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int<-1,1> $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL */ public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { @@ -773,8 +776,8 @@ class AdherentType extends CommonObject /** * Return label of status (activity, closed) * - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status + * @param int<0,6> $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function getLibStatut($mode = 0) { @@ -785,9 +788,9 @@ class AdherentType extends CommonObject /** * Return the label of a given status * - * @param int $status Status id - * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Status label + * @param int $status Status id + * @param int<0,6> $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Status label */ public function LibStatut($status, $mode = 0) { @@ -815,11 +818,11 @@ class AdherentType extends CommonObject /** * Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * - * @param array $info Info array loaded by _load_ldap_info - * @param int $mode 0=Return full DN (uid=qqq,ou=xxx,dc=aaa,dc=bbb) - * 1=Return DN without key inside (ou=xxx,dc=aaa,dc=bbb) - * 2=Return key only (uid=qqq) - * @return string DN + * @param array $info Info array loaded by _load_ldap_info + * @param int<0,2> $mode 0=Return full DN (uid=qqq,ou=xxx,dc=aaa,dc=bbb) + * 1=Return DN without key inside (ou=xxx,dc=aaa,dc=bbb) + * 2=Return key only (uid=qqq) + * @return string DN */ public function _load_ldap_dn($info, $mode = 0) { diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 78c531785a7..c515188aa20 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -40,12 +40,30 @@ class AdherentStats extends Stats */ public $table_element; + /** + * @var int + */ public $memberid; + /** + * @var int + */ public $socid; + /** + * @var int + */ public $userid; + /** + * @var string + */ public $from; + /** + * @var string + */ public $field; + /** + * @var string + */ public $where; diff --git a/htdocs/admin/dolistore/class/dolistore.class.php b/htdocs/admin/dolistore/class/dolistore.class.php index ac2e3c2ea46..cf3685d531e 100644 --- a/htdocs/admin/dolistore/class/dolistore.class.php +++ b/htdocs/admin/dolistore/class/dolistore.class.php @@ -1,6 +1,7 @@ . + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modifyion 2.0 (the "License"); * it under the terms of the GNU General Public License as published bypliance with the License. @@ -39,18 +40,48 @@ class Dolistore */ public $end; - public $per_page; // pagination: display per page - public $categorie; // the current categorie + /** + * @var int Pagination: display per page + */ + public $per_page; + /** + * @var int The current categorie + */ + public $categorie; + /** + * @var ?SimpleXMLElement + */ public $categories; // an array of categories - public $search; // the search keywords + + /** + * @var string The search keywords + */ + public $search; // setups + /** + * @var string + */ public $url; // the url of this page + /** + * @var string + */ public $shop_url; // the url of the shop + /** + * @var int + */ public $lang; // the integer representing the lang in the store + /** + * @var bool + */ public $debug_api; // useful if no dialog - + /** + * @var PrestaShopWebservice + */ public $api; + /** + * @var ?SimpleXMLElement + */ public $products; /** @@ -118,7 +149,7 @@ class Dolistore * Load data from remote Dolistore market place. * This fills ->products * - * @param array $options Options. If 'categorie' is defined, we filter products on this category id + * @param array{start:int,end:int,per_page:int,categorie:int,search:string} $options Options. If 'categorie' is defined, we filter products on this category id * @return void */ public function getRemoteProducts($options = array('start' => 0, 'end' => 10, 'per_page' => 50, 'categorie' => 0, 'search' => '')) @@ -222,14 +253,14 @@ class Dolistore if ($cat->is_root_category == 1 && $parent == 0) { $html .= '
  • description->language[$this->lang - 1])).'">'.dol_escape_htmltag($cat->name->language[$this->lang - 1]).' '.dol_escape_htmltag($cat->nb_products_recursive).'

    '; - $html .= self::get_categories($cat->id); + $html .= self::get_categories((int) $cat->id); $html .= "
  • \n"; } elseif (trim($cat->id_parent) == $parent && $cat->active == 1 && trim($cat->id_parent) != 0) { // si cat est de ce niveau $select = ($cat->id == $this->categorie) ? ' selected' : ''; $html .= '
  • description->language[$this->lang - 1])).'" '; $html .= '>'.dol_escape_htmltag($cat->name->language[$this->lang - 1]).' '.dol_escape_htmltag($cat->nb_products_recursive).''; - $html .= self::get_categories($cat->id); + $html .= self::get_categories((int) $cat->id); $html .= "
  • \n"; } } @@ -401,7 +432,7 @@ class Dolistore { // phpcs:enable $param_array = array(); - if (count($this->products) < $this->per_page) { + if ($this->products !== null && count($this->products) < $this->per_page) { $add = 0; } else { $add = $this->per_page; diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 20852515aec..543963c2539 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -40,6 +40,9 @@ require_once DOL_DOCUMENT_ROOT.'/hrm/class/establishment.class.php'; */ class Setup extends DolibarrApi { + /** + * @var ?Translate + */ private $translations = null; /** diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index c0110903334..8fe75e54edb 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -116,33 +116,118 @@ class Asset extends CommonObject 'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => 1, 'position' => 1010, 'notnull' => -1, 'visible' => 0,), 'status' => array('type' => 'smallint', 'label' => 'Status', 'enabled' => 1, 'position' => 1000, 'notnull' => 1, 'default' => '0', 'visible' => 2, 'index' => 1, 'arrayofkeyval' => array('0' => 'Draft', '1' => 'Validated', '9' => 'Canceled'), 'validate' => 1,), ); + + /** + * @var int + */ public $rowid; + /** + * @var string + */ public $ref; + /** + * @var string + */ public $label; + /** + * @var int + */ public $fk_asset_model; + /** + * @var string + */ public $reversal_amount_ht; + /** + * @var string + */ public $acquisition_value_ht; + /** + * @var string + */ public $recovered_vat; + /** + * @var string + */ public $reversal_date; + /** + * @var string + */ public $date_acquisition; + /** + * @var string + */ public $date_start; + /** + * @var float + */ public $qty; + /** + * @var int + */ public $acquisition_type; + /** + * @var int + */ public $asset_type; + /** + * @var int<0,1> + */ public $not_depreciated; + /** + * @var ?string + */ public $disposal_date; + /** + * @var null|string|int Is string, but asset/Card.php assigns int. + */ public $disposal_amount_ht; + /** + * @var ?int + */ public $fk_disposal_type; + /** + * @var int<0,1> + */ public $disposal_depreciated; + /** + * @var int<0,1> + */ public $disposal_subject_to_vat; + /** + * @var int + */ public $supplier_invoice_id; + /** + * @var string + */ public $note_public; + /** + * @var string + */ public $note_private; + /** + * @var int + */ public $fk_user_creat; + /** + * @var int + */ public $fk_user_modif; + /** + * @var string + */ public $last_main_doc; + /** + * @var string + */ public $import_key; + /** + * @var string + */ public $model_pdf; + /** + * @var int + */ public $status; /** @@ -155,9 +240,12 @@ class Asset extends CommonObject * @var AssetDepreciationOptions Used for computed fields of depreciation options class. */ public $asset_depreciation_options; + /** + * @var AssetAccountancyCodes + */ public $asset_accountancy_codes; /** - * @var array List of depreciation lines for each mode (sort by depreciation date). + * @var array> List of depreciation lines for each mode (sort by depreciation date). */ public $depreciation_lines = array(); @@ -204,9 +292,9 @@ class Asset extends CommonObject /** * Create object into database * - * @param User $user User that creates - * @param int $notrigger false=launch triggers after, true=disable triggers - * @return int Return integer <0 if KO, Id of created object if OK + * @param User $user User that creates + * @param int<0,1> $notrigger 0=launch triggers after, 1=disable triggers + * @return int<-1,max> Return integer <0 if KO, Id of created object if OK */ public function create(User $user, $notrigger = 0) { @@ -238,9 +326,9 @@ class Asset extends CommonObject /** * Clone an object into another one * - * @param User $user User that creates - * @param int $fromid Id of object to clone - * @return mixed New object created, <0 if KO + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return Object|int<-1,-1> New object created, <0 if KO */ public function createFromClone(User $user, $fromid) { @@ -338,9 +426,9 @@ class Asset extends CommonObject /** * Load object in memory from the database * - * @param int $id Id object - * @param string $ref Ref - * @return int Return integer <0 if KO, 0 if not found, >0 if OK + * @param int $id Id object + * @param string $ref Ref + * @return int<-1,max> Return integer <0 if KO, 0 if not found, >0 if OK */ public function fetch($id, $ref = null) { @@ -388,7 +476,7 @@ class Asset extends CommonObject * @param string $filter Filter as an Universal Search string. * Example: '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')' * @param string $filtermode No more used - * @return array|int int <0 if KO, array of pages if OK + * @return self[]|int int <0 if KO, array of pages if OK */ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND') { @@ -741,8 +829,8 @@ class Asset extends CommonObject * @param string $mode Depreciation mode (economic, accelerated_depreciation, ...) * @param string $ref Ref line * @param int $depreciation_date Depreciation date - * @param double $depreciation_ht Depreciation amount HT - * @param double $cumulative_depreciation_ht Depreciation cumulative amount HT + * @param float $depreciation_ht Depreciation amount HT + * @param float $cumulative_depreciation_ht Depreciation cumulative amount HT * @param string $accountancy_code_debit Accountancy code Debit * @param string $accountancy_code_credit Accountancy code Credit * @return int Return integer <0 if KO, Id of created line if OK @@ -952,7 +1040,7 @@ class Asset extends CommonObject $fiscal_period_end = $init_fiscal_period_end; } $cumulative_depreciation_ht = $last_cumulative_depreciation_ht; - $depreciation_period_amount = $depreciation_amount - $this->reversal_amount_ht; + $depreciation_period_amount = $depreciation_amount - (float) $this->reversal_amount_ht; $start_date = $depreciation_date_start; $disposal_date = isset($this->disposal_date) && $this->disposal_date !== "" ? $this->disposal_date : ""; $finish_date = $disposal_date !== "" ? $disposal_date : $depreciation_date_end; @@ -1045,7 +1133,7 @@ class Asset extends CommonObject } if ($fiscal_period_start <= $depreciation_date_end && $depreciation_date_end <= $fiscal_period_end) { // last period - $depreciation_ht = (float) price2num($depreciation_amount - $cumulative_depreciation_ht, 'MT'); + $depreciation_ht = (float) price2num($depreciation_amount - (float) $cumulative_depreciation_ht, 'MT'); $cumulative_depreciation_ht = $depreciation_amount; } else { $cumulative_depreciation_ht += $depreciation_ht; @@ -1239,8 +1327,8 @@ class Asset extends CommonObject $this->disposal_date = null; $this->disposal_amount_ht = null; $this->fk_disposal_type = null; - $this->disposal_depreciated = null; - $this->disposal_subject_to_vat = null; + $this->disposal_depreciated = 0; + $this->disposal_subject_to_vat = 0; $result = $this->update($user, 1); if ($result > 0) { $this->deleteObjectLinked(null, 'facture'); diff --git a/htdocs/asset/class/assetdepreciationoptions.class.php b/htdocs/asset/class/assetdepreciationoptions.class.php index e11ecfb9321..6e12f6fc6bf 100644 --- a/htdocs/asset/class/assetdepreciationoptions.class.php +++ b/htdocs/asset/class/assetdepreciationoptions.class.php @@ -105,8 +105,17 @@ class AssetDepreciationOptions extends CommonObject ), ), ); + /** + * @var int + */ public $fk_asset; + /** + * @var int + */ public $fk_asset_model; + /** + * @var int + */ public $fk_user_modif; /** @@ -114,10 +123,25 @@ class AssetDepreciationOptions extends CommonObject */ public $deprecation_options = array(); + /** + * @var int + */ public $depreciation_type; + /** + * @var float + */ public $degressive_coefficient; + /** + * @var int + */ public $duration; + /** + * @var int + */ public $duration_type; + /** + * @var int<0,1> + */ public $accelerated_depreciation_option; /** @@ -383,7 +407,7 @@ class AssetDepreciationOptions extends CommonObject * get general depreciation info for a mode (used in depreciation card) * * @param string $mode Depreciation mode (economic, accelerated_depreciation, ...) - * @return array|int Return integer <0 if KO otherwise array with general depreciation info + * @return array{base_depreciation_ht:string,duration:string,duration_type:string,rate:string}|int<-1,-1> Return integer <0 if KO otherwise array with general depreciation info */ public function getGeneralDepreciationInfoForMode($mode) { diff --git a/htdocs/asset/class/assetmodel.class.php b/htdocs/asset/class/assetmodel.class.php index 5faaa71b710..327bf72e9f4 100644 --- a/htdocs/asset/class/assetmodel.class.php +++ b/htdocs/asset/class/assetmodel.class.php @@ -105,19 +105,61 @@ class AssetModel extends CommonObject 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'position' => 1000, 'notnull' => -1, 'visible' => -2,), 'status' => array('type' => 'smallint', 'label' => 'Status', 'enabled' => 1, 'position' => 1000, 'notnull' => 1, 'default' => '1', 'visible' => 1, 'index' => 1, 'arrayofkeyval' => array('0' => 'Draft', '1' => 'Enabled', '9' => 'Disabled'), 'validate' => 1,), ); + /** + * @var int + */ public $rowid; + /** + * @var string + */ public $ref; + /** + * @var string + */ public $label; + /** + * @var string + */ public $asset_type; + /** + * @var string + */ public $note_public; + /** + * @var string + */ public $note_private; + /** + * @var int + */ public $fk_user_creat; + /** + * @var int + */ public $fk_user_modif; + /** + * @var string + */ public $last_main_doc; + /** + * @var string + */ public $import_key; + /** + * @var string + */ public $model_pdf; + /** + * @var int + */ public $status; + /** + * @var AssetDepreciationOptions + */ public $asset_depreciation_options; + /** + * @var AssetAccountancyCodes + */ public $asset_accountancy_codes; // /** diff --git a/htdocs/asset/depreciation.php b/htdocs/asset/depreciation.php index 26909d26289..13da0968e61 100644 --- a/htdocs/asset/depreciation.php +++ b/htdocs/asset/depreciation.php @@ -1,6 +1,7 @@ * Copyright (C) 2018 Alexandre Spangaro + * Copyright (C) 2024 MDW * * 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 @@ -189,7 +190,7 @@ if ($id > 0 || !empty($ref)) { print price($line['cumulative_depreciation_ht']); print ''; print ''; - print price(price2num($depreciation_info['base_depreciation_ht'] - $line['cumulative_depreciation_ht'], 'MT')); + print price(price2num((float) $depreciation_info['base_depreciation_ht'] - $line['cumulative_depreciation_ht'], 'MT')); print ''; print "\n"; } diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index ed45a7cba1a..9022f87df90 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -65,6 +65,9 @@ class BlockedLog */ public $signature_line = ''; + /** + * @var ?float + */ public $amounts = null; /** @@ -107,13 +110,29 @@ class BlockedLog */ public $date_modification; + /** + * @var int + */ public $date_object = 0; + /** + * @var string + */ public $ref_object = ''; + /** + * @var ?stdClass + */ public $object_data = null; + + /** + * @var string + */ public $object_version = ''; + /** + * @var string + */ public $user_fullname = ''; /** @@ -374,7 +393,7 @@ class BlockedLog * * @param CommonObject $object object to store * @param string $action action - * @param string $amounts amounts + * @param float|int $amounts amounts * @param ?User $fuser User object (forced) * @return int >0 if OK, <0 if KO */ @@ -806,9 +825,9 @@ class BlockedLog /** * Encode data * - * @param string $data Data to serialize - * @param int $mode 0=serialize, 1=json_encode - * @return string Value serialized, an object (stdClass) + * @param stdClass $data Data to serialize, an object (stdClass) + * @param int<0,1> $mode 0=serialize, 1=json_encode + * @return string Value serialized */ public function dolEncodeBlockedData($data, $mode = 0) { @@ -902,7 +921,7 @@ class BlockedLog $this->date_creation = dol_now(); - $this->object_version = ((float) DOL_VERSION); + $this->object_version = DOL_VERSION; $this->db->begin(); diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index fa8b244c594..b5b8a39d04f 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -193,8 +193,17 @@ class BOM extends CommonObject * @var int product Id */ public $fk_product; + /** + * @var float + */ public $qty; + /** + * @var string + */ public $duration; + /** + * @var float + */ public $efficiency; // END MODULEBUILDER PROPERTIES diff --git a/htdocs/bookcal/class/availabilities.class.php b/htdocs/bookcal/class/availabilities.class.php index 51c915659be..83a206e7521 100644 --- a/htdocs/bookcal/class/availabilities.class.php +++ b/htdocs/bookcal/class/availabilities.class.php @@ -124,22 +124,73 @@ class Availabilities extends CommonObject 'endHour' => array('type' => 'integer', 'label' => 'End Hour', 'enabled' => 1, 'position' => 46.5, 'notnull' => 1, 'visible' => 1,), 'status' => array('type' => 'integer', 'label' => 'Status', 'enabled' => 1, 'position' => 2000, 'notnull' => 1, 'visible' => 1, 'index' => 1, 'arrayofkeyval' => array('0' => 'Draft', '1' => 'Validated', '9' => 'Closed'), 'default' => '1', 'validate' => 1), ); + /** + * @var int + */ public $rowid; + /** + * @var string + */ public $label; + /** + * @var string + */ public $description; + /** + * @var string + */ public $note_public; + /** + * @var string + */ public $note_private; + /** + * @var int + */ public $fk_user_creat; + /** + * @var int + */ public $fk_user_modif; + /** + * @var string + */ public $last_main_doc; + /** + * @var string + */ public $import_key; + /** + * @var string + */ public $model_pdf; + /** + * @var int + */ public $status; + /** + * @var string + */ public $start; + /** + * @var string + */ public $end; + /** + * @var int + */ public $duration; + /** + * @var int + */ public $startHour; + /** + * @var int + */ public $endHour; + /** + * @var int + */ public $fk_bookcal_calendar; // END MODULEBUILDER PROPERTIES