Qual: Fix phan notices (workstation)
This commit is contained in:
parent
fbf072e95a
commit
14d68131de
6 changed files with 24 additions and 25 deletions
|
|
@ -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'],
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class FormResource
|
|||
/**
|
||||
* 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
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2019 Cedric Ancelin <icedo.anc@gmail.com>
|
||||
* Copyright (C) 2024 Christian Humpel <christian.humpel@gmail.com>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
*
|
||||
* 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 @@ require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php';
|
|||
class Workstations extends DolibarrApi
|
||||
{
|
||||
/**
|
||||
* @var Workstation $workstation {@type Workstation}
|
||||
* @var Workstation {@type Workstation}
|
||||
*/
|
||||
public $workstation;
|
||||
|
||||
|
|
@ -104,6 +104,8 @@ class Workstations extends DolibarrApi
|
|||
* @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 @@ class Workstations extends DolibarrApi
|
|||
$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
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ if ($action == 'create') {
|
|||
print '</td>';
|
||||
print '<td>';
|
||||
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 '</td></tr>';
|
||||
|
||||
print '<tr id="wsresources"><td>';
|
||||
|
|
@ -248,7 +248,7 @@ if ($action == 'create') {
|
|||
print '</td>';
|
||||
print '<td>';
|
||||
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 '</td></tr>';
|
||||
|
||||
// Other attributes
|
||||
|
|
@ -293,7 +293,7 @@ if (($id || $ref) && $action == 'edit') {
|
|||
print '</td>';
|
||||
print '<td>';
|
||||
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 '</td></tr>';
|
||||
|
||||
print '<tr id="wsresources"><td>';
|
||||
|
|
@ -301,7 +301,7 @@ if (($id || $ref) && $action == 'edit') {
|
|||
print '</td>';
|
||||
print '<td>';
|
||||
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 '</td></tr>';
|
||||
|
||||
// Other attributes
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2020 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -127,8 +127,8 @@ foreach ($object->fields as $key => $val) {
|
|||
$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 @@ foreach ($object->fields as $key => $val) {
|
|||
|
||||
$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 @@ $arrayfields['wug.fk_usergroup'] = array(
|
|||
/* 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 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
|
|||
|
||||
$object->fields = dol_sort_array($object->fields, 'position');
|
||||
$arrayfields = dol_sort_array($arrayfields, 'position');
|
||||
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
|
||||
|
||||
// Permissions
|
||||
$permissiontoread = $user->hasRight('workstation', 'workstation', 'read');
|
||||
|
|
@ -553,7 +552,7 @@ foreach ($object->fields as $key => $val) {
|
|||
} 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 '<input type="text" class="flat maxwidth'.($val['type'] == 'integer' ? '50' : '75').'" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
|
||||
}
|
||||
|
|
@ -564,14 +563,14 @@ foreach ($object->fields as $key => $val) {
|
|||
// usergroups
|
||||
if (!empty($arrayfields['wug.fk_usergroup']['checked'])) {
|
||||
print '<td class="liste_titre minwidth100">';
|
||||
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 '</td>';
|
||||
}
|
||||
|
||||
// resources
|
||||
if (!empty($arrayfields['wr.fk_resource']['checked'])) {
|
||||
print '<td class="liste_titre">';
|
||||
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 '</td>';
|
||||
}
|
||||
|
||||
|
|
@ -734,13 +733,13 @@ while ($i < $imaxinloop) {
|
|||
if (!empty($arrayfields['t.'.$key]['checked'])) {
|
||||
print '<td'.($cssforfield ? ' class="'.$cssforfield.(preg_match('/tdoverflow/', $cssforfield) ? ' classfortooltip' : '').'"' : '');
|
||||
if (preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$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, '');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue