Skip to content

Commit

Permalink
phpstan lvl 2
Browse files Browse the repository at this point in the history
  • Loading branch information
trasher committed Dec 12, 2023
1 parent 97eaf13 commit 8a2742b
Show file tree
Hide file tree
Showing 38 changed files with 229 additions and 216 deletions.
8 changes: 4 additions & 4 deletions inc/agentmodule.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -71,19 +71,19 @@ 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() == '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;
Expand Down
9 changes: 5 additions & 4 deletions inc/collect.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion inc/collect_file_content.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions inc/collect_registry_content.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
6 changes: 4 additions & 2 deletions inc/collectcommon.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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
Expand All @@ -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']);

Expand Down
6 changes: 3 additions & 3 deletions inc/collectcontentcommon.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion inc/communicationnetworkdiscovery.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions inc/communicationnetworkinventory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions inc/computer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions inc/config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions inc/deployaction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
20 changes: 10 additions & 10 deletions inc/deploycheck.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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()
{
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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()
{
Expand All @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion inc/deployfile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
16 changes: 9 additions & 7 deletions inc/deploygroup.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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(
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 8a2742b

Please sign in to comment.