Skip to content

Commit 8b091b2

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 f15e042 commit 8b091b2

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
@@ -1590,6 +1590,7 @@ public static function findContainer($itemtype, $type = 'tab', $subtype = '')
15901590

15911591
public static function findContainers($itemtype, $type = 'tab', $subtype = '', $itemId = '')
15921592
{
1593+
/** @var DBmysql $DB */
15931594
global $DB;
15941595
$ids = [];
15951596

@@ -1605,7 +1606,7 @@ public static function findContainers($itemtype, $type = 'tab', $subtype = '', $
16051606

16061607
$entityRestriction = getEntitiesRestrictCriteria('', '', $glpiActiveEntities, true, true);
16071608

1608-
if (empty($entityIds)) {
1609+
if (count($entityIds) === 0) {
16091610
$entityIds = [$entityId];
16101611
}
16111612
$entityIdList = implode(",", $entityIds);
@@ -1629,7 +1630,7 @@ public static function findContainers($itemtype, $type = 'tab', $subtype = '', $
16291630
$sql .= " AND type = '$type'";
16301631
}
16311632

1632-
if (is_array($entityRestriction) && !empty($entityRestriction)) {
1633+
if (!empty($entityRestriction)) {
16331634
$allowedEntities = [];
16341635
foreach ($entityRestriction as $restriction) {
16351636
if (isset($restriction['entities_id']) && is_array($restriction['entities_id'])) {
@@ -1648,7 +1649,7 @@ public static function findContainers($itemtype, $type = 'tab', $subtype = '', $
16481649
$containerId = (int) $row['id'];
16491650

16501651
//profiles restriction
1651-
if (isset($_SESSION['glpiactiveprofile']['id']) && $_SESSION['glpiactiveprofile']['id'] !== null) {
1652+
if (isset($_SESSION['glpiactiveprofile']['id'])) {
16521653
$profileId = $_SESSION['glpiactiveprofile']['id'];
16531654
$right = PluginFieldsProfile::getRightOnContainer($profileId, $containerId);
16541655
if ($right < READ) {

0 commit comments

Comments
 (0)