Github Actions: Add PhpStan (#5040)

Blocked by: #5061 
closes #5052, https://github.com/Icinga/icingaweb2/pull/4920,
https://github.com/Icinga/icingaweb2/pull/5003
This commit is contained in:
Johannes Meyer 2023-08-23 11:53:21 +02:00 committed by GitHub
commit 6c68578a6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
144 changed files with 26805 additions and 229 deletions

View File

@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.2', '7.3', '7.4', '8.0', '8.1']
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
os: ['ubuntu-latest']
steps:
@ -29,9 +29,16 @@ jobs:
with:
php-version: ${{ matrix.php }}
tools: phpcs
extensions: ldap
- name: Setup dependencies
run: composer require -n --no-progress overtrue/phplint
run: |
composer require -n --no-progress overtrue/phplint
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-library.git vendor/icinga-php-library
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git vendor/icinga-php-thirdparty
git clone --depth 1 https://github.com/Icinga/icingaweb2-module-x509.git vendor/modules/x509-web
git clone --depth 1 https://github.com/Icinga/icingadb-web.git vendor/modules/icingadb-web
git clone --depth 1 https://github.com/Icinga/icingaweb2-module-pdfexport.git vendor/modules/pdfexport-web
- name: PHP Lint
if: success() || matrix.allow_failure
@ -41,6 +48,10 @@ jobs:
if: success() || matrix.allow_failure
run: phpcs
- name: PHPStan
uses: php-actions/phpstan@v3
if: success() || matrix.allow_failure
test:
name: Unit tests with php ${{ matrix.php }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
@ -51,7 +62,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.2', '7.3', '7.4', '8.0', '8.1']
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
os: ['ubuntu-latest']
include:
- php: '7.2'

View File

@ -47,9 +47,9 @@ class VersionCommand extends Command
}
}
printf("%-${maxLength}s %-9s \n", 'MODULE', 'VERSION');
printf("%-{$maxLength}s %-9s \n", 'MODULE', 'VERSION');
foreach ($modules as $module) {
printf("%-${maxLength}s %-9s \n", $module->getName(), $module->getVersion());
printf("%-{$maxLength}s %-9s \n", $module->getName(), $module->getVersion());
}
}
}

View File

