Skip to content

Commit ec6cef2

Browse files
committed
Fix phpstan error
1 parent d4af460 commit ec6cef2

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

ajax/agent.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
if (isset($_POST['action']) && isset($_POST['id'])) {
4141
$agent = new Agent();
4242
if (!$agent->getFromDB($_POST['id'])) {
43-
throw new \Glpi\Exception\Http\NotFoundHttpException('Unable to load agent #' . $_POST['id']);
43+
throw new \Glpi\Exception\Http\NotFoundHttpException();
4444
};
4545
$answer = [];
4646

inc/inventoryaction.class.php

+10-6
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,14 @@ public static function runPartialInventory(Agent $agent, $fromMA = false)
112112
// not authorized
113113
return self::handleAgentResponse($response, $endpoint);
114114
}
115+
} catch (Exception $e) {
115116
}
116-
if ($fromMA) {
117-
return false;
118-
} else {
119-
// not authorized
120-
return ['answer' => __('Not allowed')];
121-
}
117+
118+
if ($fromMA) {
119+
return false;
120+
} else {
121+
// not authorized
122+
return ['answer' => $e->getMessage()];
122123
}
123124
}
124125

@@ -169,6 +170,9 @@ public static function postItemForm($item)
169170
return;
170171
}
171172

173+
/** @var array $CFG_GLPI */
174+
global $CFG_GLPI;
175+
172176
if ($item::getType() == Computer::getType()) {
173177
if ($agent = self::findAgent($item)) {
174178
$out = '<div class="mb-3 col-12 col-sm-6">';

phpstan.neon

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ parameters:
1111
scanDirectories:
1212
- ../../src
1313
- ../../inc
14+
- ../../vendor/symfony/http-kernel/Exception
1415
stubFiles:
1516
- ../../stubs/glpi_constants.php
1617
rules:

0 commit comments

Comments
 (0)