diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index f5df87a7bf0c5..367795748b24e 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -676,10 +676,8 @@ return [ 'htdocs/website/index.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'], 'htdocs/website/samples/wrapper.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/website/websiteaccount_card.php' => ['PhanUndeclaredProperty'], - 'htdocs/workstation/class/api_workstations.class.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/workstation/class/workstation.class.php' => ['PhanUndeclaredProperty'], - 'htdocs/workstation/workstation_card.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], - 'htdocs/workstation/workstation_list.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/workstation/workstation_card.php' => ['PhanUndeclaredProperty'], 'htdocs/zapier/class/api_zapier.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], 'htdocs/zapier/class/hook.class.php' => ['PhanUndeclaredProperty'], 'internal' => ['PhanUndeclaredConstant'], diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 1ce3201aa9c17..e7be7cfef1307 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -48,7 +48,7 @@ * @var string $action */ ' -@phan-var-force CommonObjectLine $line +@phan-var-force BOMLine $line @phan-var-force int $num @phan-var-force int $i @phan-var-force CommonObject $this diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index 6f5172720408c..52a601551a9a4 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -73,7 +73,7 @@ public function __construct($db) /** * Output html form to select a resource * - * @param int $selected Preselected resource id + * @param int|int[] $selected Preselected resource id * @param string $htmlname Name of field in form * @param string $filter Optional filters criteria (example: 's.rowid <> x') * @param int<0,1> $showempty Add an empty field diff --git a/htdocs/workstation/class/api_workstations.class.php b/htdocs/workstation/class/api_workstations.class.php index 263a7b28c777d..1a70145db6046 100644 --- a/htdocs/workstation/class/api_workstations.class.php +++ b/htdocs/workstation/class/api_workstations.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2019 Cedric Ancelin * Copyright (C) 2024 Christian Humpel - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 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 @@ -38,7 +38,7 @@ class Workstations extends DolibarrApi { /** - * @var Workstation $workstation {@type Workstation} + * @var Workstation {@type Workstation} */ public $workstation; @@ -104,6 +104,8 @@ public function getByRef($ref) * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.tobuy:=:0) and (t.tosell:=:1)" * @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names * @return array Array of workstation objects + * @phan-return Workstation[]|array{data:Workstation[],pagination:array{total:int,page:int,pagecount:int,limit:int}} + * @phpstan-return Workstation[]|array{data:Workstation[],pagination:array{total:int,page:int,pagecount:int,limit:int}} */ public function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '') { @@ -171,7 +173,7 @@ public function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $p $obj_ret['pagination'] = array( 'total' => (int) $total, 'page' => $page, //count starts from 0 - 'page_count' => ceil((int) $total / $limit), + 'page_count' => (int) ceil((int) $total / $limit), 'limit' => $limit ); } diff --git a/htdocs/workstation/workstation_card.php b/htdocs/workstation/workstation_card.php index c93b540984e75..c22eefe06cd53 100644 --- a/htdocs/workstation/workstation_card.php +++ b/htdocs/workstation/workstation_card.php @@ -240,7 +240,7 @@ print ''; print ''; print img_picto('', 'group'); - print $form->select_dolgroups($groups, 'groups', 1, '', 0, '', '', $object->entity, true, 'quatrevingtpercent widthcentpercentminusx'); + print $form->select_dolgroups($groups, 'groups', 1, '', 0, '', array(), (string) $object->entity, true, 'quatrevingtpercent widthcentpercentminusx'); print ''; print ''; @@ -248,7 +248,7 @@ print ''; print ''; print img_picto('', 'resource'); - print $formresource->select_resource_list($resources, 'resources', [], '', 0, '', '', $object->entity, true, 0, 'quatrevingtpercent widthcentpercentminusx', true); + print $formresource->select_resource_list($resources, 'resources', '', 0, 0, 0, array(), (string) $object->entity, 1, 0, 'quatrevingtpercent widthcentpercentminusx', true); print ''; // Other attributes @@ -293,7 +293,7 @@ print ''; print ''; print img_picto('', 'group'); - print $form->select_dolgroups(empty($groups) ? $object->usergroups : $groups, 'groups', 1, '', 0, '', '', $object->entity, true, 'quatrevingtpercent widthcentpercentminusx'); + print $form->select_dolgroups(empty($groups) ? $object->usergroups : $groups, 'groups', 1, '', 0, '', array(), (string) $object->entity, true, 'quatrevingtpercent widthcentpercentminusx'); print ''; print ''; @@ -301,7 +301,7 @@ print ''; print ''; print img_picto('', 'resource'); - print $formresource->select_resource_list(empty($resources) ? $object->resources : $resources, 'resources', [], '', 0, '', '', $object->entity, true, 0, 'quatrevingtpercent widthcentpercentminusx', true); + print $formresource->select_resource_list(empty($resources) ? $object->resources : $resources, 'resources', '', 0, 0, 0, array(), (string) $object->entity, 1, 0, 'quatrevingtpercent widthcentpercentminusx', true); print ''; // Other attributes diff --git a/htdocs/workstation/workstation_list.php b/htdocs/workstation/workstation_list.php index 254036c594522..1785b4d4e7de0 100644 --- a/htdocs/workstation/workstation_list.php +++ b/htdocs/workstation/workstation_list.php @@ -2,7 +2,7 @@ /* Copyright (C) 2007-2017 Laurent Destailleur * Copyright (C) 2020 Gauthier VERDOL - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -127,8 +127,8 @@ $visible = (int) dol_eval((string) $val['visible'], 1); $arrayfields['t.'.$key] = array( 'label' => $val['label'], - 'checked' => (($visible < 0) ? 0 : 1), - 'enabled' => (abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)), + 'checked' => (($visible < 0) ? '0' : '1'), + 'enabled' => (string) (int) (abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)), 'position' => $val['position'], 'help' => isset($val['help']) ? $val['help'] : '' ); @@ -137,8 +137,8 @@ $arrayfields['wug.fk_usergroup'] = array( 'label' => $langs->trans('UserGroups'), - 'checked' => (($visible < 0) ? 0 : 1), - 'enabled' => (abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)), + 'checked' => (($visible < 0) ? '0' : '1'), + 'enabled' => (string) (int) (abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)), 'position' => 1000, 'help' => empty($val['help']) ? '' : $val['help'], 'csslist' => 'minwidth100' @@ -147,8 +147,8 @@ /* disabled because adding resources to workstation seems not yet available in GUI $arrayfields['wr.fk_resource'] = array( 'label'=>$langs->trans('Resources'), - 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>(abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)), + 'checked'=>(($visible < 0) ? '0' : '1'), + 'enabled'=>(string)(int)(abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)), 'position'=>1001, 'help' => empty($val['help']) ? '' : $val['help'] ); @@ -159,7 +159,6 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan // Permissions $permissiontoread = $user->hasRight('workstation', 'workstation', 'read'); @@ -553,7 +552,7 @@ } elseif ($key == 'lang') { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $formadmin = new FormAdmin($db); - print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth100imp maxwidth125', 2); + print $formadmin->select_language($search[$key], 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2); } else { print ''; } @@ -564,14 +563,14 @@ // usergroups if (!empty($arrayfields['wug.fk_usergroup']['checked'])) { print ''; - print $form->select_dolgroups($groups, 'groups', 1, '', 0, '', '', $conf->entity, true); + print $form->select_dolgroups($groups, 'groups', 1, '', 0, '', array(), (string) $conf->entity, true); print ''; } // resources if (!empty($arrayfields['wr.fk_resource']['checked'])) { print ''; - print $formresource->select_resource_list($resources, 'resources', [], '', 0, '', '', $conf->entity, true, 0, '', true); + print $formresource->select_resource_list($resources, 'resources', '', 0, 0, 0, array(), (string) $conf->entity, 1, 0, '', true); print ''; } @@ -734,13 +733,13 @@ if (!empty($arrayfields['t.'.$key]['checked'])) { print '$key)) { - print ' title="'.dol_escape_htmltag($object->$key).'"'; + print ' title="'.dol_escape_htmltag((string) $object->$key).'"'; } print '>'; if ($key == 'status') { print $object->getLibStatut(5); } elseif ($key == 'rowid') { - print $object->showOutputField($val, $key, $object->id, ''); + print $object->showOutputField($val, $key, (string) $object->id, ''); } else { print $object->showOutputField($val, $key, $object->$key, ''); }