mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-04-15 21:59:47 -04:00
Add PHP 7 argument & return type declarations to all member methods
This commit is contained in:
parent
a8780494eb
commit
aefd0e1f7d
156 changed files with 821 additions and 520 deletions
|
|
@ -61,7 +61,7 @@ class CommentController extends Controller
|
|||
$this->setAutorefreshInterval(10);
|
||||
}
|
||||
|
||||
protected function fetchCommandTargets()
|
||||
protected function fetchCommandTargets(): array
|
||||
{
|
||||
return [$this->comment];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class ConfigController extends Controller
|
|||
$this->addContent(new HtmlString($form->render()));
|
||||
}
|
||||
|
||||
protected function mergeTabs(Tabs $tabs)
|
||||
protected function mergeTabs(Tabs $tabs): self
|
||||
{
|
||||
/** @var Tab $tab */
|
||||
foreach ($tabs->getTabs() as $tab) {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class DowntimeController extends Controller
|
|||
$this->setAutorefreshInterval(10);
|
||||
}
|
||||
|
||||
protected function fetchCommandTargets()
|
||||
protected function fetchCommandTargets(): array
|
||||
{
|
||||
return [$this->downtime];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ use Icinga\Module\Icingadb\Widget\ItemList\HostList;
|
|||
use Icinga\Module\Icingadb\Widget\ItemList\HistoryList;
|
||||
use Icinga\Module\Icingadb\Widget\ItemList\ServiceList;
|
||||
use ipl\Web\Url;
|
||||
use ipl\Web\Widget\Tabs;
|
||||
|
||||
class HostController extends Controller
|
||||
{
|
||||
|
|
@ -230,7 +231,7 @@ class HostController extends Controller
|
|||
$this->setAutorefreshInterval(10);
|
||||
}
|
||||
|
||||
protected function createTabs()
|
||||
protected function createTabs(): Tabs
|
||||
{
|
||||
$tabs = $this->getTabs()
|
||||
->add('index', [
|
||||
|
|
@ -260,7 +261,7 @@ class HostController extends Controller
|
|||
return $tabs;
|
||||
}
|
||||
|
||||
protected function setTitleTab($name)
|
||||
protected function setTitleTab(string $name)
|
||||
{
|
||||
$tab = $this->createTabs()->get($name);
|
||||
|
||||
|
|
@ -271,7 +272,7 @@ class HostController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
protected function fetchCommandTargets()
|
||||
protected function fetchCommandTargets(): array
|
||||
{
|
||||
return [$this->host];
|
||||
}
|
||||
|
|
@ -281,7 +282,7 @@ class HostController extends Controller
|
|||
return Links::host($this->host);
|
||||
}
|
||||
|
||||
protected function getDefaultTabControls()
|
||||
protected function getDefaultTabControls(): array
|
||||
{
|
||||
return [(new HostList([$this->host]))->setDetailActionsDisabled()->setNoSubjectLink()];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ use Icinga\Module\Icingadb\Widget\ItemList\HostList;
|
|||
use Icinga\Module\Icingadb\Widget\HostStatusBar;
|
||||
use Icinga\Module\Icingadb\Widget\ShowMore;
|
||||
use Icinga\Module\Icingadb\Web\Control\ViewModeSwitcher;
|
||||
use ipl\Orm\Query;
|
||||
use ipl\Stdlib\Filter;
|
||||
use ipl\Web\Control\LimitControl;
|
||||
use ipl\Web\Control\SortControl;
|
||||
|
|
@ -192,7 +193,7 @@ class HostsController extends Controller
|
|||
$this->setTitle(t('Adjust Filter'));
|
||||
}
|
||||
|
||||
protected function fetchCommandTargets()
|
||||
protected function fetchCommandTargets(): Query
|
||||
{
|
||||
$db = $this->getDb();
|
||||
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ class ServiceController extends Controller
|
|||
return $tabs;
|
||||
}
|
||||
|
||||
protected function setTitleTab($name)
|
||||
protected function setTitleTab(string $name)
|
||||
{
|
||||
$tab = $this->createTabs()->get($name);
|
||||
|
||||
|
|
@ -217,7 +217,7 @@ class ServiceController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
protected function fetchCommandTargets()
|
||||
protected function fetchCommandTargets(): array
|
||||
{
|
||||
return [$this->service];
|
||||
}
|
||||
|
|
@ -227,7 +227,7 @@ class ServiceController extends Controller
|
|||
return Links::service($this->service, $this->service->host);
|
||||
}
|
||||
|
||||
protected function getDefaultTabControls()
|
||||
protected function getDefaultTabControls(): array
|
||||
{
|
||||
return [(new ServiceList([$this->service]))->setDetailActionsDisabled()->setNoSubjectLink()];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ use Icinga\Module\Icingadb\Widget\ServiceStatusBar;
|
|||
use Icinga\Module\Icingadb\Widget\ShowMore;
|
||||
use Icinga\Module\Icingadb\Web\Control\ViewModeSwitcher;
|
||||
use ipl\Html\HtmlString;
|
||||
use ipl\Orm\Query;
|
||||
use ipl\Stdlib\Filter;
|
||||
use ipl\Web\Control\LimitControl;
|
||||
use ipl\Web\Control\SortControl;
|
||||
|
|
@ -314,7 +315,7 @@ class ServicesController extends Controller
|
|||
$this->setAutorefreshInterval(30);
|
||||
}
|
||||
|
||||
protected function fetchCommandTargets()
|
||||
protected function fetchCommandTargets(): Query
|
||||
{
|
||||
$db = $this->getDb();
|
||||
|
||||
|
|
@ -351,7 +352,7 @@ class ServicesController extends Controller
|
|||
return new FeatureStatus('service', $summary->first());
|
||||
}
|
||||
|
||||
public function createProblemToggle()
|
||||
public function createProblemToggle(): ProblemToggle
|
||||
{
|
||||
$filter = $this->params->shift('problems');
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ abstract class CommandForm extends Form
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setObjects($objects)
|
||||
public function setObjects($objects): self
|
||||
{
|
||||
$this->objects = $objects;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class ToggleInstanceFeaturesForm extends CommandForm
|
|||
*/
|
||||
protected $submittedFeatures = [];
|
||||
|
||||
public function __construct($featureStatus)
|
||||
public function __construct(array $featureStatus)
|
||||
{
|
||||
$this->featureStatus = $featureStatus;
|
||||
$this->features = [
|
||||
|
|
@ -136,7 +136,7 @@ class ToggleInstanceFeaturesForm extends CommandForm
|
|||
{
|
||||
}
|
||||
|
||||
protected function getCommand(Model $object)
|
||||
protected function getCommand(Model $object): \Generator
|
||||
{
|
||||
foreach ($this->features as $feature => $spec) {
|
||||
$featureState = $this->getElement($feature)->isChecked();
|
||||
|
|
@ -147,7 +147,7 @@ class ToggleInstanceFeaturesForm extends CommandForm
|
|||
|
||||
$command = new ToggleInstanceFeatureCommand();
|
||||
$command->setFeature($feature);
|
||||
$command->setEnabled((int) $featureState);
|
||||
$command->setEnabled($featureState);
|
||||
|
||||
$this->submittedFeatures[] = $command;
|
||||
|
||||
|
|
|
|||
|
|
@ -176,6 +176,9 @@ class AcknowledgeProblemForm extends CommandForm
|
|||
(new IcingaFormDecorator())->decorate($this->getElement('btn_submit'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?AcknowledgeProblemCommand
|
||||
*/
|
||||
protected function getCommand(Model $object)
|
||||
{
|
||||
if (! $this->isGrantedOn('icingadb/command/acknowledge-problem', $object)) {
|
||||
|
|
|
|||
|
|
@ -130,6 +130,9 @@ class AddCommentForm extends CommandForm
|
|||
(new IcingaFormDecorator())->decorate($this->getElement('btn_submit'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?AddCommentCommand
|
||||
*/
|
||||
protected function getCommand(Model $object)
|
||||
{
|
||||
if (! $this->isGrantedOn('icingadb/command/comment/add', $object)) {
|
||||
|
|
|
|||
|
|
@ -46,6 +46,9 @@ class CheckNowForm extends CommandForm
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?ScheduleCheckCommand
|
||||
*/
|
||||
protected function getCommand(Model $object)
|
||||
{
|
||||
if (
|
||||
|
|
|
|||
|
|
@ -53,6 +53,9 @@ class DeleteCommentForm extends CommandForm
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?DeleteCommentCommand
|
||||
*/
|
||||
protected function getCommand(Model $object)
|
||||
{
|
||||
if (! $this->isGrantedOn('icingadb/command/comment/delete', $object->{$object->object_type})) {
|
||||
|
|
|
|||
|
|
@ -67,6 +67,9 @@ class DeleteDowntimeForm extends CommandForm
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?DeleteDowntimeCommand
|
||||
*/
|
||||
protected function getCommand(Model $object)
|
||||
{
|
||||
if (
|
||||
|
|
|
|||
|
|
@ -136,6 +136,9 @@ class ProcessCheckResultForm extends CommandForm
|
|||
(new IcingaFormDecorator())->decorate($this->getElement('btn_submit'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?ProcessCheckResultCommand
|
||||
*/
|
||||
protected function getCommand(Model $object)
|
||||
{
|
||||
if (
|
||||
|
|
|
|||
|
|
@ -63,6 +63,9 @@ class RemoveAcknowledgementForm extends CommandForm
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?RemoveAcknowledgementCommand
|
||||
*/
|
||||
protected function getCommand(Model $object)
|
||||
{
|
||||
if (! $this->isGrantedOn('icingadb/command/remove-acknowledgement', $object)) {
|
||||
|
|
|
|||
|
|
@ -109,6 +109,9 @@ class ScheduleCheckForm extends CommandForm
|
|||
(new IcingaFormDecorator())->decorate($this->getElement('btn_submit'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?ScheduleCheckCommand
|
||||
*/
|
||||
protected function getCommand(Model $object)
|
||||
{
|
||||
if (
|
||||
|
|
|
|||
|
|
@ -87,6 +87,9 @@ class ScheduleHostDowntimeForm extends ScheduleServiceDowntimeForm
|
|||
$decorator->decorate($this->getElement('child_options'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?PropagateHostDowntimeCommand|ScheduleHostDowntimeCommand
|
||||
*/
|
||||
protected function getCommand(Model $object)
|
||||
{
|
||||
if (! $this->isGrantedOn('icingadb/command/downtime/schedule', $object)) {
|
||||
|
|
|
|||
|
|
@ -227,6 +227,9 @@ class ScheduleServiceDowntimeForm extends CommandForm
|
|||
(new IcingaFormDecorator())->decorate($this->getElement('btn_submit'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?ScheduleServiceDowntimeCommand
|
||||
*/
|
||||
protected function getCommand(Model $object)
|
||||
{
|
||||
if (! $this->isGrantedOn('icingadb/command/downtime/schedule', $object)) {
|
||||
|
|
|
|||
|
|
@ -109,6 +109,9 @@ class SendCustomNotificationForm extends CommandForm
|
|||
(new IcingaFormDecorator())->decorate($this->getElement('btn_submit'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?SendCustomNotificationCommand
|
||||
*/
|
||||
protected function getCommand(Model $object)
|
||||
{
|
||||
if (! $this->isGrantedOn('icingadb/command/send-custom-notification', $object)) {
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ class ToggleObjectFeaturesForm extends CommandForm
|
|||
{
|
||||
}
|
||||
|
||||
protected function getCommand(Model $object)
|
||||
protected function getCommand(Model $object): \Generator
|
||||
{
|
||||
foreach ($this->features as $feature => $spec) {
|
||||
$featureState = $this->getElement($feature)->isChecked();
|
||||
|
|
|
|||
|
|
@ -19,9 +19,6 @@ class ActionForm extends NavigationItemForm
|
|||
*/
|
||||
protected $restriction;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createElements(array $formData)
|
||||
{
|
||||
parent::createElements($formData);
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ class RedisConfigForm extends ConfigForm
|
|||
);
|
||||
}
|
||||
|
||||
public static function addSkipValidationCheckbox($form)
|
||||
public static function addSkipValidationCheckbox(Form $form)
|
||||
{
|
||||
$form->addElement(
|
||||
'checkbox',
|
||||
|
|
@ -435,7 +435,7 @@ class RedisConfigForm extends ConfigForm
|
|||
return $this;
|
||||
}
|
||||
|
||||
public static function checkRedis(Form $form)
|
||||
public static function checkRedis(Form $form): bool
|
||||
{
|
||||
$sections = [];
|
||||
|
||||
|
|
@ -520,7 +520,7 @@ class RedisConfigForm extends ConfigForm
|
|||
*
|
||||
* @return array Callback validator
|
||||
*/
|
||||
private function wrapIplValidator($cls, $element, Closure $additionalValidator = null)
|
||||
private function wrapIplValidator(string $cls, string $element, Closure $additionalValidator = null): array
|
||||
{
|
||||
return [
|
||||
'Callback',
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class ObjectAuthorization
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function grantsOn($permission, Model $for)
|
||||
public static function grantsOn(string $permission, Model $for): bool
|
||||
{
|
||||
$self = new static();
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ class ObjectAuthorization
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function grantsOnType($permission, $type, Filter\Rule $filter, $cache = true)
|
||||
public static function grantsOnType(string $permission, string $type, Filter\Rule $filter, bool $cache = true): bool
|
||||
{
|
||||
switch ($type) {
|
||||
case 'host':
|
||||
|
|
@ -142,7 +142,7 @@ class ObjectAuthorization
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function loadGrants($model, Filter\Rule $filter, $cacheKey, $cache = true)
|
||||
protected function loadGrants(string $model, Filter\Rule $filter, string $cacheKey, bool $cache = true)
|
||||
{
|
||||
/** @var Model $model */
|
||||
$query = $model::on($this->getDb());
|
||||
|
|
@ -234,7 +234,7 @@ class ObjectAuthorization
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function checkGrants($permission, $roles)
|
||||
protected function checkGrants(string $permission, array $roles): bool
|
||||
{
|
||||
if (empty($roles)) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class IcingaApiCommand
|
|||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function create($endpoint, array $data)
|
||||
public static function create(string $endpoint, array $data): self
|
||||
{
|
||||
return (new static())
|
||||
->setEndpoint($endpoint)
|
||||
|
|
@ -47,8 +47,14 @@ class IcingaApiCommand
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData()
|
||||
public function getData(): array
|
||||
{
|
||||
if ($this->data === null) {
|
||||
throw new \LogicException(
|
||||
'You are accessing an unset property. Please make sure to set it beforehand.'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
|
|
@ -59,7 +65,7 @@ class IcingaApiCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setData($data)
|
||||
public function setData(array $data): self
|
||||
{
|
||||
$this->data = $data;
|
||||
|
||||
|
|
@ -71,8 +77,14 @@ class IcingaApiCommand
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEndpoint()
|
||||
public function getEndpoint(): string
|
||||
{
|
||||
if ($this->endpoint === null) {
|
||||
throw new \LogicException(
|
||||
'You are accessing an unset property. Please make sure to set it beforehand.'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->endpoint;
|
||||
}
|
||||
|
||||
|
|
@ -83,7 +95,7 @@ class IcingaApiCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setEndpoint($endpoint)
|
||||
public function setEndpoint(string $endpoint): self
|
||||
{
|
||||
$this->endpoint = $endpoint;
|
||||
|
||||
|
|
@ -95,7 +107,7 @@ class IcingaApiCommand
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMethod()
|
||||
public function getMethod(): string
|
||||
{
|
||||
return $this->method;
|
||||
}
|
||||
|
|
@ -107,7 +119,7 @@ class IcingaApiCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMethod($method)
|
||||
public function setMethod(string $method): self
|
||||
{
|
||||
$this->method = $method;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ abstract class IcingaCommand
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
$nsParts = explode('\\', get_called_class());
|
||||
return substr_replace(end($nsParts), '', -7); // Remove 'Command' Suffix
|
||||
|
|
|
|||
|
|
@ -62,9 +62,9 @@ class ToggleInstanceFeatureCommand extends IcingaCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setFeature($feature)
|
||||
public function setFeature(string $feature): self
|
||||
{
|
||||
$this->feature = (string) $feature;
|
||||
$this->feature = $feature;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -74,8 +74,12 @@ class ToggleInstanceFeatureCommand extends IcingaCommand
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFeature()
|
||||
public function getFeature(): string
|
||||
{
|
||||
if ($this->feature === null) {
|
||||
throw new \LogicException('You have to set the feature first before getting it.');
|
||||
}
|
||||
|
||||
return $this->feature;
|
||||
}
|
||||
|
||||
|
|
@ -86,9 +90,9 @@ class ToggleInstanceFeatureCommand extends IcingaCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setEnabled($enabled = true)
|
||||
public function setEnabled(bool $enabled = true): self
|
||||
{
|
||||
$this->enabled = (bool) $enabled;
|
||||
$this->enabled = $enabled;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -96,7 +100,7 @@ class ToggleInstanceFeatureCommand extends IcingaCommand
|
|||
/**
|
||||
* Get whether the feature should be enabled or disabled
|
||||
*
|
||||
* @return bool
|
||||
* @return ?bool
|
||||
*/
|
||||
public function getEnabled()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -49,9 +49,9 @@ class AcknowledgeProblemCommand extends WithCommentCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setSticky($sticky = true)
|
||||
public function setSticky(bool $sticky = true): self
|
||||
{
|
||||
$this->sticky = (bool) $sticky;
|
||||
$this->sticky = $sticky;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ class AcknowledgeProblemCommand extends WithCommentCommand
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getSticky()
|
||||
public function getSticky(): bool
|
||||
{
|
||||
return $this->sticky;
|
||||
}
|
||||
|
|
@ -73,9 +73,9 @@ class AcknowledgeProblemCommand extends WithCommentCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setNotify($notify = true)
|
||||
public function setNotify(bool $notify = true): self
|
||||
{
|
||||
$this->notify = (bool) $notify;
|
||||
$this->notify = $notify;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -85,7 +85,7 @@ class AcknowledgeProblemCommand extends WithCommentCommand
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getNotify()
|
||||
public function getNotify(): bool
|
||||
{
|
||||
return $this->notify;
|
||||
}
|
||||
|
|
@ -97,9 +97,9 @@ class AcknowledgeProblemCommand extends WithCommentCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPersistent($persistent = true)
|
||||
public function setPersistent(bool $persistent = true): self
|
||||
{
|
||||
$this->persistent = (bool) $persistent;
|
||||
$this->persistent = $persistent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -109,7 +109,7 @@ class AcknowledgeProblemCommand extends WithCommentCommand
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getPersistent()
|
||||
public function getPersistent(): bool
|
||||
{
|
||||
return $this->persistent;
|
||||
}
|
||||
|
|
@ -121,9 +121,9 @@ class AcknowledgeProblemCommand extends WithCommentCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setExpireTime($expireTime)
|
||||
public function setExpireTime(int $expireTime): self
|
||||
{
|
||||
$this->expireTime = (int) $expireTime;
|
||||
$this->expireTime = $expireTime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -131,7 +131,7 @@ class AcknowledgeProblemCommand extends WithCommentCommand
|
|||
/**
|
||||
* Get the time when the acknowledgement should expire
|
||||
*
|
||||
* @return int
|
||||
* @return ?int
|
||||
*/
|
||||
public function getExpireTime()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ class AddCommentCommand extends WithCommentCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setExpireTime($expireTime)
|
||||
public function setExpireTime(int $expireTime): self
|
||||
{
|
||||
$this->expireTime = (int) $expireTime;
|
||||
$this->expireTime = $expireTime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ class AddCommentCommand extends WithCommentCommand
|
|||
/**
|
||||
* Get the time when the acknowledgement should expire
|
||||
*
|
||||
* @return int
|
||||
* @return ?int
|
||||
*/
|
||||
public function getExpireTime()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ trait CommandAuthor
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAuthor($author)
|
||||
public function setAuthor(string $author): self
|
||||
{
|
||||
$this->author = (string) $author;
|
||||
$this->author = $author;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -32,8 +32,14 @@ trait CommandAuthor
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthor()
|
||||
public function getAuthor(): string
|
||||
{
|
||||
if ($this->author === null) {
|
||||
throw new \LogicException(
|
||||
'You are accessing an unset property. Please make sure to set it beforehand.'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->author;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,8 +25,14 @@ class DeleteCommentCommand extends IcingaCommand
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCommentName()
|
||||
public function getCommentName(): string
|
||||
{
|
||||
if ($this->commentName === null) {
|
||||
throw new \LogicException(
|
||||
'You are accessing an unset property. Please make sure to set it beforehand.'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->commentName;
|
||||
}
|
||||
|
||||
|
|
@ -37,7 +43,7 @@ class DeleteCommentCommand extends IcingaCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCommentName($commentName)
|
||||
public function setCommentName(string $commentName): self
|
||||
{
|
||||
$this->commentName = $commentName;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,8 +29,14 @@ class DeleteDowntimeCommand extends IcingaCommand
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDowntimeName()
|
||||
public function getDowntimeName(): string
|
||||
{
|
||||
if ($this->downtimeName === null) {
|
||||
throw new \LogicException(
|
||||
'You are accessing an unset property. Please make sure to set it beforehand.'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->downtimeName;
|
||||
}
|
||||
|
||||
|
|
@ -43,7 +49,7 @@ class DeleteDowntimeCommand extends IcingaCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDowntimeName($downtimeName)
|
||||
public function setDowntimeName(string $downtimeName): self
|
||||
{
|
||||
$this->downtimeName = $downtimeName;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class GetObjectCommand extends ObjectCommand
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getObjectName()
|
||||
public function getObjectName(): string
|
||||
{
|
||||
switch (true) {
|
||||
case $this->object instanceof Service:
|
||||
|
|
@ -33,7 +33,7 @@ class GetObjectCommand extends ObjectCommand
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getObjectPluralType()
|
||||
public function getObjectPluralType(): string
|
||||
{
|
||||
switch (true) {
|
||||
case $this->object instanceof Host:
|
||||
|
|
@ -48,7 +48,7 @@ class GetObjectCommand extends ObjectCommand
|
|||
/**
|
||||
* Get the attributes to query
|
||||
*
|
||||
* @return array
|
||||
* @return ?array
|
||||
*/
|
||||
public function getAttributes()
|
||||
{
|
||||
|
|
@ -62,7 +62,7 @@ class GetObjectCommand extends ObjectCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAttributes(array $attributes)
|
||||
public function setAttributes(array $attributes): self
|
||||
{
|
||||
$this->attributes = $attributes;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ abstract class ObjectCommand extends IcingaCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setObject(Model $object)
|
||||
public function setObject(Model $object): self
|
||||
{
|
||||
$this->object = $object;
|
||||
|
||||
|
|
@ -38,8 +38,14 @@ abstract class ObjectCommand extends IcingaCommand
|
|||
*
|
||||
* @return Model
|
||||
*/
|
||||
public function getObject()
|
||||
public function getObject(): Model
|
||||
{
|
||||
if ($this->object === null) {
|
||||
throw new \LogicException(
|
||||
'You are accessing an unset property. Please make sure to set it beforehand.'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->object;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,9 +67,9 @@ class ProcessCheckResultCommand extends ObjectCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setStatus($status)
|
||||
public function setStatus(int $status): self
|
||||
{
|
||||
$this->status = (int) $status;
|
||||
$this->status = $status;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -79,8 +79,14 @@ class ProcessCheckResultCommand extends ObjectCommand
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStatus()
|
||||
public function getStatus(): int
|
||||
{
|
||||
if ($this->status === null) {
|
||||
throw new \LogicException(
|
||||
'You are accessing an unset property. Please make sure to set it beforehand.'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
|
|
@ -91,9 +97,9 @@ class ProcessCheckResultCommand extends ObjectCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setOutput($output)
|
||||
public function setOutput(string $output): self
|
||||
{
|
||||
$this->output = (string) $output;
|
||||
$this->output = $output;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -101,7 +107,7 @@ class ProcessCheckResultCommand extends ObjectCommand
|
|||
/**
|
||||
* Get the text output of the host or service check result
|
||||
*
|
||||
* @return string
|
||||
* @return ?string
|
||||
*/
|
||||
public function getOutput()
|
||||
{
|
||||
|
|
@ -115,9 +121,9 @@ class ProcessCheckResultCommand extends ObjectCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPerformanceData($performanceData)
|
||||
public function setPerformanceData(string $performanceData): self
|
||||
{
|
||||
$this->performanceData = (string) $performanceData;
|
||||
$this->performanceData = $performanceData;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -125,7 +131,7 @@ class ProcessCheckResultCommand extends ObjectCommand
|
|||
/**
|
||||
* Get the performance data of the host or service check result
|
||||
*
|
||||
* @return string
|
||||
* @return ?string
|
||||
*/
|
||||
public function getPerformanceData()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ class PropagateHostDowntimeCommand extends ScheduleHostDowntimeCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTriggered($triggered = true)
|
||||
public function setTriggered(bool $triggered = true): self
|
||||
{
|
||||
$this->triggered = (bool) $triggered;
|
||||
$this->triggered = $triggered;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ class PropagateHostDowntimeCommand extends ScheduleHostDowntimeCommand
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getTriggered()
|
||||
public function getTriggered(): bool
|
||||
{
|
||||
return $this->triggered;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@ class ScheduleCheckCommand extends ObjectCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCheckTime($checkTime)
|
||||
public function setCheckTime(int $checkTime): self
|
||||
{
|
||||
$this->checkTime = (int) $checkTime;
|
||||
$this->checkTime = $checkTime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -49,8 +49,14 @@ class ScheduleCheckCommand extends ObjectCommand
|
|||
*
|
||||
* @return int Unix timestamp
|
||||
*/
|
||||
public function getCheckTime()
|
||||
public function getCheckTime(): int
|
||||
{
|
||||
if ($this->checkTime === null) {
|
||||
throw new \LogicException(
|
||||
'You are accessing an unset property. Please make sure to set it beforehand.'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->checkTime;
|
||||
}
|
||||
|
||||
|
|
@ -61,9 +67,9 @@ class ScheduleCheckCommand extends ObjectCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setForced($forced = true)
|
||||
public function setForced(bool $forced = true): self
|
||||
{
|
||||
$this->forced = (bool) $forced;
|
||||
$this->forced = $forced;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -73,7 +79,7 @@ class ScheduleCheckCommand extends ObjectCommand
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getForced()
|
||||
public function getForced(): bool
|
||||
{
|
||||
return $this->forced;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ class ScheduleHostDowntimeCommand extends ScheduleServiceDowntimeCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setForAllServices($forAllServices = true)
|
||||
public function setForAllServices(bool $forAllServices = true): self
|
||||
{
|
||||
$this->forAllServices = (bool) $forAllServices;
|
||||
$this->forAllServices = $forAllServices;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ class ScheduleHostDowntimeCommand extends ScheduleServiceDowntimeCommand
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getForAllServices()
|
||||
public function getForAllServices(): bool
|
||||
{
|
||||
return $this->forAllServices;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,9 +64,9 @@ class ScheduleServiceDowntimeCommand extends AddCommentCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setStart($start)
|
||||
public function setStart(int $start): self
|
||||
{
|
||||
$this->start = (int) $start;
|
||||
$this->start = $start;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -76,8 +76,14 @@ class ScheduleServiceDowntimeCommand extends AddCommentCommand
|
|||
*
|
||||
* @return int Unix timestamp
|
||||
*/
|
||||
public function getStart()
|
||||
public function getStart(): int
|
||||
{
|
||||
if ($this->start === null) {
|
||||
throw new \LogicException(
|
||||
'You are accessing an unset property. Please make sure to set it beforehand.'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->start;
|
||||
}
|
||||
|
||||
|
|
@ -88,9 +94,9 @@ class ScheduleServiceDowntimeCommand extends AddCommentCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setEnd($end)
|
||||
public function setEnd(int $end): self
|
||||
{
|
||||
$this->end = (int) $end;
|
||||
$this->end = $end;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -100,8 +106,14 @@ class ScheduleServiceDowntimeCommand extends AddCommentCommand
|
|||
*
|
||||
* @return int Unix timestamp
|
||||
*/
|
||||
public function getEnd()
|
||||
public function getEnd(): int
|
||||
{
|
||||
if ($this->start === null) {
|
||||
throw new \LogicException(
|
||||
'You are accessing an unset property. Please make sure to set it beforehand.'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->end;
|
||||
}
|
||||
|
||||
|
|
@ -112,9 +124,9 @@ class ScheduleServiceDowntimeCommand extends AddCommentCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setFixed($fixed = true)
|
||||
public function setFixed(bool $fixed = true): self
|
||||
{
|
||||
$this->fixed = (bool) $fixed;
|
||||
$this->fixed = $fixed;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -124,7 +136,7 @@ class ScheduleServiceDowntimeCommand extends AddCommentCommand
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getFixed()
|
||||
public function getFixed(): bool
|
||||
{
|
||||
return $this->fixed;
|
||||
}
|
||||
|
|
@ -136,9 +148,9 @@ class ScheduleServiceDowntimeCommand extends AddCommentCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTriggerId($triggerId)
|
||||
public function setTriggerId(int $triggerId): self
|
||||
{
|
||||
$this->triggerId = (int) $triggerId;
|
||||
$this->triggerId = $triggerId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -160,9 +172,9 @@ class ScheduleServiceDowntimeCommand extends AddCommentCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDuration($duration)
|
||||
public function setDuration(int $duration): self
|
||||
{
|
||||
$this->duration = (int) $duration;
|
||||
$this->duration = $duration;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -177,7 +189,7 @@ class ScheduleServiceDowntimeCommand extends AddCommentCommand
|
|||
return $this->duration;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return 'ScheduleDowntime';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class SendCustomNotificationCommand extends WithCommentCommand
|
|||
/**
|
||||
* Get whether to force the notification
|
||||
*
|
||||
* @return bool
|
||||
* @return ?bool
|
||||
*/
|
||||
public function getForced()
|
||||
{
|
||||
|
|
@ -35,7 +35,7 @@ class SendCustomNotificationCommand extends WithCommentCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setForced($forced = true)
|
||||
public function setForced(bool $forced = true): self
|
||||
{
|
||||
$this->forced = $forced;
|
||||
|
||||
|
|
|
|||
|
|
@ -59,9 +59,9 @@ class ToggleObjectFeatureCommand extends ObjectCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setFeature($feature)
|
||||
public function setFeature(string $feature): self
|
||||
{
|
||||
$this->feature = (string) $feature;
|
||||
$this->feature = $feature;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -71,8 +71,14 @@ class ToggleObjectFeatureCommand extends ObjectCommand
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFeature()
|
||||
public function getFeature(): string
|
||||
{
|
||||
if ($this->feature === null) {
|
||||
throw new \LogicException(
|
||||
'You are accessing an unset property. Please make sure to set it beforehand.'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->feature;
|
||||
}
|
||||
|
||||
|
|
@ -83,9 +89,9 @@ class ToggleObjectFeatureCommand extends ObjectCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setEnabled($enabled = true)
|
||||
public function setEnabled(bool $enabled = true): self
|
||||
{
|
||||
$this->enabled = (bool) $enabled;
|
||||
$this->enabled = $enabled;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -93,7 +99,7 @@ class ToggleObjectFeatureCommand extends ObjectCommand
|
|||
/**
|
||||
* Get whether the feature should be enabled or disabled
|
||||
*
|
||||
* @return bool
|
||||
* @return ?bool
|
||||
*/
|
||||
public function getEnabled()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ abstract class WithCommentCommand extends ObjectCommand
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setComment($comment)
|
||||
public function setComment(string $comment): self
|
||||
{
|
||||
$this->comment = (string) $comment;
|
||||
$this->comment = $comment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -37,8 +37,14 @@ abstract class WithCommentCommand extends ObjectCommand
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getComment()
|
||||
public function getComment(): string
|
||||
{
|
||||
if ($this->comment === null) {
|
||||
throw new \LogicException(
|
||||
'You are accessing an unset property. Please make sure to set it beforehand.'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->comment;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class IcingaApiCommandRenderer implements IcingaCommandRendererInterface
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getApp()
|
||||
public function getApp(): string
|
||||
{
|
||||
return $this->app;
|
||||
}
|
||||
|
|
@ -54,7 +54,7 @@ class IcingaApiCommandRenderer implements IcingaCommandRendererInterface
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setApp($app)
|
||||
public function setApp(string $app): self
|
||||
{
|
||||
$this->app = $app;
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ class IcingaApiCommandRenderer implements IcingaCommandRendererInterface
|
|||
* @param array $data
|
||||
* @param Model $object
|
||||
*
|
||||
* @return array
|
||||
* @return void
|
||||
*/
|
||||
protected function applyFilter(array &$data, Model $object)
|
||||
{
|
||||
|
|
@ -86,7 +86,7 @@ class IcingaApiCommandRenderer implements IcingaCommandRendererInterface
|
|||
*
|
||||
* @return IcingaApiCommand
|
||||
*/
|
||||
public function render(IcingaCommand $command)
|
||||
public function render(IcingaCommand $command): IcingaApiCommand
|
||||
{
|
||||
$renderMethod = 'render' . $command->getName();
|
||||
if (! method_exists($this, $renderMethod)) {
|
||||
|
|
@ -98,7 +98,7 @@ class IcingaApiCommandRenderer implements IcingaCommandRendererInterface
|
|||
return $this->$renderMethod($command);
|
||||
}
|
||||
|
||||
public function renderGetObject(GetObjectCommand $command)
|
||||
public function renderGetObject(GetObjectCommand $command): IcingaApiCommand
|
||||
{
|
||||
$endpoint = sprintf(
|
||||
'objects/%s/%s',
|
||||
|
|
@ -114,7 +114,7 @@ class IcingaApiCommandRenderer implements IcingaCommandRendererInterface
|
|||
return IcingaApiCommand::create($endpoint, $data)->setMethod('GET');
|
||||
}
|
||||
|
||||
public function renderAddComment(AddCommentCommand $command)
|
||||
public function renderAddComment(AddCommentCommand $command): IcingaApiCommand
|
||||
{
|
||||
$endpoint = 'actions/add-comment';
|
||||
$data = [
|
||||
|
|
@ -130,7 +130,7 @@ class IcingaApiCommandRenderer implements IcingaCommandRendererInterface
|
|||
return IcingaApiCommand::create($endpoint, $data);
|
||||
}
|
||||
|
||||
public function renderSendCustomNotification(SendCustomNotificationCommand $command)
|
||||
public function renderSendCustomNotification(SendCustomNotificationCommand $command): IcingaApiCommand
|
||||
{
|
||||
$endpoint = 'actions/send-custom-notification';
|
||||
$data = [
|
||||
|
|
@ -143,7 +143,7 @@ class IcingaApiCommandRenderer implements IcingaCommandRendererInterface
|
|||
return IcingaApiCommand::create($endpoint, $data);
|
||||
}
|
||||
|
||||
public function renderProcessCheckResult(ProcessCheckResultCommand $command)
|
||||
public function renderProcessCheckResult(ProcessCheckResultCommand $command): IcingaApiCommand
|
||||
{
|
||||
$endpoint = 'actions/process-check-result';
|
||||
$data = [
|
||||
|
|
@ -156,7 +156,7 @@ class IcingaApiCommandRenderer implements IcingaCommandRendererInterface
|
|||
return IcingaApiCommand::create($endpoint, $data);
|
||||
}
|
||||
|
||||
public function renderScheduleCheck(ScheduleCheckCommand $command)
|
||||
public function renderScheduleCheck(ScheduleCheckCommand $command): IcingaApiCommand
|
||||
{
|
||||
$endpoint = 'actions/reschedule-check';
|
||||
$data = [
|
||||
|
|
@ -168,7 +168,7 @@ class IcingaApiCommandRenderer implements IcingaCommandRendererInterface
|
|||
return IcingaApiCommand::create($endpoint, $data);
|
||||
}
|
||||
|
||||
public function renderScheduleDowntime(ScheduleServiceDowntimeCommand $command)
|
||||
public function renderScheduleDowntime(ScheduleServiceDowntimeCommand $command): IcingaApiCommand
|
||||
{
|
||||
$endpoint = 'actions/schedule-downtime';
|
||||
$data = [
|
||||
|
|
@ -193,7 +193,7 @@ class IcingaApiCommandRenderer implements IcingaCommandRendererInterface
|
|||
return IcingaApiCommand::create($endpoint, $data);
|
||||
}
|
||||
|
||||
public function renderAcknowledgeProblem(AcknowledgeProblemCommand $command)
|
||||
public function renderAcknowledgeProblem(AcknowledgeProblemCommand $command): IcingaApiCommand
|
||||
{
|
||||
$endpoint = 'actions/acknowledge-problem';
|
||||
$data = [
|
||||
|
|
@ -212,7 +212,7 @@ class IcingaApiCommandRenderer implements IcingaCommandRendererInterface
|
|||
return IcingaApiCommand::create($endpoint, $data);
|
||||
}
|
||||
|
||||
public function renderToggleObjectFeature(ToggleObjectFeatureCommand $command)
|
||||
public function renderToggleObjectFeature(ToggleObjectFeatureCommand $command): IcingaApiCommand
|
||||
{
|
||||
switch ($command->getFeature()) {
|
||||
case ToggleObjectFeatureCommand::FEATURE_ACTIVE_CHECKS:
|
||||
|
|
@ -253,7 +253,7 @@ class IcingaApiCommandRenderer implements IcingaCommandRendererInterface
|
|||
return IcingaApiCommand::create($endpoint, $data);
|
||||
}
|
||||
|
||||
public function renderDeleteComment(DeleteCommentCommand $command)
|
||||
public function renderDeleteComment(DeleteCommentCommand $command): IcingaApiCommand
|
||||
{
|
||||
$endpoint = 'actions/remove-comment';
|
||||
$data = [
|
||||
|
|
@ -264,7 +264,7 @@ class IcingaApiCommandRenderer implements IcingaCommandRendererInterface
|
|||
return IcingaApiCommand::create($endpoint, $data);
|
||||
}
|
||||
|
||||
public function renderDeleteDowntime(DeleteDowntimeCommand $command)
|
||||
public function renderDeleteDowntime(DeleteDowntimeCommand $command): IcingaApiCommand
|
||||
{
|
||||
$endpoint = 'actions/remove-downtime';
|
||||
$data = [
|
||||
|
|
@ -275,7 +275,7 @@ class IcingaApiCommandRenderer implements IcingaCommandRendererInterface
|
|||
return IcingaApiCommand::create($endpoint, $data);
|
||||
}
|
||||
|
||||
public function renderRemoveAcknowledgement(RemoveAcknowledgementCommand $command)
|
||||
public function renderRemoveAcknowledgement(RemoveAcknowledgementCommand $command): IcingaApiCommand
|
||||
{
|
||||
$endpoint = 'actions/remove-acknowledgement';
|
||||
$data = ['author' => $command->getAuthor()];
|
||||
|
|
@ -284,7 +284,7 @@ class IcingaApiCommandRenderer implements IcingaCommandRendererInterface
|
|||
return IcingaApiCommand::create($endpoint, $data);
|
||||
}
|
||||
|
||||
public function renderToggleInstanceFeature(ToggleInstanceFeatureCommand $command)
|
||||
public function renderToggleInstanceFeature(ToggleInstanceFeatureCommand $command): IcingaApiCommand
|
||||
{
|
||||
$endpoint = 'objects/icingaapplications/' . $this->getApp();
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class ApiCommandTransport implements CommandTransportInterface
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setApp($app)
|
||||
public function setApp(string $app): self
|
||||
{
|
||||
$this->renderer->setApp($app);
|
||||
|
||||
|
|
@ -86,8 +86,14 @@ class ApiCommandTransport implements CommandTransportInterface
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHost()
|
||||
public function getHost(): string
|
||||
{
|
||||
if ($this->host === null) {
|
||||
throw new \LogicException(
|
||||
'You are accessing an unset property. Please make sure to set it beforehand.'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->host;
|
||||
}
|
||||
|
||||
|
|
@ -98,7 +104,7 @@ class ApiCommandTransport implements CommandTransportInterface
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setHost($host)
|
||||
public function setHost(string $host): self
|
||||
{
|
||||
$this->host = $host;
|
||||
|
||||
|
|
@ -110,8 +116,14 @@ class ApiCommandTransport implements CommandTransportInterface
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPassword()
|
||||
public function getPassword(): string
|
||||
{
|
||||
if ($this->password === null) {
|
||||
throw new \LogicException(
|
||||
'You are accessing an unset property. Please make sure to set it beforehand.'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
|
|
@ -122,7 +134,7 @@ class ApiCommandTransport implements CommandTransportInterface
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPassword($password)
|
||||
public function setPassword(string $password): self
|
||||
{
|
||||
$this->password = $password;
|
||||
|
||||
|
|
@ -134,7 +146,7 @@ class ApiCommandTransport implements CommandTransportInterface
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPort()
|
||||
public function getPort(): int
|
||||
{
|
||||
return $this->port;
|
||||
}
|
||||
|
|
@ -146,9 +158,9 @@ class ApiCommandTransport implements CommandTransportInterface
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPort($port)
|
||||
public function setPort(int $port): self
|
||||
{
|
||||
$this->port = (int) $port;
|
||||
$this->port = $port;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -158,8 +170,14 @@ class ApiCommandTransport implements CommandTransportInterface
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUsername()
|
||||
public function getUsername(): string
|
||||
{
|
||||
if ($this->username === null) {
|
||||
throw new \LogicException(
|
||||
'You are accessing an unset property. Please make sure to set it beforehand.'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
|
|
@ -170,7 +188,7 @@ class ApiCommandTransport implements CommandTransportInterface
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUsername($username)
|
||||
public function setUsername(string $username): self
|
||||
{
|
||||
$this->username = $username;
|
||||
|
||||
|
|
@ -184,11 +202,18 @@ class ApiCommandTransport implements CommandTransportInterface
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getUriFor($endpoint)
|
||||
protected function getUriFor(string $endpoint): string
|
||||
{
|
||||
return sprintf('https://%s:%u/v1/%s', $this->getHost(), $this->getPort(), $endpoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given command to the icinga2's REST API
|
||||
*
|
||||
* @param IcingaApiCommand $command
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function sendCommand(IcingaApiCommand $command)
|
||||
{
|
||||
Logger::debug(
|
||||
|
|
@ -268,8 +293,10 @@ class ApiCommandTransport implements CommandTransportInterface
|
|||
* @param int|null $now
|
||||
*
|
||||
* @throws CommandTransportException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function send(IcingaCommand $command, $now = null)
|
||||
public function send(IcingaCommand $command, int $now = null)
|
||||
{
|
||||
return $this->sendCommand($this->renderer->render($command));
|
||||
}
|
||||
|
|
@ -277,6 +304,8 @@ class ApiCommandTransport implements CommandTransportInterface
|
|||
/**
|
||||
* Try to connect to the API
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws CommandTransportException In case the connection was not successful
|
||||
*/
|
||||
public function probe()
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class CommandTransport implements CommandTransportInterface
|
|||
*
|
||||
* @throws ConfigurationError
|
||||
*/
|
||||
public static function getConfig()
|
||||
public static function getConfig(): Config
|
||||
{
|
||||
if (static::$config === null) {
|
||||
$config = Config::module('icingadb', 'commandtransports');
|
||||
|
|
@ -56,7 +56,7 @@ class CommandTransport implements CommandTransportInterface
|
|||
*
|
||||
* @throws ConfigurationError
|
||||
*/
|
||||
public static function createTransport(ConfigObject $config)
|
||||
public static function createTransport(ConfigObject $config): ApiCommandTransport
|
||||
{
|
||||
$config = clone $config;
|
||||
switch (strtolower($config->transport)) {
|
||||
|
|
@ -97,8 +97,10 @@ class CommandTransport implements CommandTransportInterface
|
|||
* @param int|null $now Timestamp of the command or null for now
|
||||
*
|
||||
* @throws CommandTransportException If sending the Icinga command failed
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function send(IcingaCommand $command, $now = null)
|
||||
public function send(IcingaCommand $command, int $now = null)
|
||||
{
|
||||
$errors = [];
|
||||
|
||||
|
|
|
|||
|
|
@ -19,5 +19,5 @@ interface CommandTransportInterface
|
|||
*
|
||||
* @throws CommandTransportException If sending the Icinga command failed
|
||||
*/
|
||||
public function send(IcingaCommand $command, $now = null);
|
||||
public function send(IcingaCommand $command, int $now = null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
namespace Icinga\Module\Icingadb\Common;
|
||||
|
||||
use Icinga\Authentication\Auth as IcingaAuth;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use Icinga\Module\Icingadb\Authentication\ObjectAuthorization;
|
||||
use Icinga\Util\StringHelper;
|
||||
|
|
@ -17,9 +18,9 @@ use ipl\Web\Filter\QueryString;
|
|||
|
||||
trait Auth
|
||||
{
|
||||
public function getAuth()
|
||||
public function getAuth(): IcingaAuth
|
||||
{
|
||||
return \Icinga\Authentication\Auth::getInstance();
|
||||
return IcingaAuth::getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -29,7 +30,7 @@ trait Auth
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isPermittedRoute($name)
|
||||
public function isPermittedRoute(string $name): bool
|
||||
{
|
||||
if ($this->getAuth()->getUser()->isUnrestricted()) {
|
||||
return true;
|
||||
|
|
@ -51,7 +52,7 @@ trait Auth
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isGrantedOn($permission, Model $object)
|
||||
public function isGrantedOn(string $permission, Model $object): bool
|
||||
{
|
||||
if ($this->getAuth()->getUser()->isUnrestricted()) {
|
||||
return $this->getAuth()->hasPermission($permission);
|
||||
|
|
@ -76,7 +77,7 @@ trait Auth
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isGrantedOnType($permission, $type, Filter\Rule $filter, $cache = true)
|
||||
public function isGrantedOnType(string $permission, string $type, Filter\Rule $filter, bool $cache = true): bool
|
||||
{
|
||||
if ($this->getAuth()->getUser()->isUnrestricted()) {
|
||||
return $this->getAuth()->hasPermission($permission);
|
||||
|
|
@ -247,7 +248,7 @@ trait Auth
|
|||
*
|
||||
* @return Filter\Rule
|
||||
*/
|
||||
protected function parseRestriction($queryString, $restriction)
|
||||
protected function parseRestriction(string $queryString, string $restriction): Filter\Rule
|
||||
{
|
||||
$allowedColumns = [
|
||||
'host.name',
|
||||
|
|
@ -311,7 +312,7 @@ trait Auth
|
|||
*
|
||||
* @return Filter\None
|
||||
*/
|
||||
protected function parseBlacklist($blacklist, $column)
|
||||
protected function parseBlacklist(string $blacklist, string $column): Filter\None
|
||||
{
|
||||
$filter = Filter::none();
|
||||
foreach (explode(',', $blacklist) as $value) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ trait BaseFilter
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasBaseFilter()
|
||||
public function hasBaseFilter(): bool
|
||||
{
|
||||
return $this->baseFilter !== null;
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@ trait BaseFilter
|
|||
/**
|
||||
* Get the base filter
|
||||
*
|
||||
* @return Rule
|
||||
* @return ?Rule
|
||||
*/
|
||||
public function getBaseFilter()
|
||||
{
|
||||
|
|
@ -38,7 +38,7 @@ trait BaseFilter
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setBaseFilter(Rule $baseFilter = null)
|
||||
public function setBaseFilter(Rule $baseFilter = null): self
|
||||
{
|
||||
$this->baseFilter = $baseFilter;
|
||||
|
||||
|
|
|
|||
|
|
@ -49,14 +49,14 @@ abstract class BaseItemList extends BaseHtmlElement
|
|||
$this->init();
|
||||
}
|
||||
|
||||
abstract protected function getItemClass();
|
||||
abstract protected function getItemClass(): string;
|
||||
|
||||
/**
|
||||
* Get whether the list contains at least one item with an icon_image
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasIconImages()
|
||||
public function hasIconImages(): bool
|
||||
{
|
||||
return $this->hasIconImages;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ abstract class BaseListItem extends BaseHtmlElement
|
|||
{
|
||||
}
|
||||
|
||||
protected function createCaption()
|
||||
protected function createCaption(): BaseHtmlElement
|
||||
{
|
||||
$caption = Html::tag('section', ['class' => 'caption']);
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ abstract class BaseListItem extends BaseHtmlElement
|
|||
return $caption;
|
||||
}
|
||||
|
||||
protected function createHeader()
|
||||
protected function createHeader(): BaseHtmlElement
|
||||
{
|
||||
$header = Html::tag('header');
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ abstract class BaseListItem extends BaseHtmlElement
|
|||
return $header;
|
||||
}
|
||||
|
||||
protected function createMain()
|
||||
protected function createMain(): BaseHtmlElement
|
||||
{
|
||||
$main = Html::tag('div', ['class' => 'main']);
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ abstract class BaseListItem extends BaseHtmlElement
|
|||
return $main;
|
||||
}
|
||||
|
||||
protected function createFooter()
|
||||
protected function createFooter(): BaseHtmlElement
|
||||
{
|
||||
$footer = new HtmlElement('footer');
|
||||
|
||||
|
|
@ -102,6 +102,9 @@ abstract class BaseListItem extends BaseHtmlElement
|
|||
return $footer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?BaseHtmlElement
|
||||
*/
|
||||
protected function createIconImage()
|
||||
{
|
||||
if (! $this->list->hasIconImages()) {
|
||||
|
|
@ -121,7 +124,7 @@ abstract class BaseListItem extends BaseHtmlElement
|
|||
{
|
||||
}
|
||||
|
||||
protected function createTitle()
|
||||
protected function createTitle(): BaseHtmlElement
|
||||
{
|
||||
$title = HTML::tag('div', ['class' => 'title']);
|
||||
|
||||
|
|
@ -130,6 +133,9 @@ abstract class BaseListItem extends BaseHtmlElement
|
|||
return $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?BaseHtmlElement
|
||||
*/
|
||||
protected function createVisual()
|
||||
{
|
||||
$visual = Html::tag('div', ['class' => 'visual']);
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ abstract class BaseOrderedListItem extends BaseListItem
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setOrder($order)
|
||||
public function setOrder(int $order): self
|
||||
{
|
||||
$this->order = (int) $order;
|
||||
$this->order = $order;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -30,6 +30,12 @@ abstract class BaseOrderedListItem extends BaseListItem
|
|||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
if ($this->order === null) {
|
||||
throw new \LogicException(
|
||||
'You are accessing an unset property. Please make sure to set it beforehand.'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->order;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ abstract class BaseStatusBar extends BaseHtmlElement
|
|||
|
||||
abstract protected function assembleTotal(BaseHtmlElement $total);
|
||||
|
||||
abstract protected function createStateBadges();
|
||||
abstract protected function createStateBadges(): BaseHtmlElement;
|
||||
|
||||
protected function createCount()
|
||||
protected function createCount(): BaseHtmlElement
|
||||
{
|
||||
$total = Html::tag('span', ['class' => 'item-count']);
|
||||
|
||||
|
|
|
|||
|
|
@ -47,12 +47,12 @@ abstract class BaseTableRowItem extends BaseHtmlElement
|
|||
{
|
||||
}
|
||||
|
||||
protected function createColumn($content = null)
|
||||
protected function createColumn($content = null): BaseHtmlElement
|
||||
{
|
||||
return Html::tag('div', ['class' => 'col'], $content);
|
||||
}
|
||||
|
||||
protected function createColumns()
|
||||
protected function createColumns(): HtmlDocument
|
||||
{
|
||||
$columns = new HtmlDocument();
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ abstract class BaseTableRowItem extends BaseHtmlElement
|
|||
return $columns;
|
||||
}
|
||||
|
||||
protected function createTitle()
|
||||
protected function createTitle(): BaseHtmlElement
|
||||
{
|
||||
$title = $this->createColumn()->addAttributes(['class' => 'title']);
|
||||
|
||||
|
|
@ -70,6 +70,9 @@ abstract class BaseTableRowItem extends BaseHtmlElement
|
|||
return $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?BaseHtmlElement
|
||||
*/
|
||||
protected function createVisual()
|
||||
{
|
||||
$visual = new HtmlElement('div', Attributes::create(['class' => 'visual']));
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ trait CaptionDisabled
|
|||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isCaptionDisabled()
|
||||
public function isCaptionDisabled(): bool
|
||||
{
|
||||
return $this->captionDisabled;
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@ trait CaptionDisabled
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCaptionDisabled($captionDisabled = true)
|
||||
public function setCaptionDisabled(bool $captionDisabled = true): self
|
||||
{
|
||||
$this->captionDisabled = $captionDisabled;
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ trait CommandActions
|
|||
*
|
||||
* @return Model
|
||||
*/
|
||||
protected function getCommandTargetModel()
|
||||
protected function getCommandTargetModel(): Model
|
||||
{
|
||||
if (! isset($this->commandTargetModel)) {
|
||||
$commandTargets = $this->getCommandTargets();
|
||||
|
|
@ -95,7 +95,7 @@ trait CommandActions
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isGrantedOnCommandTargets($permission)
|
||||
protected function isGrantedOnCommandTargets(string $permission): bool
|
||||
{
|
||||
$commandTargets = $this->getCommandTargets();
|
||||
if (is_array($commandTargets)) {
|
||||
|
|
@ -122,7 +122,7 @@ trait CommandActions
|
|||
*
|
||||
* @throws SecurityException
|
||||
*/
|
||||
protected function assertIsGrantedOnCommandTargets($permission)
|
||||
protected function assertIsGrantedOnCommandTargets(string $permission)
|
||||
{
|
||||
if (! $this->isGrantedOnCommandTargets($permission)) {
|
||||
throw new SecurityException('No permission for %s', $permission);
|
||||
|
|
@ -133,6 +133,8 @@ trait CommandActions
|
|||
* Handle and register the given command form
|
||||
*
|
||||
* @param string|CommandForm $form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function handleCommandForm($form)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ trait Database
|
|||
*
|
||||
* @throws ConfigurationError If the related resource configuration does not exist
|
||||
*/
|
||||
public function getDb()
|
||||
public function getDb(): Connection
|
||||
{
|
||||
if ($this->db === null) {
|
||||
$config = new SqlConfig(ResourceFactory::getResourceConfig(
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ trait DetailActions
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDetailActionsDisabled($state = true)
|
||||
public function setDetailActionsDisabled(bool $state = true): self
|
||||
{
|
||||
$this->detailActionsDisabled = $state;
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ trait DetailActions
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getDetailActionsDisabled()
|
||||
public function getDetailActionsDisabled(): bool
|
||||
{
|
||||
return $this->detailActionsDisabled;
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ trait DetailActions
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function initializeDetailActions()
|
||||
public function initializeDetailActions(): self
|
||||
{
|
||||
$this->getAttributes()
|
||||
->registerAttributeCallback('class', function () {
|
||||
|
|
@ -63,7 +63,7 @@ trait DetailActions
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function setMultiselectUrl(Url $url)
|
||||
protected function setMultiselectUrl(Url $url): self
|
||||
{
|
||||
/** @var BaseHtmlElement $this */
|
||||
$this->getAttributes()
|
||||
|
|
@ -81,7 +81,7 @@ trait DetailActions
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function setDetailUrl(Url $url)
|
||||
protected function setDetailUrl(Url $url): self
|
||||
{
|
||||
/** @var BaseHtmlElement $this */
|
||||
$this->getAttributes()
|
||||
|
|
@ -100,7 +100,7 @@ trait DetailActions
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addMultiselectFilterAttribute(BaseHtmlElement $element, Filter\Rule $filter)
|
||||
public function addMultiselectFilterAttribute(BaseHtmlElement $element, Filter\Rule $filter): self
|
||||
{
|
||||
$element->getAttributes()
|
||||
->registerAttributeCallback('data-icinga-multiselect-filter', function () use ($filter) {
|
||||
|
|
@ -118,7 +118,7 @@ trait DetailActions
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addDetailFilterAttribute(BaseHtmlElement $element, Filter\Rule $filter)
|
||||
public function addDetailFilterAttribute(BaseHtmlElement $element, Filter\Rule $filter): self
|
||||
{
|
||||
$element->getAttributes()
|
||||
->registerAttributeCallback('data-icinga-detail-filter', function () use ($filter) {
|
||||
|
|
|
|||
|
|
@ -5,12 +5,13 @@
|
|||
namespace Icinga\Module\Icingadb\Common;
|
||||
|
||||
use Icinga\Module\Icingadb\Model\Host;
|
||||
use ipl\Html\BaseHtmlElement;
|
||||
use ipl\Html\Html;
|
||||
use ipl\Web\Widget\StateBall;
|
||||
|
||||
trait HostLink
|
||||
{
|
||||
protected function createHostLink(Host $host, $withStateBall = false)
|
||||
protected function createHostLink(Host $host, bool $withStateBall = false): BaseHtmlElement
|
||||
{
|
||||
$content = [];
|
||||
|
||||
|
|
|
|||
|
|
@ -9,67 +9,67 @@ use ipl\Web\Url;
|
|||
|
||||
abstract class HostLinks
|
||||
{
|
||||
public static function acknowledge(Host $host)
|
||||
public static function acknowledge(Host $host): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/host/acknowledge', ['name' => $host->name]);
|
||||
}
|
||||
|
||||
public static function addComment(Host $host)
|
||||
public static function addComment(Host $host): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/host/add-comment', ['name' => $host->name]);
|
||||
}
|
||||
|
||||
public static function checkNow(Host $host)
|
||||
public static function checkNow(Host $host): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/host/check-now', ['name' => $host->name]);
|
||||
}
|
||||
|
||||
public static function scheduleCheck(Host $host)
|
||||
public static function scheduleCheck(Host $host): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/host/schedule-check', ['name' => $host->name]);
|
||||
}
|
||||
|
||||
public static function comments(Host $host)
|
||||
public static function comments(Host $host): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/comments', ['host.name' => $host->name]);
|
||||
}
|
||||
|
||||
public static function downtimes(Host $host)
|
||||
public static function downtimes(Host $host): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/downtimes', ['host.name' => $host->name]);
|
||||
}
|
||||
|
||||
public static function history(Host $host)
|
||||
public static function history(Host $host): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/host/history', ['name' => $host->name]);
|
||||
}
|
||||
|
||||
public static function removeAcknowledgement(Host $host)
|
||||
public static function removeAcknowledgement(Host $host): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/host/remove-acknowledgement', ['name' => $host->name]);
|
||||
}
|
||||
|
||||
public static function scheduleDowntime(Host $host)
|
||||
public static function scheduleDowntime(Host $host): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/host/schedule-downtime', ['name' => $host->name]);
|
||||
}
|
||||
|
||||
public static function sendCustomNotification(Host $host)
|
||||
public static function sendCustomNotification(Host $host): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/host/send-custom-notification', ['name' => $host->name]);
|
||||
}
|
||||
|
||||
public static function processCheckresult(Host $host)
|
||||
public static function processCheckresult(Host $host): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/host/process-checkresult', ['name' => $host->name]);
|
||||
}
|
||||
|
||||
public static function toggleFeatures(Host $host)
|
||||
public static function toggleFeatures(Host $host): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/host/toggle-features', ['name' => $host->name]);
|
||||
}
|
||||
|
||||
public static function services(Host $host)
|
||||
public static function services(Host $host): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/host/services', ['name' => $host->name]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class HostStates
|
|||
*
|
||||
* @throws \InvalidArgumentException If the given host state is invalid, i.e. not known
|
||||
*/
|
||||
public static function int($state)
|
||||
public static function int(string $state): int
|
||||
{
|
||||
switch (strtolower($state)) {
|
||||
case 'up':
|
||||
|
|
@ -57,7 +57,7 @@ class HostStates
|
|||
*
|
||||
* @throws \InvalidArgumentException If the given host state is invalid, i.e. not known
|
||||
*/
|
||||
public static function text($state)
|
||||
public static function text(int $state): string
|
||||
{
|
||||
switch (true) {
|
||||
case $state === self::UP:
|
||||
|
|
@ -91,7 +91,7 @@ class HostStates
|
|||
*
|
||||
* @throws \InvalidArgumentException If the given host state is invalid, i.e. not known
|
||||
*/
|
||||
public static function translated($state)
|
||||
public static function translated(int $state): string
|
||||
{
|
||||
switch (true) {
|
||||
case $state === self::UP:
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class IcingaRedis
|
|||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getConnection()
|
||||
public function getConnection(): Redis
|
||||
{
|
||||
if ($this->redisUnavailable) {
|
||||
throw new Exception('Redis is still not available');
|
||||
|
|
@ -95,6 +95,13 @@ class IcingaRedis
|
|||
return $this->redis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last icinga heartbeat from redis
|
||||
*
|
||||
* @param Redis|null $redis
|
||||
*
|
||||
* @return ?float|int
|
||||
*/
|
||||
public static function getLastIcingaHeartbeat(Redis $redis = null)
|
||||
{
|
||||
if ($redis === null) {
|
||||
|
|
@ -126,7 +133,15 @@ class IcingaRedis
|
|||
return null;
|
||||
}
|
||||
|
||||
public static function getPrimaryRedis(Config $moduleConfig = null, Config $redisConfig = null)
|
||||
/**
|
||||
* Get the primary redis instance
|
||||
*
|
||||
* @param Config|null $moduleConfig
|
||||
* @param Config|null $redisConfig
|
||||
*
|
||||
* @return Redis
|
||||
*/
|
||||
public static function getPrimaryRedis(Config $moduleConfig = null, Config $redisConfig = null): Redis
|
||||
{
|
||||
if ($moduleConfig === null) {
|
||||
$moduleConfig = Config::module('icingadb');
|
||||
|
|
@ -149,6 +164,14 @@ class IcingaRedis
|
|||
return $redis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the secondary redis instance if exists
|
||||
*
|
||||
* @param Config|null $moduleConfig
|
||||
* @param Config|null $redisConfig
|
||||
*
|
||||
* @return ?Redis
|
||||
*/
|
||||
public static function getSecondaryRedis(Config $moduleConfig = null, Config $redisConfig = null)
|
||||
{
|
||||
if ($moduleConfig === null) {
|
||||
|
|
@ -177,7 +200,7 @@ class IcingaRedis
|
|||
return $redis;
|
||||
}
|
||||
|
||||
private static function getTlsParams(Config $config)
|
||||
private static function getTlsParams(Config $config): array
|
||||
{
|
||||
$config = $config->getSection('redis');
|
||||
|
||||
|
|
|
|||
|
|
@ -16,127 +16,127 @@ use ipl\Web\Url;
|
|||
|
||||
abstract class Links
|
||||
{
|
||||
public static function comment(Comment $comment)
|
||||
public static function comment(Comment $comment): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/comment', ['name' => $comment->name]);
|
||||
}
|
||||
|
||||
public static function comments()
|
||||
public static function comments(): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/comments');
|
||||
}
|
||||
|
||||
public static function commentsDelete()
|
||||
public static function commentsDelete(): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/comments/delete');
|
||||
}
|
||||
|
||||
public static function commentsDetails()
|
||||
public static function commentsDetails(): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/comments/details');
|
||||
}
|
||||
|
||||
public static function downtime(Downtime $downtime)
|
||||
public static function downtime(Downtime $downtime): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/downtime', ['name' => $downtime->name]);
|
||||
}
|
||||
|
||||
public static function downtimes()
|
||||
public static function downtimes(): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/downtimes');
|
||||
}
|
||||
|
||||
public static function downtimesDelete()
|
||||
public static function downtimesDelete(): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/downtimes/delete');
|
||||
}
|
||||
|
||||
public static function downtimesDetails()
|
||||
public static function downtimesDetails(): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/downtimes/details');
|
||||
}
|
||||
|
||||
public static function host(Host $host)
|
||||
public static function host(Host $host): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/host', ['name' => $host->name]);
|
||||
}
|
||||
|
||||
public static function hostSource(Host $host)
|
||||
public static function hostSource(Host $host): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/host/source', ['name' => $host->name]);
|
||||
}
|
||||
|
||||
public static function hostsDetails()
|
||||
public static function hostsDetails(): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/hosts/details');
|
||||
}
|
||||
|
||||
public static function hostgroup($hostgroup)
|
||||
public static function hostgroup($hostgroup): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/hostgroup', ['name' => $hostgroup->name]);
|
||||
}
|
||||
|
||||
public static function hosts()
|
||||
public static function hosts(): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/hosts');
|
||||
}
|
||||
|
||||
public static function service(Service $service, Host $host)
|
||||
public static function service(Service $service, Host $host): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/service', ['name' => $service->name, 'host.name' => $host->name]);
|
||||
}
|
||||
|
||||
public static function serviceSource(Service $service, Host $host)
|
||||
public static function serviceSource(Service $service, Host $host): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/service/source', ['name' => $service->name, 'host.name' => $host->name]);
|
||||
}
|
||||
|
||||
public static function servicesDetails()
|
||||
public static function servicesDetails(): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/services/details');
|
||||
}
|
||||
|
||||
public static function servicegroup($servicegroup)
|
||||
public static function servicegroup($servicegroup): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/servicegroup', ['name' => $servicegroup->name]);
|
||||
}
|
||||
|
||||
public static function services()
|
||||
public static function services(): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/services');
|
||||
}
|
||||
|
||||
public static function toggleHostsFeatures()
|
||||
public static function toggleHostsFeatures(): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/hosts/toggle-features');
|
||||
}
|
||||
|
||||
public static function toggleServicesFeatures()
|
||||
public static function toggleServicesFeatures(): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/services/toggle-features');
|
||||
}
|
||||
|
||||
public static function user(User $user)
|
||||
public static function user(User $user): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/user', ['name' => $user->name]);
|
||||
}
|
||||
|
||||
public static function usergroup(Usergroup $usergroup)
|
||||
public static function usergroup(Usergroup $usergroup): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/usergroup', ['name' => $usergroup->name]);
|
||||
}
|
||||
|
||||
public static function users()
|
||||
public static function users(): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/users');
|
||||
}
|
||||
|
||||
public static function usergroups()
|
||||
public static function usergroups(): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/usergroups');
|
||||
}
|
||||
|
||||
public static function event(History $event)
|
||||
public static function event(History $event): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/event', ['id' => bin2hex($event->id)]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ trait LoadMore
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPageSize($size)
|
||||
public function setPageSize(int $size): self
|
||||
{
|
||||
$this->pageSize = $size;
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ trait LoadMore
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPageNumber($number)
|
||||
public function setPageNumber(int $number): self
|
||||
{
|
||||
$this->pageNumber = $number;
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ trait LoadMore
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLoadMoreUrl(Url $url)
|
||||
public function setLoadMoreUrl(Url $url): self
|
||||
{
|
||||
$this->loadMoreUrl = $url;
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ trait LoadMore
|
|||
*
|
||||
* @return Generator
|
||||
*/
|
||||
protected function getIterator(ResultSet $result)
|
||||
protected function getIterator(ResultSet $result): Generator
|
||||
{
|
||||
$count = 0;
|
||||
$pageNumber = $this->pageNumber ?: 1;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ trait NoSubjectLink
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setNoSubjectLink($state = true)
|
||||
public function setNoSubjectLink(bool $state = true): self
|
||||
{
|
||||
$this->noSubjectLink = $state;
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ trait NoSubjectLink
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getNoSubjectLink()
|
||||
public function getNoSubjectLink(): bool
|
||||
{
|
||||
return $this->noSubjectLink;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,11 @@ abstract class ObjectInspectionDetail extends BaseHtmlElement
|
|||
$this->joins = $apiResult['joins'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the object source location
|
||||
*
|
||||
* @return ?array
|
||||
*/
|
||||
protected function createSourceLocation()
|
||||
{
|
||||
if (! isset($this->attrs['source_location'])) {
|
||||
|
|
@ -58,6 +63,11 @@ abstract class ObjectInspectionDetail extends BaseHtmlElement
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Render object's last check result
|
||||
*
|
||||
* @return ?array
|
||||
*/
|
||||
protected function createLastCheckResult()
|
||||
{
|
||||
if (! isset($this->attrs['last_check_result'])) {
|
||||
|
|
@ -94,7 +104,7 @@ abstract class ObjectInspectionDetail extends BaseHtmlElement
|
|||
];
|
||||
}
|
||||
|
||||
protected function createRedisInfo()
|
||||
protected function createRedisInfo(): array
|
||||
{
|
||||
$title = new HtmlElement('h2', null, Text::create(t('Volatile State Details')));
|
||||
|
||||
|
|
@ -138,7 +148,7 @@ abstract class ObjectInspectionDetail extends BaseHtmlElement
|
|||
)];
|
||||
}
|
||||
|
||||
protected function createAttributes()
|
||||
protected function createAttributes(): array
|
||||
{
|
||||
$blacklist = [
|
||||
'name',
|
||||
|
|
@ -188,6 +198,13 @@ abstract class ObjectInspectionDetail extends BaseHtmlElement
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the given value as a json
|
||||
*
|
||||
* @param mixed $json
|
||||
*
|
||||
* @return BaseHtmlElement|string
|
||||
*/
|
||||
private function formatJson($json)
|
||||
{
|
||||
if (is_scalar($json)) {
|
||||
|
|
@ -201,7 +218,7 @@ abstract class ObjectInspectionDetail extends BaseHtmlElement
|
|||
);
|
||||
}
|
||||
|
||||
private function formatTimestamp($ts)
|
||||
private function formatTimestamp($ts): string
|
||||
{
|
||||
if (empty($ts)) {
|
||||
return new EmptyState(t('n. a.'));
|
||||
|
|
@ -217,22 +234,22 @@ abstract class ObjectInspectionDetail extends BaseHtmlElement
|
|||
->format('Y-m-d\TH:i:s.vP');
|
||||
}
|
||||
|
||||
private function formatMillisecondTimestamp($ms)
|
||||
private function formatMillisecondTimestamp($ms): string
|
||||
{
|
||||
return $this->formatTimestamp($ms / 1000.0);
|
||||
}
|
||||
|
||||
private function formatSeconds($s)
|
||||
private function formatSeconds($s): string
|
||||
{
|
||||
return Format::seconds($s);
|
||||
}
|
||||
|
||||
private function formatMilliseconds($ms)
|
||||
private function formatMilliseconds($ms): string
|
||||
{
|
||||
return Format::seconds($ms / 1000.0);
|
||||
}
|
||||
|
||||
private function formatState($state)
|
||||
private function formatState(int $state): string
|
||||
{
|
||||
switch (true) {
|
||||
case $this->object instanceof Host:
|
||||
|
|
@ -244,7 +261,7 @@ abstract class ObjectInspectionDetail extends BaseHtmlElement
|
|||
}
|
||||
}
|
||||
|
||||
private function createNameValueTable(array $data, array $formatters)
|
||||
private function createNameValueTable(array $data, array $formatters): Table
|
||||
{
|
||||
$table = new Table();
|
||||
$table->addAttributes(['class' => 'name-value-table']);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ trait ObjectLinkDisabled
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setObjectLinkDisabled($state = true)
|
||||
public function setObjectLinkDisabled(bool $state = true): self
|
||||
{
|
||||
$this->objectLinkDisabled = $state;
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ trait ObjectLinkDisabled
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getObjectLinkDisabled()
|
||||
public function getObjectLinkDisabled(): bool
|
||||
{
|
||||
return $this->objectLinkDisabled;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,12 +6,13 @@ namespace Icinga\Module\Icingadb\Common;
|
|||
|
||||
use Icinga\Module\Icingadb\Model\Host;
|
||||
use Icinga\Module\Icingadb\Model\Service;
|
||||
use ipl\Html\FormattedString;
|
||||
use ipl\Html\Html;
|
||||
use ipl\Web\Widget\StateBall;
|
||||
|
||||
trait ServiceLink
|
||||
{
|
||||
protected function createServiceLink(Service $service, Host $host, $withStateBall = false)
|
||||
protected function createServiceLink(Service $service, Host $host, bool $withStateBall = false): FormattedString
|
||||
{
|
||||
$content = [];
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use ipl\Web\Url;
|
|||
|
||||
abstract class ServiceLinks
|
||||
{
|
||||
public static function acknowledge(Service $service, Host $host)
|
||||
public static function acknowledge(Service $service, Host $host): Url
|
||||
{
|
||||
return Url::fromPath(
|
||||
'icingadb/service/acknowledge',
|
||||
|
|
@ -18,7 +18,7 @@ abstract class ServiceLinks
|
|||
);
|
||||
}
|
||||
|
||||
public static function addComment(Service $service, Host $host)
|
||||
public static function addComment(Service $service, Host $host): Url
|
||||
{
|
||||
return Url::fromPath(
|
||||
'icingadb/service/add-comment',
|
||||
|
|
@ -26,7 +26,7 @@ abstract class ServiceLinks
|
|||
);
|
||||
}
|
||||
|
||||
public static function checkNow(Service $service, Host $host)
|
||||
public static function checkNow(Service $service, Host $host): Url
|
||||
{
|
||||
return Url::fromPath(
|
||||
'icingadb/service/check-now',
|
||||
|
|
@ -34,7 +34,7 @@ abstract class ServiceLinks
|
|||
);
|
||||
}
|
||||
|
||||
public static function scheduleCheck(Service $service, Host $host)
|
||||
public static function scheduleCheck(Service $service, Host $host): Url
|
||||
{
|
||||
return Url::fromPath(
|
||||
'icingadb/service/schedule-check',
|
||||
|
|
@ -42,7 +42,7 @@ abstract class ServiceLinks
|
|||
);
|
||||
}
|
||||
|
||||
public static function comments(Service $service, Host $host)
|
||||
public static function comments(Service $service, Host $host): Url
|
||||
{
|
||||
return Url::fromPath(
|
||||
'icingadb/comments',
|
||||
|
|
@ -50,7 +50,7 @@ abstract class ServiceLinks
|
|||
);
|
||||
}
|
||||
|
||||
public static function downtimes(Service $service, Host $host)
|
||||
public static function downtimes(Service $service, Host $host): Url
|
||||
{
|
||||
return Url::fromPath(
|
||||
'icingadb/downtimes',
|
||||
|
|
@ -58,7 +58,7 @@ abstract class ServiceLinks
|
|||
);
|
||||
}
|
||||
|
||||
public static function history(Service $service, Host $host)
|
||||
public static function history(Service $service, Host $host): Url
|
||||
{
|
||||
return Url::fromPath(
|
||||
'icingadb/service/history',
|
||||
|
|
@ -66,7 +66,7 @@ abstract class ServiceLinks
|
|||
);
|
||||
}
|
||||
|
||||
public static function removeAcknowledgement(Service $service, Host $host)
|
||||
public static function removeAcknowledgement(Service $service, Host $host): Url
|
||||
{
|
||||
return Url::fromPath(
|
||||
'icingadb/service/remove-acknowledgement',
|
||||
|
|
@ -74,7 +74,7 @@ abstract class ServiceLinks
|
|||
);
|
||||
}
|
||||
|
||||
public static function scheduleDowntime(Service $service, Host $host)
|
||||
public static function scheduleDowntime(Service $service, Host $host): Url
|
||||
{
|
||||
return Url::fromPath(
|
||||
'icingadb/service/schedule-downtime',
|
||||
|
|
@ -82,7 +82,7 @@ abstract class ServiceLinks
|
|||
);
|
||||
}
|
||||
|
||||
public static function sendCustomNotification(Service $service, Host $host)
|
||||
public static function sendCustomNotification(Service $service, Host $host): Url
|
||||
{
|
||||
return Url::fromPath(
|
||||
'icingadb/service/send-custom-notification',
|
||||
|
|
@ -90,7 +90,7 @@ abstract class ServiceLinks
|
|||
);
|
||||
}
|
||||
|
||||
public static function processCheckresult(Service $service, Host $host)
|
||||
public static function processCheckresult(Service $service, Host $host): Url
|
||||
{
|
||||
return Url::fromPath(
|
||||
'icingadb/service/process-checkresult',
|
||||
|
|
@ -98,7 +98,7 @@ abstract class ServiceLinks
|
|||
);
|
||||
}
|
||||
|
||||
public static function toggleFeatures(Service $service, Host $host)
|
||||
public static function toggleFeatures(Service $service, Host $host): Url
|
||||
{
|
||||
return Url::fromPath(
|
||||
'icingadb/service/toggle-features',
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class ServiceStates
|
|||
*
|
||||
* @throws \InvalidArgumentException If the given service state is invalid, i.e. not known
|
||||
*/
|
||||
public static function int($state)
|
||||
public static function int(string $state): int
|
||||
{
|
||||
switch (strtolower($state)) {
|
||||
case 'ok':
|
||||
|
|
@ -62,7 +62,7 @@ class ServiceStates
|
|||
*
|
||||
* @throws \InvalidArgumentException If the given service state is invalid, i.e. not known
|
||||
*/
|
||||
public static function text($state)
|
||||
public static function text(int $state): string
|
||||
{
|
||||
switch (true) {
|
||||
case $state === self::OK:
|
||||
|
|
@ -99,7 +99,7 @@ class ServiceStates
|
|||
*
|
||||
* @throws \InvalidArgumentException If the given service state is invalid, i.e. not known
|
||||
*/
|
||||
public static function translated($state)
|
||||
public static function translated(int $state): string
|
||||
{
|
||||
switch (true) {
|
||||
case $state === self::OK:
|
||||
|
|
|
|||
|
|
@ -46,14 +46,14 @@ abstract class StateBadges extends BaseHtmlElement
|
|||
*
|
||||
* @return Url
|
||||
*/
|
||||
abstract protected function getBaseUrl();
|
||||
abstract protected function getBaseUrl(): Url;
|
||||
|
||||
/**
|
||||
* Get the prefix for accessing state information
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getPrefix();
|
||||
abstract protected function getPrefix(): string;
|
||||
|
||||
/**
|
||||
* Get the integer of the given state text
|
||||
|
|
@ -62,14 +62,14 @@ abstract class StateBadges extends BaseHtmlElement
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
abstract protected function getStateInt($state);
|
||||
abstract protected function getStateInt(string $state): int;
|
||||
|
||||
/**
|
||||
* Get the badge URL
|
||||
*
|
||||
* @return Url
|
||||
*/
|
||||
public function getUrl()
|
||||
public function getUrl(): Url
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ abstract class StateBadges extends BaseHtmlElement
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUrl($url)
|
||||
public function setUrl(Url $url): self
|
||||
{
|
||||
$this->url = $url;
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ abstract class StateBadges extends BaseHtmlElement
|
|||
*
|
||||
* @return Link
|
||||
*/
|
||||
public function createLink($content, array $params = null)
|
||||
public function createLink($content, array $params = null): Link
|
||||
{
|
||||
$url = clone $this->getUrl();
|
||||
|
||||
|
|
@ -111,7 +111,14 @@ abstract class StateBadges extends BaseHtmlElement
|
|||
return new Link($content, $url);
|
||||
}
|
||||
|
||||
protected function createBadge($state)
|
||||
/**
|
||||
* Create a state bade
|
||||
*
|
||||
* @param string $state
|
||||
*
|
||||
* @return ?BaseHtmlElement
|
||||
*/
|
||||
protected function createBadge(string $state)
|
||||
{
|
||||
$key = $this->prefix . "_{$state}";
|
||||
|
||||
|
|
@ -125,7 +132,14 @@ abstract class StateBadges extends BaseHtmlElement
|
|||
return null;
|
||||
}
|
||||
|
||||
protected function createGroup($state)
|
||||
/**
|
||||
* Create a state group
|
||||
*
|
||||
* @param string $state
|
||||
*
|
||||
* @return ?BaseHtmlElement
|
||||
*/
|
||||
protected function createGroup(string $state)
|
||||
{
|
||||
$content = [];
|
||||
$handledKey = $this->prefix . "_{$state}_handled";
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ trait ViewMode
|
|||
/**
|
||||
* Get the view mode
|
||||
*
|
||||
* @return string
|
||||
* @return ?string
|
||||
*/
|
||||
public function getViewMode()
|
||||
{
|
||||
|
|
@ -26,7 +26,7 @@ trait ViewMode
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setViewMode($viewMode)
|
||||
public function setViewMode(string $viewMode): self
|
||||
{
|
||||
$this->viewMode = $viewMode;
|
||||
|
||||
|
|
|
|||
|
|
@ -51,17 +51,17 @@ trait CompatObject
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->object->name;
|
||||
}
|
||||
|
||||
public function fetch()
|
||||
public function fetch(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function fetchRawCustomvars()
|
||||
protected function fetchRawCustomvars(): self
|
||||
{
|
||||
if ($this->rawCustomvars !== null) {
|
||||
return $this;
|
||||
|
|
@ -79,7 +79,7 @@ trait CompatObject
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function fetchCustomvars()
|
||||
public function fetchCustomvars(): self
|
||||
{
|
||||
if ($this->customvars !== null) {
|
||||
return $this;
|
||||
|
|
@ -181,6 +181,13 @@ trait CompatObject
|
|||
throw new NotImplementedError('getDataView() is not supported');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bool type of the given value as an int
|
||||
*
|
||||
* @param bool|string $value
|
||||
*
|
||||
* @return ?int
|
||||
*/
|
||||
private function getBoolType($value)
|
||||
{
|
||||
switch ($value) {
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ class CompatService extends Service
|
|||
*
|
||||
* @return CompatHost
|
||||
*/
|
||||
public function getHost()
|
||||
public function getHost(): CompatHost
|
||||
{
|
||||
if ($this->host === null) {
|
||||
$this->host = new CompatHost($this->object->host);
|
||||
|
|
|
|||
|
|
@ -39,18 +39,18 @@ class UrlMigrator
|
|||
'monitoring/tactical' => ['services', 'icingadb/tactical']
|
||||
];
|
||||
|
||||
public static function isSupportedUrl(Url $url)
|
||||
public static function isSupportedUrl(Url $url): bool
|
||||
{
|
||||
$supportedPaths = self::SUPPORTED_PATHS;
|
||||
return isset($supportedPaths[$url->getPath()]);
|
||||
}
|
||||
|
||||
public static function hasQueryTransformer($name)
|
||||
public static function hasQueryTransformer(string $name): bool
|
||||
{
|
||||
return method_exists(new self(), $name . 'Columns');
|
||||
}
|
||||
|
||||
public static function transformUrl(Url $url)
|
||||
public static function transformUrl(Url $url): Url
|
||||
{
|
||||
if (! self::isSupportedUrl($url)) {
|
||||
throw new InvalidArgumentException(sprintf('Url path "%s" is not supported', $url->getPath()));
|
||||
|
|
@ -70,7 +70,15 @@ class UrlMigrator
|
|||
return $url;
|
||||
}
|
||||
|
||||
public static function transformFilter(Filter\Rule $filter, $queryTransformer = null)
|
||||
/**
|
||||
* Transform the given legacy filter
|
||||
*
|
||||
* @param Filter\Rule $filter
|
||||
* @param string|null $queryTransformer
|
||||
*
|
||||
* @return Filter\Rule|false
|
||||
*/
|
||||
public static function transformFilter(Filter\Rule $filter, string $queryTransformer = null)
|
||||
{
|
||||
$transformer = new self();
|
||||
|
||||
|
|
@ -87,6 +95,15 @@ class UrlMigrator
|
|||
return $rewritten === false ? false : ($rewritten instanceof Filter\Rule ? $rewritten : $filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewrite the given filter and legacy columns
|
||||
*
|
||||
* @param Filter\Rule $filter
|
||||
* @param array $legacyColumns
|
||||
* @param Filter\Chain|null $parent
|
||||
*
|
||||
* @return ?mixed
|
||||
*/
|
||||
protected function rewrite(Filter\Rule $filter, array $legacyColumns, Filter\Chain $parent = null)
|
||||
{
|
||||
$rewritten = null;
|
||||
|
|
@ -174,7 +191,7 @@ class UrlMigrator
|
|||
return $rewritten;
|
||||
}
|
||||
|
||||
protected static function commonColumns()
|
||||
protected static function commonColumns(): array
|
||||
{
|
||||
return [
|
||||
|
||||
|
|
@ -222,7 +239,7 @@ class UrlMigrator
|
|||
];
|
||||
}
|
||||
|
||||
protected static function hostsColumns()
|
||||
protected static function hostsColumns(): array
|
||||
{
|
||||
return [
|
||||
|
||||
|
|
@ -402,7 +419,7 @@ class UrlMigrator
|
|||
];
|
||||
}
|
||||
|
||||
protected static function multipleHostsColumns()
|
||||
protected static function multipleHostsColumns(): array
|
||||
{
|
||||
return array_merge(
|
||||
static::hostsColumns(),
|
||||
|
|
@ -414,7 +431,7 @@ class UrlMigrator
|
|||
);
|
||||
}
|
||||
|
||||
protected static function hostColumns()
|
||||
protected static function hostColumns(): array
|
||||
{
|
||||
return [
|
||||
'host' => [
|
||||
|
|
@ -423,7 +440,7 @@ class UrlMigrator
|
|||
];
|
||||
}
|
||||
|
||||
protected static function servicesColumns()
|
||||
protected static function servicesColumns(): array
|
||||
{
|
||||
return [
|
||||
|
||||
|
|
@ -723,7 +740,7 @@ class UrlMigrator
|
|||
];
|
||||
}
|
||||
|
||||
protected static function multipleServicesColumns()
|
||||
protected static function multipleServicesColumns(): array
|
||||
{
|
||||
return array_merge(
|
||||
static::servicesColumns(),
|
||||
|
|
@ -738,7 +755,7 @@ class UrlMigrator
|
|||
);
|
||||
}
|
||||
|
||||
protected static function serviceColumns()
|
||||
protected static function serviceColumns(): array
|
||||
{
|
||||
return [
|
||||
'host' => [
|
||||
|
|
@ -750,7 +767,7 @@ class UrlMigrator
|
|||
];
|
||||
}
|
||||
|
||||
protected static function hostgroupsColumns()
|
||||
protected static function hostgroupsColumns(): array
|
||||
{
|
||||
return [
|
||||
|
||||
|
|
@ -772,7 +789,7 @@ class UrlMigrator
|
|||
];
|
||||
}
|
||||
|
||||
protected static function servicegroupsColumns()
|
||||
protected static function servicegroupsColumns(): array
|
||||
{
|
||||
return [
|
||||
|
||||
|
|
@ -799,7 +816,7 @@ class UrlMigrator
|
|||
];
|
||||
}
|
||||
|
||||
protected static function contactgroupsColumns()
|
||||
protected static function contactgroupsColumns(): array
|
||||
{
|
||||
return [
|
||||
|
||||
|
|
@ -819,7 +836,7 @@ class UrlMigrator
|
|||
];
|
||||
}
|
||||
|
||||
protected static function contactsColumns()
|
||||
protected static function contactsColumns(): array
|
||||
{
|
||||
$receivesStateNotifications = function ($state, $type = null) {
|
||||
return function ($filter) use ($state, $type) {
|
||||
|
|
@ -939,7 +956,7 @@ class UrlMigrator
|
|||
];
|
||||
}
|
||||
|
||||
protected static function commentsColumns()
|
||||
protected static function commentsColumns(): array
|
||||
{
|
||||
return [
|
||||
|
||||
|
|
@ -986,7 +1003,7 @@ class UrlMigrator
|
|||
];
|
||||
}
|
||||
|
||||
protected static function downtimesColumns()
|
||||
protected static function downtimesColumns(): array
|
||||
{
|
||||
return [
|
||||
|
||||
|
|
@ -1054,7 +1071,7 @@ class UrlMigrator
|
|||
];
|
||||
}
|
||||
|
||||
protected static function historyColumns()
|
||||
protected static function historyColumns(): array
|
||||
{
|
||||
return [
|
||||
|
||||
|
|
@ -1117,7 +1134,7 @@ class UrlMigrator
|
|||
];
|
||||
}
|
||||
|
||||
protected static function notificationHistoryColumns()
|
||||
protected static function notificationHistoryColumns(): array
|
||||
{
|
||||
return [
|
||||
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ class PivotTable
|
|||
* @param string $yAxisColumn Y-axis pivot column
|
||||
* @param array $gridcols Grid columns
|
||||
*/
|
||||
public function __construct(Query $query, $xAxisColumn, $yAxisColumn, $gridcols)
|
||||
public function __construct(Query $query, string $xAxisColumn, string $yAxisColumn, array $gridcols)
|
||||
{
|
||||
foreach ($query->getOrderBy() as $sort) {
|
||||
$this->order[$sort[0]] = $sort[1];
|
||||
|
|
@ -118,7 +118,7 @@ class PivotTable
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setXAxisFilter(Filter\Rule $filter = null)
|
||||
public function setXAxisFilter(Filter\Rule $filter = null): self
|
||||
{
|
||||
$this->xAxisFilter = $filter;
|
||||
return $this;
|
||||
|
|
@ -127,11 +127,11 @@ class PivotTable
|
|||
/**
|
||||
* Set the filter to apply on the query for the y-axis
|
||||
*
|
||||
* @param Filter $filter
|
||||
* @param Filter\Rule $filter
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setYAxisFilter(Filter\Rule $filter = null)
|
||||
public function setYAxisFilter(Filter\Rule $filter = null): self
|
||||
{
|
||||
$this->yAxisFilter = $filter;
|
||||
return $this;
|
||||
|
|
@ -144,8 +144,14 @@ class PivotTable
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getXAxisHeader()
|
||||
public function getXAxisHeader(): string
|
||||
{
|
||||
if ($this->xAxisHeader === null && $this->xAxisColumn === null) {
|
||||
throw new \LogicException(
|
||||
'You are accessing an unset property. Please make sure to set it beforehand.'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->xAxisHeader !== null ? $this->xAxisHeader : $this->xAxisColumn;
|
||||
}
|
||||
|
||||
|
|
@ -156,9 +162,9 @@ class PivotTable
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setXAxisHeader($xAxisHeader)
|
||||
public function setXAxisHeader(string $xAxisHeader): self
|
||||
{
|
||||
$this->xAxisHeader = (string) $xAxisHeader;
|
||||
$this->xAxisHeader = $xAxisHeader;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -169,8 +175,14 @@ class PivotTable
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getYAxisHeader()
|
||||
public function getYAxisHeader(): string
|
||||
{
|
||||
if ($this->yAxisHeader === null && $this->yAxisColumn === null) {
|
||||
throw new \LogicException(
|
||||
'You are accessing an unset property. Please make sure to set it beforehand.'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->yAxisHeader !== null ? $this->yAxisHeader : $this->yAxisColumn;
|
||||
}
|
||||
|
||||
|
|
@ -181,9 +193,9 @@ class PivotTable
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setYAxisHeader($yAxisHeader)
|
||||
public function setYAxisHeader(string $yAxisHeader): self
|
||||
{
|
||||
$this->yAxisHeader = (string) $yAxisHeader;
|
||||
$this->yAxisHeader = $yAxisHeader;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -196,7 +208,7 @@ class PivotTable
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getPaginationParameter($axis, $param, $default = null)
|
||||
protected function getPaginationParameter(string $axis, string $param, int $default = null): int
|
||||
{
|
||||
$request = Icinga::app()->getRequest();
|
||||
|
||||
|
|
@ -214,7 +226,7 @@ class PivotTable
|
|||
*
|
||||
* @return Query
|
||||
*/
|
||||
protected function queryXAxis()
|
||||
protected function queryXAxis(): Query
|
||||
{
|
||||
if ($this->xAxisQuery === null) {
|
||||
$this->xAxisQuery = clone $this->baseQuery;
|
||||
|
|
@ -263,7 +275,7 @@ class PivotTable
|
|||
*
|
||||
* @return Query
|
||||
*/
|
||||
protected function queryYAxis()
|
||||
protected function queryYAxis(): Query
|
||||
{
|
||||
if ($this->yAxisQuery === null) {
|
||||
$this->yAxisQuery = clone $this->baseQuery;
|
||||
|
|
@ -317,7 +329,7 @@ class PivotTable
|
|||
*
|
||||
* @return Paginatable
|
||||
*/
|
||||
public function paginateXAxis($limit = null, $page = null)
|
||||
public function paginateXAxis(int $limit = null, int $page = null): Paginatable
|
||||
{
|
||||
if ($limit === null || $page === null) {
|
||||
if ($limit === null) {
|
||||
|
|
@ -348,7 +360,7 @@ class PivotTable
|
|||
*
|
||||
* @return Paginatable
|
||||
*/
|
||||
public function paginateYAxis($limit = null, $page = null)
|
||||
public function paginateYAxis(int $limit = null, int $page = null): Paginatable
|
||||
{
|
||||
if ($limit === null || $page === null) {
|
||||
if ($limit === null) {
|
||||
|
|
@ -372,7 +384,7 @@ class PivotTable
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
public function toArray(): array
|
||||
{
|
||||
if (
|
||||
($this->xAxisFilter === null && $this->yAxisFilter === null)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ trait HookActions
|
|||
*
|
||||
* @return ValidHtml[]
|
||||
*/
|
||||
abstract protected function getDefaultTabControls();
|
||||
abstract protected function getDefaultTabControls(): array;
|
||||
|
||||
public function __call($methodName, $args)
|
||||
{
|
||||
|
|
@ -50,6 +50,8 @@ trait HookActions
|
|||
* Register the object for which to load additional tabs
|
||||
*
|
||||
* @param Model $object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function loadTabsForObject(Model $object)
|
||||
{
|
||||
|
|
@ -103,6 +105,8 @@ trait HookActions
|
|||
* Render the given tab hook
|
||||
*
|
||||
* @param TabHook $hook
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function showTabHook(TabHook $hook)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class ReRoute implements RewriteBehavior
|
|||
$this->routes = $routes;
|
||||
}
|
||||
|
||||
public function getRoutes()
|
||||
public function getRoutes(): array
|
||||
{
|
||||
return $this->routes;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class CustomvarFlat extends Model
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function unFlattenVars(Traversable $flattenedVars)
|
||||
public function unFlattenVars(Traversable $flattenedVars): array
|
||||
{
|
||||
$registerValue = function (&$data, $path, $value) use (&$registerValue) {
|
||||
$step = array_shift($path);
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class HostState extends State
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStateText()
|
||||
public function getStateText(): string
|
||||
{
|
||||
return HostStates::text($this->soft_state);
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ class HostState extends State
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStateTextTranslated()
|
||||
public function getStateTextTranslated(): string
|
||||
{
|
||||
return HostStates::text($this->soft_state);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class ServiceState extends State
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStateText()
|
||||
public function getStateText(): string
|
||||
{
|
||||
return ServiceStates::text($this->soft_state);
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@ class ServiceState extends State
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStateTextTranslated()
|
||||
public function getStateTextTranslated(): string
|
||||
{
|
||||
return ServiceStates::text($this->soft_state);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,12 +16,12 @@ class IcingaHealth extends HealthHook
|
|||
/** @var Instance */
|
||||
protected $instance;
|
||||
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Icinga DB';
|
||||
}
|
||||
|
||||
public function getUrl()
|
||||
public function getUrl(): Url
|
||||
{
|
||||
return Url::fromPath('icingadb/health');
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@ class IcingaHealth extends HealthHook
|
|||
}
|
||||
}
|
||||
|
||||
protected function getInstance()
|
||||
protected function getInstance(): Instance
|
||||
{
|
||||
if ($this->instance === null) {
|
||||
$this->instance = Instance::on($this->getDb())
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class RedisHealth extends HealthHook
|
|||
{
|
||||
use Database;
|
||||
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Icinga Redis';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
namespace Icinga\Module\Icingadb\ProvidedHook\X509;
|
||||
|
||||
use Generator;
|
||||
use Icinga\Data\Filter\Filter;
|
||||
use Icinga\Module\Icingadb\Common\Auth;
|
||||
use Icinga\Module\Icingadb\Common\Database;
|
||||
|
|
@ -19,7 +20,7 @@ class Sni extends SniHook
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getHosts(Filter $filter = null)
|
||||
public function getHosts(Filter $filter = null): Generator
|
||||
{
|
||||
$queryHost = Host::on($this->getDb());
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class VolatileState
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function fetch(State $state)
|
||||
public function fetch(State $state): self
|
||||
{
|
||||
$type = substr($state->getTableName(), 0, -6);
|
||||
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ class ApiTransportPage extends Form
|
|||
return true;
|
||||
}
|
||||
|
||||
protected function validateConfiguration()
|
||||
protected function validateConfiguration(): bool
|
||||
{
|
||||
try {
|
||||
CommandTransport::createTransport(new ConfigObject($this->getValues()))->probe();
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ class DbResourcePage extends Form
|
|||
return true;
|
||||
}
|
||||
|
||||
protected function validateConfiguration($showLog = false)
|
||||
protected function validateConfiguration(bool $showLog = false): bool
|
||||
{
|
||||
$inspection = ResourceConfigForm::inspectResource($this);
|
||||
if ($inspection !== null) {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use Icinga\Module\Icingadb\Command\Object\ToggleObjectFeatureCommand;
|
|||
|
||||
class FeatureStatus extends ArrayObject
|
||||
{
|
||||
public function __construct($type, $summary)
|
||||
public function __construct(string $type, $summary)
|
||||
{
|
||||
$prefix = "{$type}s";
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ class FeatureStatus extends ArrayObject
|
|||
parent::__construct($featureStatus, ArrayObject::ARRAY_AS_PROPS);
|
||||
}
|
||||
|
||||
protected function getFeatureStatus($feature, $prefix, $summary)
|
||||
protected function getFeatureStatus(string $feature, string $prefix, $summary): int
|
||||
{
|
||||
$key = "{$prefix}_{$feature}";
|
||||
$value = (int) $summary->$key;
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class PerfData
|
|||
* @param string $label The perfdata label
|
||||
* @param string $value The perfdata value
|
||||
*/
|
||||
public function __construct($label, $value)
|
||||
public function __construct(string $label, string $value)
|
||||
{
|
||||
$this->perfdataValue = $value;
|
||||
$this->label = $label;
|
||||
|
|
@ -111,7 +111,7 @@ class PerfData
|
|||
*
|
||||
* @throws InvalidArgumentException In case the given performance data has no content or a invalid format
|
||||
*/
|
||||
public static function fromString($perfdata)
|
||||
public static function fromString(string $perfdata): self
|
||||
{
|
||||
if (empty($perfdata)) {
|
||||
throw new InvalidArgumentException('PerfData::fromString expects a string with content');
|
||||
|
|
@ -130,7 +130,7 @@ class PerfData
|
|||
*
|
||||
* @return bool True in case it's a number, otherwise False
|
||||
*/
|
||||
public function isNumber()
|
||||
public function isNumber(): bool
|
||||
{
|
||||
return $this->unit === null;
|
||||
}
|
||||
|
|
@ -140,7 +140,7 @@ class PerfData
|
|||
*
|
||||
* @return bool True in case it's seconds, otherwise False
|
||||
*/
|
||||
public function isSeconds()
|
||||
public function isSeconds(): bool
|
||||
{
|
||||
return $this->unit === 's';
|
||||
}
|
||||
|
|
@ -150,7 +150,7 @@ class PerfData
|
|||
*
|
||||
* @return bool True in case it's temperature, otherwise False
|
||||
*/
|
||||
public function isTemperature()
|
||||
public function isTemperature(): bool
|
||||
{
|
||||
return in_array($this->unit, array('C', 'F', 'K'));
|
||||
}
|
||||
|
|
@ -160,7 +160,7 @@ class PerfData
|
|||
*
|
||||
* @return bool True in case it's in percentage, otherwise False
|
||||
*/
|
||||
public function isPercentage()
|
||||
public function isPercentage(): bool
|
||||
{
|
||||
return $this->unit === '%';
|
||||
}
|
||||
|
|
@ -170,7 +170,7 @@ class PerfData
|
|||
*
|
||||
* @return bool True in case it's in packets
|
||||
*/
|
||||
public function isPackets()
|
||||
public function isPackets(): bool
|
||||
{
|
||||
return $this->unit === 'packets';
|
||||
}
|
||||
|
|
@ -180,7 +180,7 @@ class PerfData
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isLumens()
|
||||
public function isLumens(): bool
|
||||
{
|
||||
return $this->unit === 'lm';
|
||||
}
|
||||
|
|
@ -190,7 +190,7 @@ class PerfData
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDecibelMilliWatts()
|
||||
public function isDecibelMilliWatts(): bool
|
||||
{
|
||||
return $this->unit === 'dBm';
|
||||
}
|
||||
|
|
@ -200,7 +200,7 @@ class PerfData
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isBits()
|
||||
public function isBits(): bool
|
||||
{
|
||||
return $this->unit === 'b';
|
||||
}
|
||||
|
|
@ -210,7 +210,7 @@ class PerfData
|
|||
*
|
||||
* @return bool True in case it's in bytes, otherwise False
|
||||
*/
|
||||
public function isBytes()
|
||||
public function isBytes(): bool
|
||||
{
|
||||
return $this->unit === 'B';
|
||||
}
|
||||
|
|
@ -220,7 +220,7 @@ class PerfData
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isWattHours()
|
||||
public function isWattHours(): bool
|
||||
{
|
||||
return $this->unit === 'Wh';
|
||||
}
|
||||
|
|
@ -230,7 +230,7 @@ class PerfData
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isWatts()
|
||||
public function isWatts(): bool
|
||||
{
|
||||
return $this->unit === 'W';
|
||||
}
|
||||
|
|
@ -240,7 +240,7 @@ class PerfData
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isAmperes()
|
||||
public function isAmperes(): bool
|
||||
{
|
||||
return $this->unit === 'A';
|
||||
}
|
||||
|
|
@ -250,7 +250,7 @@ class PerfData
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isAmpSeconds()
|
||||
public function isAmpSeconds(): bool
|
||||
{
|
||||
return $this->unit === 'As';
|
||||
}
|
||||
|
|
@ -260,7 +260,7 @@ class PerfData
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isVolts()
|
||||
public function isVolts(): bool
|
||||
{
|
||||
return $this->unit === 'V';
|
||||
}
|
||||
|
|
@ -270,7 +270,7 @@ class PerfData
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isOhms()
|
||||
public function isOhms(): bool
|
||||
{
|
||||
return $this->unit === 'O';
|
||||
}
|
||||
|
|
@ -280,7 +280,7 @@ class PerfData
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isGrams()
|
||||
public function isGrams(): bool
|
||||
{
|
||||
return $this->unit === 'g';
|
||||
}
|
||||
|
|
@ -290,7 +290,7 @@ class PerfData
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isLiters()
|
||||
public function isLiters(): bool
|
||||
{
|
||||
return $this->unit === 'l';
|
||||
}
|
||||
|
|
@ -300,7 +300,7 @@ class PerfData
|
|||
*
|
||||
* @return bool True in case it's a counter, otherwise False
|
||||
*/
|
||||
public function isCounter()
|
||||
public function isCounter(): bool
|
||||
{
|
||||
return $this->unit === 'c';
|
||||
}
|
||||
|
|
@ -310,7 +310,7 @@ class PerfData
|
|||
*
|
||||
* @return bool True when the perfdata is visualizable
|
||||
*/
|
||||
public function isVisualizable()
|
||||
public function isVisualizable(): bool
|
||||
{
|
||||
return isset($this->minValue) && isset($this->maxValue) && isset($this->value);
|
||||
}
|
||||
|
|
@ -318,7 +318,7 @@ class PerfData
|
|||
/**
|
||||
* Return this perfomance data's label
|
||||
*/
|
||||
public function getLabel()
|
||||
public function getLabel(): string
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
|
@ -336,7 +336,7 @@ class PerfData
|
|||
/**
|
||||
* Return the unit as a string
|
||||
*
|
||||
* @return string
|
||||
* @return ?string
|
||||
*/
|
||||
public function getUnit()
|
||||
{
|
||||
|
|
@ -371,7 +371,7 @@ class PerfData
|
|||
*
|
||||
* @return ThresholdRange
|
||||
*/
|
||||
public function getWarningThreshold()
|
||||
public function getWarningThreshold(): ThresholdRange
|
||||
{
|
||||
return $this->warningThreshold;
|
||||
}
|
||||
|
|
@ -381,7 +381,7 @@ class PerfData
|
|||
*
|
||||
* @return ThresholdRange
|
||||
*/
|
||||
public function getCriticalThreshold()
|
||||
public function getCriticalThreshold(): ThresholdRange
|
||||
{
|
||||
return $this->criticalThreshold;
|
||||
}
|
||||
|
|
@ -389,7 +389,7 @@ class PerfData
|
|||
/**
|
||||
* Return the minimum value or null if it is not available
|
||||
*
|
||||
* @return null|string
|
||||
* @return ?float
|
||||
*/
|
||||
public function getMinimumValue()
|
||||
{
|
||||
|
|
@ -460,7 +460,7 @@ class PerfData
|
|||
}
|
||||
}
|
||||
|
||||
protected function calculatePieChartData()
|
||||
protected function calculatePieChartData(): array
|
||||
{
|
||||
$rawValue = $this->getValue();
|
||||
$minValue = $this->getMinimumValue() !== null ? $this->getMinimumValue() : 0;
|
||||
|
|
@ -482,7 +482,7 @@ class PerfData
|
|||
}
|
||||
|
||||
|
||||
public function asInlinePie()
|
||||
public function asInlinePie(): InlinePie
|
||||
{
|
||||
if (! $this->isVisualizable()) {
|
||||
throw new LogicException('Cannot calculate piechart data for unvisualizable perfdata entry.');
|
||||
|
|
@ -560,7 +560,7 @@ class PerfData
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function formatLabel($html = false)
|
||||
public function formatLabel(bool $html = false): string
|
||||
{
|
||||
return sprintf(
|
||||
$html ? '<b>%s %s</b> (%s%%)' : '%s %s (%s%%)',
|
||||
|
|
@ -570,7 +570,7 @@ class PerfData
|
|||
);
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
public function toArray(): array
|
||||
{
|
||||
return array(
|
||||
'label' => $this->getLabel(),
|
||||
|
|
@ -591,7 +591,7 @@ class PerfData
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getState()
|
||||
public function getState(): int
|
||||
{
|
||||
if ($this->value === null) {
|
||||
return ServiceStates::UNKNOWN;
|
||||
|
|
@ -617,7 +617,7 @@ class PerfData
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function worseThan(PerfData $rhs)
|
||||
public function worseThan(PerfData $rhs): bool
|
||||
{
|
||||
if (($state = $this->getState()) === ($rhsState = $rhs->getState())) {
|
||||
return $this->getPercentage() > $rhs->getPercentage();
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class PerfDataFormat
|
|||
|
||||
protected static $secondPrefix = [-3 => 'ns', -2 => 'µs', -1 => 'ms', 's'];
|
||||
|
||||
public static function getInstance()
|
||||
public static function getInstance(): self
|
||||
{
|
||||
if (self::$instance === null) {
|
||||
self::$instance = new PerfDataFormat();
|
||||
|
|
@ -65,57 +65,57 @@ class PerfDataFormat
|
|||
return self::$instance;
|
||||
}
|
||||
|
||||
public static function bits($value)
|
||||
public static function bits($value): string
|
||||
{
|
||||
return self::formatForUnits($value, self::$bitPrefix, self::$generalBase);
|
||||
}
|
||||
|
||||
public static function bytes($value)
|
||||
public static function bytes($value): string
|
||||
{
|
||||
return self::formatForUnits($value, self::$bytePrefix, self::$generalBase);
|
||||
}
|
||||
|
||||
public static function wattHours($value)
|
||||
public static function wattHours($value): string
|
||||
{
|
||||
return self::formatForUnits($value, self::$wattHourPrefix, self::$generalBase);
|
||||
}
|
||||
|
||||
public static function watts($value)
|
||||
public static function watts($value): string
|
||||
{
|
||||
return self::formatForUnits($value, self::$wattPrefix, self::$generalBase);
|
||||
}
|
||||
|
||||
public static function amperes($value)
|
||||
public static function amperes($value): string
|
||||
{
|
||||
return self::formatForUnits($value, self::$amperePrefix, self::$generalBase);
|
||||
}
|
||||
|
||||
public static function ampereSeconds($value)
|
||||
public static function ampereSeconds($value): string
|
||||
{
|
||||
return self::formatForUnits($value, self::$ampSecondPrefix, self::$generalBase);
|
||||
}
|
||||
|
||||
public static function volts($value)
|
||||
public static function volts($value): string
|
||||
{
|
||||
return self::formatForUnits($value, self::$voltPrefix, self::$generalBase);
|
||||
}
|
||||
|
||||
public static function ohms($value)
|
||||
public static function ohms($value): string
|
||||
{
|
||||
return self::formatForUnits($value, self::$ohmPrefix, self::$generalBase);
|
||||
}
|
||||
|
||||
public static function grams($value)
|
||||
public static function grams($value): string
|
||||
{
|
||||
return self::formatForUnits($value, self::$gramPrefix, self::$generalBase);
|
||||
}
|
||||
|
||||
public static function liters($value)
|
||||
public static function liters($value): string
|
||||
{
|
||||
return self::formatForUnits($value, self::$literPrefix, self::$generalBase);
|
||||
}
|
||||
|
||||
public static function seconds($value)
|
||||
public static function seconds($value): string
|
||||
{
|
||||
$absValue = abs($value);
|
||||
|
||||
|
|
@ -130,7 +130,7 @@ class PerfDataFormat
|
|||
return sprintf('%0.2f d', $value / 86400);
|
||||
}
|
||||
|
||||
protected static function formatForUnits($value, &$units, $base)
|
||||
protected static function formatForUnits($value, array &$units, int $base): string
|
||||
{
|
||||
$sign = '';
|
||||
if ($value < 0) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class PerfDataSet implements IteratorAggregate
|
|||
*
|
||||
* @param string $perfdataStr A space separated list of label/value pairs
|
||||
*/
|
||||
protected function __construct($perfdataStr)
|
||||
protected function __construct(string $perfdataStr)
|
||||
{
|
||||
if (($perfdataStr = trim($perfdataStr)) !== '') {
|
||||
$this->perfdataStr = $perfdataStr;
|
||||
|
|
@ -48,7 +48,7 @@ class PerfDataSet implements IteratorAggregate
|
|||
*
|
||||
* @return ArrayIterator
|
||||
*/
|
||||
public function getIterator()
|
||||
public function getIterator(): ArrayIterator
|
||||
{
|
||||
return new ArrayIterator($this->asArray());
|
||||
}
|
||||
|
|
@ -60,7 +60,7 @@ class PerfDataSet implements IteratorAggregate
|
|||
*
|
||||
* @return PerfDataSet
|
||||
*/
|
||||
public static function fromString($perfdataStr)
|
||||
public static function fromString(string $perfdataStr): self
|
||||
{
|
||||
return new static($perfdataStr);
|
||||
}
|
||||
|
|
@ -70,7 +70,7 @@ class PerfDataSet implements IteratorAggregate
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function asArray()
|
||||
public function asArray(): array
|
||||
{
|
||||
return $this->perfdata;
|
||||
}
|
||||
|
|
@ -95,7 +95,7 @@ class PerfDataSet implements IteratorAggregate
|
|||
*
|
||||
* @return string The label found
|
||||
*/
|
||||
protected function readLabel()
|
||||
protected function readLabel(): string
|
||||
{
|
||||
$this->skipSpaces();
|
||||
if (in_array($this->perfdataStr[$this->parserPos], array('"', "'"))) {
|
||||
|
|
@ -122,7 +122,7 @@ class PerfDataSet implements IteratorAggregate
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function readUntil($stopChar)
|
||||
protected function readUntil(string $stopChar): string
|
||||
{
|
||||
$start = $this->parserPos;
|
||||
while ($this->parserPos < strlen($this->perfdataStr) && $this->perfdataStr[$this->parserPos] !== $stopChar) {
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ class PluginOutput extends HtmlString
|
|||
* @todo Do we really need to create a DOM here? Or is a preg_replace like we do it for text also feasible?
|
||||
* @return string
|
||||
*/
|
||||
protected function processHtml($html)
|
||||
protected function processHtml(string $html): string
|
||||
{
|
||||
$pattern = '/[([](OK|WARNING|CRITICAL|UNKNOWN|UP|DOWN)[)\]]/';
|
||||
$doc = new DOMDocument();
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class ThresholdRange
|
|||
*
|
||||
* @return ThresholdRange
|
||||
*/
|
||||
public static function fromString($rawRange)
|
||||
public static function fromString(string $rawRange): self
|
||||
{
|
||||
$range = new static();
|
||||
$range->raw = $rawRange;
|
||||
|
|
@ -92,7 +92,7 @@ class ThresholdRange
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMin($min)
|
||||
public function setMin(float $min): self
|
||||
{
|
||||
$this->min = $min;
|
||||
return $this;
|
||||
|
|
@ -115,7 +115,7 @@ class ThresholdRange
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMax($max)
|
||||
public function setMax(float $max): self
|
||||
{
|
||||
$this->max = $max;
|
||||
return $this;
|
||||
|
|
@ -138,7 +138,7 @@ class ThresholdRange
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setInverted($inverted = true)
|
||||
public function setInverted(bool $inverted = true): self
|
||||
{
|
||||
$this->inverted = $inverted;
|
||||
return $this;
|
||||
|
|
@ -149,7 +149,7 @@ class ThresholdRange
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isInverted()
|
||||
public function isInverted(): bool
|
||||
{
|
||||
return $this->inverted;
|
||||
}
|
||||
|
|
@ -161,7 +161,7 @@ class ThresholdRange
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function contains($value)
|
||||
public function contains(float $value): bool
|
||||
{
|
||||
return (bool) ($this->inverted ^ (
|
||||
($this->min === null || $this->min <= $value) && ($this->max === null || $this->max >= $value)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class ProblemToggle extends CompatForm
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setIdProtector($protector)
|
||||
public function setIdProtector(callable $protector): self
|
||||
{
|
||||
$this->protector = $protector;
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ class ProblemToggle extends CompatForm
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isChecked()
|
||||
public function isChecked(): bool
|
||||
{
|
||||
$this->ensureAssembled();
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
namespace Icinga\Module\Icingadb\Web\Control\SearchBar;
|
||||
|
||||
use Generator;
|
||||
use Icinga\Module\Icingadb\Common\Auth;
|
||||
use Icinga\Module\Icingadb\Common\Database;
|
||||
use Icinga\Module\Icingadb\Model\Behavior\ReRoute;
|
||||
|
|
@ -61,7 +62,7 @@ class ObjectSuggestions extends Suggestions
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setModel($model)
|
||||
public function setModel($model): self
|
||||
{
|
||||
if (is_string($model)) {
|
||||
$model = new $model();
|
||||
|
|
@ -77,8 +78,14 @@ class ObjectSuggestions extends Suggestions
|
|||
*
|
||||
* @return Model
|
||||
*/
|
||||
public function getModel()
|
||||
public function getModel(): Model
|
||||
{
|
||||
if ($this->model === null) {
|
||||
throw new \LogicException(
|
||||
'You are accessing an unset property. Please make sure to set it beforehand.'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
|
|
@ -216,7 +223,7 @@ class ObjectSuggestions extends Suggestions
|
|||
*
|
||||
* @return Select
|
||||
*/
|
||||
protected function queryCustomvarConfig($searchTerm)
|
||||
protected function queryCustomvarConfig(string $searchTerm): Select
|
||||
{
|
||||
$customVars = CustomvarFlat::on($this->getDb());
|
||||
$tableName = $customVars->getModel()->getTableName();
|
||||
|
|
@ -260,9 +267,9 @@ class ObjectSuggestions extends Suggestions
|
|||
* @param Model $model
|
||||
* @param Resolver $resolver
|
||||
*
|
||||
* @return \Generator
|
||||
* @return Generator
|
||||
*/
|
||||
public static function collectFilterColumns(Model $model, Resolver $resolver = null)
|
||||
public static function collectFilterColumns(Model $model, Resolver $resolver = null): Generator
|
||||
{
|
||||
if ($resolver === null) {
|
||||
$resolver = new Resolver();
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class ViewModeSwitcher extends Form
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultViewMode()
|
||||
public function getDefaultViewMode(): string
|
||||
{
|
||||
return $this->defaultViewMode ?: static::DEFAULT_VIEW_MODE;
|
||||
}
|
||||
|
|
@ -63,7 +63,7 @@ class ViewModeSwitcher extends Form
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDefaultViewMode($defaultViewMode)
|
||||
public function setDefaultViewMode(string $defaultViewMode): self
|
||||
{
|
||||
$this->defaultViewMode = $defaultViewMode;
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ class ViewModeSwitcher extends Form
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getViewModeParam()
|
||||
public function getViewModeParam(): string
|
||||
{
|
||||
return $this->viewModeParam;
|
||||
}
|
||||
|
|
@ -87,7 +87,7 @@ class ViewModeSwitcher extends Form
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setViewModeParam($viewModeParam)
|
||||
public function setViewModeParam(string $viewModeParam): self
|
||||
{
|
||||
$this->viewModeParam = $viewModeParam;
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ class ViewModeSwitcher extends Form
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getViewMode()
|
||||
public function getViewMode(): string
|
||||
{
|
||||
return $this->getValue($this->getViewModeParam(), $this->getDefaultViewMode());
|
||||
}
|
||||
|
|
@ -111,7 +111,7 @@ class ViewModeSwitcher extends Form
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setIdProtector($protector)
|
||||
public function setIdProtector(callable $protector): self
|
||||
{
|
||||
$this->protector = $protector;
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class Controller extends CompatController
|
|||
use Auth;
|
||||
use Database;
|
||||
|
||||
/** @var Filter Filter from query string parameters */
|
||||
/** @var Filter\Rule Filter from query string parameters */
|
||||
private $filter;
|
||||
|
||||
/** @var string|null */
|
||||
|
|
@ -64,7 +64,7 @@ class Controller extends CompatController
|
|||
*
|
||||
* @return Filter\Rule
|
||||
*/
|
||||
public function getFilter()
|
||||
public function getFilter(): Filter\Rule
|
||||
{
|
||||
if ($this->filter === null) {
|
||||
$this->filter = QueryString::parse((string) $this->params);
|
||||
|
|
@ -80,7 +80,7 @@ class Controller extends CompatController
|
|||
*
|
||||
* @return LimitControl
|
||||
*/
|
||||
public function createLimitControl()
|
||||
public function createLimitControl(): LimitControl
|
||||
{
|
||||
$limitControl = new LimitControl(Url::fromRequest());
|
||||
$limitControl->setDefaultLimit($this->getPageSize(null));
|
||||
|
|
@ -97,7 +97,7 @@ class Controller extends CompatController
|
|||
*
|
||||
* @return PaginationControl
|
||||
*/
|
||||
public function createPaginationControl(Paginatable $paginatable)
|
||||
public function createPaginationControl(Paginatable $paginatable): PaginationControl
|
||||
{
|
||||
$paginationControl = new PaginationControl($paginatable, Url::fromRequest());
|
||||
$paginationControl->setDefaultPageSize($this->getPageSize(null));
|
||||
|
|
@ -119,7 +119,7 @@ class Controller extends CompatController
|
|||
*
|
||||
* @return SortControl
|
||||
*/
|
||||
public function createSortControl(Query $query, array $columns)
|
||||
public function createSortControl(Query $query, array $columns): SortControl
|
||||
{
|
||||
$default = (array) $query->getModel()->getDefaultSort();
|
||||
$normalized = [];
|
||||
|
|
@ -152,7 +152,7 @@ class Controller extends CompatController
|
|||
*
|
||||
* @return SearchBar
|
||||
*/
|
||||
public function createSearchBar(Query $query, array $preserveParams = null)
|
||||
public function createSearchBar(Query $query, array $preserveParams = null): SearchBar
|
||||
{
|
||||
$requestUrl = Url::fromRequest();
|
||||
$redirectUrl = $preserveParams !== null
|
||||
|
|
@ -253,7 +253,7 @@ class Controller extends CompatController
|
|||
*
|
||||
* @return SearchEditor
|
||||
*/
|
||||
public function createSearchEditor(Query $query, array $preserveParams = null)
|
||||
public function createSearchEditor(Query $query, array $preserveParams = null): SearchEditor
|
||||
{
|
||||
$requestUrl = Url::fromRequest();
|
||||
$redirectUrl = Url::fromPath('icingadb/' . $this->getRequest()->getControllerName());
|
||||
|
|
@ -333,7 +333,7 @@ class Controller extends CompatController
|
|||
*
|
||||
* @return ContinueWith
|
||||
*/
|
||||
public function createContinueWith(Url $detailsUrl, SearchBar $searchBar)
|
||||
public function createContinueWith(Url $detailsUrl, SearchBar $searchBar): ContinueWith
|
||||
{
|
||||
$continueWith = new ContinueWith($detailsUrl, [$searchBar, 'getFilter']);
|
||||
$continueWith->setTitle(t('Show bulk processing actions for all filtered results'));
|
||||
|
|
@ -353,14 +353,15 @@ class Controller extends CompatController
|
|||
*
|
||||
* @param PaginationControl $paginationControl
|
||||
* @param LimitControl $limitControl
|
||||
* @param bool $verticalPagination
|
||||
*
|
||||
* @return ViewModeSwitcher
|
||||
*/
|
||||
public function createViewModeSwitcher(
|
||||
PaginationControl $paginationControl,
|
||||
LimitControl $limitControl,
|
||||
$verticalPagination = false
|
||||
) {
|
||||
bool $verticalPagination = false
|
||||
): ViewModeSwitcher {
|
||||
$viewModeSwitcher = new ViewModeSwitcher();
|
||||
$viewModeSwitcher->setIdProtector([$this->getRequest(), 'protectId']);
|
||||
|
||||
|
|
@ -488,6 +489,8 @@ class Controller extends CompatController
|
|||
* Process a search request
|
||||
*
|
||||
* @param Query $query
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handleSearchRequest(Query $query)
|
||||
{
|
||||
|
|
@ -519,7 +522,7 @@ class Controller extends CompatController
|
|||
*
|
||||
* @throws SecurityException
|
||||
*/
|
||||
public function assertRouteAccess($name = null)
|
||||
public function assertRouteAccess(string $name = null)
|
||||
{
|
||||
if (! $name) {
|
||||
$name = $this->getRequest()->getControllerName();
|
||||
|
|
@ -786,7 +789,7 @@ class Controller extends CompatController
|
|||
return parent::addContent($content);
|
||||
}
|
||||
|
||||
public function filter(Query $query, Filter\Rule $filter = null)
|
||||
public function filter(Query $query, Filter\Rule $filter = null): self
|
||||
{
|
||||
if ($this->format !== 'sql' || $this->hasPermission('config/authentication/roles/show')) {
|
||||
$this->applyRestrictions($query);
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class Action extends NavigationItem
|
|||
/**
|
||||
* Get the filter to use when being asked whether to render this action
|
||||
*
|
||||
* @return string
|
||||
* @return ?string
|
||||
*/
|
||||
public function getFilter()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ namespace Icinga\Module\Icingadb\Web\Navigation\Renderer;
|
|||
use Icinga\Module\Icingadb\Common\Auth;
|
||||
use Icinga\Module\Icingadb\Common\Links;
|
||||
use Icinga\Module\Icingadb\Model\HoststateSummary;
|
||||
use ipl\Web\Url;
|
||||
|
||||
class HostProblemsBadge extends ProblemsBadge
|
||||
{
|
||||
|
|
@ -20,7 +21,7 @@ class HostProblemsBadge extends ProblemsBadge
|
|||
return $summary->first()->hosts_down_unhandled;
|
||||
}
|
||||
|
||||
protected function getUrl()
|
||||
protected function getUrl(): Url
|
||||
{
|
||||
return Links::hosts()->setParams(['host.state.is_problem' => 'y', 'sort' => 'host.state.severity desc']);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ abstract class ProblemsBadge extends NavigationItemRenderer
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setState($state)
|
||||
public function setState(string $state): self
|
||||
{
|
||||
$this->state = $state;
|
||||
|
||||
|
|
@ -79,8 +79,14 @@ abstract class ProblemsBadge extends NavigationItemRenderer
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getState()
|
||||
public function getState(): string
|
||||
{
|
||||
if ($this->state === null) {
|
||||
throw new \LogicException(
|
||||
'You are accessing an unset property. Please make sure to set it beforehand.'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
|
|
@ -91,7 +97,7 @@ abstract class ProblemsBadge extends NavigationItemRenderer
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTitle($title)
|
||||
public function setTitle(string $title): self
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
|
|
@ -103,12 +109,18 @@ abstract class ProblemsBadge extends NavigationItemRenderer
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
public function getTitle(): string
|
||||
{
|
||||
if ($this->title === null) {
|
||||
throw new \LogicException(
|
||||
'You are accessing an unset property. Please make sure to set it beforehand.'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function render(NavigationItem $item = null)
|
||||
public function render(NavigationItem $item = null): string
|
||||
{
|
||||
if ($item === null) {
|
||||
$item = $this->getItem();
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ namespace Icinga\Module\Icingadb\Web\Navigation\Renderer;
|
|||
use Icinga\Module\Icingadb\Common\Auth;
|
||||
use Icinga\Module\Icingadb\Common\Links;
|
||||
use Icinga\Module\Icingadb\Model\ServicestateSummary;
|
||||
use ipl\Web\Url;
|
||||
|
||||
class ServiceProblemsBadge extends ProblemsBadge
|
||||
{
|
||||
|
|
@ -20,7 +21,7 @@ class ServiceProblemsBadge extends ProblemsBadge
|
|||
return $summary->first()->services_critical_unhandled;
|
||||
}
|
||||
|
||||
protected function getUrl()
|
||||
protected function getUrl(): Url
|
||||
{
|
||||
return Links::services()
|
||||
->setParams(['service.state.is_problem' => 'y', 'sort' => 'service.state.severity desc']);
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue