Skip to content

Commit

Permalink
phpstan lvl 5
Browse files Browse the repository at this point in the history
  • Loading branch information
trasher committed Nov 13, 2023
1 parent bcbea88 commit 26b6065
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 23 deletions.
14 changes: 4 additions & 10 deletions inc/config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ public static function getTypeName($nb = 0)
return __('General setup of useditemsexport', 'useditemsexport');
}

/**
* Print the config form
*
* @param $ID Integer : ID of the item
* @param $options array
*
* @return void (display)
**/
public function showForm($ID, $options = [])
{

Expand Down Expand Up @@ -89,11 +81,13 @@ public function showForm($ID, $options = [])
echo "</tr>";

$this->showFormButtons($options);

return true;
}

/**
* Show dropdown Orientation (Landscape / Portrait)
* @param value (current preselected value)
* @param string $value (current preselected value)
* @return void (display dropdown)
*/
public function dropdownOrientation($value)
Expand All @@ -109,7 +103,7 @@ public function dropdownOrientation($value)

/**
* Show dropdown Format (A4, A3, etc...)
* @param value (current preselected value)
* @param string $value (current preselected value)
* @return void (display dropdown)
*/
public function dropdownFormat($value)
Expand Down
18 changes: 7 additions & 11 deletions inc/export.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static function getTypeName($nb = 0)
public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
{

if ($item->getType() == 'User') {
if ($item instanceof User) {
if ($_SESSION['glpishow_count_on_tabs']) {
return self::createTabEntry(self::getTypeName(), self::countForItem($item));
}
Expand All @@ -63,7 +63,7 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $
/** @var array $CFG_GLPI */
global $CFG_GLPI;

if ($item->getType() == 'User') {
if ($item instanceof User) {
if (Session::haveRightsOr('plugin_useditemsexport_export', [READ, CREATE, PURGE])) {
$PluginUseditemsexportExport = new self();
$PluginUseditemsexportExport->showForUser($item);
Expand Down Expand Up @@ -212,7 +212,7 @@ public function showForUser($item, $options = [])
*
* @param $users_id user ID
*
* @return array of exports
* @return boolean
**/
public static function generatePDF($users_id)
{
Expand Down Expand Up @@ -389,7 +389,7 @@ public static function generatePDF($users_id)

/**
* Store Document into GLPi DB
* @param refnumber
* @param string $refnumber
* @return integer id of Document
*/
public static function createDocument($refnumber)
Expand All @@ -414,7 +414,6 @@ public static function createDocument($refnumber)

/**
* Get next num
* @param nothing
* @return integer
*/
public static function getNextNum()
Expand All @@ -433,13 +432,10 @@ public static function getNextNum()
$nextNum++;
return $nextNum;
}

return false;
}

/**
* Compute next refnumber
* @param nothing
* @return string
*/
public static function getNextRefnumber()
Expand All @@ -448,17 +444,17 @@ public static function getNextRefnumber()
global $DB;

if ($nextNum = self::getNextNum()) {
$nextRefnumber = str_pad($nextNum, 4, "0", STR_PAD_LEFT);
$nextRefnumber = str_pad((string)$nextNum, 4, "0", STR_PAD_LEFT);
$date = new DateTime();
return $nextRefnumber . '-' . $date->format('Y');
} else {
return false;
return '';
}
}

/**
* Get all used items for user
* @param ID of user
* @param integer $ID ID of user
* @return array
*/
public static function getAllUsedItemsForUser($ID)
Expand Down
2 changes: 1 addition & 1 deletion inc/profile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class PluginUseditemsexportProfile extends CommonDBTM
public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
{

if ($item->getType() == 'Profile' && $item->getField('interface') != 'helpdesk') {
if ($item instanceof Profile && $item->getField('interface') != 'helpdesk') {
return PluginUseditemsexportExport::getTypeName();
}
return '';
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
parameters:
parallel:
maximumNumberOfProcesses: 2
level: 1
level: 5
bootstrapFiles:
- ../../inc/based_config.php
paths:
Expand Down

0 comments on commit 26b6065

Please sign in to comment.