diff --git a/inc/agentmodule.class.php b/inc/agentmodule.class.php index 65f37c2195..7472cbeea1 100644 --- a/inc/agentmodule.class.php +++ b/inc/agentmodule.class.php @@ -52,7 +52,7 @@ class PluginGlpiinventoryAgentmodule extends CommonDBTM /** * Get the tab name used for item * - * @param object $item the item object + * @param CommonGLPI $item the item object * @param integer $withtemplate 1 if is a template form * @return string name of the tab */ @@ -71,7 +71,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) /** * Display the content of the tab * - * @param object $item + * @param CommonGLPI $item * @param integer $tabnum number of the tab to display * @param integer $withtemplate 1 if is a template form * @return boolean @@ -79,11 +79,11 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { - if ($item->getType() == 'PluginGlpiinventoryConfig') { + if ($item instanceof PluginGlpiinventoryConfig) { $pfAgentmodule = new self(); $pfAgentmodule->showModuleForm(); return true; - } elseif ($item->getType() == 'Agent') { + } elseif ($item instanceof Agent) { $pfAgentmodule = new self(); $pfAgentmodule->showFormAgentException($item->fields['id']); return true; diff --git a/inc/collect.class.php b/inc/collect.class.php index b93d26b0b8..74d1fa20c6 100644 --- a/inc/collect.class.php +++ b/inc/collect.class.php @@ -63,12 +63,13 @@ public static function getTypeName($nb = 0) /** * Get the tab name used for item * - * @param object $item the item object + * @param CommonGLPI $item the item object * @param integer $withtemplate 1 if is a template form * @return string name of the tab */ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { + /** @var CommonDBTM $item */ if ($item->fields['id'] > 0) { $index = self::getNumberOfCollectsForAComputer($item->fields['id']); $nb = 0; @@ -86,14 +87,14 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) /** * Display the content of the tab * - * @param object $item + * @param CommonGLPI $item * @param integer $tabnum number of the tab to display * @param integer $withtemplate 1 if is a template form * @return boolean */ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { - if ($item->getType() != 'Computer') { + if (!$item instanceof Computer) { return false; } @@ -121,7 +122,7 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $ * @since 9.2 * * @param integer $computers_id the computer ID - * @return the number of collects for this computer + * @return integer the number of collects for this computer */ public static function getNumberOfCollectsForAComputer($computers_id) { diff --git a/inc/collect_file_content.class.php b/inc/collect_file_content.class.php index b93e9b3635..eeaa74f9b7 100644 --- a/inc/collect_file_content.class.php +++ b/inc/collect_file_content.class.php @@ -50,8 +50,8 @@ class PluginGlpiinventoryCollect_File_Content extends PluginGlpiinventoryCollect * * @global object $DB * @param integer $computers_id id of the computer + * @param array $file_data * @param integer $collects_files_id id of collect_file - * @param integer $taskjobstates_id id of taskjobstate */ public function updateComputer($computers_id, $file_data, $collects_files_id) { diff --git a/inc/collect_registry_content.class.php b/inc/collect_registry_content.class.php index 03547d7094..618e99c3c7 100644 --- a/inc/collect_registry_content.class.php +++ b/inc/collect_registry_content.class.php @@ -48,13 +48,13 @@ class PluginGlpiinventoryCollect_Registry_Content extends PluginGlpiinventoryCol /** * Get the tab name used for item * - * @param object $item the item object + * @param CommonGLPI $item the item object * @param integer $withtemplate 1 if is a template form * @return string name of the tab */ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { - + /** @var CommonDBTM $item */ if ($item->fields['id'] > 0) { if (get_class($item) == 'PluginGlpiinventoryCollect') { if ($item->fields['type'] == 'registry') { diff --git a/inc/collectcommon.class.php b/inc/collectcommon.class.php index 54b2113474..17e3c313c0 100644 --- a/inc/collectcommon.class.php +++ b/inc/collectcommon.class.php @@ -65,12 +65,13 @@ public static function getTypeName($nb = 0) /** * Get the tab name used for item * - * @param object $item the item object + * @param CommonGLPI $item the item object * @param integer $withtemplate 1 if is a template form * @return string name of the tab */ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { + /** @var CommonDBTM $item */ if ($item->fields['id'] > 0) { if ($item->fields['type'] == $this->type) { return __('Collect configuration'); @@ -83,7 +84,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) /** * Display the content of the tab * - * @param object $item + * @param CommonGLPI $item * @param integer $tabnum number of the tab to display * @param integer $withtemplate 1 if is a template form * @return boolean @@ -92,6 +93,7 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $ { $class = get_called_class(); $pfCollect = new $class(); + /** @var CommonDBTM $item */ $pfCollect->showForm($item->fields['id']); $pfCollect->showList($item->fields['id']); diff --git a/inc/collectcontentcommon.class.php b/inc/collectcontentcommon.class.php index 38add2458d..1312920525 100644 --- a/inc/collectcontentcommon.class.php +++ b/inc/collectcontentcommon.class.php @@ -78,7 +78,7 @@ public function getCollectClass() /** * Display the content of the tab * - * @param object $item + * @param CommonGLPI $item * @param integer $tabnum number of the tab to display * @param integer $withtemplate 1 if is a template form * @return boolean @@ -98,13 +98,13 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $ /** * Get the tab name used for item * - * @param object $item the item object + * @param CommonGLPI $item the item object * @param integer $withtemplate 1 if is a template form * @return string name of the tab */ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { - + /** @var CommonDBTM $item */ if ($item->fields['id'] > 0) { $class = $this->collect_itemtype; $collect = $this->getCollectClass(); diff --git a/inc/communicationnetworkdiscovery.class.php b/inc/communicationnetworkdiscovery.class.php index 678f479f50..37d9e28dec 100644 --- a/inc/communicationnetworkdiscovery.class.php +++ b/inc/communicationnetworkdiscovery.class.php @@ -135,7 +135,7 @@ public function import($p_DEVICEID, $a_CONTENT, Inventory $inventory): array } else { $refused = $inventory->getMainAsset()->getRefused(); $device = $a_CONTENT->content->network_device; - if (isset($refused) && count($refused)) { + if (count($refused)) { $a_text = []; if (isset($device)) { foreach (["type", "name", "mac", "ips"] as $property) { diff --git a/inc/communicationnetworkinventory.class.php b/inc/communicationnetworkinventory.class.php index 05c95bd977..d5147b4985 100644 --- a/inc/communicationnetworkinventory.class.php +++ b/inc/communicationnetworkinventory.class.php @@ -73,7 +73,7 @@ public function __construct() * * @param string $p_DEVICEID device_id of the agent * @param object $a_CONTENT - * @param Inventory $arrayinventory + * @param Inventory $inventory */ public function import($p_DEVICEID, $a_CONTENT, Inventory $inventory) { @@ -90,6 +90,7 @@ public function import($p_DEVICEID, $a_CONTENT, Inventory $inventory) if (!isset($a_CONTENT->jobid)) { if (isset($a_CONTENT->content->processnumber)) { + // @phpstan-ignore-next-line $a_CONTENT->jobid = $a_CONTENT->content->processnumber; } else { $a_CONTENT->jobid = 1; @@ -174,7 +175,7 @@ public function import($p_DEVICEID, $a_CONTENT, Inventory $inventory) } else { $refused = $inventory->getMainAsset()->getRefused(); $device = $a_CONTENT->content->network_device; - if (isset($refused) && count($refused)) { + if (count($refused)) { $a_text = []; if (isset($device)) { foreach (["type", "name", "mac", "ips"] as $property) { diff --git a/inc/computer.class.php b/inc/computer.class.php index 523702a2f4..a56a423d9a 100644 --- a/inc/computer.class.php +++ b/inc/computer.class.php @@ -106,8 +106,8 @@ public function getForbiddenStandardMassiveAction() /** * Execution code for massive action * - * @param object $ma MassiveAction instance - * @param object $item item on which execute the code + * @param MassiveAction $ma MassiveAction instance + * @param CommonDBTM $item item on which execute the code * @param array $ids list of ID on which execute the code */ public static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) @@ -164,7 +164,7 @@ public static function processMassiveActionsForOneItemtype(MassiveAction $ma, Co /** * Display form related to the massive action selected * - * @param object $ma MassiveAction instance + * @param MassiveAction $ma MassiveAction instance * @return boolean */ public static function showMassiveActionsSubForm(MassiveAction $ma) diff --git a/inc/config.class.php b/inc/config.class.php index 5f7e7b430f..0d695856c3 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -217,7 +217,7 @@ public function defineTabs($options = []) /** * Get the tab name used for item * - * @param object $item the item object + * @param CommonGLPI $item the item object * @param integer $withtemplate 1 if is a template form * @return string|array name of the tab */ @@ -238,14 +238,14 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) /** * Display the content of the tab * - * @param object $item + * @param CommonGLPI $item * @param integer $tabnum number of the tab to display * @param integer $withtemplate 1 if is a template form * @return boolean */ public static function displayTabContentForItem($item, $tabnum = 1, $withtemplate = 0) { - + /** @var PluginGlpiinventoryConfig $item */ switch ($tabnum) { case 0: $item->showConfigForm(); diff --git a/inc/deployaction.class.php b/inc/deployaction.class.php index c25ec5b97b..0f1036bf92 100644 --- a/inc/deployaction.class.php +++ b/inc/deployaction.class.php @@ -97,7 +97,7 @@ public function getLabelForAType($type) /** * Display form * - * @param object $package PluginGlpiinventoryDeployPackage instance + * @param PluginGlpiinventoryDeployPackage $package PluginGlpiinventoryDeployPackage instance * @param array $request_data * @param string $rand unique element id used to identify/update an element * @param string $mode possible values: init|edit|create @@ -162,13 +162,13 @@ public function displayForm(PluginGlpiinventoryDeployPackage $package, $request_ /** * Display list of actions * - * @global array $CFG_GLPI - * @param object $package PluginGlpiinventoryDeployPackage instance + * @param PluginGlpiinventoryDeployPackage $package PluginGlpiinventoryDeployPackage instance * @param array $data array converted of 'json' field in DB where stored actions * @param string $rand unique element id used to identify/update an element */ public function displayList(PluginGlpiinventoryDeployPackage $package, $data, $rand) { + /** @var array $CFG_GLPI */ global $CFG_GLPI; $canedit = $package->canUpdateContent(); diff --git a/inc/deploycheck.class.php b/inc/deploycheck.class.php index 1f94f70af7..7e28b10fe8 100644 --- a/inc/deploycheck.class.php +++ b/inc/deploycheck.class.php @@ -83,8 +83,8 @@ public function getTypes() /** * Get label for a type - * @param the type value - * @return the type label + * @param string $type the type value + * @return string the type label */ public function getLabelForAType($type) { @@ -158,7 +158,7 @@ public function getUnitSize($unit) * Get all registry value types handled by the agent * * @since 9.2 - * @return an array of registry values types + * @return array of registry values types */ public function getRegistryTypes() { @@ -189,7 +189,7 @@ public function dropdownRegistryTypes($value = 'REG_SZ') * Display list of checks * * @global array $CFG_GLPI - * @param object $package PluginGlpiinventoryDeployPackage instance + * @param PluginGlpiinventoryDeployPackage $package PluginGlpiinventoryDeployPackage instance * @param array $data array converted of 'json' field in DB where stored checks * @param string $rand unique element id used to identify/update an element */ @@ -337,9 +337,9 @@ public function getValues($type, $data, $mode) /** * Get labels and type for a check - * @param check_type the type of check - * @param mandatory indicates if mandatory mark must be added to the label - * @return the labels and type for a check + * @param string $check_type the type of check + * @param boolean $mandatory indicates if mandatory mark must be added to the label + * @return array the labels and type for a check */ public function getLabelsAndTypes($check_type, $mandatory = false) { @@ -572,7 +572,7 @@ public function displayAjaxValues($config, $request_data, $rand, $mode) /** * Get all possible return values for a check - * @return an array of return values and their labels + * @return array of return values and their labels */ public function getAllReturnValues() { @@ -587,8 +587,8 @@ public function getAllReturnValues() /** * Get the label for a return value - * @param the check return value - * @return the label for the return value + * @param string $value the check return value + * @return string the label for the return value */ public function getValueForReturn($value) { diff --git a/inc/deployfile.class.php b/inc/deployfile.class.php index 17ccfe94ed..3f84649d95 100644 --- a/inc/deployfile.class.php +++ b/inc/deployfile.class.php @@ -71,7 +71,7 @@ public function getTypes() * Display list of files * * @global array $CFG_GLPI - * @param object $package PluginGlpiinventoryDeployPackage instance + * @param PluginGlpiinventoryDeployPackage $package PluginGlpiinventoryDeployPackage instance * @param array $data array converted of 'json' field in DB where stored actions * @param string $rand unique element id used to identify/update an element */ diff --git a/inc/deploygroup.class.php b/inc/deploygroup.class.php index 3213dc93c2..d73020e3cf 100644 --- a/inc/deploygroup.class.php +++ b/inc/deploygroup.class.php @@ -64,7 +64,7 @@ class PluginGlpiinventoryDeployGroup extends CommonDBTM /** * Define the array of itemtype allowed in static groups * - * @var type + * @var array */ protected $static_group_types = ['Computer']; @@ -140,7 +140,7 @@ public function getMatchingItemsCount($itemtype) /** * Display the content of the tab * - * @param object $item + * @param CommonGLPI $item * @param integer $tabnum number of the tab to display * @param integer $withtemplate 1 if is a template form * @return boolean @@ -227,7 +227,7 @@ public function getSpecificMassiveActions($checkitem = null) /** * Display form related to the massive action selected * - * @param object $ma MassiveAction instance + * @param MassiveAction $ma MassiveAction instance * @return boolean */ public static function showMassiveActionsSubForm(MassiveAction $ma) @@ -252,8 +252,8 @@ public static function showMassiveActionsSubForm(MassiveAction $ma) /** * Execution code for massive action * - * @param object $ma MassiveAction instance - * @param object $item item on which execute the code + * @param MassiveAction $ma MassiveAction instance + * @param CommonDBTM $item item on which execute the code * @param array $ids list of ID on which execute the code */ public static function processMassiveActionsForOneItemtype( @@ -580,8 +580,10 @@ public static function getSearchEngineTargetURL($deploygroup_id, $is_dynamic = f /** * Show criteria to search computers * - * @param object $item PluginGlpiinventoryDeployGroup instance + * @param PluginGlpiinventoryDeployGroup $item PluginGlpiinventoryDeployGroup instance * @param array $p + * + * @return void */ public static function showCriteria(PluginGlpiinventoryDeployGroup $item, $p) { @@ -650,7 +652,7 @@ public static function getTargetsForGroup($groups_id, $use_cache = false) * Get search parameters as an array * * @global object $DB - * @param object $group PluginGlpiinventoryDeployGroup instance + * @param PluginGlpiinventoryDeployGroup $group PluginGlpiinventoryDeployGroup instance * @param boolean $check_post_values * @param boolean $getAll * @return array diff --git a/inc/deploygroup_dynamicdata.class.php b/inc/deploygroup_dynamicdata.class.php index 5e0514e878..978d969490 100644 --- a/inc/deploygroup_dynamicdata.class.php +++ b/inc/deploygroup_dynamicdata.class.php @@ -65,13 +65,14 @@ class PluginGlpiinventoryDeployGroup_Dynamicdata extends CommonDBChild /** * Get the tab name used for item * - * @param object $item the item object + * @param CommonGLPI $item the item object * @param integer $withtemplate 1 if is a template form * @return string name of the tab */ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { + /** @var CommonDBTM $item */ if ( !$withtemplate && $item->fields['type'] == PluginGlpiinventoryDeployGroup::DYNAMIC_GROUP @@ -96,8 +97,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) * This function saves and restores the pagination parameters to avoid breaking the pagination in the * query results. * - * @param object $item the item object - * @param integer $withtemplate 1 if is a template form + * @param CommonGLPI $item the item object * @return string name of the tab */ public function getMatchingItemsCount(CommonGLPI $item) @@ -133,7 +133,7 @@ public function getMatchingItemsCount(CommonGLPI $item) /** * Display the content of the tab * - * @param object $item + * @param CommonGLPI $item * @param integer $tabnum number of the tab to display * @param integer $withtemplate 1 if is a template form * @return boolean @@ -174,7 +174,9 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $ /** * Display criteria form + list of computers * - * @param object $item PluginGlpiinventoryDeployGroup instance + * @param PluginGlpiinventoryDeployGroup $item PluginGlpiinventoryDeployGroup instance + * + * @return void */ public static function showCriteriaAndSearch(PluginGlpiinventoryDeployGroup $item) { @@ -188,7 +190,7 @@ public static function showCriteriaAndSearch(PluginGlpiinventoryDeployGroup $ite // WITHOUT checking post values $search_params = PluginGlpiinventoryDeployGroup::getSearchParamsAsAnArray($item, false); //If metacriteria array is empty, remove it as it displays the metacriteria form, - //and it's is not we want ! + //and it is not we want ! if (isset($search_params['metacriteria']) && empty($search_params['metacriteria'])) { unset($search_params['metacriteria']); } @@ -250,9 +252,9 @@ public static function getDatas($itemtype, $params, array $forcedisplay = []) * * @since 0.85+1.0 * - * @param group the group object - * @param use_cache retrieve computers_id from cache (computers_id_cache field) - * @return an array of computer ids + * @param PluginGlpiinventoryDeployGroup $group the group object + * @param boolean $use_cache retrieve computers_id from cache (computers_id_cache field) + * @return array of computer ids */ public static function getTargetsByGroup(PluginGlpiinventoryDeployGroup $group, $use_cache = false) { @@ -338,9 +340,9 @@ public static function retrieveCache(PluginGlpiinventoryDeployGroup $group) /** * Duplicate entries from one group to another - * @param $source_deploygroups_id the source group ID - * @param $target_deploygroups_id the target group ID - * @return the duplication status, as a boolean + * @param integer $source_deploygroups_id the source group ID + * @param integer $target_deploygroups_id the target group ID + * @return boolean the duplication status */ public static function duplicate($source_deploygroups_id, $target_deploygroups_id) { diff --git a/inc/deploygroup_staticdata.class.php b/inc/deploygroup_staticdata.class.php index eb6e995a39..bc8d8eaa57 100644 --- a/inc/deploygroup_staticdata.class.php +++ b/inc/deploygroup_staticdata.class.php @@ -79,7 +79,7 @@ class PluginGlpiinventoryDeployGroup_Staticdata extends CommonDBRelation /** * Get the tab name used for item * - * @param object $item the item object + * @param CommonGLPI $item the item object * @param integer $withtemplate 1 if is a template form * @return string|array name of the tab */ @@ -88,7 +88,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) if ( !$withtemplate - && ($item->getType() == 'PluginGlpiinventoryDeployGroup') + && ($item instanceof PluginGlpiinventoryDeployGroup) && $item->fields['type'] == PluginGlpiinventoryDeployGroup::STATIC_GROUP ) { $tabs[1] = _n('Criterion', 'Criteria', 2); @@ -114,7 +114,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) /** * Display the content of the tab * - * @param object $item + * @param CommonGLPI $item * @param integer $tabnum number of the tab to display * @param integer $withtemplate 1 if is a template form * @return boolean @@ -141,7 +141,7 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $ /** * Display criteria form + list of computers * - * @param object $item PluginGlpiinventoryDeployGroup instance + * @param PluginGlpiinventoryDeployGroup $item PluginGlpiinventoryDeployGroup instance */ public static function showCriteriaAndSearch(PluginGlpiinventoryDeployGroup $item) { @@ -291,9 +291,9 @@ public static function showResults(PluginGlpiinventoryDeployGroup $item) /** * Duplicate entries from one group to another - * @param $source_deploygroups_id the source group ID - * @param $target_deploygroups_id the target group ID - * @return the duplication status, as a boolean + * @param integer $source_deploygroups_id the source group ID + * @param integer $target_deploygroups_id the target group ID + * @return boolean the duplication status */ public static function duplicate($source_deploygroups_id, $target_deploygroups_id) { @@ -318,7 +318,7 @@ public static function duplicate($source_deploygroups_id, $target_deploygroups_i * * @since 9.2+2.0 * - * @param object $item it's an instance of PluginGlpiinventoryDeployGroup class + * @param PluginGlpiinventoryDeployGroup $item it's an instance of PluginGlpiinventoryDeployGroup class * * @return boolean */ diff --git a/inc/deploymirror.class.php b/inc/deploymirror.class.php index e49530d1a6..df0b5f504d 100644 --- a/inc/deploymirror.class.php +++ b/inc/deploymirror.class.php @@ -333,7 +333,7 @@ public function getSpecificMassiveActions($checkitem = null) /** * Display form related to the massive action selected * - * @param object $ma MassiveAction instance + * @param MassiveAction $ma MassiveAction instance * @return boolean */ public static function showMassiveActionsSubForm(MassiveAction $ma) @@ -350,8 +350,8 @@ public static function showMassiveActionsSubForm(MassiveAction $ma) /** * Execution code for massive action * - * @param object $ma MassiveAction instance - * @param object $item item on which execute the code + * @param MassiveAction $ma MassiveAction instance + * @param CommonDBTM $item item on which execute the code * @param array $ids list of ID on which execute the code */ public static function processMassiveActionsForOneItemtype( diff --git a/inc/deploypackage.class.php b/inc/deploypackage.class.php index ed28eee07b..44e30412ae 100644 --- a/inc/deploypackage.class.php +++ b/inc/deploypackage.class.php @@ -123,7 +123,7 @@ public function getFromDB($ID) * * Also call canUpdateItem() * - * @return booleen + * @return boolean **/ public function canUpdateContent() { @@ -179,7 +179,7 @@ public function getForbiddenStandardMassiveAction() /** * Display form related to the massive action selected * - * @param object $ma MassiveAction instance + * @param MassiveAction $ma MassiveAction instance * @return boolean */ public static function showMassiveActionsSubForm(MassiveAction $ma) @@ -204,13 +204,13 @@ public static function showMassiveActionsSubForm(MassiveAction $ma) /** * Execution code for massive action * - * @param object $ma MassiveAction instance - * @param object $item item on which execute the code + * @param MassiveAction $ma MassiveAction instance + * @param CommonDBTM $item item on which execute the code * @param array $ids list of ID on which execute the code */ public static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { - + /** @var PluginGlpiinventoryDeployPackage $item */ switch ($ma->getAction()) { case 'export': foreach ($ids as $key) { @@ -391,7 +391,7 @@ public function rawSearchOptions() /** * Get all packages in json format * - * @return json + * @return string json */ public function getAllDatas() { @@ -1014,7 +1014,7 @@ public static function updateOrderJson($packages_id, $datas) /** * Get the tab name used for item * - * @param object $item the item object + * @param CommonGLPI $item the item object * @param integer $withtemplate 1 if is a template form * @return string name of the tab */ @@ -1022,8 +1022,8 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { if (!$withtemplate) { - switch ($item->getType()) { - case __CLASS__: + switch (get_class($item)) { + case self::class: if ($item->canUpdateItem()) { $tabs = []; if ($item->fields['id'] > 0) { @@ -1054,7 +1054,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) } break; - case 'Computer': + case Computer::class: if ( Session::haveRight("plugin_glpiinventory_selfpackage", READ) && PluginGlpiinventoryToolbox::isAnInventoryDevice($item) @@ -1072,7 +1072,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) /** * Display the content of the tab * - * @param object $item + * @param CommonGLPI $item * @param integer $tabnum number of the tab to display * @param integer $withtemplate 1 if is a template form * @return boolean @@ -1080,7 +1080,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { - if ($item->getType() == __CLASS__) { + if ($item instanceof self) { if ($tabnum == 2) { $item->showVisibility(); return true; @@ -1088,7 +1088,7 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $ $item->displayOrderTypeForm(); return true; } - } elseif ($item->getType() == 'Computer') { + } elseif ($item instanceof Computer) { $package = new self(); $package->showPackageForMe($_SESSION['glpiID'], $item); return true; @@ -1359,7 +1359,7 @@ public function post_getFromDB() /** * Get all available states for a package - * @return an array of states and their labels + * @return array of states and their labels */ public static function getPackageDeploymentStates() { @@ -1375,8 +1375,8 @@ public static function getPackageDeploymentStates() /** * Get a label for a state - * @param state the state - * @return the label associated to a state + * @param string $state the state + * @return string the label associated to a state */ public static function getDeploymentLabelForAState($state) { @@ -1930,13 +1930,13 @@ public function deployToComputer($computers_id, $packages_id, $users_id) * Get all packages that a user has requested to install * on one of it's computer * - * @global object $DB * @param array $computers_packages - * @param integer $users_id + * @param false|integer $users_id * @return array */ public function getMyDepoyPackages($computers_packages, $users_id = false) { + /** @var DBmysql $DB */ global $DB; // Get packages yet deployed by enduser @@ -2148,8 +2148,8 @@ public function canUserDeploySelf() /** * Duplicate a deploy package - * @param $deploypackages_id the ID of the package to duplicate - * @return duplication process status + * @param integer $deploypackages_id the ID of the package to duplicate + * @return boolean duplication process status */ public function duplicate($deploypackages_id) { diff --git a/inc/deploypackage_entity.class.php b/inc/deploypackage_entity.class.php index 39cca86082..8990debb28 100644 --- a/inc/deploypackage_entity.class.php +++ b/inc/deploypackage_entity.class.php @@ -78,7 +78,7 @@ class PluginGlpiinventoryDeployPackage_Entity extends CommonDBRelation /** * Logs for the second item are disabled * - * @var type + * @var boolean */ public static $logs_for_item_2 = false; diff --git a/inc/deploypackage_group.class.php b/inc/deploypackage_group.class.php index a287c9a656..281acfaf23 100644 --- a/inc/deploypackage_group.class.php +++ b/inc/deploypackage_group.class.php @@ -78,7 +78,7 @@ class PluginGlpiinventoryDeployPackage_Group extends CommonDBRelation /** * Logs for the second item are disabled * - * @var type + * @var boolean */ public static $logs_for_item_2 = false; diff --git a/inc/deploypackage_profile.class.php b/inc/deploypackage_profile.class.php index 02ee70660b..dbf18d5b7c 100644 --- a/inc/deploypackage_profile.class.php +++ b/inc/deploypackage_profile.class.php @@ -78,7 +78,7 @@ class PluginGlpiinventoryDeployPackage_Profile extends CommonDBRelation /** * Logs for the second item are disabled * - * @var type + * @var boolean */ public static $logs_for_item_2 = false; diff --git a/inc/deploypackage_user.class.php b/inc/deploypackage_user.class.php index 0715837639..59d1a16656 100644 --- a/inc/deploypackage_user.class.php +++ b/inc/deploypackage_user.class.php @@ -78,7 +78,7 @@ class PluginGlpiinventoryDeployPackage_User extends CommonDBRelation /** * Logs for the second item are disabled * - * @var type + * @var boolean */ public static $logs_for_item_2 = false; diff --git a/inc/deploypackageitem.class.php b/inc/deploypackageitem.class.php index 17995a1dba..5e25ecf1a7 100644 --- a/inc/deploypackageitem.class.php +++ b/inc/deploypackageitem.class.php @@ -56,7 +56,7 @@ class PluginGlpiinventoryDeployPackageItem extends CommonDBTM /** * Get an event label by its identifier * @since 9.2 - * @return array + * @return false|string */ public function getLabelForAType($type) { @@ -72,8 +72,8 @@ public function getLabelForAType($type) /** * Get the types already in used, so they cannot be selected anymore * @since 9.2 - * @param $package the package to check - * @return the types already in used + * @param PluginGlpiinventoryDeployPackage $package the package to check + * @return array the types already in used */ public function getTypesAlreadyInUse(PluginGlpiinventoryDeployPackage $package) { @@ -85,7 +85,7 @@ public function getTypesAlreadyInUse(PluginGlpiinventoryDeployPackage $package) * Display the dropdown to select type of element * * @global array $CFG_GLPI - * @param object $package the package + * @param PluginGlpiinventoryDeployPackage $package the package * @param array $config order item configuration * @param string $rand unique element id used to identify/update an element * @param string $mode mode in use (create, edit...) @@ -172,7 +172,7 @@ public function getItemConfig(PluginGlpiinventoryDeployPackage $package, $reques /** * Display form * - * @param object $package PluginGlpiinventoryDeployPackage instance + * @param PluginGlpiinventoryDeployPackage $package PluginGlpiinventoryDeployPackage instance * @param array $request_data * @param string $rand unique element id used to identify/update an element * @param string $mode possible values: init|edit|create @@ -234,7 +234,7 @@ public function displayForm( /** * Get an HTML mandatory mark (a red star) * @since 9.2 - * @return the html code for a red star + * @return string the html code for a red star */ public function getMandatoryMark() { @@ -243,12 +243,15 @@ public function getMandatoryMark() /** - * Common method to add an item to the package JSON definition - * - * @since 9.2 - * @param id the package ID - * @param item the item to add to the package definition - */ + * Common method to add an item to the package JSON definition + * + * @since 9.2 + * @param integer $id the package ID + * @param string $item the item to add to the package definition + * @param integer $order the order of the item + * + * @return void + */ public function addToPackage($id, $item, $order) { //get current json package defintion @@ -426,8 +429,10 @@ public function processFilesize($filesize) * Display a add or save button * @since 9.2 * - * @param pfDeployPackage the package in use - * @param mode the mode (edit or create) + * @param PluginGlpiinventoryDeployPackage $pfDeployPackage the package in use + * @param string $mode the mode (edit or create) + * + * @return void */ public function addOrSaveButton(PluginGlpiinventoryDeployPackage $pfDeployPackage, $mode) { diff --git a/inc/deploytask.class.php b/inc/deploytask.class.php index c462fbfcaa..74ed7797e3 100644 --- a/inc/deploytask.class.php +++ b/inc/deploytask.class.php @@ -102,7 +102,7 @@ public function defineTabs($options = []) /** * Get the tab name used for item * - * @param object $item the item object + * @param CommonGLPI $item the item object * @param integer $withtemplate 1 if is a template form * @return string name of the tab */ @@ -120,7 +120,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) /** * Display the content of the tab * - * @param object $item + * @param CommonGLPI $item * @param integer $tabnum number of the tab to display * @param integer $withtemplate 1 if is a template form * @return boolean diff --git a/inc/deployuserinteraction.class.php b/inc/deployuserinteraction.class.php index 28a78bf843..9310aa4c2f 100644 --- a/inc/deployuserinteraction.class.php +++ b/inc/deployuserinteraction.class.php @@ -109,9 +109,9 @@ public function getTypes() /** - * Get an event label by it's identifier + * Get an event label by its identifier * @since 9.2 - * @return array + * @return string */ public function getLabelForAType($event) { @@ -244,13 +244,13 @@ public function getValues($type, $data, $mode) /** * Display list of user interactions * - * @global array $CFG_GLPI - * @param object $package PluginGlpiinventoryDeployPackage instance + * @param PluginGlpiinventoryDeployPackage $package PluginGlpiinventoryDeployPackage instance * @param array $data array converted of 'json' field in DB where stored checks * @param string $rand unique element id used to identify/update an element */ public function displayList(PluginGlpiinventoryDeployPackage $package, $data, $rand) { + /** @var array $CFG_GLPI */ global $CFG_GLPI; $interaction_types = $this->getTypes(); @@ -306,8 +306,8 @@ public function displayList(PluginGlpiinventoryDeployPackage $package, $data, $r * Get of a short description of a user interaction * * @since 9.2 - * @param interaction an array representing an interaction - * @return a short description + * @param string $interaction an array representing an interaction + * @return string a short description */ public function getInteractionDescription($interaction) { @@ -391,6 +391,10 @@ public function save_item($params) } + /** + * @param PluginGlpiinventoryDeployPackage $package + * @return array + */ public function getTypesAlreadyInUse(PluginGlpiinventoryDeployPackage $package) { $used_interactions = []; @@ -414,11 +418,11 @@ public function getTypesAlreadyInUse(PluginGlpiinventoryDeployPackage $package) * Get a log message depending on an agent response * @since 9.2 * - * @param behavior the behavior the agent must adopt for the job - * @param type the type of event that triggered the user interaction - * @param $event the button clicked by the user + * @param string $behavior the behavior the agent must adopt for the job + * @param string $type the type of event that triggered the user interaction + * @param string $event the button clicked by the user * (or the what's happened in special cases, as defined in a template) - * @param user userid the user who performed the interaction + * @param integer $user userid the user who performed the interaction * @return string the message to be display in a taskjob log */ public function getLogMessage($behavior, $type, $event, $user) diff --git a/inc/deployuserinteractiontemplate.class.php b/inc/deployuserinteractiontemplate.class.php index 96f4964fe5..0cf8ddd39b 100644 --- a/inc/deployuserinteractiontemplate.class.php +++ b/inc/deployuserinteractiontemplate.class.php @@ -84,9 +84,6 @@ class PluginGlpiinventoryDeployUserinteractionTemplate extends CommonDropdown const WTS_ICON_ERROR = 'error'; - /** - * @see CommonGLPI::defineTabs() - **/ public function defineTabs($options = []) { @@ -98,9 +95,6 @@ public function defineTabs($options = []) } - /** - * @see CommonGLPI::getTabNameForItem() - **/ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { $tabs[1] = __('General'); @@ -116,9 +110,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) **/ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { - global $CFG_GLPI; - - if ($item->getType() == __CLASS__) { + if ($item instanceof self) { switch ($tabnum) { case 1: $item->showForm($item->fields['id']); @@ -167,7 +159,7 @@ public static function getTypes() * Get available buttons for alerts, by interaction type * * @since 9.2 - * @param interaction_type the type of interaction + * @param string $interaction_type the type of interaction * @return array */ public static function getButtons($interaction_type = '') @@ -196,7 +188,7 @@ public static function getButtons($interaction_type = '') * Get available icons for alerts, by interaction type * * @since 9.2 - * @param interaction_type the type of interaction + * @param string $interaction_type the type of interaction * @return array */ public static function getIcons($interaction_type = self::ALERT_WTS) @@ -237,8 +229,10 @@ public static function getBehaviors() * Display a dropdown with the list of available behaviors * * @since 9.2 - * @param type the type of bahaviors (if one already selected) - * @return rand + * @param string $name the name of the dropdown + * @param string $behavior the default behavior + * + * @return integer */ public function dropdownBehaviors($name, $behavior = self::BEHAVIOR_CONTINUE_DEPLOY) { @@ -251,10 +245,10 @@ public function dropdownBehaviors($name, $behavior = self::BEHAVIOR_CONTINUE_DEP /** - * Get the fields to be encoded in json - * @since 9.2 - * @return an array of field names - */ + * Get the fields to be encoded in json + * @since 9.2 + * @return array of field names + */ public function getJsonFields() { return array_merge( @@ -265,10 +259,10 @@ public function getJsonFields() /** - * Get the fields to be encoded in json - * @since 9.2 - * @return an array of field names - */ + * Get the fields to be encoded in json + * @since 9.2 + * @return array of field names + */ public function getMainFormFields() { return ['platform', 'timeout', 'buttons', 'icon', @@ -277,10 +271,10 @@ public function getMainFormFields() /** - * Get the fields to be encoded in json - * @since 9.2 - * @return an array of field names - */ + * Get the fields to be encoded in json + * @since 9.2 + * @return array of field names + */ public function getBehaviorsFields() { return ['on_timeout', 'on_nouser', 'on_multiusers', 'on_ok', 'on_no', @@ -290,11 +284,12 @@ public function getBehaviorsFields() /** - * Initialize json fields - * @since 9.2 - * - * @return an array of field names - */ + * Initialize json fields + * @since 9.2 + * + * @param array $json_fields the json fields + * @return array of field names + */ public function initializeJsonFields($json_fields) { foreach ($this->getJsonFields() as $field) { @@ -309,8 +304,8 @@ public function initializeJsonFields($json_fields) /** * Save form data as a json encoded array * @since 9.2 - * @param params form parameters - * @return json encoded array + * @param array $params form parameters + * @return string json encoded array */ public function saveToJson($params = []) { @@ -328,8 +323,9 @@ public function saveToJson($params = []) * Add the json template fields to package * * @since 9.2 - * @param the input array - * @param array now containing input data + data from the template + * @param array $params the input array + * + * @return array now containing input data + data from the template */ public function addJsonFieldsToArray($params = []) { @@ -354,8 +350,8 @@ public function addJsonFieldsToArray($params = []) /** * Display an interaction template form * @since 9.2 - * @param $id id of a template to edit - * @param options POST form options + * @param integer $id id of a template to edit + * @param array $options POST form options */ public function showForm($id, $options = []) { @@ -562,7 +558,8 @@ public function getDefaultBehaviorForAButton($button) * Show behaviors form * * @since 9.2 - * @param ID the template's ID + * + * @param integer $ID the template's ID */ public function showBehaviors($ID) { diff --git a/inc/display.class.php b/inc/display.class.php index 808cf048fe..b4f02f5fbe 100644 --- a/inc/display.class.php +++ b/inc/display.class.php @@ -49,7 +49,7 @@ class PluginGlpiinventoryDisplay extends CommonDBTM * @param integer $width * @param integer $height */ - public static function bar($percentage, $message = '', $order = '', $width = '400', $height = '20') + public static function bar($percentage, $message = '', $order = '', $width = 400, $height = 20) { if ((!empty($percentage)) and ($percentage < 0)) { $percentage = ""; diff --git a/inc/iprange_snmpcredential.class.php b/inc/iprange_snmpcredential.class.php index 2a0a81c99a..c68addb961 100644 --- a/inc/iprange_snmpcredential.class.php +++ b/inc/iprange_snmpcredential.class.php @@ -86,13 +86,13 @@ class PluginGlpiinventoryIPRange_SNMPCredential extends CommonDBRelation /** * Get the tab name used for item * - * @param object $item the item object + * @param CommonGLPI $item the item object * @param integer $withtemplate 1 if is a template form * @return string name of the tab */ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { - + /** @var CommonDBTM $item */ if ($item->fields['id'] > 0) { $nb = 0; if ($_SESSION['glpishow_count_on_tabs']) { @@ -112,7 +112,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) /** * Display the content of the tab * - * @param object $item + * @param CommonGLPI $item * @param integer $tabnum number of the tab to display * @param integer $withtemplate 1 if is a template form * @return true @@ -141,7 +141,7 @@ public function getForbiddenStandardMassiveAction() /** * Display form * - * @param object $item + * @param CommonDBTM $item * @param array $options * @return boolean */ diff --git a/inc/networkdiscovery.class.php b/inc/networkdiscovery.class.php index 9cb11c2965..68a226243a 100644 --- a/inc/networkdiscovery.class.php +++ b/inc/networkdiscovery.class.php @@ -263,8 +263,8 @@ public function run($jobstate) $first_ip = $pfIPRange->getIp2long($pfIPRange->fields["ip_start"]); - $last_ip = long2ip($first_ip + $a_split[1]); - $first_ip = long2ip($first_ip + $a_split[0]); + $last_ip = long2ip($first_ip + (int)$a_split[1]); + $first_ip = long2ip($first_ip + (int)$a_split[0]); if ($first_ip != '0.0.0.0' && $last_ip != '0.0.0.0') { $iprange_attrs['IPSTART'] = $first_ip; $iprange_attrs['IPEND'] = $last_ip; diff --git a/inc/profile.class.php b/inc/profile.class.php index 7e4741953d..f4b602460b 100644 --- a/inc/profile.class.php +++ b/inc/profile.class.php @@ -111,7 +111,7 @@ public static function getOldRightsMappings() /** * Get the tab name used for item * - * @param object $item the item object + * @param CommonGLPI $item the item object * @param integer $withtemplate 1 if is a template form * @return string name of the tab */ @@ -124,7 +124,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) /** * Display the content of the tab * - * @param object $item + * @param CommonGLPI $item * @param integer $tabnum number of the tab to display * @param integer $withtemplate 1 if is a template form * @return boolean @@ -132,6 +132,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { $pfProfile = new self(); + /** @var CommonDBTM $item */ if ($item->fields['interface'] == 'central') { $pfProfile->showForm($item->fields['id']); } else { diff --git a/inc/staticmisc.class.php b/inc/staticmisc.class.php index 50c38f8d7b..5bb1ece020 100644 --- a/inc/staticmisc.class.php +++ b/inc/staticmisc.class.php @@ -183,7 +183,7 @@ public static function task_definitiontype_InventoryComputerESX($a_itemtype) * defined in task_definitiontype_InventoryComputerESX * * @global object $DB - * @param string (not used) + * @param string $title (not used) * @return string unique html element id */ public static function task_definitionselection_PluginGlpiinventoryCredentialIp_InventoryComputerESX($title) @@ -518,7 +518,6 @@ public static function task_definitiontype_deployinstall($a_itemtype) * Get all packages of definition type 'PluginGlpiinventoryDeployPackage' * defined in task_definitiontype_deployinstall * - * @param string $title (not used) * @return string unique html element id */ public static function task_definitionselection_PluginGlpiinventoryDeployPackage_deployinstall() @@ -652,7 +651,6 @@ public static function task_definitiontype_collect($a_itemtype) * Get all collects of definition type 'PluginGlpiinventoryCollect' * defined in task_definitiontype_collect * - * @param string (not used) * @return string unique html element id */ public static function task_definitionselection_PluginGlpiinventoryCollect_collect() diff --git a/inc/task.class.php b/inc/task.class.php index 1996d7fa5f..add588cccd 100644 --- a/inc/task.class.php +++ b/inc/task.class.php @@ -169,12 +169,13 @@ public function rawSearchOptions() /** * Get the tab name used for item * - * @param object $item the item object + * @param CommonGLPI $item the item object * @param integer $withtemplate 1 if is a template form * @return string name of the tab */ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { + /** @var CommonDBTM $item */ if ($item->fields['id'] > 0) { $nb = 0; if ($_SESSION['glpishow_count_on_tabs']) { @@ -189,7 +190,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) /** * Display the content of the tab * - * @param object $item + * @param CommonGLPI $item * @param integer $tabnum number of the tab to display * @param integer $withtemplate 1 if is a template form * @return true @@ -205,7 +206,7 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $ /** * Display form * - * @param object $item + * @param CommonDBTM $item * @param array $options * @return boolean */ @@ -344,7 +345,7 @@ public static function cleanTasksbyMethod($method) * * @global object $DB * @param integer $agent_id - * @param string $methods + * @param array $methods * @param array $options * @return array */ @@ -648,8 +649,8 @@ public static function cronCleanOnDemand($task = null) /** * Get all on demand tasks to clean - * @param $interval number of days to look for successful tasks - * @return an array of tasks ID to clean + * @param integer $interval number of days to look for successful tasks + * @return array of tasks ID to clean */ public function cleanTasksAndJobs($interval) { @@ -733,9 +734,9 @@ public function cleanTasksAndJobs($interval) /** * Give cron information * - * @param $name : task's name + * @param string $name task's name * - * @return arrray of information + * @return array **/ public static function cronInfo($name) { @@ -1654,7 +1655,7 @@ public function getSpecificMassiveActions($checkitem = null) * Display form related to the massive action selected * * @global array $CFG_GLPI - * @param object $ma MassiveAction instance + * @param MassiveAction $ma MassiveAction instance * @return boolean */ public static function showMassiveActionsSubForm(MassiveAction $ma) @@ -1755,8 +1756,8 @@ public static function showMassiveActionsSubForm(MassiveAction $ma) /** * Execution code for massive action * - * @param object $ma MassiveAction instance - * @param object $item item on which execute the code + * @param MassiveAction $ma MassiveAction instance + * @param CommonDBTM $item item on which execute the code * @param array $ids list of ID on which execute the code */ public static function processMassiveActionsForOneItemtype( @@ -1936,8 +1937,8 @@ public static function processMassiveActionsForOneItemtype( /** * Duplicate a task - * @param $source_tasks_id the ID of the task to duplicate - * @return void + * @param integer $source_tasks_id the ID of the task to duplicate + * @return boolean */ public function duplicate($source_tasks_id) { diff --git a/inc/taskjob.class.php b/inc/taskjob.class.php index 608afc4745..efffef4c27 100644 --- a/inc/taskjob.class.php +++ b/inc/taskjob.class.php @@ -674,7 +674,7 @@ public function CronCheckRunnningJobs() 'FROM' => 'glpi_plugin_glpiinventory_taskjobs', 'WHERE' => [ 'status' => 1, - new \QueryExpression($sub_query->getSQL() . ' = 0') + new \QueryExpression($sub_query->getQuery() . ' = 0') ] ]); @@ -889,7 +889,7 @@ public function additemtodefatc($type, $itemtype, $items_id, $taskjobs_id) * * @global array $CFG_GLPI * @param string $type - * @param string $items_id + * @param string $a_items_id * @param integer $taskjobs_id */ public function deleteitemtodefatc($type, $a_items_id, $taskjobs_id) @@ -1215,8 +1215,8 @@ public function getSpecificMassiveActions($checkitem = null) /** * Execution code for massive action * - * @param object $ma MassiveAction instance - * @param object $item item on which execute the code + * @param MassiveAction $ma MassiveAction instance + * @param CommonDBTM $item item on which execute the code * @param array $ids list of ID on which execute the code */ public static function processMassiveActionsForOneItemtype( diff --git a/inc/taskjobstate.class.php b/inc/taskjobstate.class.php index 7955b53c9d..aba8b686a9 100644 --- a/inc/taskjobstate.class.php +++ b/inc/taskjobstate.class.php @@ -110,7 +110,7 @@ class PluginGlpiinventoryTaskjobstate extends CommonDBTM /** * Get the tab name used for item * - * @param object $item the item object + * @param CommonGLPI $item the item object * @param integer $withtemplate 1 if is a template form * @return string name of the tab */ @@ -150,17 +150,17 @@ public static function getStateNames() /** * Display the content of the tab * - * @param object $item + * @param CommonGLPI $item * @param integer $tabnum number of the tab to display * @param integer $withtemplate 1 if is a template form * @return boolean */ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { - if ($item->getType() == 'PluginGlpiinventoryTask') { + if ($item instanceof PluginGlpiinventoryTask) { $item->showJobLogs(); return true; - } elseif ($item->getType() == 'Computer') { + } elseif ($item instanceof Computer) { $pfTaskJobState = new PluginGlpiinventoryTaskjobstate(); $pfTaskJobState->showStatesForComputer($item->fields['id']); echo "
"; @@ -596,7 +596,7 @@ public static function cronCleantaskjob() /** * Fill a taskjobstate by it's uuid * @since 9.2 - * @param uniqid taskjobstate's uniqid + * @param string $uniqid taskjobstate's uniqid */ public function getFromDBByUniqID($uniqid) { diff --git a/inc/taskjobview.class.php b/inc/taskjobview.class.php index 33992de873..8f0c65fc8e 100644 --- a/inc/taskjobview.class.php +++ b/inc/taskjobview.class.php @@ -58,13 +58,14 @@ public function __construct() /** * Get the tab name used for item * - * @param object $item the item object + * @param CommonGLPI $item the item object * @param integer $withtemplate 1 if is a template form * @return string name of the tab */ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { $tab_names = []; + /** @var CommonDBTM $item */ if ($item->fields['id'] > 0 and $this->can('task', READ)) { return __('Job configuration', 'glpiinventory'); } @@ -75,7 +76,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) /** * Display the content of the tab * - * @param object $item + * @param CommonGLPI $item * @param integer $tabnum number of the tab to display * @param integer $withtemplate 1 if is a template form * @return boolean @@ -85,25 +86,23 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $ $pfTaskJob = new PluginGlpiinventoryTaskjob(); - if ($item->fields['id'] > 0) { - if ($item->getType() == 'PluginGlpiinventoryTask') { - //keep this code for multi task job if reintroduced - //echo "
"; - //echo "
"; - //echo "
"; - //$pfTaskJob->showListForTask($item->fields['id']); - //echo "
"; - - //display the unique job attached to task if needed - $taskjobs = $pfTaskJob->getTaskjobs($item->fields['id']); - $taskjob_id = 0; - if (count($taskjobs)) { - $taskjob_id = reset($taskjobs)['id']; - } - $pfTaskJob->showForm($taskjob_id, ['task_id' => $item->fields['id']]); - - return true; + if ($item instanceof PluginGlpiinventoryTask && $item->fields['id'] > 0) { + //keep this code for multi task job if reintroduced + //echo "
"; + //echo "
"; + //echo "
"; + //$pfTaskJob->showListForTask($item->fields['id']); + //echo "
"; + + //display the unique job attached to task if needed + $taskjobs = $pfTaskJob->getTaskjobs($item->fields['id']); + $taskjob_id = 0; + if (count($taskjobs)) { + $taskjob_id = reset($taskjobs)['id']; } + $pfTaskJob->showForm($taskjob_id, ['task_id' => $item->fields['id']]); + + return true; } return false; } diff --git a/inc/taskview.class.php b/inc/taskview.class.php index f2e797f369..2e5d2fc64c 100644 --- a/inc/taskview.class.php +++ b/inc/taskview.class.php @@ -524,7 +524,7 @@ public function rawSearchOptions() } /** - * Export a list of jobs in CSV format + * Export a list of jobs in CSV format, and download file * * @param array $params these possible entries: * - agent_state_types: array of agent states to filter output @@ -534,7 +534,7 @@ public function rawSearchOptions() * - 1 : display params AND html table, * - 2: like 1 + display also json of jobs logs * - * @return nothing (force a download of csv) + * @return void */ public function csvExport($params = []) { @@ -711,13 +711,13 @@ public function forceRunning() /** * Prepare task jobs * - * @global object $DB * @param array $methods - * @param string $task_id; the concerned task + * @param false|integer $tasks_id the concerned task * @return true */ public function prepareTaskjobs($methods = [], $tasks_id = false) { + /** @var DBmysql $DB */ global $DB; $now = new DateTime(); diff --git a/inc/timeslot.class.php b/inc/timeslot.class.php index ac39a7aae9..2df969d4ac 100644 --- a/inc/timeslot.class.php +++ b/inc/timeslot.class.php @@ -243,7 +243,7 @@ public function getCurrentActiveTimeslots() * * @since 0.85+1.0 * - * @param null|object $datetime The date and time we want to transform into + * @param DateTime $datetime The date and time we want to transform into * cursor. If null the default value is now() * @return integer */ diff --git a/phpstan.neon b/phpstan.neon index 7d28e224ae..a9cb812c2c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,7 +1,7 @@ parameters: parallel: maximumNumberOfProcesses: 2 - level: 1 + level: 2 bootstrapFiles: - ../../inc/based_config.php - setup.php