@ -51,7 +51,7 @@ class AuthenticationController extends Controller
if ($authenticated) {
$rememberMe = $rememberMeOld->renew();
$this->getResponse()->setCookie($rememberMe->getCookie());
$rememberMe->persist($rememberMeOld->getAesCrypt()->getIv());
$rememberMe->persist($rememberMeOld->getAesCrypt()->getIV());
}
} catch (RuntimeException $e) {
Logger::error("Can't authenticate user via remember me cookie: %s", $e->getMessage());

View File

@ -91,7 +91,7 @@ class StaticController extends Controller
}
$s = stat($filePath);
$eTag = sprintf('%x-%x-%x', $s['ino'], $s['size'], (float) str_pad($s['mtime'], 16, '0'));
$eTag = sprintf('%x-%x-%x', $s['ino'], $s['size'], (float) str_pad((string) $s['mtime'], 16, '0'));
$this->getResponse()->setHeader(
'Cache-Control',

View File

@ -18,6 +18,7 @@ use Icinga\Forms\Config\Resource\LdapResourceForm;
use Icinga\Forms\Config\Resource\SshResourceForm;
use Icinga\Web\Form;
use Icinga\Web\Notification;
use Zend_Form_Element;
class ResourceConfigForm extends ConfigForm
{
@ -98,7 +99,7 @@ class ResourceConfigForm extends ConfigForm
* @param string $name The name of the resource to edit
* @param array $values The values to edit the configuration with
*
* @return array The edited configuration
* @return ConfigObject The edited configuration
*
* @throws InvalidArgumentException In case the resource does not exist
*/
@ -134,7 +135,7 @@ class ResourceConfigForm extends ConfigForm
*
* @param string $name The name of the resource to remove
*
* @return array The removed resource configuration
* @return ConfigObject The removed resource configuration
*
* @throws InvalidArgumentException In case the resource does not exist
*/
@ -294,7 +295,7 @@ class ResourceConfigForm extends ConfigForm
*
* @param Form $form
*
* @return Inspection
* @return ?Inspection
*/
public static function inspectResource(Form $form)
{

View File

@ -113,6 +113,7 @@ class CreateMembershipForm extends Form
}
$single = null;
$groupName = null;
foreach ($this->getValue('groups') as $backendAndGroup) {
list($backendName, $groupName) = explode(';', $backendAndGroup, 2);
try {

View File

@ -147,6 +147,7 @@ class AddMemberForm extends Form
}
$single = null;
$userName = null;
foreach ($userNames as $userName) {
try {
$this->backend->insert(

View File

@ -815,6 +815,7 @@ class NavigationConfigForm extends ConfigForm
$className = StringHelper::cname($type, '-') . 'Form';
$form = null;
$classPath = null;
foreach (Icinga::app()->getModuleManager()->getLoadedModules() as $module) {
$classPath = 'Icinga\\Module\\'
. ucfirst($module->getName())

View File

@ -100,7 +100,7 @@ class PreferenceForm extends Form
$defaultTheme = Config::app()->get('themes', 'default', StyleSheet::DEFAULT_THEME);
$this->preferences = new Preferences($this->store ? $this->store->load() : array());
$webPreferences = $this->preferences->get('icingaweb', array());
$webPreferences = $this->preferences->get('icingaweb');
foreach ($this->getValues() as $key => $value) {
if ($value === ''
|| $value === null
@ -215,6 +215,7 @@ class PreferenceForm extends Form
$themeFile = StyleSheet::getThemeFile($formData['theme']);
}
$disabled = [];
if ($themeFile !== null) {
$file = @file_get_contents($themeFile);
if ($file && strpos($file, StyleSheet::LIGHT_MODE_IDENTIFIER) === false) {
@ -242,8 +243,7 @@ class PreferenceForm extends Form
['src' => $this->getView()->href('img/theme-mode-thumbnail-system.svg')]
) . HtmlElement::create('span', [], $this->translate('System'))
],
'value' => isset($value) ? $value : '',
'disable' => isset($disabled) ? $disabled : [],
'disable' => $disabled,
'escape' => false,
'decorators' => array_merge(
array_slice(self::$defaultElementDecorators, 0, -1),

View File

@ -321,7 +321,7 @@ abstract class RepositoryForm extends Form
/**
* Apply the requested mode on the repository
*
* @return bool
* @return ?bool
*/
public function onSuccess()
{

View File

@ -17,7 +17,7 @@ class Zend_View_Helper_CreateTicketLinks extends Zend_View_Helper_Abstract
public function createTicketLinks($text)
{
$tickets = $this->view->tickets;
/** @var \Icinga\Application\Hook\TicketHook $tickets */
return isset($tickets) ? $tickets->createLinks($text) : $text;
/** @var \Icinga\Application\Hook\TicketHook|array|null $tickets */
return ! empty($tickets) ? $tickets->createLinks($text) : $text;
}
}

View File

@ -648,7 +648,7 @@ abstract class ApplicationBootstrap
*/
final protected function setupTimezone()
{
$timezone = $this->detectTimeZone();
$timezone = $this->detectTimezone();
if ($timezone === null || @date_default_timezone_set($timezone) === false) {
date_default_timezone_set(@date_default_timezone_get());
}

View File

@ -77,8 +77,7 @@ class Benchmark
* otherwise. Use Benchmark::TIME and Benchmark::MEMORY to choose whether
* you prefer to show either time or memory or both in your output
*
* @param int Whether to get time and/or memory summary
* @return string
* @param ?int $what Whether to get time and/or memory summary
*/
public static function dump($what = null)
{
@ -95,7 +94,7 @@ class Benchmark
* Use Benchmark::TIME and Icinga::MEMORY to choose whether you prefer to
* show either time or memory or both in your output
*
* @param int Whether to get time and/or memory summary
* @param ?int $what Whether to get time and/or memory summary
* @return string
*/
public static function renderToText($what = null)
@ -131,7 +130,8 @@ class Benchmark
* Use Benchmark::TIME and Benchmark::MEMORY to choose whether you prefer
* to show either time or memory or both in your output
*
* @param int Whether to get time and/or memory summary
* @param ?int $what Whether to get time and/or memory summary
*
* @return string
*/
public static function renderToHtml($what = null)
@ -176,8 +176,9 @@ class Benchmark
* Use Benchmark::TIME and Benchmark::MEMORY to choose whether you prefer
* to have either time or memory or both in your output
*
* @param int Whether to get time and/or memory summary
* @return array
* @param ?int $what Whether to get time and/or memory summary
*
* @return object
*/
protected static function prepareDataForRendering($what = null)
{

View File

@ -3,6 +3,7 @@
namespace Icinga\Application;
use Icinga\Exception\NotWritableError;
use Iterator;
use Countable;
use LogicException;
@ -405,7 +406,7 @@ class Config implements Countable, Iterator, Selectable
*
* @param string $modulename The name of the module where to look for the requested configuration
* @param string $configname The configuration name (without ini suffix) to read and return
* @param string $fromDisk When set true, the configuration will be read from disk, even
* @param bool $fromDisk When set true, the configuration will be read from disk, even
* if it already has been read
*
* @return Config The requested configuration

View File

@ -113,7 +113,7 @@ class Hook
{
$name = self::normalizeHookName($name);
if (!self::has($name, $key)) {
if (!self::has($name)) {
return null;
}

View File

@ -63,7 +63,7 @@ abstract class ConfigFormEventsHook
*/
final public static function getLastErrors()
{
return static::$lastErrors;
return self::$lastErrors;
}
/**
@ -92,7 +92,7 @@ abstract class ConfigFormEventsHook
private static function runEventMethod($eventMethod, Form $form)
{
static::$lastErrors = [];
self::$lastErrors = [];
if (! Hook::has('ConfigFormEvents')) {
return true;
@ -109,7 +109,7 @@ abstract class ConfigFormEventsHook
try {
$hook->$eventMethod($form);
} catch (\Exception $e) {
static::$lastErrors[] = $e->getMessage();
self::$lastErrors[] = $e->getMessage();
Logger::error("%s\n%s", $e, IcingaException::getConfidentialTraceAsString($e));

View File

@ -4,6 +4,8 @@
namespace Icinga\Application;
require_once dirname(__FILE__) . '/Web.php';
use Exception;
use Icinga\Exception\ProgrammingError;
class LegacyWeb extends Web

View File

@ -41,6 +41,7 @@ class StderrWriter extends LogWriter
*/
public function log($severity, $message)
{
$color = null;
switch ($severity) {
case Logger::ERROR:
$color = 'red';

View File

@ -76,6 +76,13 @@ class Module
*/
private $libdir;
/**
* Config directory
*
* @var string
*/
private $configdir;
/**
* Directory containing translations
*
@ -1308,7 +1315,7 @@ class Module
$router = $this->app->getFrontController()->getRouter();
// TODO: We should not be required to do this. Please check dispatch()
$this->app->getfrontController()->addControllerDirectory(
$this->app->getFrontController()->addControllerDirectory(
$this->getControllerDir(),
$this->getName()
);

View File

@ -260,7 +260,7 @@ class Platform
/**
* Return the username PHP is running as
*
* @return string
* @return ?string
*/
public static function getPhpUser()
{

View File

@ -66,6 +66,9 @@ class Web extends EmbeddedWeb
*/
private $user;
/** @var array */
protected $accessibleMenuItems;
/**
* Identify web bootstrap
*
@ -243,7 +246,7 @@ class Web extends EmbeddedWeb
if ($type === 'dashboard-pane') {
$panes = array();
foreach ($config as $dashletName => $dashletConfig) {
if ($this->hasAccessToSharedNavigationItem($dashletConfig)) {
if ($this->hasAccessToSharedNavigationItem($dashletConfig, $config)) {
// TODO: Throw ConfigurationError if pane or url is missing
$panes[$dashletConfig->pane][$dashletName] = $dashletConfig->url;
}

View File

@ -4,11 +4,13 @@
namespace Icinga\Authentication\User;
use DateTime;
use Exception;
use Icinga\Data\ConfigObject;
use Icinga\Data\Inspectable;
use Icinga\Data\Inspection;
use Icinga\Exception\AuthenticationException;
use Icinga\Exception\ProgrammingError;
use Icinga\Exception\QueryException;
use Icinga\Repository\LdapRepository;
use Icinga\Repository\RepositoryQuery;
use Icinga\Protocol\Ldap\LdapException;

View File

@ -187,6 +187,7 @@ class UserBackend implements ConfigAwareFactory
$name
);
}
if ($backendType === 'external') {
$backend = new ExternalBackend($backendConfig);
$backend->setName($name);
@ -229,6 +230,7 @@ class UserBackend implements ConfigAwareFactory
}
$resource = ResourceFactory::createResource($resourceConfig);
$backend = null;
switch ($backendType) {
case 'db':
$backend = new DbUserBackend($resource);

View File

@ -271,7 +271,7 @@ class DbUserGroupBackend extends DbRepository implements Inspectable, UserGroupB
*/
protected function persistGroupId($groupName)
{
if (! $groupName || empty($groupName) || is_numeric($groupName)) {
if (empty($groupName) || is_numeric($groupName)) {
return $groupName;
}

View File

@ -13,6 +13,7 @@ use Icinga\Data\Inspection;
use Icinga\Exception\AuthenticationException;
use Icinga\Exception\ConfigurationError;
use Icinga\Exception\ProgrammingError;
use Icinga\Exception\QueryException;
use Icinga\Protocol\Ldap\LdapException;
use Icinga\Protocol\Ldap\LdapUtils;
use Icinga\Repository\LdapRepository;
@ -645,7 +646,7 @@ class LdapUserGroupBackend extends LdapRepository implements Inspectable, UserGr
*
* @param string $username
*
* @param string
* @return string
*/
protected function retrieveUserName($dn)
{

View File

@ -170,6 +170,7 @@ class UserGroupBackend
$resourceConfig->charset = 'utf8mb4';
}
$backend = null;
$resource = ResourceFactory::createResource($resourceConfig);
switch ($backendType) {
case 'db':

View File

@ -67,6 +67,7 @@ class BarGraph extends Styleable implements Drawable
$this->dataSet = $dataSet;
$this->tooltips = $tooltips;
$ts = [];
foreach ($this->tooltips as $value) {
$ts[] = $value;
}
@ -97,7 +98,7 @@ class BarGraph extends Styleable implements Drawable
* @param array $point The
* @param string $fill The fill color to use
* @param $strokeWidth
* @param null $index
* @param ?int $index
*
* @return Rect
*/

View File

@ -45,6 +45,12 @@ class LineGraph extends Styleable implements Drawable
*/
private $tooltips;
/** @var array */
private $graphs;
/** @var int */
private $order;
/**
* The default stroke width
* @var int
@ -74,6 +80,7 @@ class LineGraph extends Styleable implements Drawable
$this->graphs = $graphs;
$this->tooltips = $tooltips;
$ts = [];
foreach ($this->tooltips as $value) {
$ts[] = $value;
}

View File

@ -80,7 +80,7 @@ class Animation implements Drawable
$animate->setAttribute('to', $this->to);
$animate->setAttribute('begin', $this->begin . 's');
$animate->setAttribute('dur', $this->duration . 's');
$animate->setAttributE('fill', "freeze");
$animate->setAttribute('fill', "freeze");
return $animate;
}

View File

@ -164,10 +164,10 @@ class PieSlice extends Animatable implements Drawable
$midX += intval($r/2 * sin(M_PI/9)) * ($midRadius > M_PI ? -1 : 1);
$midY -= intval($r/2 * cos(M_PI/3)) * ($midRadius < M_PI*1.4 && $midRadius > M_PI/3 ? -1 : 1);
if ($ctx->ytoRelative($midY) > 100) {
if ($ctx->yToRelative($midY) > 100) {
$midY = $ctx->yToAbsolute(100);
} elseif ($ctx->ytoRelative($midY) < 0) {
$midY = $ctx->yToAbsolute($ctx->ytoRelative(100+$midY));
} elseif ($ctx->yToRelative($midY) < 0) {
$midY = $ctx->yToAbsolute($ctx->yToRelative(100+$midY));
}
$path->append(array($midX , $midY));

View File

@ -3,7 +3,7 @@
namespace Icinga\Chart\Primitive;
use DomElement;
use DOMElement;
use Icinga\Chart\Render\RenderContext;
use Icinga\Chart\Format;

View File

@ -15,7 +15,7 @@ class Styleable
/**
* The stroke width to use
*
* @var int
* @var int|float
*/
public $strokeWidth = 0;
@ -57,7 +57,7 @@ class Styleable
/**
* Set the stroke width for this drawable
*
* @param string $width The stroke with with unit
* @param int|float $width The stroke with unit
*
* @return $this Fluid interface
*/

View File

@ -124,7 +124,7 @@ class CalendarUnit extends LinearUnit
*
* @return int The position of the next tick (between 0 and 100)
*/
public function current()
public function current(): int
{
return 100 * (key($this->labels) / count($this->labels));
}
@ -132,7 +132,7 @@ class CalendarUnit extends LinearUnit
/**
* Move to next tick
*/
public function next()
public function next(): void
{
next($this->labels);
}
@ -142,7 +142,7 @@ class CalendarUnit extends LinearUnit
*
* @return string
*/
public function key()
public function key(): string
{
return current($this->labels);
}
@ -152,7 +152,7 @@ class CalendarUnit extends LinearUnit
*
* @return bool
*/
public function valid()
public function valid(): bool
{
return current($this->labels) !== false;
}
@ -160,7 +160,7 @@ class CalendarUnit extends LinearUnit
/**
* Rewind the internal array
*/
public function rewind()
public function rewind(): void
{
reset($this->labels);
}

View File

@ -111,7 +111,7 @@ class LogarithmicUnit implements AxisUnit
*
* @return int
*/
public function current()
public function current(): int
{
return $this->currentTick * (100 / $this->getTicks());
}
@ -119,7 +119,7 @@ class LogarithmicUnit implements AxisUnit
/**
* Calculate the next tick and tick value
*/
public function next()
public function next(): void
{
++ $this->currentTick;
}
@ -129,7 +129,7 @@ class LogarithmicUnit implements AxisUnit
*
* @return string The label for the current tick
*/
public function key()
public function key(): string
{
$currentBase = $this->currentTick + $this->minExp;
if (abs($currentBase) > 4) {
@ -143,7 +143,7 @@ class LogarithmicUnit implements AxisUnit
*
* @return bool
*/
public function valid()
public function valid(): bool
{
return $this->currentTick >= 0 && $this->currentTick < $this->getTicks();
}
@ -151,7 +151,7 @@ class LogarithmicUnit implements AxisUnit
/**
* Reset the current tick and label value
*/
public function rewind()
public function rewind(): void
{
$this->currentTick = 0;
}

View File

@ -65,9 +65,9 @@ class StaticAxis implements AxisUnit
* (PHP 5 &gt;= 5.0.0)<br/>
* Return the current element
* @link http://php.net/manual/en/iterator.current.php
* @return mixed Can return any type.
* @return int.
*/
public function current()
public function current(): int
{
return 1 + (99 / count($this->items) * key($this->items));
}
@ -78,9 +78,9 @@ class StaticAxis implements AxisUnit
* @link http://php.net/manual/en/iterator.next.php
* @return void Any returned value is ignored.
*/
public function next()
public function next(): void
{
return next($this->items);
next($this->items);
}
/**
@ -89,6 +89,7 @@ class StaticAxis implements AxisUnit
* @link http://php.net/manual/en/iterator.key.php
* @return mixed scalar on success, or null on failure.
*/
#[\ReturnTypeWillChange]
public function key()
{
return current($this->items);
@ -101,7 +102,7 @@ class StaticAxis implements AxisUnit
* @return boolean The return value will be casted to boolean and then evaluated.
* Returns true on success or false on failure.
*/
public function valid()
public function valid(): bool
{
return current($this->items) !== false;
}
@ -112,9 +113,9 @@ class StaticAxis implements AxisUnit
* @link http://php.net/manual/en/iterator.rewind.php
* @return void Any returned value is ignored.
*/
public function rewind()
public function rewind(): void
{
return reset($this->items);
reset($this->items);
}
/**

View File

@ -50,6 +50,9 @@ abstract class Command
/** @var bool Whether to automatically load enabled modules */
protected $loadEnabledModules = true;
/** @var bool Whether to enable trace for the CLI commands */
protected $trace = false;
public function __construct(App $app, $moduleName, $commandName, $actionName, $initialize = true)
{
$this->app = $app;
@ -138,6 +141,11 @@ abstract class Command
return $this->trace;
}
/**
* @param $msg
*
* @throws IcingaException
*/
public function fail($msg)
{
throw new IcingaException('%s', $msg);

View File

@ -12,6 +12,10 @@ class Documentation
{
protected $icinga;
protected $app;
protected $loader;
public function __construct(App $app)
{
$this->app = $app;
@ -73,6 +77,7 @@ class Documentation
return "The '$module' module does not provide any CLI commands\n";
}
$d = '';
$obj = null;
if ($command) {
$obj = $this->loader->getModuleCommandInstance($module, $command);
}

View File

@ -188,6 +188,7 @@ class Loader
$params = $this->app->getParams();
}
$first = null;
if ($this->moduleName === null) {
$first = $params->shift();
if (! $first) {
@ -250,6 +251,7 @@ class Loader
return false;
}
$obj = null;
try {
if ($this->moduleName) {
$this->app->getModuleManager()->loadModule($this->moduleName);
@ -266,7 +268,7 @@ class Loader
$obj->init();
return $obj->{$this->actionName . 'Action'}();
} catch (Exception $e) {
if ($obj && $obj instanceof Command && $obj->showTrace()) {
if ($obj instanceof Command && $obj->showTrace()) {
fwrite(STDERR, $this->formatTrace($e->getTrace()));
}

View File

@ -8,6 +8,7 @@ use DateTime;
use DateTimeZone;
use Exception;
use Icinga\Data\Filter\Filter;
use Zend_Db_Adapter_Abstract;
use Zend_Db_Expr;
use Zend_Db_Select;
use Icinga\Application\Logger;

View File

@ -71,7 +71,7 @@ class Inspection
*
* @throws ProgrammingError When called multiple times
*
* @return this fluent interface
* @return $this fluent interface
*/
public function error($entry)
{

View File

@ -14,7 +14,7 @@ class TreeNodeIterator implements RecursiveIterator
/**
* The node's children
*
* @var array
* @var ArrayIterator
*/
protected $children;

View File

@ -151,7 +151,7 @@ class DateFormatter
* @param bool $timeOnly
* @param bool $requireTime
*
* @return string
* @return ?string
*/
public static function timeAgo($time, $timeOnly = false, $requireTime = false)
{
@ -159,6 +159,8 @@ class DateFormatter
if ($timeOnly) {
return $ago;
}
$formatted = null;
switch ($type) {
case static::DATE:
// Move to next case
@ -188,7 +190,7 @@ class DateFormatter
* @param bool $timeOnly
* @param bool $requireTime
*
* @return string
* @return ?string
*/
public static function timeSince($time, $timeOnly = false, $requireTime = false)
{
@ -196,6 +198,8 @@ class DateFormatter
if ($timeOnly) {
return $since;
}
$formatted = null;
switch ($type) {
case static::RELATIVE:
$formatted = sprintf(
@ -224,7 +228,7 @@ class DateFormatter
* @param bool $timeOnly
* @param bool $requireTime
*
* @return string
* @return ?string
*/
public static function timeUntil($time, $timeOnly = false, $requireTime = false)
{
@ -235,6 +239,8 @@ class DateFormatter
if ($timeOnly) {
return $until;
}
$formatted = null;
switch ($type) {
case static::DATE:
// Move to next case

View File

@ -79,6 +79,7 @@ class IcingaException extends Exception
{
$trace = array();
$index = 0;
foreach ($exception->getTrace() as $index => $frame) {
$trace[] = isset($frame['file'])
? "#{$index} {$frame['file']}({$frame['line']}): "

View File

@ -34,7 +34,7 @@ class Section
/**
* Comment added at the end of the same line
*
* @var string
* @var Comment
*/
protected $commentPost;

View File

@ -118,7 +118,7 @@ class IniWriter
{
$doc = new Document();
$dangling = $oldDoc->getCommentsDangling();
if (isset($dangling)) {
if (! empty($dangling)) {
$doc->setCommentsDangling($dangling);
}
foreach ($newconfig->toArray() as $section => $directives) {

View File

@ -76,6 +76,8 @@ class LocalFileStorage implements StorageInterface
} catch (ErrorException $e) {
throw new NotWritableError('Couldn\'t create the file "%s": %s', $path, $e);
}
return $this;
}
public function read($path)
@ -98,6 +100,8 @@ class LocalFileStorage implements StorageInterface
} catch (ErrorException $e) {
throw new NotWritableError('Couldn\'t update the file "%s": %s', $path, $e);
}
return $this;
}
public function delete($path)
@ -109,6 +113,8 @@ class LocalFileStorage implements StorageInterface
} catch (ErrorException $e) {
throw new NotWritableError('Couldn\'t delete the file "%s": %s', $path, $e);
}
return $this;
}
public function resolvePath($path, $assertExistence = false)

View File

@ -189,16 +189,6 @@ CSS;
->setVariable($v);
}
public function visitColor($c)
{
if ($this->definingVariable !== false) {
// Make sure that all less tree colors do have a proper name
$c->name = $this->variableOrigin->name;
}
return $c;
}
public function run($node)
{
$this->lightMode = new LightMode();

View File

@ -129,7 +129,7 @@ class FileReader implements Selectable, Countable
}
$lines = array();
if ($query->sortDesc()) {
$count = $this->count($query);
$count = $this->count();
if ($count <= $skip) {
return $lines;
} elseif ($count < ($skip + $read)) {

View File

@ -94,7 +94,7 @@ class Discovery
/**
* Discover LDAP servers on the given domain
*
* @param string $domain The object containing the form elements
* @param ?string $domain The object containing the form elements
*
* @return Discovery True when the discovery was successful, false when the configuration was guessed
*/
@ -130,7 +130,7 @@ class Discovery
* @param $host The host on which to execute the discovery
* @param $port The port on which to execute the discovery
*
* @return Discover The resulting Discovery
* @return Discovery The resulting Discovery
*/
public static function discover($host, $port)
{

View File

@ -4,6 +4,7 @@
namespace Icinga\Protocol\Ldap;
use Icinga\Application\Logger;
use stdClass;
/**
* The properties and capabilities of an LDAP server
@ -83,7 +84,7 @@ class LdapCapabilities
/**
* Attributes of the LDAP Server returned by the discovery query
*
* @var StdClass
* @var stdClass
*/
private $attributes;
@ -97,7 +98,7 @@ class LdapCapabilities
/**
* Construct a new capability
*
* @param $attributes StdClass The attributes returned, may be null for guessing default capabilities
* @param $attributes stdClass The attributes returned, may be null for guessing default capabilities
*/
public function __construct($attributes = null)
{
@ -107,7 +108,7 @@ class LdapCapabilities
/**
* Set the attributes and (re)build the OIDs
*
* @param $attributes StdClass The attributes returned, may be null for guessing default capabilities
* @param $attributes stdClass The attributes returned, may be null for guessing default capabilities
*/
protected function setAttributes($attributes)
{

View File

@ -273,7 +273,7 @@ class LdapQuery extends SimpleQuery
);
$sorted[$new_key] = $key;
}
unset($groups);
ksort($sorted);
$tree = Root::forConnection($this->ds);

View File

@ -72,6 +72,7 @@ class Root
$dn = $this->stripMyDN($dn);
$parts = array_reverse(LdapUtils::explodeDN($dn));
$parent = $this;
$child = null;
while ($rdn = array_shift($parts)) {
if ($parent->hasChildRDN($rdn)) {
$child = $parent->getChildByRDN($rdn);

View File

@ -3,6 +3,7 @@
namespace Icinga\Repository;
use Icinga\Exception\QueryException;
use Zend_Db_Expr;
use Icinga\Data\Db\DbConnection;
use Icinga\Data\Extensible;
@ -297,7 +298,7 @@ abstract class DbRepository extends Repository implements Extensible, Updatable,
} elseif (is_string($table)) {
$table = (strpos($table, $prefix) === false ? $prefix : '') . $table;
} else {
throw new IcingaException('Table prefix handling for type "%s" is not supported', type($table));
throw new IcingaException('Table prefix handling for type "%s" is not supported', gettype($table));
}
return $table;
@ -330,7 +331,7 @@ abstract class DbRepository extends Repository implements Extensible, Updatable,
$table = str_replace($prefix, '', $table);
}
} else {
throw new IcingaException('Table prefix handling for type "%s" is not supported', type($table));
throw new IcingaException('Table prefix handling for type "%s" is not supported', gettype($table));
}
return $table;
@ -988,7 +989,7 @@ abstract class DbRepository extends Repository implements Extensible, Updatable,
*
* @param string $name The alias or column name to join into $target
* @param string $target The table to join $name into
* @param RepositoryQUery $query The query to apply the JOIN-clause on
* @param RepositoryQuery $query The query to apply the JOIN-clause on
*
* @return string|null The resolved alias or $name, null if no join logic is found
*/

View File

@ -200,8 +200,6 @@ abstract class IniRepository extends Repository implements Extensible, Updatable
*
* @param string $table
* @param ConfigObject $old
*
* @return ConfigObject
*/
public function onDelete($table, ConfigObject $old)
{
@ -217,7 +215,7 @@ abstract class IniRepository extends Repository implements Extensible, Updatable
* @param string $table The table name for which to return a trigger method
* @param string $event The name of the event type
*
* @return string
* @return ?string
*/
protected function getTrigger($table, $event)
{

View File

@ -55,7 +55,7 @@ abstract class LdapRepository extends Repository
/**
* Return the given attribute name normed to known LDAP enviroments, if possible
*
* @param string $name
* @param ?string $name
*
* @return string
*/

View File

@ -783,7 +783,7 @@ abstract class Repository implements Selectable
* @param RepositoryQuery $query An optional query to pass as context
* (unused by the base implementation)
*
* @return string
* @return ?string
*
* @throws ProgrammingError In case a conversion rule is found but not any conversion method
*/
@ -791,7 +791,7 @@ abstract class Repository implements Selectable
{
$conversionRules = $this->getConversionRules();
if (! isset($conversionRules[$table])) {
return;
return null;
}
$tableRules = $conversionRules[$table];
@ -930,7 +930,7 @@ abstract class Repository implements Selectable
*
* @param string|null $value
*
* @return int
* @return ?int
*
* @see https://tools.ietf.org/html/rfc4517#section-3.3.13
*/
@ -941,7 +941,7 @@ abstract class Repository implements Selectable
}
try {
return ASN1::parseGeneralizedTime($value)->getTimeStamp();
return ASN1::parseGeneralizedTime($value)->getTimestamp();
} catch (InvalidArgumentException $e) {
Logger::debug(sprintf('Repository "%s": %s', $this->getName(), $e->getMessage()));
}

View File

@ -140,6 +140,7 @@ class DirectoryIterator implements RecursiveIterator
public function next(): void
{
$path = null;
do {
$this->files->next();
$skip = false;

View File

@ -36,7 +36,7 @@ class GlobFilter
/**
* Create a new filter from a comma-separated list of GLOB-like filters or an array of such lists.
*
* @param string|\Traversable $filters
* @param string|\Traversable|iterable $filters
*/
public function __construct($filters)
{

View File

@ -104,7 +104,7 @@ class AnnouncementCookie extends Cookie
/**
* Get the timestamp of the next active announcement
*
* @return int
* @return ?int
*/
public function getNextActive()
{
@ -114,11 +114,11 @@ class AnnouncementCookie extends Cookie
/**
* Set the timestamp of the next active announcement
*
* @param int $nextActive
* @param ?int $nextActive
*
* @return $this
*/
public function setNextActive($nextActive)
public function setNextActive(?int $nextActive)
{
$this->nextActive = $nextActive;
return $this;

View File

@ -156,7 +156,7 @@ class Controller extends ModuleActionController
/**
* Get the page size configured via user preferences or return the default value
*
* @param int $default
* @param ?int $default
*
* @return int
*/

View File

@ -6,6 +6,7 @@ namespace Icinga\Web\Controller;
use Icinga\Application\Modules\Module;
use Icinga\Common\PdfExport;
use Icinga\File\Pdf;
use Icinga\Web\View;
use ipl\I18n\Translation;
use Zend_Controller_Action;
use Zend_Controller_Action_HelperBroker;
@ -114,6 +115,11 @@ class ActionController extends Zend_Controller_Action
*/
protected $params;
/**
* @var View
*/
public $view;
/**
* The constructor starts benchmarking, loads the configuration and sets
* other useful controller properties
@ -582,6 +588,6 @@ class ActionController extends Zend_Controller_Action
return call_user_func_array(array($this, $deprecatedMethod), $params);
}
return parent::__call($name, $params);
parent::__call($name, $params);
}
}

View File

@ -63,6 +63,7 @@ class AuthBackendController extends CompatController
*/
protected function getUserBackend($name = null, $interface = 'Icinga\Data\Selectable')
{
$backend = null;
if ($name !== null) {
$config = Config::app('authentication');
if (! $config->hasSection($name)) {
@ -121,6 +122,7 @@ class AuthBackendController extends CompatController
*/
protected function getUserGroupBackend($name = null, $interface = 'Icinga\Data\Selectable')
{
$backend = null;
if ($name !== null) {
$config = Config::app('groups');
if (! $config->hasSection($name)) {

View File

@ -17,7 +17,7 @@ class FormDescriptions extends Zend_Form_Decorator_Abstract
*
* @param string $content The html rendered so far
*
* @return string The updated html
* @return ?string The updated html
*/
public function render($content = '')
{

View File

@ -41,7 +41,7 @@ class FormHints extends Zend_Form_Decorator_Abstract
*
* @param string $content The html rendered so far
*
* @return string The updated html
* @return ?string The updated html
*/
public function render($content = '')
{

View File

@ -18,7 +18,7 @@ class FormNotifications extends Zend_Form_Decorator_Abstract
*
* @param string $content The html rendered so far
*
* @return string The updated html
* @return ?string The updated html
*/
public function render($content = '')
{

View File

@ -72,7 +72,7 @@ class Help extends Zend_Form_Decorator_Abstract
*
* @param string $content The html rendered so far
*
* @return string The updated html
* @return ?string The updated html
*/
public function render($content = '')
{

View File

@ -27,7 +27,7 @@ class Spinner extends Zend_Form_Decorator_Abstract
*
* @param string $content The html rendered so far
*
* @return string The updated html
* @return ?string The updated html
*/
public function render($content = '')
{

View File

@ -6,6 +6,7 @@ namespace Icinga\Web\Form\Element;
use Icinga\Web\Request;
use Icinga\Application\Icinga;
use Icinga\Web\Form\FormElement;
use Zend_Config;
/**
* A button

View File

@ -37,7 +37,7 @@ class FormElement extends Zend_Form_Element
* Icinga Web 2 loads its own default element decorators. For loading Zend's default element decorators set
* FormElement::$_disableLoadDefaultDecorators to false.
*
* @return this
* @return $this
* @see Form::$defaultElementDecorators For Icinga Web 2's default element decorators.
*/
public function loadDefaultDecorators()

View File

@ -62,8 +62,6 @@ class LessCompiler
public function __construct()
{
$this->lessc = new LessParser();
// Discourage usage of import because we're caching based on an explicit list of LESS files to compile
$this->lessc->importDisabled = true;
}
/**

View File

@ -173,12 +173,10 @@ class ConfigMenu extends BaseHtmlElement
protected function getHealthCount()
{
$count = 0;
$title = null;
$worstState = null;
foreach (HealthHook::collectHealthData()->select() as $result) {
if ($worstState === null || $result->state > $worstState) {
$worstState = $result->state;
$title = $result->message;
$count = 1;
} elseif ($worstState === $result->state) {
$count++;
@ -200,8 +198,6 @@ class ConfigMenu extends BaseHtmlElement
break;
}
$this->title = $title;
return $count;
}

View File

@ -122,6 +122,7 @@ class Navigation implements ArrayAccess, Countable, IteratorAggregate
}
$item = null;
$classPath = null;
foreach (Icinga::app()->getModuleManager()->getLoadedModules() as $module) {
$classPath = 'Icinga\\Module\\'
. ucfirst($module->getName())
@ -345,7 +346,7 @@ class Navigation implements ArrayAccess, Countable, IteratorAggregate
*
* @param string $name
*
* @return NavigationItem
* @return ?NavigationItem
*/
public function findItem($name)
{
@ -380,7 +381,7 @@ class Navigation implements ArrayAccess, Countable, IteratorAggregate
$name = $item->getName();
do {
if (preg_match('~_(\d+)$~', $name, $matches)) {
$name = preg_replace('~_\d+$~', $matches[1] + 1, $name);
$name = preg_replace('~_\d+$~', (int) $matches[1] + 1, $name);
} else {
$name .= '_2';
}

View File

@ -780,6 +780,7 @@ class NavigationItem implements IteratorAggregate
}
$renderer = null;
$classPath = null;
foreach (Icinga::app()->getModuleManager()->getLoadedModules() as $module) {
$classPath = 'Icinga\\Module\\' . ucfirst($module->getName()) . '\\' . static::RENDERER_NS . '\\' . $name;
if (class_exists($classPath)) {

View File

@ -80,6 +80,8 @@ class NavigationItemRenderer
$this->$setter($value);
}
}
return $this;
}
/**

View File

@ -98,7 +98,7 @@ class Url
* and overwrite any existing parameters
*
* @param UrlParams|array $params Parameters that should additionally be considered for the url
* @param Zend_Request $request A request to use instead of the default one
* @param Request $request A request to use instead of the default one
*
* @return static
*/
@ -132,7 +132,7 @@ class Url
/**
* Return a request object that should be used for determining the URL
*
* @return Zend_Abstract_Request
* @return Request
*/
protected static function getRequest()
{
@ -154,7 +154,7 @@ class Url
*
* @param string $url The string representation of the url to parse
* @param array $params An array of parameters that should additionally be considered for the url
* @param Zend_Request $request A request to use instead of the default one
* @param Request $request A request to use instead of the default one
*
* @return static
*/
@ -243,7 +243,7 @@ class Url
*
* @param string $url The url to apply the new filter to
* @param Filter $filter The base filter
* @param Filter $optional The optional filter
* @param ?Filter $optional The optional filter
*
* @return static The altered URL containing the new filter
* @throws ProgrammingError
@ -642,8 +642,8 @@ class Url
/**
* Set a single parameter, overwriting any existing one with the same name
*
* @param string $param The query parameter name
* @param array|string $value An array or string to set as the parameter value
* @param string $param The query parameter name
* @param array|string|bool $value An array or string to set as the parameter value
*
* @return $this
*/
@ -748,7 +748,7 @@ class Url
* remove from the query list
*
* @param string|array $param A single string or an array containing parameter names
* @param array $values an optional values array
* @param mixed $values an optional values array
*
* @return static
*/

View File

@ -30,8 +30,8 @@ class UrlParams
* Returns the last URL param if defined multiple times, $default if not
* given at all
*
* @param string $param The parameter you're interested in
* @param string $default An optional default value
* @param string $param The parameter you're interested in
* @param string|int|bool|null $default An optional default value
*
* @return mixed
*/
@ -74,7 +74,7 @@ class UrlParams
* $default if none.
*
* @param string $param The parameter you're interested in
* @param string $default An optional default value
* @param array $default An optional default value
*
* @return mixed
*/
@ -180,8 +180,8 @@ class UrlParams
* This will add the given parameter, regardless of whether it already
* exists.
*
* @param string $param The parameter you're interested in
* @param string $value The value to be stored
* @param string $param The parameter you're interested in
* @param string|bool $value The value to be stored
*
* @return $this
*/
@ -196,8 +196,8 @@ class UrlParams
* This may be used with either a list of values for a single parameter or
* with a list of parameter / value pairs.
*
* @param string $param Parameter name or param/value list
* @param string $value The value to be stored
* @param string|array $param Parameter name or param/value list
* @param ?array $value The value to be stored
*
* @return $this
*/

View File

@ -99,12 +99,12 @@ class View extends Zend_View_Abstract
/**
* Escape the given value top be safely used in view scripts
*
* @param string $value The output to be escaped
* @param ?string $var The output to be escaped
* @return string
*/
public function escape($value)
public function escape($var)
{
return htmlspecialchars($value ?? '', ENT_COMPAT | ENT_SUBSTITUTE | ENT_HTML5, self::CHARSET, true);
return htmlspecialchars($var ?? '', ENT_COMPAT | ENT_SUBSTITUTE | ENT_HTML5, self::CHARSET, true);
}
/**

View File

@ -4,6 +4,7 @@
namespace Icinga\Web;
use Icinga\Exception\ProgrammingError;
use Icinga\Web\Widget\AbstractWidget;
/**
* Web widgets make things easier for you!
@ -29,7 +30,7 @@ class Widget
* @param string $name Widget name
* @param array $options Widget constructor options
*
* @return Icinga\Web\Widget\AbstractWidget
* @return AbstractWidget
*/
public static function create($name, $options = array(), $module_name = null)
{

View File

@ -6,6 +6,7 @@ namespace Icinga\Web\Widget;
use Icinga\Exception\ProgrammingError;
use Icinga\Application\Icinga;
use Exception;
use Zend_View_Abstract;
/**
* Web widgets MUST extend this class
@ -111,7 +112,7 @@ abstract class AbstractWidget
public function __toString()
{
try {
$html = $this->render($this->view());
$html = $this->render();
} catch (Exception $e) {
return htmlspecialchars($e->getMessage());
}

View File

@ -14,7 +14,7 @@ use Icinga\Web\Url;
* @property string $title Tab title
* @property string $icon Icon URL, preferrably relative to the Icinga
* base URL
* @property string $url Action URL, preferrably relative to the Icinga
* @property string|URL $url Action URL, preferrably relative to the Icinga
* base URL
* @property string $urlParams Action URL Parameters
*
@ -52,7 +52,7 @@ class Tab extends AbstractWidget
/**
* The Url this tab points to
*
* @var string|null
* @var Url|null
*/
private $url = null;
@ -172,7 +172,7 @@ class Tab extends AbstractWidget
/**
* Set the Url this tab points to
*
* @param string $url The Url to use for this tab
* @param string|Url $url The Url to use for this tab
*/
public function setUrl($url)
{

View File

@ -3,6 +3,7 @@
namespace Icinga\Web\Widget;
use Exception;
use Icinga\Exception\Http\HttpNotFoundException;
use Icinga\Exception\ProgrammingError;
use Icinga\Web\Url;
@ -106,6 +107,13 @@ EOT;
*/
private $closeTab = true;
/**
* CSS class name(s) for the &lt;ul&gt; element
*
* @var string
*/
private $tab_class;
/**
* Set whether the current tab is closable
*/
@ -389,7 +397,7 @@ EOT;
public function __toString()
{
try {
$html = $this->render(Icinga::app()->getViewRenderer()->view);
$html = $this->render();
} catch (Exception $e) {
return htmlspecialchars($e->getMessage());
}

View File

@ -4,6 +4,7 @@
namespace Icinga\Web;
use Icinga\Forms\ConfigForm;
use Icinga\Module\Setup\Forms\ModulePage;
use LogicException;
use InvalidArgumentException;
use Icinga\Web\Session\SessionNamespace;
@ -131,9 +132,9 @@ class Wizard
*
* Note that it's also possible to retrieve a nested wizard's page by using this method.
*
* @param string $name The name of the page to return
* @param string $name The name of the page to return
*
* @return null|Form The page or null in case there is no page with the given name
* @return ModulePage|Form|null The page or null in case there is no page with the given name
*/
public function getPage($name)
{
@ -154,7 +155,7 @@ class Wizard
public function addPage($page)
{
if (! $page instanceof Form && ! $page instanceof self) {
throw InvalidArgumentException(
throw new InvalidArgumentException(
'The $page argument must be an instance of Icinga\Web\Form '
. 'or Icinga\Web\Wizard but is of type: ' . get_class($page)
);

View File

@ -11,7 +11,7 @@ class IcingawebController extends DocController
/**
* Get the path to Icinga Web 2's documentation
*
* @return string
* @return ?string
*
* @throws \Icinga\Exception\Http\HttpNotFoundException If Icinga Web 2's documentation is not available
*/

View File

@ -152,7 +152,7 @@ class ModuleController extends DocController
$lastModified = gmdate('D, d M Y H:i:s T', $imageInfo->getMTime());
$match = false;
if (isset($_SERER['HTTP_IF_NONE_MATCH'])) {
if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
$ifNoneMatch = explode(', ', stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
foreach ($ifNoneMatch as $tag) {
if ($tag === $etag) {

View File

@ -79,7 +79,7 @@ class SearchController extends DocController
/**
* Get the path to Icinga Web 2's documentation
*
* @return string
* @return ?string
*/
protected function getWebPath()
{

View File

@ -5,6 +5,7 @@ namespace Icinga\Module\Doc\Renderer;
use DOMDocument;
use DOMXPath;
use Icinga\Module\Doc\DocSection;
use Parsedown;
use RecursiveIteratorIterator;
use Icinga\Data\Tree\SimpleTree;
@ -201,7 +202,7 @@ class DocSectionRenderer extends DocRenderer
false
);
$url = $this->getView()->url($path);
/** @var \Icinga\Web\Url $url */
/** @var Url $url */
$img->setAttribute('src', $url->getAbsoluteUrl());
return substr_replace($doc->saveXML($img), '', -2, 1); // Replace '/>' with '>'
}
@ -218,7 +219,7 @@ class DocSectionRenderer extends DocRenderer
if (($chapter = $this->tree->getNode($this->decodeAnchor($match['chapter']))) === null) {
return $match[0];
}
/** @var \Icinga\Module\Doc\DocSection $section */
/** @var DocSection $section */
$path = $this->getView()->getHelper('Url')->url(
array_merge(
$this->urlParams,
@ -231,7 +232,7 @@ class DocSectionRenderer extends DocRenderer
false
);
$url = $this->getView()->url($path);
/** @var \Icinga\Web\Url $url */
/** @var Url $url */
return sprintf(
'<a %s%shref="%s"',
strlen($match['attribs']) ? trim($match['attribs']) . ' ' : '',
@ -252,7 +253,7 @@ class DocSectionRenderer extends DocRenderer
if (($section = $this->tree->getNode($this->decodeAnchor($match['section']))) === null) {
return $match[0];
}
/** @var \Icinga\Module\Doc\DocSection $section */
/** @var DocSection $section */
$path = $this->getView()->getHelper('Url')->url(
array_merge(
$this->urlParams,
@ -265,7 +266,7 @@ class DocSectionRenderer extends DocRenderer
false
);
$url = $this->getView()->url($path);
/** @var \Icinga\Web\Url $url */
/** @var Url $url */
$url->setAnchor($this->encodeAnchor($section->getId()));
return sprintf(
'<a %s%shref="%s"',

View File

@ -3,6 +3,7 @@
namespace Icinga\Module\Doc\Search;
use Icinga\Module\Doc\DocSection;
use RecursiveFilterIterator;
use RecursiveIteratorIterator;
use Icinga\Data\Tree\TreeNodeIterator;
@ -46,8 +47,8 @@ class DocSearchIterator extends RecursiveFilterIterator
*/
public function accept(): bool
{
/** @var $section DocSection */
$section = $this->current();
/** @var $section \Icinga\Module\Doc\DocSection */
$matches = array();
if (($match = $this->search->search($section->getTitle())) !== null) {
$matches[] = $match->setMatchType(DocSearchMatch::MATCH_HEADER);

View File

@ -223,7 +223,7 @@ class EventController extends Controller
*
* @param string $eventType
*
* @return string[]
* @return ?string[]
*/
protected function getIconAndLabel($eventType)
{
@ -263,7 +263,7 @@ class EventController extends Controller
* @param string $type
* @param int $id
*
* @return Queryable
* @return ?Queryable
*/
protected function query($type, $id)
{
@ -358,7 +358,7 @@ class EventController extends Controller
* @param string $type
* @param \stdClass $event
*
* @return string[][]
* @return ?string[][]
*/
protected function getDetails($type, $event)
{

View File

@ -88,7 +88,8 @@ class HealthController extends Controller
$this->handleFormatRequest($programStatus);
$programStatus = $programStatus->fetchRow();
if ($programStatus === false) {
return $this->render('not-running', true, null);
$this->render('not-running', true, null);
return;
}
$this->view->programStatus = $programStatus;
$toggleFeaturesForm = new ToggleInstanceFeaturesCommandForm();

View File

@ -105,7 +105,7 @@ class HostsController extends Controller
}
$acknowledgedObjects = $this->hostList->getAcknowledgedObjects();
if (! empty($acknowledgedObjects)) {
if ($acknowledgedObjects->count()) {
$removeAckForm = new RemoveAcknowledgementCommandForm();
$removeAckForm
->setObjects($acknowledgedObjects)

View File

@ -370,9 +370,9 @@ class ListController extends Controller
array('day', $form->getValue('state'))
);
$this->params->remove(array('objecttype', 'from', 'to', 'state', 'btn_submit'));
$this->view->filter = Filter::fromQuerystring((string) $this->params);
$this->view->filter = Filter::fromQueryString((string) $this->params);
$query->applyFilter($this->view->filter);
$query->applyFilter(Filter::fromQuerystring('timestamp>=' . $from));
$query->applyFilter(Filter::fromQueryString('timestamp>=' . $from));
$this->applyRestriction('monitoring/filter/objects', $query);
$this->view->summary = $query;
$this->view->column = $form->getValue('state');
@ -803,6 +803,6 @@ class ListController extends Controller
*/
private function createTabs()
{
$this->getTabs()->extend(new OutputFormat())->extend(new DashboardAction())->extend(new MenuAction());
return $this->getTabs()->extend(new OutputFormat())->extend(new DashboardAction())->extend(new MenuAction());
}
}

View File

@ -112,7 +112,7 @@ class ServicesController extends Controller
}
$acknowledgedObjects = $this->serviceList->getAcknowledgedObjects();
if (! empty($acknowledgedObjects)) {
if ($acknowledgedObjects->count()) {
$removeAckForm = new RemoveAcknowledgementCommandForm();
$removeAckForm
->setObjects($acknowledgedObjects)

View File

@ -40,6 +40,7 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm
*/
public function createElements(array $formData)
{
$object = null;
foreach ($this->getObjects() as $object) {
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
// Nasty, but as getObjects() returns everything but an object with a real

View File

@ -97,19 +97,19 @@ class EventOverviewForm extends Form
public function getFilter()
{
$filters = array();
if ($this->getValue('statechange', 1)) {
if ($this->getValue('statechange')) {
$filters[] = $this->stateChangeFilter();
}
if ($this->getValue('comment', 1)) {
if ($this->getValue('comment')) {
$filters[] = $this->commentFilter();
}
if ($this->getValue('notification', 1)) {
if ($this->getValue('notification')) {
$filters[] = $this->notificationFilter();
}
if ($this->getValue('downtime', 1)) {
if ($this->getValue('downtime')) {
$filters[] = $this->downtimeFilter();
}
if ($this->getValue('flapping', 1)) {
if ($this->getValue('flapping')) {
$filters[] = $this->flappingFilter();
}
return Filter::matchAny($filters);

View File

@ -31,7 +31,7 @@ class StatehistoryForm extends Form
Filter::expression('type', '=', 'hard_state')
);
if ($this->getValue('objecttype', 'hosts') === 'hosts') {
if ($this->getValue('objecttype') === 'hosts') {
$objectTypeFilter = Filter::expression('object_type', '=', 'host');
} else {
$objectTypeFilter = Filter::expression('object_type', '=', 'service');
@ -46,7 +46,7 @@ class StatehistoryForm extends Form
'cnt_unknown_hard' => Filter::expression('state', '=', '3'),
'cnt_ok' => Filter::expression('state', '=', '0')
);
$state = $this->getValue('state', 'cnt_critical_hard');
$state = $this->getValue('state');
$stateFilter = $states[$state];
if (in_array($state, array('cnt_ok', 'cnt_up'))) {
return Filter::matchAll($objectTypeFilter, $stateFilter);

View File

@ -1,8 +1,13 @@
<?php
/* Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */
use Icinga\Web\View;
class Zend_View_Helper_Customvar extends Zend_View_Helper_Abstract
{
/** @var View */
public $view;
/**
* Create dispatch instance
*

View File

@ -1,8 +1,13 @@
<?php
/* Icinga Web 2 | (c) 2015 Icinga Development Team | GPLv2+ */
use Icinga\Web\View;
class Zend_View_Helper_HostFlags extends Zend_View_Helper_Abstract
{
/** @var View */
public $view;
public function hostFlags($host)
{
$icons = array();

View File

@ -2,12 +2,17 @@
/* Icinga Web 2 | (c) 2015 Icinga Development Team | GPLv2+ */
use Icinga\Module\Monitoring\Object\Macro;
use Icinga\Module\Monitoring\Object\MonitoredObject;
use Icinga\Web\View;
/**
* Generate icons to describe a given hosts state
*/
class Zend_View_Helper_IconImage extends Zend_View_Helper_Abstract
{
/** @var View */
public $view;
/**
* Create dispatch instance
*

View File

@ -1,7 +1,7 @@
<?php
/* Icinga Web 2 | (c) 2013 Icinga Development Team | GPLv2+ */
/* use Icinga\Module\Monitoring\Object\MonitoredObject; */
use Icinga\Module\Monitoring\Object\MonitoredObject;
/**
* Rendering helper for object's properties which may be either enabled or disabled

View File

@ -4,9 +4,13 @@
use Icinga\Module\Monitoring\Plugin\Perfdata;
use Icinga\Module\Monitoring\Plugin\PerfdataSet;
use Icinga\Util\StringHelper;
use Icinga\Web\View;
class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
{
/** @var View */
public $view;
/**
* Display the given perfdata string to the user
*

Some files were not shown because too many files have changed in this diff Show More