diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 5ca02d5529cee..297c8c32a5ab1 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -12,21 +12,19 @@ return [ // PhanUndeclaredProperty : 560+ occurrences // PhanPossiblyUndeclaredGlobalVariable : 520+ occurrences // PhanUndeclaredGlobalVariable : 350+ occurrences - // PhanTypeMismatchArgumentProbablyReal : 320+ occurrences + // PhanTypeMismatchArgumentProbablyReal : 310+ occurrences // PhanPluginUnknownArrayMethodReturnType : 180+ occurrences // PhanTypeMismatchProperty : 160+ occurrences // PhanPluginUnknownPropertyType : 130+ occurrences // PhanPluginUnknownArrayMethodParamType : 120+ occurrences // PhanPossiblyUndeclaredVariable : 110+ occurrences // PhanPluginUndeclaredVariableIsset : 65+ occurrences - // PhanTypeMismatchArgumentNullableInternal : 50+ occurrences // PhanRedefineFunction : 45+ occurrences - // PhanTypeExpectedObjectPropAccess : 40+ occurrences + // PhanTypeExpectedObjectPropAccess : 45+ occurrences + // PhanTypeMismatchArgumentNullableInternal : 45+ occurrences // PhanTypeMismatchDimFetch : 40+ occurrences // PhanPluginEmptyStatementIf : 35+ occurrences - // PhanPluginUnknownArrayFunctionParamType : 35+ occurrences - // PhanPluginUnknownArrayFunctionReturnType : 30+ occurrences - // PhanTypeInvalidDimOffset : 30+ occurrences + // PhanTypeInvalidDimOffset : 35+ occurrences // PhanUndeclaredConstant : 15+ occurrences // PhanEmptyForeach : 10+ occurrences // PhanPluginUnknownObjectMethodCall : 10+ occurrences @@ -39,17 +37,17 @@ return [ // PhanPluginDuplicateExpressionBinaryOp : 7 occurrences // PhanParamTooMany : 5 occurrences // PhanPossiblyNullTypeMismatchProperty : 5 occurrences - // PhanTypeMismatchReturn : 5 occurrences // PhanPluginDuplicateArrayKey : 4 occurrences // PhanEmptyFQSENInClasslike : 3 occurrences // PhanInvalidFQSENInClasslike : 3 occurrences + // PhanTypeMismatchReturn : 3 occurrences // PhanPluginUnknownArrayPropertyType : 2 occurrences // PhanTypeExpectedObjectPropAccessButGotNull : 2 occurrences // PhanTypeMismatchDimAssignment : 2 occurrences + // PhanTypeSuspiciousStringExpression : 2 occurrences // PhanAccessMethodProtected : 1 occurrence // PhanParamTooFew : 1 occurrence // PhanTypeConversionFromArray : 1 occurrence - // PhanTypeSuspiciousStringExpression : 1 occurrence // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ @@ -102,11 +100,11 @@ return [ 'htdocs/comm/action/class/api_agendaevents.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchProperty'], 'htdocs/comm/action/class/cactioncomm.class.php' => ['PhanPluginUnknownArrayPropertyType'], 'htdocs/comm/action/document.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/comm/action/index.php' => ['PhanPluginEmptyStatementIf', 'PhanPluginUnknownArrayFunctionParamType', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty'], + 'htdocs/comm/action/index.php' => ['PhanPluginEmptyStatementIf', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty'], 'htdocs/comm/action/info.php' => ['PhanUndeclaredProperty'], 'htdocs/comm/action/list.php' => ['PhanTypeMismatchProperty'], - 'htdocs/comm/action/pertype.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanTypeComparisonFromArray', 'PhanTypeMismatchDimFetch'], - 'htdocs/comm/action/peruser.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanTypeComparisonFromArray'], + 'htdocs/comm/action/pertype.php' => ['PhanTypeComparisonFromArray', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchDimFetch'], + 'htdocs/comm/action/peruser.php' => ['PhanTypeComparisonFromArray'], 'htdocs/comm/mailing/card.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/comm/mailing/cibles.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], 'htdocs/comm/mailing/index.php' => ['PhanUndeclaredProperty'], @@ -212,8 +210,7 @@ return [ 'htdocs/core/actions_sendmails.inc.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/core/actions_setmoduleoptions.inc.php' => ['PhanPluginUnknownObjectMethodCall'], 'htdocs/core/ajax/ajaxdirpreview.php' => ['PhanPossiblyUndeclaredGlobalVariable'], - 'htdocs/core/ajax/ajaxdirtree.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchProperty', 'PhanUndeclaredGlobalVariable'], - 'htdocs/core/ajax/onlineSign.php' => ['PhanPluginUnknownArrayFunctionParamType'], + 'htdocs/core/ajax/ajaxdirtree.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchProperty', 'PhanUndeclaredGlobalVariable'], 'htdocs/core/ajax/selectobject.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/core/ajax/selectsearchbox.php' => ['PhanPluginUndeclaredVariableIsset'], 'htdocs/core/boxes/box_actions.php' => ['PhanPossiblyUndeclaredVariable'], @@ -285,7 +282,7 @@ return [ 'htdocs/core/modules/expedition/doc/pdf_merou.modules.php' => ['PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/core/modules/expensereport/doc/pdf_standard_expensereport.modules.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'], 'htdocs/core/modules/facture/doc/pdf_crabe.modules.php' => ['PhanPluginEmptyStatementIf', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], - 'htdocs/core/modules/facture/doc/pdf_octopus.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanTypeMismatchReturn', 'PhanUndeclaredProperty'], + 'htdocs/core/modules/facture/doc/pdf_octopus.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], 'htdocs/core/modules/facture/doc/pdf_sponge.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], 'htdocs/core/modules/facture/modules_facture.php' => ['PhanPluginUnknownPropertyType'], 'htdocs/core/modules/fichinter/mod_pacific.php' => ['PhanPossiblyUndeclaredVariable'], @@ -295,7 +292,6 @@ return [ 'htdocs/core/modules/import/import_xlsx.modules.php' => ['PhanTypeMismatchProperty'], 'htdocs/core/modules/mailings/contacts1.modules.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/core/modules/mailings/thirdparties.modules.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/core/modules/member/modules_cards.php' => ['PhanPluginUnknownArrayFunctionParamType'], 'htdocs/core/modules/movement/doc/pdf_standard_movementstock.modules.php' => ['PhanPluginDuplicateExpressionBinaryOp', 'PhanPluginEmptyStatementIf', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable'], 'htdocs/core/modules/mrp/doc/pdf_vinci.modules.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], 'htdocs/core/modules/mrp/mod_mo_advanced.php' => ['PhanUndeclaredProperty'], @@ -448,7 +444,6 @@ return [ 'htdocs/hrm/class/skill.class.php' => ['PhanUndeclaredProperty'], 'htdocs/hrm/class/skilldet.class.php' => ['PhanUndeclaredProperty'], 'htdocs/hrm/class/skillrank.class.php' => ['PhanUndeclaredProperty'], - 'htdocs/hrm/compare.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType'], 'htdocs/hrm/core/tpl/objectline_view.tpl.php' => ['PhanPluginEmptyStatementIf', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/hrm/evaluation_list.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/hrm/job_agenda.php' => ['PhanPossiblyUndeclaredGlobalVariable'], @@ -458,7 +453,7 @@ return [ 'htdocs/hrm/skill_card.php' => ['PhanTypeExpectedObjectPropAccess', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/hrm/skill_list.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/imports/emptyexample.php' => ['PhanRedefineFunction', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/imports/import.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/imports/import.php' => ['PhanTypeInvalidDimOffset', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch'], 'htdocs/install/check.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal'], 'htdocs/install/fileconf.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/install/inc.php' => ['PhanPluginUndeclaredVariableIsset'], @@ -549,7 +544,7 @@ return [ 'htdocs/projet/class/api_tasks.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], 'htdocs/projet/contact.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeComparisonFromArray', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/projet/element.php' => ['PhanUndeclaredProperty'], - 'htdocs/projet/ganttchart.inc.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], + 'htdocs/projet/ganttchart.inc.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], 'htdocs/projet/ganttview.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/projet/graph_opportunities.inc.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanUndeclaredGlobalVariable'], 'htdocs/projet/index.php' => ['PhanUndeclaredGlobalVariable'], @@ -690,17 +685,17 @@ return [ 'htdocs/webportal/class/html.formcardwebportal.class.php' => ['PhanUndeclaredProperty'], 'htdocs/webportal/class/html.formlistwebportal.class.php' => ['PhanTypeInvalidDimOffset', 'PhanUndeclaredProperty'], 'htdocs/webportal/class/webportalpropal.class.php' => ['PhanUndeclaredProperty'], - 'htdocs/webservices/server_actioncomm.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanUndeclaredProperty'], + 'htdocs/webservices/server_actioncomm.php' => ['PhanUndeclaredProperty'], 'htdocs/webservices/server_category.php' => ['PhanUndeclaredProperty'], - 'htdocs/webservices/server_contact.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], - 'htdocs/webservices/server_invoice.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], - 'htdocs/webservices/server_order.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeExpectedObjectPropAccess', 'PhanUndeclaredProperty'], + 'htdocs/webservices/server_contact.php' => ['PhanUndeclaredProperty'], + 'htdocs/webservices/server_invoice.php' => ['PhanUndeclaredProperty'], + 'htdocs/webservices/server_order.php' => ['PhanTypeExpectedObjectPropAccess', 'PhanTypeInvalidDimOffset', 'PhanTypeSuspiciousStringExpression', 'PhanUndeclaredProperty'], 'htdocs/webservices/server_payment.php' => ['PhanTypeExpectedObjectPropAccess', 'PhanUndeclaredProperty'], - 'htdocs/webservices/server_productorservice.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanUndeclaredProperty'], - 'htdocs/webservices/server_project.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], - 'htdocs/webservices/server_supplier_invoice.php' => ['PhanPluginUnknownArrayFunctionReturnType', 'PhanUndeclaredProperty'], - 'htdocs/webservices/server_thirdparty.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], - 'htdocs/webservices/server_user.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanUndeclaredProperty'], + 'htdocs/webservices/server_productorservice.php' => ['PhanUndeclaredProperty'], + 'htdocs/webservices/server_project.php' => ['PhanUndeclaredProperty'], + 'htdocs/webservices/server_supplier_invoice.php' => ['PhanUndeclaredProperty'], + 'htdocs/webservices/server_thirdparty.php' => ['PhanUndeclaredProperty'], + 'htdocs/webservices/server_user.php' => ['PhanUndeclaredProperty'], 'htdocs/website/class/website.class.php' => ['PhanPossiblyNullTypeMismatchProperty', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal'], 'htdocs/website/index.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/website/samples/wrapper.php' => ['PhanTypeMismatchArgumentProbablyReal'], diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index ba7237dba4237..53bc33241f85d 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1826,13 +1826,13 @@ * @param int $year Year * @param int $monthshown Current month shown in calendar view * @param string $style Style to use for this day - * @param array $eventarray Array of events + * @param array $eventarray Array of events * @param int $maxprint Nb of actions to show each day on month view (0 means no limit) * @param int $maxnbofchar Nb of characters to show for event line * @param string $newparam Parameters on current URL * @param int $showinfo Add extended information (used by day and week view) * @param int $minheight Minimum height for each event. 60px by default. - * @param int $nonew 0=Add "new entry button", 1=No "new entry button", -1=Only "new entry button" + * @param int<-1,1> $nonew 0=Add "new entry button", 1=No "new entry button", -1=Only "new entry button" * @param array{}|array{0:array{0:int,1:int,2:int},1:array{0:int,1:int,2:int},2:array{0:int,1:int,2:int}} $bookcalcalendarsarray Used for Bookcal module array of calendar of bookcal * @return void */ diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 04c62142d86c6..e4b43bbddc89c 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -834,9 +834,9 @@ $sql = "SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX."c_actioncomm ORDER BY position"; $resql = $db->query($sql); while ($obj = $db->fetch_object($resql)) { - $typeofevents[$obj->code] = $obj->code; - $colorsbytype[$obj->code] = $obj->color; - $labelbytype[$obj->code] = $obj->label; + $typeofevents[(string) $obj->code] = (string) $obj->code; + $colorsbytype[(string) $obj->code] = (string) $obj->color; + $labelbytype[(string) $obj->code] = (string) $obj->label; } // Loop on each user to show calendar @@ -961,20 +961,20 @@ /** * Show event line of a particular day for a user * - * @param User $username Login + * @param string $username Login * @param int $day Day * @param int $month Month * @param int $year Year * @param int $monthshown Current month shown in calendar view * @param string $style Style to use for this day - * @param array $eventarray Array of events + * @param array $eventarray Array of events * @param int $maxprint Nb of actions to show each day on month view (0 means no limit) * @param int $maxnbofchar Nb of characters to show for event line * @param string $newparam Parameters on current URL * @param int $showinfo Add extended information (used by day view) * @param int $minheight Minimum height for each event. 60px by default. - * @param boolean $showheader Show header - * @param array $colorsbytype Array with colors by type + * @param bool $showheader Show header + * @param array $colorsbytype Array with colors by type * @param bool $var true or false for alternat style on tr/td * @return void */ diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index cb8e44d9d8c3e..ffe50ab8e4188 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -1146,14 +1146,14 @@ * @param int $year Year * @param int $monthshown Current month shown in calendar view * @param string $style Style to use for this day - * @param array $eventarray Array of events + * @param array $eventarray Array of events * @param int $maxprint Nb of actions to show each day on month view (0 means no limit) * @param int $maxnbofchar Nb of characters to show for event line * @param string $newparam Parameters on current URL * @param int $showinfo Add extended information (used by day view) * @param int $minheight Minimum height for each event. 60px by default. * @param boolean $showheader Show header - * @param array $colorsbytype Array with colors by type + * @param array $colorsbytype Array with colors by type * @param bool $var true or false for alternat style on tr/td * @return void */ diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index fbb4fc966420b..469f846470ed1 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1400,7 +1400,7 @@ public function createFromClone(User $user, $fromid = 0) /** * Load an object from an order and create a new invoice into database * - * @param Facture $object Object source + * @param Commande $object Object source * @param User $user Object user * @return int<-1,1> Return integer <0 if KO, 0 if nothing done, 1 if OK */ diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index a8c42dd10ea1c..330f398feed83 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -367,7 +367,7 @@ /** * treeOutputForAbsoluteDir * - * @param array $sqltree Sqltree + * @param array $sqltree Sqltree * @param string $selecteddir Selected dir * @param string $fullpathselecteddir Full path of selected dir * @param string $modulepart Modulepart diff --git a/htdocs/core/ajax/onlineSign.php b/htdocs/core/ajax/onlineSign.php index c82dd322a3797..abe7725bfe0df 100644 --- a/htdocs/core/ajax/onlineSign.php +++ b/htdocs/core/ajax/onlineSign.php @@ -228,7 +228,7 @@ // TODO Get position of box from PDF template if (getDolGlobalString("PROPAL_SIGNATURE_XFORIMGSTART")) { - $param['xforimgstart'] = getDolGlobalString("PROPAL_SIGNATURE_XFORIMGSTART"); + $param['xforimgstart'] = getDolGlobalString("PROPAL_SIGNATURE_XFORIMGSTART"); } else { $param['xforimgstart'] = (empty($s['w']) ? 120 : round($s['w'] / 2) + 15); } @@ -945,7 +945,7 @@ * * @param TCPDF $pdf PDF handler * @param Translate $langs Language - * @param array $params Array of params + * @param array $params Array of params * @return void */ function dolPrintSignatureImage(TCPDF $pdf, $langs, $params) diff --git a/htdocs/core/modules/member/modules_cards.php b/htdocs/core/modules/member/modules_cards.php index 8179aaed99c9b..20c82a20ad7c6 100644 --- a/htdocs/core/modules/member/modules_cards.php +++ b/htdocs/core/modules/member/modules_cards.php @@ -68,7 +68,7 @@ public static function liste_modeles($db, $maxfilenamelength = 0) * Cree un fichier de cartes de visites en fonction du modele de ADHERENT_CARDS_ADDON_PDF * * @param DoliDB $db Database handler - * @param array $arrayofmembers Array of members + * @param array $arrayofmembers Array of members * @param string $modele Force modele to use ('' to not force) * @param Translate $outputlangs Object langs to use for translation * @param string $outputdir Output directory diff --git a/htdocs/hrm/compare.php b/htdocs/hrm/compare.php index 68e90ea9853cf..71115bb12a679 100644 --- a/htdocs/hrm/compare.php +++ b/htdocs/hrm/compare.php @@ -297,7 +297,7 @@ * * Return a html list element with diff between required rank and user rank * - * @param array $TMergedSkills skill list with all rate to add good picto + * @param array $TMergedSkills skill list with all rate to add good picto * @return string */ function diff(&$TMergedSkills) @@ -331,7 +331,7 @@ function diff(&$TMergedSkills) /** * Return a html list with rank information - * @param array $TMergedSkills skill list for display + * @param array $TMergedSkills skill list for display * @param string $field which column of comparison we are working with * @return string */ @@ -371,7 +371,7 @@ function rate(&$TMergedSkills, $field) /** * return a html ul list of skills * - * @param array $TMergedSkills skill list for display + * @param array $TMergedSkills skill list for display * @return string (ul list in html ) */ function skillList(&$TMergedSkills) @@ -393,9 +393,9 @@ function skillList(&$TMergedSkills) /** * create an array of lines [ skillLabel,description, maxrank on group1 , minrank needed for this skill ] * - * @param array $TSkill1 skill list of first column - * @param array $TSkill2 skill list of second column - * @return array + * @param array $TSkill1 skill list of first column + * @param array $TSkill2 skill list of second column + * @return array */ function mergeSkills($TSkill1, $TSkill2) { @@ -428,7 +428,7 @@ function mergeSkills($TSkill1, $TSkill2) /** * Display a list of User with picto * - * @param array $TUser list of users (employees) in selected usergroup of a column + * @param int[] $TUser list of users (employees) in selected usergroup of a column * @param int $fk_usergroup selected usergroup id * @param string $namelist html name * @return string diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 845978f19f246..e146f8e728c6a 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -2407,7 +2407,7 @@ /** * Function to put the movable box of a source field * - * @param array $fieldssource List of source fields + * @param array,position:int}> $fieldssource List of source fields * @param int $pos Pos * @param string $key Key * @return void @@ -2490,9 +2490,9 @@ function show_elem($fieldssource, $pos, $key) /** * Return not used field number * - * @param array $fieldssource Array of field source - * @param array $listofkey Array of keys - * @return integer + * @param array $fieldssource Array of field source + * @param array $listofkey Array of keys + * @return int */ function getnewkey(&$fieldssource, &$listofkey) { @@ -2517,10 +2517,10 @@ function getnewkey(&$fieldssource, &$listofkey) /** * Return array with element inserted in it at position $position * - * @param array $array Array of field source - * @param mixed $position key of position to insert to - * @param array $insertArray Array to insert - * @return array + * @param array $array Array of field source + * @param int $position key of position to insert to + * @param array{label:string,example1:string,required:bool,bool,position:int} $insertArray Array to insert + * @return array */ function arrayInsert($array, $position, $insertArray) { diff --git a/htdocs/projet/ganttchart.inc.php b/htdocs/projet/ganttchart.inc.php index 204e383f98cb4..a887f6d24b571 100644 --- a/htdocs/projet/ganttchart.inc.php +++ b/htdocs/projet/ganttchart.inc.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * 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 @@ -128,15 +129,15 @@ function reloadGraph() { $projecttmp = new Project($db); $projecttmp->fetch($t['task_project_id']); $tmpt = array( - 'task_id'=> '-'.$t['task_project_id'], - 'task_alternate_id'=> '-'.$t['task_project_id'], - 'task_name'=>$projecttmp->ref.' '.$projecttmp->title, - 'task_resources'=>'', - 'task_start_date'=>'', - 'task_end_date'=>'', - 'task_is_group'=>1, 'task_position'=>0, 'task_css'=>'ggroupblack', 'task_milestone'=> 0, 'task_parent'=>0, 'task_parent_alternate_id'=>0, - 'task_notes'=>'', - 'task_planned_workload'=>0 + 'task_id' => '-'.$t['task_project_id'], + 'task_alternate_id' => '-'.$t['task_project_id'], + 'task_name' => $projecttmp->ref.' '.$projecttmp->title, + 'task_resources' => '', + 'task_start_date' => '', + 'task_end_date' => '', + 'task_is_group' => 1, 'task_position' => 0, 'task_css' => 'ggroupblack', 'task_milestone' => 0, 'task_parent' => 0, 'task_parent_alternate_id' => 0, + 'task_notes' => '', + 'task_planned_workload' => 0 ); constructGanttLine($tasks, $tmpt, array(), 0, $t['task_project_id']); $old_project_id = $t['task_project_id']; @@ -167,9 +168,9 @@ function reloadGraph() { /** * Add a gant chart line * - * @param array $tarr Array of all tasks - * @param array $task Array with properties of one task - * @param array $task_dependencies Task dependencies (array(array(0=>idtask,1=>idtasktofinishfisrt)) + * @param array,task_position:int,task_css:string,task_milestone:int,task_parent:int,task_parent_alternate_id:int}> $tarr Array of all tasks + * @param array{task_id:string,task_alternate_id:string,task_name:string,task_resources:string,task_start_date:string,task_end_date:string,task_is_group:int<0,1>,task_position:int,task_css:string,task_milestone:int,task_parent:int,task_parent_alternate_id:int} $task Array with properties of one task + * @param array $task_dependencies Task dependencies (array(array(0=>idtask,1=>idtasktofinishfisrt)) * @param int $level Level * @param int $project_id Id of project * @return void @@ -279,9 +280,9 @@ function constructGanttLine($tarr, $task, $task_dependencies, $level = 0, $proje /** * Find child Gantt line * - * @param array $tarr tarr - * @param int $parent Parent - * @param array $task_dependencies Task dependencies + * @param array,task_position:int,task_css:string,task_milestone:int,task_parent:int,task_parent_alternate_id:int}> $tarr tarr + * @param string $parent Parent + * @param array $task_dependencies Task dependencies * @param int $level Level * @return void */ diff --git a/htdocs/webservices/server_actioncomm.php b/htdocs/webservices/server_actioncomm.php index bd85865ceee75..e90bb4c758210 100644 --- a/htdocs/webservices/server_actioncomm.php +++ b/htdocs/webservices/server_actioncomm.php @@ -135,7 +135,6 @@ 'fk_element' => array('name' => 'fk_element', 'type' => 'xsd:string'), 'elementtype' => array('name' => 'elementtype', 'type' => 'xsd:string')); - $elementtype = 'actioncomm'; //Retrieve all extrafield for actioncomm @@ -434,8 +433,8 @@ function getListActionCommType($authentication) * Create ActionComm * * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information - * @param array $actioncomm $actioncomm - * @return array Array result + * @param array{id:string,ref:string,ref_ext:string,type_id:string,type_code:string,type:string,label:string,datep:int,datef:int,datec:int,datem:int,note:string,percentage:string,author:string,usermod:string,userownerid:string,priority:string,fulldayevent:string,location:string,socid:string,contactid:string,projectid:string,fk_element:string,elementtype:string} $actioncomm $actioncomm + * @return array{result:array{result_code:string,result_label:string}} Array result */ function createActionComm($authentication, $actioncomm) { @@ -462,18 +461,18 @@ function createActionComm($authentication, $actioncomm) $newobject->datep = $actioncomm['datep']; $newobject->datef = $actioncomm['datef']; $newobject->type_code = $actioncomm['type_code']; - $newobject->socid = $actioncomm['socid']; - $newobject->fk_project = $actioncomm['projectid']; + $newobject->socid = (int) $actioncomm['socid']; + $newobject->fk_project = (int) $actioncomm['projectid']; $newobject->note = $actioncomm['note']; $newobject->note_private = $actioncomm['note']; - $newobject->contact_id = $actioncomm['contactid']; - $newobject->userownerid = $actioncomm['userownerid']; + $newobject->contact_id = (int) $actioncomm['contactid']; + $newobject->userownerid = (int) $actioncomm['userownerid']; $newobject->label = $actioncomm['label']; - $newobject->percentage = $actioncomm['percentage']; - $newobject->priority = $actioncomm['priority']; - $newobject->fulldayevent = $actioncomm['fulldayevent']; + $newobject->percentage = (int) $actioncomm['percentage']; + $newobject->priority = (int) $actioncomm['priority']; + $newobject->fulldayevent = (int) $actioncomm['fulldayevent']; $newobject->location = $actioncomm['location']; - $newobject->fk_element = $actioncomm['fk_element']; + $newobject->fk_element = (int) $actioncomm['fk_element']; $newobject->elementtype = $actioncomm['elementtype']; $elementtype = 'actioncomm'; @@ -518,8 +517,8 @@ function createActionComm($authentication, $actioncomm) * Create ActionComm * * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information - * @param array $actioncomm $actioncomm - * @return array Array result + * @param array{id:string,ref:string,ref_ext:string,type_id:string,type_code:string,type:string,label:string,datep:int,datef:int,datec:int,datem:int,note:string,percentage:string,author:string,usermod:string,userownerid:string,priority:string,fulldayevent:string,location:string,socid:string,contactid:string,projectid:string,fk_element:string,elementtype:string} $actioncomm $actioncomm + * @return array{result:array{result_code:string,result_label:string}} Array result */ function updateActionComm($authentication, $actioncomm) { @@ -558,17 +557,17 @@ function updateActionComm($authentication, $actioncomm) $object->datep = $actioncomm['datep']; $object->datef = $actioncomm['datef']; $object->type_code = $actioncomm['type_code']; - $object->socid = $actioncomm['socid']; - $object->contact_id = $actioncomm['contactid']; - $object->fk_project = $actioncomm['projectid']; + $object->socid = (int) $actioncomm['socid']; + $object->contact_id = (int) $actioncomm['contactid']; + $object->fk_project = (int) $actioncomm['projectid']; $object->note = $actioncomm['note']; - $object->userownerid = $actioncomm['userownerid']; + $object->userownerid = (int) $actioncomm['userownerid']; $object->label = $actioncomm['label']; - $object->percentage = $actioncomm['percentage']; - $object->priority = $actioncomm['priority']; - $object->fulldayevent = $actioncomm['fulldayevent']; + $object->percentage = (int) $actioncomm['percentage']; + $object->priority = (int) $actioncomm['priority']; + $object->fulldayevent = (int) $actioncomm['fulldayevent']; $object->location = $actioncomm['location']; - $object->fk_element = $actioncomm['fk_element']; + $object->fk_element = (int) $actioncomm['fk_element']; $object->elementtype = $actioncomm['elementtype']; $elementtype = 'actioncomm'; diff --git a/htdocs/webservices/server_contact.php b/htdocs/webservices/server_contact.php index 294d10f41303f..2dea9d176cfe5 100644 --- a/htdocs/webservices/server_contact.php +++ b/htdocs/webservices/server_contact.php @@ -267,7 +267,7 @@ * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information * @param int $id Id of object * @param string $ref_ext Ref external of object - * @return mixed + * @return array{result:array{result_code:string,result_label:string}} Array result */ function getContact($authentication, $id, $ref_ext) { @@ -382,8 +382,8 @@ function getContact($authentication, $id, $ref_ext) * Create Contact * * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information - * @param array $contact $contact - * @return array Array result + * @param array{id:string,ref_ext:string,lastname:string,firstname:string,address:string,zip:string,town:string,state_id:string,state_code:string,state:string,country_id:string,country_code:string,country:string,socid:string,status:string,phone_pro:string,fax:string,phone_perso:string,phone_mobile:string,code:string,email:string,birthday:string,default_lang:string,note:string,ref_facturation:string,ref_contrat:string,ref_commande:string,ref_propal:string,user_id:string,user_login:string,civility_id:string,poste:string} $contact $contact + * @return array{result:array{result_code:string,result_label:string}} Array result */ function createContact($authentication, $contact) { @@ -413,7 +413,7 @@ function createContact($authentication, $contact) if (!$error) { $newobject = new Contact($db); - $newobject->id = $contact['id']; + $newobject->id = (int) $contact['id']; $newobject->ref_ext = $contact['ref_ext']; $newobject->civility_id = $contact['civility_id']; $newobject->lastname = $contact['lastname']; @@ -421,14 +421,14 @@ function createContact($authentication, $contact) $newobject->address = $contact['address']; $newobject->zip = $contact['zip']; $newobject->town = $contact['town']; - $newobject->state_id = $contact['state_id']; + $newobject->state_id = (int) $contact['state_id']; $newobject->state_code = $contact['state_code']; $newobject->state = $contact['state']; - $newobject->country_id = $contact['country_id']; + $newobject->country_id = (int) $contact['country_id']; $newobject->country_code = $contact['country_code']; $newobject->country = $contact['country']; - $newobject->socid = $contact['socid']; - $newobject->statut = $contact['status']; + $newobject->socid = (int) $contact['socid']; + $newobject->statut = (int) $contact['status']; $newobject->phone_pro = $contact['phone_pro']; $newobject->fax = $contact['fax']; $newobject->phone_perso = $contact['phone_perso']; @@ -438,11 +438,11 @@ function createContact($authentication, $contact) $newobject->birthday = $contact['birthday']; $newobject->default_lang = $contact['default_lang']; $newobject->note = $contact['note']; - $newobject->ref_facturation = $contact['ref_facturation']; - $newobject->ref_contrat = $contact['ref_contrat']; - $newobject->ref_commande = $contact['ref_commande']; - $newobject->ref_propal = $contact['ref_propal']; - $newobject->user_id = $contact['user_id']; + $newobject->ref_facturation = (int) $contact['ref_facturation']; + $newobject->ref_contrat = (int) $contact['ref_contrat']; + $newobject->ref_commande = (int) $contact['ref_commande']; + $newobject->ref_propal = (int) $contact['ref_propal']; + $newobject->user_id = (int) $contact['user_id']; $newobject->user_login = $contact['user_login']; $newobject->poste = $contact['poste']; @@ -492,7 +492,7 @@ function createContact($authentication, $contact) * * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information * @param int $idthirdparty Id thirdparty - * @return array Array result + * @return array{result:array{result_code:string,result_label:string}} Array result */ function getContactsForThirdParty($authentication, $idthirdparty) { @@ -620,8 +620,8 @@ function getContactsForThirdParty($authentication, $idthirdparty) * Update a contact * * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information - * @param array $contact Contact - * @return array Array result + * @param array{id:string,ref_ext:string,lastname:string,firstname:string,address:string,zip:string,town:string,state_id:string,state_code:string,state:string,country_id:string,country_code:string,country:string,socid:string,status:string,phone_pro:string,fax:string,phone_perso:string,phone_mobile:string,code:string,email:string,birthday:string,default_lang:string,note:string,ref_facturation:string,ref_contrat:string,ref_commande:string,ref_propal:string,user_id:string,user_login:string,civility_id:string,poste:string} $contact Contact + * @return array{result:array{result_code:string,result_label:string}} Array result */ function updateContact($authentication, $contact) { @@ -674,11 +674,11 @@ function updateContact($authentication, $contact) $object->zip = $contact['zip']; $object->town = $contact['town']; - $object->country_id = $contact['country_id']; + $object->country_id = (int) $contact['country_id']; if ($contact['country_code']) { $object->country_id = getCountry($contact['country_code'], '3'); } - $object->province_id = $contact['province_id']; + $object->province_id = isset($contact['province_id']) ? $contact['province_id'] : null; $object->phone_pro = $contact['phone_pro']; @@ -690,7 +690,7 @@ function updateContact($authentication, $contact) $object->civility_id = $contact['civility_id']; $object->poste = $contact['poste']; - $object->statut = $contact['status']; + $object->statut = (int) $contact['status']; $elementtype = 'socpeople'; diff --git a/htdocs/webservices/server_invoice.php b/htdocs/webservices/server_invoice.php index ba07779693b6b..833d6b88e94e8 100644 --- a/htdocs/webservices/server_invoice.php +++ b/htdocs/webservices/server_invoice.php @@ -162,7 +162,7 @@ 'maxOccurs' => 'unbounded' ) ), - null, + array(), 'tns:line' ); @@ -226,7 +226,7 @@ 'maxOccurs' => 'unbounded' ) ), - null, + array(), 'tns:invoice' ); @@ -309,7 +309,7 @@ * @param int $id Id * @param string $ref Ref * @param string $ref_ext Ref_ext - * @return array Array result + * @return array{result:array{result_code:string,result_label:string}} Array result */ function getInvoice($authentication, $id = 0, $ref = '', $ref_ext = '') { @@ -418,7 +418,7 @@ function getInvoice($authentication, $id = 0, $ref = '', $ref_ext = '') * * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information * @param int $idthirdparty Id thirdparty - * @return array Array result + * @return array{result:array{result_code:string,result_label:string}} Array result */ function getInvoicesForThirdParty($authentication, $idthirdparty) { @@ -435,6 +435,7 @@ function getInvoicesForThirdParty($authentication, $idthirdparty) $errorcode = ''; $errorlabel = ''; $error = 0; + $socid = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); if ($fuser->socid) { @@ -552,8 +553,8 @@ function getInvoicesForThirdParty($authentication, $idthirdparty) * Create an invoice * * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information - * @param array $invoice Invoice - * @return array Array result + * @param array{id:string,ref:string,ref_ext:string,thirdparty_id:int,fk_user_author:string,fk_user_valid:string,date:string,date_due:string,date_creation:string,date_validation:string,date_modification:string,payment_mode_id:string,type:int,total_net:float,total_vat:float,total:float,note_private:string,note_public:string,status:int,close_code:string,close_note:string,project_id:string,lines?:array{id:string,type:int,desc:string,vat_rate:float,qty:float,unitprice:float,total_net:float,total_vat:float,total:float,date_start:string,date_end:string,product_id:int,product_ref:string,product_label:string,product_desc:string}} $invoice Invoice + * @return array{result:array{result_code:string,result_label:string}} Array result */ function createInvoice($authentication, $invoice) { @@ -562,7 +563,6 @@ function createInvoice($authentication, $invoice) $now = dol_now(); dol_syslog("Function: createInvoice login=".$authentication['login']." id=".$invoice['id'].", ref=".$invoice['ref'].", ref_ext=".$invoice['ref_ext']); - if ($authentication['entity']) { $conf->entity = $authentication['entity']; } @@ -590,7 +590,7 @@ function createInvoice($authentication, $invoice) $new_invoice->note_private = $invoice['note_private']; $new_invoice->note_public = $invoice['note_public']; $new_invoice->statut = Facture::STATUS_DRAFT; // We start with status draft - $new_invoice->fk_project = $invoice['project_id']; + $new_invoice->fk_project = (int) $invoice['project_id']; $new_invoice->date_creation = $now; //take mode_reglement and cond_reglement from thirdparty @@ -600,16 +600,19 @@ function createInvoice($authentication, $invoice) $new_invoice->mode_reglement_id = !empty($invoice['payment_mode_id']) ? $invoice['payment_mode_id'] : $soc->mode_reglement_id; $new_invoice->cond_reglement_id = $soc->cond_reglement_id; } else { - $new_invoice->mode_reglement_id = $invoice['payment_mode_id']; + $new_invoice->mode_reglement_id = (int) $invoice['payment_mode_id']; } // Trick because nusoap does not store data with same structure if there is one or several lines $arrayoflines = array(); if (isset($invoice['lines']['line'][0])) { - $arrayoflines = $invoice['lines']['line']; + $arrayoflines = $invoice['lines']['line']; // @phan-suppress-current-line PhanTypeInvalidDimOffset } else { $arrayoflines = $invoice['lines']; } + if (!is_array($arrayoflines)) { + $arrayoflines = array(); + } foreach ($arrayoflines as $line) { // $key can be 'line' or '0','1',... @@ -689,6 +692,8 @@ function createInvoiceFromOrder($authentication, $id_order = '', $ref_order = '' $errorcode = ''; $errorlabel = ''; $error = 0; + $newobject = null; + $socid = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); if ($fuser->socid) { $socid = $fuser->socid; @@ -737,7 +742,7 @@ function createInvoiceFromOrder($authentication, $id_order = '', $ref_order = '' } } - if ($error) { + if ($error || $newobject === null) { $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel)); } else { $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'id' => $newobject->id, 'ref' => $newobject->ref, 'ref_ext' => $newobject->ref_ext); @@ -782,7 +787,7 @@ function updateInvoice($authentication, $invoice) $objectfound = false; $object = new Facture($db); - $result = $object->fetch($invoice['id'], $invoice['ref'], $invoice['ref_ext'], ''); + $result = $object->fetch($invoice['id'], $invoice['ref'], $invoice['ref_ext'], 0); if (!empty($object->id)) { $objectfound = true; diff --git a/htdocs/webservices/server_order.php b/htdocs/webservices/server_order.php index a599cb5b2a7f4..26ef230e0c5d2 100644 --- a/htdocs/webservices/server_order.php +++ b/htdocs/webservices/server_order.php @@ -377,7 +377,7 @@ * @param int $id Id * @param string $ref Ref * @param string $ref_ext Ref_ext - * @return array Array result + * @return array{result:array{result_code:string,result_label:string}} Array result */ function getOrder($authentication, $id = 0, $ref = '', $ref_ext = '') { @@ -520,7 +520,7 @@ function getOrder($authentication, $id = 0, $ref = '', $ref_ext = '') * * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information * @param int $idthirdparty Id of thirdparty - * @return array Array result + * @return array{result:array{result_code:string,result_label:string}} Array result */ function getOrdersForThirdParty($authentication, $idthirdparty) { @@ -541,6 +541,8 @@ function getOrdersForThirdParty($authentication, $idthirdparty) if ($fuser->socid) { $socid = $fuser->socid; + } else { + $socid = 0; } // Check parameters @@ -672,8 +674,8 @@ function getOrdersForThirdParty($authentication, $idthirdparty) * Create order * * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information - * @param array $order Order info - * @return array array of new order + * @param array{id:string,ref:string,ref_client:string,ref_ext:string,thirdparty_id:int,status:int,billed:string,total_net:float,total_vat:float,total_localtax1:float,total_localtax2:float,total:float,date:string,date_creation:string,date_validation:string,date_modification:string,source:string,note_private:string,note_public:string,project_id:string,mode_reglement_id:string,mode_reglement_code:string,mode_reglement:string,cond_reglement_id:string,cond_reglement_code:string,cond_reglement:string,cond_reglement_doc:string,date_livraison:int,demand_reason_id:string,lines:array{lines:array}} $order Order info + * @return array{result:array{result_code:string,result_label:string}} Array result */ function createOrder($authentication, $order) { @@ -695,6 +697,7 @@ function createOrder($authentication, $order) $errorlabel = ''; $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); + $newobject = null; // Check parameters @@ -709,10 +712,10 @@ function createOrder($authentication, $order) $newobject->note_private = $order['note_private']; $newobject->note_public = $order['note_public']; $newobject->statut = Commande::STATUS_DRAFT; // We start with status draft - $newobject->billed = $order['billed']; - $newobject->fk_project = $order['project_id']; - $newobject->cond_reglement_id = $order['cond_reglement_id']; - $newobject->demand_reason_id = $order['demand_reason_id']; + $newobject->billed = (int) $order['billed']; + $newobject->fk_project = (int) $order['project_id']; + $newobject->cond_reglement_id = (int) $order['cond_reglement_id']; + $newobject->demand_reason_id = (int) $order['demand_reason_id']; $newobject->date_creation = $now; $elementtype = 'commande'; @@ -731,10 +734,13 @@ function createOrder($authentication, $order) // Trick because nusoap does not store data with same structure if there is one or several lines $arrayoflines = array(); if (isset($order['lines']['line'][0])) { - $arrayoflines = $order['lines']['line']; + $arrayoflines = $order['lines']['line']; // @phan-suppress-current-line PhanTypeInvalidDimOffset } else { $arrayoflines = $order['lines']; } + if (!is_array($arrayoflines)) { + $arrayoflines = array(); + } foreach ($arrayoflines as $key => $line) { // $key can be 'line' or '0','1',... @@ -815,7 +821,7 @@ function createOrder($authentication, $order) * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information * @param int $id Id of order to validate * @param int $id_warehouse Id of warehouse to use for stock decrease - * @return array Array result + * @return array{result:array{result_code:string,result_label:string}} Array result */ function validOrder($authentication, $id = 0, $id_warehouse = 0) { @@ -884,7 +890,7 @@ function validOrder($authentication, $id = 0, $id_warehouse = 0) * * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information * @param array{id:string,ref:string,refext:string} $order Order info - * @return array Array result + * @return array{result:array{result_code:string,result_label:string}} Array result */ function updateOrder($authentication, $order) { diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index 8ce21e5ccda73..f8f23fb3518d5 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -2,6 +2,7 @@ /* Copyright (C) 2006-2016 Laurent Destailleur * Copyright (C) 2012 JF FERRY * Copyright (C) 2020-2024 Frédéric France + * 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 @@ -91,11 +92,11 @@ 'all', '', array( - 'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'), - 'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'), - 'login' => array('name'=>'login', 'type'=>'xsd:string'), - 'password' => array('name'=>'password', 'type'=>'xsd:string'), - 'entity' => array('name'=>'entity', 'type'=>'xsd:string') + 'dolibarrkey' => array('name' => 'dolibarrkey', 'type' => 'xsd:string'), + 'sourceapplication' => array('name' => 'sourceapplication', 'type' => 'xsd:string'), + 'login' => array('name' => 'login', 'type' => 'xsd:string'), + 'password' => array('name' => 'password', 'type' => 'xsd:string'), + 'entity' => array('name' => 'entity', 'type' => 'xsd:string') ) ); // Define WSDL Return object @@ -106,51 +107,51 @@ 'all', '', array( - 'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'), - 'result_label' => array('name'=>'result_label', 'type'=>'xsd:string') + 'result_code' => array('name' => 'result_code', 'type' => 'xsd:string'), + 'result_label' => array('name' => 'result_label', 'type' => 'xsd:string') ) ); $productorservice_fields = array( - 'id' => array('name'=>'id', 'type'=>'xsd:string'), - 'ref' => array('name'=>'ref', 'type'=>'xsd:string'), - 'ref_ext' => array('name'=>'ref_ext', 'type'=>'xsd:string'), - 'type' => array('name'=>'type', 'type'=>'xsd:string'), - 'label' => array('name'=>'label', 'type'=>'xsd:string'), - 'description' => array('name'=>'description', 'type'=>'xsd:string'), - 'date_creation' => array('name'=>'date_creation', 'type'=>'xsd:dateTime'), - 'date_modification' => array('name'=>'date_modification', 'type'=>'xsd:dateTime'), - 'note' => array('name'=>'note', 'type'=>'xsd:string'), - 'status_tobuy' => array('name'=>'status_tobuy', 'type'=>'xsd:string'), - 'status_tosell' => array('name'=>'status_tosell', 'type'=>'xsd:string'), - 'barcode' => array('name'=>'barcode', 'type'=>'xsd:string'), - 'barcode_type' => array('name'=>'barcode_type', 'type'=>'xsd:string'), - 'country_id' => array('name'=>'country_id', 'type'=>'xsd:string'), - 'country_code' => array('name'=>'country_code', 'type'=>'xsd:string'), - 'customcode' => array('name'=>'customcode', 'type'=>'xsd:string'), - - 'price_net' => array('name'=>'price_net', 'type'=>'xsd:string'), - 'price' => array('name'=>'price', 'type'=>'xsd:string'), - 'price_min_net' => array('name'=>'price_min_net', 'type'=>'xsd:string'), - 'price_min' => array('name'=>'price_min', 'type'=>'xsd:string'), - - 'price_base_type' => array('name'=>'price_base_type', 'type'=>'xsd:string'), - - 'vat_rate' => array('name'=>'vat_rate', 'type'=>'xsd:string'), - 'vat_npr' => array('name'=>'vat_npr', 'type'=>'xsd:string'), - 'localtax1_tx' => array('name'=>'localtax1_tx', 'type'=>'xsd:string'), - 'localtax2_tx' => array('name'=>'localtax2_tx', 'type'=>'xsd:string'), - - 'stock_alert' => array('name'=>'stock_alert', 'type'=>'xsd:string'), - 'stock_real' => array('name'=>'stock_real', 'type'=>'xsd:string'), - 'stock_pmp' => array('name'=>'stock_pmp', 'type'=>'xsd:string'), - 'warehouse_ref' => array('name'=>'warehouse_ref', 'type'=>'xsd:string'), // Used only for create or update to set which warehouse to use for stock correction if stock_real differs from database - - 'canvas' => array('name'=>'canvas', 'type'=>'xsd:string'), - 'import_key' => array('name'=>'import_key', 'type'=>'xsd:string'), - - 'dir' => array('name'=>'dir', 'type'=>'xsd:string'), - 'images' => array('name'=>'images', 'type'=>'tns:ImagesArray') + 'id' => array('name' => 'id', 'type' => 'xsd:string'), + 'ref' => array('name' => 'ref', 'type' => 'xsd:string'), + 'ref_ext' => array('name' => 'ref_ext', 'type' => 'xsd:string'), + 'type' => array('name' => 'type', 'type' => 'xsd:string'), + 'label' => array('name' => 'label', 'type' => 'xsd:string'), + 'description' => array('name' => 'description', 'type' => 'xsd:string'), + 'date_creation' => array('name' => 'date_creation', 'type' => 'xsd:dateTime'), + 'date_modification' => array('name' => 'date_modification', 'type' => 'xsd:dateTime'), + 'note' => array('name' => 'note', 'type' => 'xsd:string'), + 'status_tobuy' => array('name' => 'status_tobuy', 'type' => 'xsd:string'), + 'status_tosell' => array('name' => 'status_tosell', 'type' => 'xsd:string'), + 'barcode' => array('name' => 'barcode', 'type' => 'xsd:string'), + 'barcode_type' => array('name' => 'barcode_type', 'type' => 'xsd:string'), + 'country_id' => array('name' => 'country_id', 'type' => 'xsd:string'), + 'country_code' => array('name' => 'country_code', 'type' => 'xsd:string'), + 'customcode' => array('name' => 'customcode', 'type' => 'xsd:string'), + + 'price_net' => array('name' => 'price_net', 'type' => 'xsd:string'), + 'price' => array('name' => 'price', 'type' => 'xsd:string'), + 'price_min_net' => array('name' => 'price_min_net', 'type' => 'xsd:string'), + 'price_min' => array('name' => 'price_min', 'type' => 'xsd:string'), + + 'price_base_type' => array('name' => 'price_base_type', 'type' => 'xsd:string'), + + 'vat_rate' => array('name' => 'vat_rate', 'type' => 'xsd:string'), + 'vat_npr' => array('name' => 'vat_npr', 'type' => 'xsd:string'), + 'localtax1_tx' => array('name' => 'localtax1_tx', 'type' => 'xsd:string'), + 'localtax2_tx' => array('name' => 'localtax2_tx', 'type' => 'xsd:string'), + + 'stock_alert' => array('name' => 'stock_alert', 'type' => 'xsd:string'), + 'stock_real' => array('name' => 'stock_real', 'type' => 'xsd:string'), + 'stock_pmp' => array('name' => 'stock_pmp', 'type' => 'xsd:string'), + 'warehouse_ref' => array('name' => 'warehouse_ref', 'type' => 'xsd:string'), // Used only for create or update to set which warehouse to use for stock correction if stock_real differs from database + + 'canvas' => array('name' => 'canvas', 'type' => 'xsd:string'), + 'import_key' => array('name' => 'import_key', 'type' => 'xsd:string'), + + 'dir' => array('name' => 'dir', 'type' => 'xsd:string'), + 'images' => array('name' => 'images', 'type' => 'tns:ImagesArray') ); @@ -174,7 +175,7 @@ $type = 'xsd:string'; } - $extrafield_array['options_'.$key] = array('name'=>'options_'.$key, 'type'=>$type); + $extrafield_array['options_'.$key] = array('name' => 'options_'.$key, 'type' => $type); } } @@ -222,10 +223,10 @@ 'all', '', array( - 'photo' => array('name'=>'photo', 'type'=>'xsd:string'), - 'photo_vignette' => array('name'=>'photo_vignette', 'type'=>'xsd:string'), - 'imgWidth' => array('name'=>'imgWidth', 'type'=>'xsd:string'), - 'imgHeight' => array('name'=>'imgHeight', 'type'=>'xsd:string') + 'photo' => array('name' => 'photo', 'type' => 'xsd:string'), + 'photo_vignette' => array('name' => 'photo_vignette', 'type' => 'xsd:string'), + 'imgWidth' => array('name' => 'imgWidth', 'type' => 'xsd:string'), + 'imgHeight' => array('name' => 'imgHeight', 'type' => 'xsd:string') ) ); @@ -239,9 +240,9 @@ '', array( //'limit' => array('name'=>'limit','type'=>'xsd:string'), - 'type' => array('name'=>'type', 'type'=>'xsd:string'), - 'status_tobuy' => array('name'=>'status_tobuy', 'type'=>'xsd:string'), - 'status_tosell' => array('name'=>'status_tosell', 'type'=>'xsd:string'), + 'type' => array('name' => 'type', 'type' => 'xsd:string'), + 'status_tobuy' => array('name' => 'status_tobuy', 'type' => 'xsd:string'), + 'status_tosell' => array('name' => 'status_tosell', 'type' => 'xsd:string'), ) ); @@ -274,9 +275,9 @@ $server->register( 'getProductOrService', // Entry values - array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'ref'=>'xsd:string', 'ref_ext'=>'xsd:string', 'lang'=>'xsd:string'), + array('authentication' => 'tns:authentication', 'id' => 'xsd:string', 'ref' => 'xsd:string', 'ref_ext' => 'xsd:string', 'lang' => 'xsd:string'), // Exit values - array('result'=>'tns:result', 'product'=>'tns:product'), + array('result' => 'tns:result', 'product' => 'tns:product'), $ns, $ns.'#getProductOrService', $styledoc, @@ -288,9 +289,9 @@ $server->register( 'createProductOrService', // Entry values - array('authentication'=>'tns:authentication', 'product'=>'tns:product'), + array('authentication' => 'tns:authentication', 'product' => 'tns:product'), // Exit values - array('result'=>'tns:result', 'id'=>'xsd:string'), + array('result' => 'tns:result', 'id' => 'xsd:string'), $ns, $ns.'#createProductOrService', $styledoc, @@ -302,9 +303,9 @@ $server->register( 'updateProductOrService', // Entry values - array('authentication'=>'tns:authentication', 'product'=>'tns:product'), + array('authentication' => 'tns:authentication', 'product' => 'tns:product'), // Exit values - array('result'=>'tns:result', 'id'=>'xsd:string'), + array('result' => 'tns:result', 'id' => 'xsd:string'), $ns, $ns.'#updateProductOrService', $styledoc, @@ -316,9 +317,9 @@ $server->register( 'deleteProductOrService', // Entry values - array('authentication'=>'tns:authentication', 'listofid'=>'xsd:string'), + array('authentication' => 'tns:authentication', 'listofid' => 'xsd:string'), // Exit values - array('result'=>'tns:result', 'nbdeleted'=>'xsd:int'), + array('result' => 'tns:result', 'nbdeleted' => 'xsd:int'), $ns, $ns.'#deleteProductOrService', $styledoc, @@ -330,9 +331,9 @@ $server->register( 'getListOfProductsOrServices', // Entry values - array('authentication'=>'tns:authentication', 'filterproduct'=>'tns:filterproduct'), + array('authentication' => 'tns:authentication', 'filterproduct' => 'tns:filterproduct'), // Exit values - array('result'=>'tns:result', 'products'=>'tns:ProductsArray2'), + array('result' => 'tns:result', 'products' => 'tns:ProductsArray2'), $ns, $ns.'#getListOfProductsOrServices', $styledoc, @@ -344,9 +345,9 @@ $server->register( 'getProductsForCategory', // Entry values - array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'lang'=>'xsd:string'), + array('authentication' => 'tns:authentication', 'id' => 'xsd:string', 'lang' => 'xsd:string'), // Exit values - array('result'=>'tns:result', 'products'=>'tns:ProductsArray2'), + array('result' => 'tns:result', 'products' => 'tns:ProductsArray2'), $ns, $ns.'#getProductsForCategory', $styledoc, @@ -363,7 +364,7 @@ * @param string $ref Ref of object * @param string $ref_ext Ref external of object * @param string $lang Lang to force - * @return mixed + * @return array{product?:mixed[],result:array{result_code:string,result_label:string}} Array result */ function getProductOrService($authentication, $id = 0, $ref = '', $ref_ext = '', $lang = '') { @@ -475,8 +476,8 @@ function getProductOrService($authentication, $id = 0, $ref = '', $ref_ext = '', // Create $objectresp = array( - 'result'=>array('result_code'=>'OK', 'result_label'=>''), - 'product'=>$productorservice_result_fields + 'result' => array('result_code' => 'OK', 'result_label' => ''), + 'product' => $productorservice_result_fields ); } else { $error++; @@ -491,7 +492,7 @@ function getProductOrService($authentication, $id = 0, $ref = '', $ref_ext = '', } if ($error) { - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); + $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel)); } //var_dump($objectresp);exit; return $objectresp; @@ -502,8 +503,8 @@ function getProductOrService($authentication, $id = 0, $ref = '', $ref_ext = '', * Create an invoice * * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information - * @param array $product Product - * @return array Array result + * @param array{id:string,ref:string,ref_ext:string,type:string,label:string,description:string,date_creation:string,date_modification:string,note:string,status_tobuy:string,status_tosell:string,barcode:string,barcode_type:string,country_id:string,country_code:string,customcode:string,price_net:string,price:string,price_min_net:string,price_min:string,price_base_type:string,vat_rate:string,vat_npr:string,localtax1_tx:string,localtax2_tx:string,stock_alert:string,stock_real:string,stock_pmp:string,warehouse_ref:string,canvas:string,import_key:string,dir:string,images:array} $product Product + * @return array{result:array{result_code:string,result_label:string}} Array result */ function createProductOrService($authentication, $product) { @@ -558,22 +559,22 @@ function createProductOrService($authentication, $product) $newobject->note_private = empty($product['note_private']) ? '' : $product['note_private']; $newobject->status = empty($product['status_tosell']) ? 0 : $product['status_tosell']; $newobject->status_buy = empty($product['status_tobuy']) ? 0 : $product['status_tobuy']; - $newobject->price = isset($product['price_net']) ? $product['price_net'] : 0; - $newobject->price_ttc = isset($product['price']) ? $product['price'] : 0; + $newobject->price = isset($product['price_net']) ? (float) $product['price_net'] : 0; + $newobject->price_ttc = isset($product['price']) ? (float) $product['price'] : 0; $newobject->tva_tx = empty($product['vat_rate']) ? 0 : $product['vat_rate']; $newobject->price_base_type = $product['price_base_type']; $newobject->date_creation = $now; if (!empty($product['barcode'])) { $newobject->barcode = $product['barcode']; - $newobject->barcode_type = $product['barcode_type']; + $newobject->barcode_type = (int) $product['barcode_type']; } - $newobject->stock_reel = isset($product['stock_real']) ? $product['stock_real'] : null; - $newobject->pmp = isset($product['pmp']) ? $product['pmp'] : null; - $newobject->seuil_stock_alerte = isset($product['stock_alert']) ? $product['stock_alert'] : null; + $newobject->stock_reel = isset($product['stock_real']) ? (int) $product['stock_real'] : null; + $newobject->pmp = isset($product['pmp']) ? (float) $product['pmp'] : 0; + $newobject->seuil_stock_alerte = isset($product['stock_alert']) ? (float) $product['stock_alert'] : null; - $newobject->country_id = isset($product['country_id']) ? $product['country_id'] : 0; + $newobject->country_id = isset($product['country_id']) ? (int) $product['country_id'] : 0; if (!empty($product['country_code'])) { $newobject->country_id = getCountry($product['country_code'], '3'); } @@ -647,7 +648,7 @@ function createProductOrService($authentication, $product) if (!$error) { $db->commit(); - $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref); + $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'id' => $newobject->id, 'ref' => $newobject->ref); } else { $db->rollback(); $error++; @@ -657,7 +658,7 @@ function createProductOrService($authentication, $product) } if ($error) { - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); + $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel)); } return $objectresp; @@ -668,8 +669,8 @@ function createProductOrService($authentication, $product) * Update a product or service * * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information - * @param array $product Product - * @return array Array result + * @param array{id:string,ref:string,ref_ext:string,type:string,label:string,description:string,date_creation:string,date_modification:string,note:string,status_tobuy:string,status_tosell:string,barcode:string,barcode_type:string,country_id:string,country_code:string,customcode:string,price_net:string,price:string,price_min_net:string,price_min:string,price_base_type:string,vat_rate:string,vat_npr:string,localtax1_tx:string,localtax2_tx:string,stock_alert:string,stock_real:string,stock_pmp:string,warehouse_ref:string,canvas:string,import_key:string,dir:string,images:array} $product Product + * @return array{result:array{result_code:string,result_label:string}} Array result */ function updateProductOrService($authentication, $product) { @@ -722,28 +723,28 @@ function updateProductOrService($authentication, $product) if (isset($product['ref_ext'])) { $newobject->ref_ext = $product['ref_ext']; } - $newobject->type = $product['type']; + $newobject->type = (int) $product['type']; $newobject->label = $product['label']; $newobject->description = $product['description']; $newobject->note = $product['note']; - $newobject->status = $product['status_tosell']; - $newobject->status_buy = $product['status_tobuy']; - $newobject->price = $product['price_net']; - $newobject->price_ttc = $product['price']; + $newobject->status = (int) $product['status_tosell']; + $newobject->status_buy = (int) $product['status_tobuy']; + $newobject->price = (float) $product['price_net']; + $newobject->price_ttc = (float) $product['price']; $newobject->tva_tx = $product['vat_rate']; $newobject->price_base_type = $product['price_base_type']; $newobject->date_creation = $now; if ($product['barcode']) { $newobject->barcode = $product['barcode']; - $newobject->barcode_type = $product['barcode_type']; + $newobject->barcode_type = (int) $product['barcode_type']; } - $newobject->stock_reel = isset($product['stock_real']) ? $product['stock_real'] : null; - $newobject->pmp = isset($product['pmp']) ? $product['pmp'] : null; - $newobject->seuil_stock_alerte = isset($product['stock_alert']) ? $product['stock_alert'] : null; + $newobject->stock_reel = isset($product['stock_real']) ? (int) $product['stock_real'] : null; + $newobject->pmp = isset($product['pmp']) ? (float) $product['pmp'] : 0; + $newobject->seuil_stock_alerte = isset($product['stock_alert']) ? (float) $product['stock_alert'] : null; - $newobject->country_id = isset($product['country_id']) ? $product['country_id'] : 0; + $newobject->country_id = isset($product['country_id']) ? (int) $product['country_id'] : 0; if (!empty($product['country_code'])) { $newobject->country_id = getCountry($product['country_code'], '3'); } @@ -814,7 +815,7 @@ function updateProductOrService($authentication, $product) if (!$error) { $db->commit(); - $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref); + $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'id' => $newobject->id, 'ref' => $newobject->ref); } else { $db->rollback(); $error++; @@ -824,7 +825,7 @@ function updateProductOrService($authentication, $product) } if ($error) { - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); + $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel)); } return $objectresp; @@ -836,7 +837,7 @@ function updateProductOrService($authentication, $product) * * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information * @param string $listofidstring List of id with comma - * @return array Array result + * @return array{result:array{result_code:string,result_label:string}} Array result */ function deleteProductOrService($authentication, $listofidstring) { @@ -897,7 +898,7 @@ function deleteProductOrService($authentication, $listofidstring) if (!$error) { $db->commit(); //$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'listofid'=>$listofiddeleted); - $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'nbdeleted'=>count($listofiddeleted)); + $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'nbdeleted' => count($listofiddeleted)); } else { $db->rollback(); $error++; @@ -908,10 +909,10 @@ function deleteProductOrService($authentication, $listofidstring) if ($error) { //$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), 'listofid'=>$listofiddeleted); - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), 'nbdeleted'=>0); + $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel), 'nbdeleted' => 0); } elseif (count($listofiddeleted) == 0) { //$objectresp=array('result'=>array('result_code'=>'NOT_FOUND', 'result_label'=>'No product or service with id '.join(',',$listofid).' found'), 'listofid'=>$listofiddeleted); - $objectresp = array('result'=>array('result_code'=>'NOT_FOUND', 'result_label'=>'No product or service with id '.implode(',', $listofid).' found'), 'nbdeleted'=>0); + $objectresp = array('result' => array('result_code' => 'NOT_FOUND', 'result_label' => 'No product or service with id '.implode(',', $listofid).' found'), 'nbdeleted' => 0); } return $objectresp; @@ -922,8 +923,8 @@ function deleteProductOrService($authentication, $listofidstring) * getListOfProductsOrServices * * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information - * @param array $filterproduct Filter fields - * @return array Array result + * @param array $filterproduct Filter fields + * @return array{result:array{result_code:string,result_label:string}} Array result */ function getListOfProductsOrServices($authentication, $filterproduct) { @@ -966,7 +967,7 @@ function getListOfProductsOrServices($authentication, $filterproduct) $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); - $arrayproducts[] = array('id'=>$obj->rowid, 'ref'=>$obj->ref, 'ref_ext'=>$obj->ref_ext); + $arrayproducts[] = array('id' => $obj->rowid, 'ref' => $obj->ref, 'ref_ext' => $obj->ref_ext); $i++; } } else { @@ -978,13 +979,13 @@ function getListOfProductsOrServices($authentication, $filterproduct) if ($error) { $objectresp = array( - 'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), - 'products'=>$arrayproducts + 'result' => array('result_code' => $errorcode, 'result_label' => $errorlabel), + 'products' => $arrayproducts ); } else { $objectresp = array( - 'result'=>array('result_code' => 'OK', 'result_label' => ''), - 'products'=>$arrayproducts + 'result' => array('result_code' => 'OK', 'result_label' => ''), + 'products' => $arrayproducts ); } @@ -998,7 +999,7 @@ function getListOfProductsOrServices($authentication, $filterproduct) * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information * @param int $id Category id * @param string $lang Force lang - * @return array Array result + * @return array{result:array{result_code:string,result_label:string}} Array result */ function getProductsForCategory($authentication, $id, $lang = '') { @@ -1112,13 +1113,13 @@ function getProductsForCategory($authentication, $id, $lang = '') // Retour $objectresp = array( - 'result'=>array('result_code'=>'OK', 'result_label'=>''), - 'products'=> $products + 'result' => array('result_code' => 'OK', 'result_label' => ''), + 'products' => $products ); } else { $errorcode = 'NORECORDS_FOR_ASSOCIATION'; $errorlabel = 'No products associated'.$sql; - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); + $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel)); dol_syslog("getProductsForCategory:: ".$errorcode, LOG_DEBUG); } } else { @@ -1134,7 +1135,7 @@ function getProductsForCategory($authentication, $id, $lang = '') } if ($error) { - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); + $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel)); } return $objectresp; diff --git a/htdocs/webservices/server_project.php b/htdocs/webservices/server_project.php index f504b7cc16fbe..4f9091a3df439 100644 --- a/htdocs/webservices/server_project.php +++ b/htdocs/webservices/server_project.php @@ -2,6 +2,7 @@ /* Copyright (C) 2006-2016 Laurent Destailleur * Copyright (C) 2016 Ion Agorria * Copyright (C) 2024 Frédéric France + * 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 @@ -104,11 +105,11 @@ 'all', '', array( - 'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'), - 'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'), - 'login' => array('name'=>'login', 'type'=>'xsd:string'), - 'password' => array('name'=>'password', 'type'=>'xsd:string'), - 'entity' => array('name'=>'entity', 'type'=>'xsd:string'), + 'dolibarrkey' => array('name' => 'dolibarrkey', 'type' => 'xsd:string'), + 'sourceapplication' => array('name' => 'sourceapplication', 'type' => 'xsd:string'), + 'login' => array('name' => 'login', 'type' => 'xsd:string'), + 'password' => array('name' => 'password', 'type' => 'xsd:string'), + 'entity' => array('name' => 'entity', 'type' => 'xsd:string'), ) ); @@ -120,8 +121,8 @@ 'all', '', array( - 'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'), - 'result_label' => array('name'=>'result_label', 'type'=>'xsd:string'), + 'result_code' => array('name' => 'result_code', 'type' => 'xsd:string'), + 'result_label' => array('name' => 'result_label', 'type' => 'xsd:string'), ) ); @@ -133,8 +134,8 @@ 'all', '', array( - 'id' => array('name'=>'id', 'type'=>'xsd:int'), - 'user' => array('name'=>'user', 'type'=>'xsd:int'), + 'id' => array('name' => 'id', 'type' => 'xsd:int'), + 'user' => array('name' => 'user', 'type' => 'xsd:int'), ) ); @@ -156,7 +157,7 @@ $project_elements = array(); foreach ($listofreferent as $key => $label) { - $project_elements[$key] = array('name'=>$key, 'type'=>'tns:elementsArray'); + $project_elements[$key] = array('name' => $key, 'type' => 'tns:elementsArray'); } $server->wsdl->addComplexType( 'elements', @@ -169,17 +170,17 @@ // Define project $project_fields = array( - 'id' => array('name'=>'id', 'type'=>'xsd:string'), - 'ref' => array('name'=>'ref', 'type'=>'xsd:string'), - 'label' => array('name'=>'label', 'type'=>'xsd:string'), - 'thirdparty_id' => array('name'=>'thirdparty_id', 'type'=>'xsd:int'), - 'public' => array('name'=>'public', 'type'=>'xsd:int'), - 'status' => array('name'=>'status', 'type'=>'xsd:int'), - 'date_start' => array('name'=>'date_start', 'type'=>'xsd:date'), - 'date_end' => array('name'=>'date_end', 'type'=>'xsd:date'), - 'budget' => array('name'=>'budget', 'type'=>'xsd:int'), - 'description' => array('name'=>'description', 'type'=>'xsd:string'), - 'elements' => array('name'=>'elements', 'type'=>'tns:elements') + 'id' => array('name' => 'id', 'type' => 'xsd:string'), + 'ref' => array('name' => 'ref', 'type' => 'xsd:string'), + 'label' => array('name' => 'label', 'type' => 'xsd:string'), + 'thirdparty_id' => array('name' => 'thirdparty_id', 'type' => 'xsd:int'), + 'public' => array('name' => 'public', 'type' => 'xsd:int'), + 'status' => array('name' => 'status', 'type' => 'xsd:int'), + 'date_start' => array('name' => 'date_start', 'type' => 'xsd:date'), + 'date_end' => array('name' => 'date_end', 'type' => 'xsd:date'), + 'budget' => array('name' => 'budget', 'type' => 'xsd:int'), + 'description' => array('name' => 'description', 'type' => 'xsd:string'), + 'elements' => array('name' => 'elements', 'type' => 'tns:elements') ); $elementtype = 'project'; @@ -201,7 +202,7 @@ } else { $type = 'xsd:string'; } - $extrafield_array['options_'.$key] = array('name'=>'options_'.$key, 'type'=>$type); + $extrafield_array['options_'.$key] = array('name' => 'options_'.$key, 'type' => $type); } } if (is_array($extrafield_array)) { @@ -228,9 +229,9 @@ $server->register( 'createProject', // Entry values - array('authentication'=>'tns:authentication', 'project'=>'tns:project'), + array('authentication' => 'tns:authentication', 'project' => 'tns:project'), // Exit values - array('result'=>'tns:result', 'id'=>'xsd:string', 'ref'=>'xsd:string'), + array('result' => 'tns:result', 'id' => 'xsd:string', 'ref' => 'xsd:string'), $ns, $ns.'#createProject', $styledoc, @@ -242,9 +243,9 @@ $server->register( 'getProject', // Entry values - array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'ref'=>'xsd:string'), + array('authentication' => 'tns:authentication', 'id' => 'xsd:string', 'ref' => 'xsd:string'), // Exit values - array('result'=>'tns:result', 'project'=>'tns:project'), + array('result' => 'tns:result', 'project' => 'tns:project'), $ns, $ns.'#getProject', $styledoc, @@ -257,8 +258,8 @@ * Create project * * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information - * @param array $project Project info - * @return array array of new order + * @param array{id:string,ref:string,label:string,thirdparty_id:int,public:int,status:int,date_start:string,date_end:string,budget:int,description:string,elements:array} $project Project info + * @return array{id?:int,ref?:string,result:array{result_code:string,result_label:string}} Array result */ function createProject($authentication, $project) { @@ -327,7 +328,7 @@ function createProject($authentication, $project) if (!$error) { $db->commit(); - $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref); + $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'id' => $newobject->id, 'ref' => $newobject->ref); } else { $db->rollback(); $error++; @@ -342,7 +343,7 @@ function createProject($authentication, $project) } if ($error) { - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); + $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel)); } return $objectresp; @@ -354,7 +355,7 @@ function createProject($authentication, $project) * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information * @param string $id internal id * @param string $ref internal reference - * @return array Array result + * @return array{result:array{result_code:string,result_label:string}} Array result */ function getProject($authentication, $id = '', $ref = '') { @@ -432,8 +433,8 @@ function getProject($authentication, $id = '', $ref = '') //Result $objectresp = array( - 'result'=>array('result_code'=>'OK', 'result_label'=>''), - 'project'=>$project_result_fields + 'result' => array('result_code' => 'OK', 'result_label' => ''), + 'project' => $project_result_fields ); } else { $error++; @@ -448,7 +449,7 @@ function getProject($authentication, $id = '', $ref = '') } if ($error) { - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); + $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel)); } return $objectresp; diff --git a/htdocs/webservices/server_supplier_invoice.php b/htdocs/webservices/server_supplier_invoice.php index 102399a28be95..f7e0f3f32e5ea 100644 --- a/htdocs/webservices/server_supplier_invoice.php +++ b/htdocs/webservices/server_supplier_invoice.php @@ -246,7 +246,7 @@ * @param int $id Id * @param string $ref Ref * @param string $ref_ext Ref_ext - * @return array Array result + * @return array{result:array{result_code:string,result_label:string}} Array result */ function getSupplierInvoice($authentication, $id = 0, $ref = '', $ref_ext = '') { @@ -351,7 +351,7 @@ function getSupplierInvoice($authentication, $id = 0, $ref = '', $ref_ext = '') * * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information * @param int $idthirdparty Id thirdparty - * @return array Array result + * @return array{result:array{result_code:string,result_label:string}} Array result */ function getSupplierInvoicesForThirdParty($authentication, $idthirdparty) { diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index 9800b86a8b97d..c3060e27bbdfd 100644 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -317,7 +317,7 @@ * @param string $barcode barcode * @param string $profid1 profid1 * @param string $profid2 profid2 - * @return array Array result + * @return array{result:array{result_code:string,result_label:string}} Array result */ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '', $barcode = '', $profid1 = '', $profid2 = '') { @@ -438,8 +438,8 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '', $bar * Create a thirdparty * * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information - * @param array $thirdparty Thirdparty - * @return array Array result + * @param array{id:string,ref:string,ref_ext:string,fk_user_author:string,status:string,client:string,supplier:string,customer_code:string,supplier_code:string,customer_code_accountancy:string,supplier_code_accountancy:string,date_creation:string,date_modification:string,note_private:string,note_public:string,address:string,zip:string,town:string,region_code:string,country_id:string,country_code:string,country:string,phone:string,fax:string,email:string,url:string,profid1:string,profid2:string,profid3:string,profid4:string,profid5:string,profid6:string,capital:string,vat_used:string,vat_number:string} $thirdparty Thirdparty + * @return array{result:array{result_code:string,result_label:string}} Array result */ function createThirdParty($authentication, $thirdparty) { @@ -474,9 +474,9 @@ function createThirdParty($authentication, $thirdparty) $newobject->ref = $thirdparty['ref']; $newobject->name = $thirdparty['ref']; $newobject->ref_ext = $thirdparty['ref_ext']; - $newobject->status = $thirdparty['status']; - $newobject->client = $thirdparty['client']; - $newobject->fournisseur = $thirdparty['supplier']; + $newobject->status = (int) $thirdparty['status']; + $newobject->client = (int) $thirdparty['client']; + $newobject->fournisseur = (int) $thirdparty['supplier']; $newobject->code_client = $thirdparty['customer_code']; $newobject->code_fournisseur = $thirdparty['supplier_code']; $newobject->code_compta = $thirdparty['customer_code_accountancy']; @@ -489,7 +489,7 @@ function createThirdParty($authentication, $thirdparty) $newobject->zip = $thirdparty['zip']; $newobject->town = $thirdparty['town']; - $newobject->country_id = $thirdparty['country_id']; + $newobject->country_id = (int) $thirdparty['country_id']; if ($thirdparty['country_code']) { $newobject->country_id = getCountry($thirdparty['country_code'], '3'); } @@ -507,13 +507,13 @@ function createThirdParty($authentication, $thirdparty) $newobject->idprof5 = $thirdparty['profid5']; $newobject->idprof6 = $thirdparty['profid6']; - $newobject->capital = $thirdparty['capital']; + $newobject->capital = (float) $thirdparty['capital']; - $newobject->barcode = empty($thirdparty['barcode']) ? '' : $thirdparty['barcode']; + $newobject->barcode = !isset($thirdparty['barcode']) ? '' : $thirdparty['barcode']; $newobject->tva_assuj = empty($thirdparty['vat_used']) ? 0 : $thirdparty['vat_used']; $newobject->tva_intra = empty($thirdparty['vat_number']) ? '' : $thirdparty['vat_number']; - $newobject->canvas = empty($thirdparty['canvas']) ? '' : $thirdparty['canvas']; + $newobject->canvas = !isset($thirdparty['canvas']) ? '' : $thirdparty['canvas']; $newobject->particulier = empty($thirdparty['individual']) ? 0 : $thirdparty['individual']; $elementtype = 'societe'; @@ -535,8 +535,8 @@ function createThirdParty($authentication, $thirdparty) $result = $newobject->create($fuser); if ($newobject->particulier && $result > 0) { - $newobject->firstname = $thirdparty['firstname']; - $newobject->name_bis = $thirdparty['lastname']; + $newobject->firstname = isset($thirdparty['firstname']) ? $thirdparty['firstname'] : ''; + $newobject->name_bis = isset($thirdparty['lastname']) ? $thirdparty['lastname'] : ''; $result = $newobject->create_individual($fuser); } if ($result <= 0) { @@ -546,9 +546,9 @@ function createThirdParty($authentication, $thirdparty) if (!$error) { $db->commit(); - // Patch to add capability to associate (one) sale representative - if (!empty($thirdparty['commid']) && $thirdparty['commid'] > 0) { - $newobject->add_commercial($fuser, $thirdparty["commid"]); + // Patch to add capability to associate (one) sales representative + if (isset($thirdparty['commid']) && $thirdparty['commid'] > 0) { // @phan-suppress-current-line PhanTypeInvalidDimOffset + $newobject->add_commercial($fuser, $thirdparty['commid']); } $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'id' => $newobject->id, 'ref' => $newobject->ref); @@ -571,8 +571,8 @@ function createThirdParty($authentication, $thirdparty) * Update a thirdparty * * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information - * @param array $thirdparty Thirdparty - * @return array Array result + * @param array{id:string,ref:string,ref_ext:string,fk_user_author:string,status:string,client:string,supplier:string,customer_code:string,supplier_code:string,customer_code_accountancy:string,supplier_code_accountancy:string,date_creation:string,date_modification:string,note_private:string,note_public:string,address:string,zip:string,town:string,region_code:string,country_id:string,country_code:string,country:string,phone:string,fax:string,email:string,url:string,profid1:string,profid2:string,profid3:string,profid4:string,profid5:string,profid6:string,capital:string,vat_used:string,vat_number:string} $thirdparty Thirdparty + * @return array{result:array{result_code:string,result_label:string}} Array result */ function updateThirdParty($authentication, $thirdparty) { @@ -613,9 +613,9 @@ function updateThirdParty($authentication, $thirdparty) $object->ref = $thirdparty['ref']; $object->name = $thirdparty['ref']; $object->ref_ext = $thirdparty['ref_ext']; - $object->status = $thirdparty['status']; - $object->client = $thirdparty['client']; - $object->fournisseur = $thirdparty['supplier']; + $object->status = (int) $thirdparty['status']; + $object->client = (int) $thirdparty['client']; + $object->fournisseur = (int) $thirdparty['supplier']; $object->code_client = $thirdparty['customer_code']; $object->code_fournisseur = $thirdparty['supplier_code']; $object->code_compta = $thirdparty['customer_code_accountancy']; @@ -628,7 +628,7 @@ function updateThirdParty($authentication, $thirdparty) $object->zip = $thirdparty['zip']; $object->town = $thirdparty['town']; - $object->country_id = $thirdparty['country_id']; + $object->country_id = (int) $thirdparty['country_id']; if ($thirdparty['country_code']) { $object->country_id = getCountry($thirdparty['country_code'], '3'); } @@ -646,13 +646,13 @@ function updateThirdParty($authentication, $thirdparty) $object->idprof5 = $thirdparty['profid5']; $object->idprof6 = $thirdparty['profid6']; - $object->capital = $thirdparty['capital']; + $object->capital = (float) $thirdparty['capital']; - $object->barcode = $thirdparty['barcode']; - $object->tva_assuj = $thirdparty['vat_used']; + $object->barcode = !isset($thirdparty['barcode']) ? '' : $thirdparty['barcode']; + $object->tva_assuj = (int) $thirdparty['vat_used']; $object->tva_intra = $thirdparty['vat_number']; - $object->canvas = $thirdparty['canvas']; + $object->canvas = !isset($thirdparty['canvas']) ? '' : $thirdparty['canvas']; $elementtype = 'societe'; @@ -710,8 +710,8 @@ function updateThirdParty($authentication, $thirdparty) * getListOfThirdParties * * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information - * @param array $filterthirdparty Filter fields (key=>value to filer on. For example 'client'=>2, 'supplier'=>1, 'category'=>idcateg, 'name'=>'searchstring', ...) - * @return array Array result + * @param array $filterthirdparty Filter fields (key=>value to filer on. For example 'client'=>2, 'supplier'=>1, 'category'=>idcateg, 'name'=>'searchstring', ...) + * @return array{result:array{result_code:string,result_label:string}} Array result */ function getListOfThirdParties($authentication, $filterthirdparty) { @@ -823,7 +823,7 @@ function getListOfThirdParties($authentication, $filterthirdparty) * @param string $id internal id * @param string $ref internal reference * @param string $ref_ext external reference - * @return array Array result + * @return array{result:array{result_code:string,result_label:string}} Array result */ function deleteThirdParty($authentication, $id = '', $ref = '', $ref_ext = '') { diff --git a/htdocs/webservices/server_user.php b/htdocs/webservices/server_user.php index 7567532ba990a..7caa707932002 100644 --- a/htdocs/webservices/server_user.php +++ b/htdocs/webservices/server_user.php @@ -422,7 +422,7 @@ function getUser($authentication, $id, $ref = '', $ref_ext = '') * getListOfGroups * * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information - * @return array Array result + * @return array{result:array{result_code:string,result_label:string}} Array result */ function getListOfGroups($authentication) { @@ -490,8 +490,8 @@ function getListOfGroups($authentication) * Create an external user with thirdparty and contact * * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information - * @param array $thirdpartywithuser Datas - * @return mixed + * @param array{name:string,firstname:string,name_thirdparty:string,ref_ext:string,client:string,fournisseur:string,address:string,zip:string,town:string,country_id:string,country_code:string,phone:string,phone_mobile:string,fax:string,email:string,url:string,profid1:string,profid2:string,profid3:string,profid4:string,profid5:string,profid6:string,capital:string,tva_assuj:string,tva_intra:string,login:string,password:string,group_id:string} $thirdpartywithuser Datas + * @return array{id?:int,result:array{result_code:string,result_label:string}} Array result */ function createUserFromThirdparty($authentication, $thirdpartywithuser) { @@ -552,7 +552,7 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser) $thirdparty->address = $thirdpartywithuser['address']; $thirdparty->zip = $thirdpartywithuser['zip']; $thirdparty->town = $thirdpartywithuser['town']; - $thirdparty->country_id = $thirdpartywithuser['country_id']; + $thirdparty->country_id = (int) $thirdpartywithuser['country_id']; $thirdparty->country_code = $thirdpartywithuser['country_code']; // find the country id by code @@ -583,8 +583,8 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser) $thirdparty->idprof5 = $thirdpartywithuser['prof5']; $thirdparty->idprof6 = $thirdpartywithuser['prof6']; - $thirdparty->client = $thirdpartywithuser['client']; - $thirdparty->fournisseur = $thirdpartywithuser['fournisseur']; + $thirdparty->client = (int) $thirdpartywithuser['client']; + $thirdparty->fournisseur = (int) $thirdpartywithuser['fournisseur']; $socid_return = $thirdparty->create($fuser);