Skip to content

Commit 519a5bd

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 13ea826 commit 519a5bd

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

16931693
public static function findContainers($itemtype, $type = 'tab', $subtype = '', $itemId = '')
16941694
{
1695+
/** @var DBmysql $DB */
16951696
global $DB;
16961697
$ids = [];
16971698

@@ -1707,7 +1708,7 @@ public static function findContainers($itemtype, $type = 'tab', $subtype = '', $
17071708

17081709
$entityRestriction = getEntitiesRestrictCriteria('', '', $glpiActiveEntities, true, true);
17091710

1710-
if (empty($entityIds)) {
1711+
if (count($entityIds) === 0) {
17111712
$entityIds = [$entityId];
17121713
}
17131714
$entityIdList = implode(",", $entityIds);
@@ -1731,7 +1732,7 @@ public static function findContainers($itemtype, $type = 'tab', $subtype = '', $
17311732
$sql .= " AND type = '$type'";
17321733
}
17331734

1734-
if (is_array($entityRestriction) && !empty($entityRestriction)) {
1735+
if (!empty($entityRestriction)) {
17351736
$allowedEntities = [];
17361737
foreach ($entityRestriction as $restriction) {
17371738
if (isset($restriction['entities_id']) && is_array($restriction['entities_id'])) {
@@ -1750,7 +1751,7 @@ public static function findContainers($itemtype, $type = 'tab', $subtype = '', $
17501751
$containerId = (int) $row['id'];
17511752

17521753
//profiles restriction
1753-
if (isset($_SESSION['glpiactiveprofile']['id']) && $_SESSION['glpiactiveprofile']['id'] !== null) {
1754+
if (isset($_SESSION['glpiactiveprofile']['id'])) {
17541755
$profileId = $_SESSION['glpiactiveprofile']['id'];
17551756
$right = PluginFieldsProfile::getRightOnContainer($profileId, $containerId);
17561757
if ($right < READ) {

0 commit comments

Comments
 (0)