Skip to content

Commit 45ac61c

Browse files
fix: PHPStan warnings in findContainers()
- Added missing @var annotation for global $DB - Replaced empty() on $entityIds with count() - Removed redundant is_array() check on $entityRestriction - Simplified isset() condition by removing unnecessary !== null check
1 parent f023e59 commit 45ac61c

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

inc/container.class.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,7 @@ public static function findContainer($itemtype, $type = 'tab', $subtype = '')
16981698

16991699
public static function findContainers($itemtype, $type = 'tab', $subtype = '', $itemId = '')
17001700
{
1701+
/** @var DBmysql $DB */
17011702
global $DB;
17021703
$ids = [];
17031704

@@ -1713,7 +1714,7 @@ public static function findContainers($itemtype, $type = 'tab', $subtype = '', $
17131714

17141715
$entityRestriction = getEntitiesRestrictCriteria('', '', $glpiActiveEntities, true, true);
17151716

1716-
if (empty($entityIds)) {
1717+
if (count($entityIds) === 0) {
17171718
$entityIds = [$entityId];
17181719
}
17191720
$entityIdList = implode(",", $entityIds);
@@ -1737,7 +1738,7 @@ public static function findContainers($itemtype, $type = 'tab', $subtype = '', $
17371738
$sql .= " AND type = '$type'";
17381739
}
17391740

1740-
if (is_array($entityRestriction) && !empty($entityRestriction)) {
1741+
if (!empty($entityRestriction)) {
17411742
$allowedEntities = [];
17421743
foreach ($entityRestriction as $restriction) {
17431744
if (isset($restriction['entities_id']) && is_array($restriction['entities_id'])) {
@@ -1756,7 +1757,7 @@ public static function findContainers($itemtype, $type = 'tab', $subtype = '', $
17561757
$containerId = (int) $row['id'];
17571758

17581759
//profiles restriction
1759-
if (isset($_SESSION['glpiactiveprofile']['id']) && $_SESSION['glpiactiveprofile']['id'] !== null) {
1760+
if (isset($_SESSION['glpiactiveprofile']['id'])) {
17601761
$profileId = $_SESSION['glpiactiveprofile']['id'];
17611762
$right = PluginFieldsProfile::getRightOnContainer($profileId, $containerId);
17621763
if ($right < READ) {

0 commit comments

Comments
 (0)