mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-30 17:24:18 +02:00
Phpstan: Fix deprecated function param types (#2858)
This commit is contained in:
commit
c65369602f
@ -370,7 +370,7 @@ class ConfigController extends ActionController
|
||||
|
||||
$configs = $db->enumDeployedConfigs();
|
||||
foreach (array($leftSum, $rightSum) as $sum) {
|
||||
if (! array_key_exists($sum, $configs)) {
|
||||
if ($sum && ! array_key_exists($sum, $configs)) {
|
||||
$configs[$sum] = substr($sum, 0, 7);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class ImportsourcesController extends ActionController
|
||||
}
|
||||
|
||||
$this->addTitle($this->translate('Import source'))
|
||||
->setAutoRefreshInterval(10)
|
||||
->setAutorefreshInterval(10)
|
||||
->addAddLink(
|
||||
$this->translate('Add a new Import Source'),
|
||||
'director/importsource/add'
|
||||
|
@ -11,7 +11,7 @@ class JobsController extends ActionController
|
||||
public function indexAction()
|
||||
{
|
||||
$this->addTitle($this->translate('Jobs'))
|
||||
->setAutoRefreshInterval(10)
|
||||
->setAutorefreshInterval(10)
|
||||
->addAddLink($this->translate('Add a new Job'), 'director/job/add')
|
||||
->tabs(new ImportTabs())->activate('jobs');
|
||||
|
||||
|
@ -62,7 +62,7 @@ class SchemaController extends ActionController
|
||||
return file_get_contents(
|
||||
sprintf(
|
||||
'%s/schema/%s.sql',
|
||||
$this->Module()->getBasedir(),
|
||||
$this->Module()->getBaseDir(),
|
||||
$type
|
||||
)
|
||||
);
|
||||
|
@ -194,7 +194,7 @@ class SelfServiceController extends ActionController
|
||||
} else {
|
||||
throw new ProgrammingError(
|
||||
'Expected boolean value, got %s',
|
||||
var_export($value, 1)
|
||||
var_export($value, true)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -275,7 +275,7 @@ class SelfServiceController extends ActionController
|
||||
// PluginsUrl => framework_plugins_url
|
||||
];
|
||||
$username = $settings->get('self-service/icinga_service_user');
|
||||
if ($username !== null && strlen($username) > 0) {
|
||||
if ($username) {
|
||||
$params['icinga_service_user'] = $username;
|
||||
}
|
||||
|
||||
@ -404,7 +404,7 @@ class SelfServiceController extends ActionController
|
||||
{
|
||||
foreach ($keys as $key) {
|
||||
$value = $settings->get("self-service/$key");
|
||||
if (strlen($value)) {
|
||||
if ($value) {
|
||||
$params[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class SyncruleController extends ActionController
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$this->setAutoRefreshInterval(10);
|
||||
$this->setAutorefreshInterval(10);
|
||||
$rule = $this->requireSyncRule();
|
||||
$this->tabs(new SyncRuleTabs($rule))->activate('show');
|
||||
$ruleName = $rule->get('rule_name');
|
||||
@ -642,7 +642,7 @@ class SyncruleController extends ActionController
|
||||
*/
|
||||
public function historyAction()
|
||||
{
|
||||
$this->setAutoRefreshInterval(30);
|
||||
$this->setAutorefreshInterval(30);
|
||||
$rule = $this->requireSyncRule();
|
||||
$this->tabs(new SyncRuleTabs($rule))->activate('history');
|
||||
$this->addTitle($this->translate('Sync history') . ': ' . $rule->get('rule_name'));
|
||||
|
@ -23,7 +23,7 @@ class SyncrulesController extends ActionController
|
||||
}
|
||||
|
||||
$this->addTitle($this->translate('Sync rule'))
|
||||
->setAutoRefreshInterval(10)
|
||||
->setAutorefreshInterval(10)
|
||||
->addAddLink(
|
||||
$this->translate('Add a new Sync Rule'),
|
||||
'director/syncrule/add'
|
||||
|
@ -19,7 +19,7 @@ class IcingaTemplateChoiceForm extends DirectorObjectForm
|
||||
{
|
||||
if ($name !== null) {
|
||||
/** @var IcingaTemplateChoice $class - cheating IDE */
|
||||
$class = $this->getObjectClassName();
|
||||
$class = $this->getObjectClassname();
|
||||
$this->setObject($class::load($name, $this->getDb()));
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ class IcingaTemplateChoiceForm extends DirectorObjectForm
|
||||
/** @var IcingaTemplateChoice $object */
|
||||
$object = $this->object();
|
||||
$this->setSuccessUrl(
|
||||
'director/templatechoice/' . $object->getObjectshortTableName(),
|
||||
'director/templatechoice/' . $object->getObjectShortTableName(),
|
||||
$object->getUrlParams()
|
||||
);
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class SyncCheckForm extends DirectorForm
|
||||
} elseif ($sum['modify'] > 1) {
|
||||
}
|
||||
*/
|
||||
$html = '<pre>' . print_r($sum, 1) . '</pre>';
|
||||
$html = '<pre>' . print_r($sum, true) . '</pre>';
|
||||
|
||||
$this->addHtml($html);
|
||||
} elseif ($this->rule->get('sync_state') === 'in-sync') {
|
||||
|
@ -44,14 +44,16 @@ class Zend_View_Helper_FormDataFilter extends Zend_View_Helper_FormElement
|
||||
{
|
||||
$info = $this->_getInfo($name, $value, $attribs);
|
||||
extract($info); // id, name, value, attribs, options, listsep, disable
|
||||
if (array_key_exists('columns', $attribs)) {
|
||||
$this->setColumns($attribs['columns']);
|
||||
unset($attribs['columns']);
|
||||
}
|
||||
if ($attribs) {
|
||||
if (array_key_exists('columns', $attribs)) {
|
||||
$this->setColumns($attribs['columns']);
|
||||
unset($attribs['columns']);
|
||||
}
|
||||
|
||||
if (array_key_exists('suggestionContext', $attribs)) {
|
||||
$this->setSuggestionContext($attribs['suggestionContext']);
|
||||
unset($attribs['suggestionContext']);
|
||||
if (array_key_exists('suggestionContext', $attribs)) {
|
||||
$this->setSuggestionContext($attribs['suggestionContext']);
|
||||
unset($attribs['suggestionContext']);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: check for columns in attribs, preserve & remove them from the
|
||||
|
@ -82,9 +82,9 @@ class Command extends CliCommand
|
||||
{
|
||||
MemoryLimit::raiseTo('1024M');
|
||||
|
||||
ini_set('max_execution_time', 0);
|
||||
ini_set('max_execution_time', '0');
|
||||
if (version_compare(PHP_VERSION, '7.0.0') < 0) {
|
||||
ini_set('zend.enable_gc', 0);
|
||||
ini_set('zend.enable_gc', '0');
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@ -428,7 +428,7 @@ class ObjectCommand extends Command
|
||||
}
|
||||
|
||||
$stdin = file_get_contents('php://stdin');
|
||||
if (strlen($stdin) === 0) {
|
||||
if (! $stdin) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -569,7 +569,7 @@ constants
|
||||
'icon_image_alt' => 'icon_image_alt',
|
||||
];
|
||||
|
||||
if (version_compare($this->getVersion(), '2.8.0', '>=')) {
|
||||
if (version_compare($this->getVersion() ?? '', '2.8.0', '>=')) {
|
||||
$params['flapping_threshold_high'] = 'flapping_threshold_high';
|
||||
$params['flapping_threshold_low'] = 'flapping_threshold_low';
|
||||
}
|
||||
|
@ -128,6 +128,10 @@ class LegacyDeploymentApi implements DeploymentApiInterface
|
||||
if (file_exists($path)) {
|
||||
if (is_link($path)) {
|
||||
$linkTarget = readlink($path);
|
||||
if (! $linkTarget) {
|
||||
throw new IcingaException('Failed to read symlink');
|
||||
}
|
||||
|
||||
$linkTargetDir = dirname($linkTarget);
|
||||
$linkTargetName = basename($linkTarget);
|
||||
|
||||
@ -165,7 +169,7 @@ class LegacyDeploymentApi implements DeploymentApiInterface
|
||||
$this->assertDeploymentPath();
|
||||
|
||||
$dh = @opendir($this->deploymentPath);
|
||||
if ($dh === null) {
|
||||
if ($dh === false) {
|
||||
throw new IcingaException('Can not list contents of %s', $this->deploymentPath);
|
||||
}
|
||||
|
||||
@ -279,7 +283,7 @@ class LegacyDeploymentApi implements DeploymentApiInterface
|
||||
$this->mkdir(dirname($fullPath), true);
|
||||
|
||||
$fh = @fopen($fullPath, 'w');
|
||||
if ($fh === null) {
|
||||
if ($fh === false) {
|
||||
throw new IcingaException('Could not open file "%s" for writing.', $fullPath);
|
||||
}
|
||||
chmod($fullPath, $this->file_mode);
|
||||
@ -334,7 +338,7 @@ class LegacyDeploymentApi implements DeploymentApiInterface
|
||||
protected function listDirectoryContents($path, $depth = 0)
|
||||
{
|
||||
$dh = @opendir($path);
|
||||
if ($dh === null) {
|
||||
if ($dh === false) {
|
||||
throw new IcingaException('Can not list contents of %s', $path);
|
||||
}
|
||||
|
||||
|
@ -206,14 +206,14 @@ class RestApiClient
|
||||
}
|
||||
|
||||
/**
|
||||
* @return resource
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function curl()
|
||||
{
|
||||
if ($this->curl === null) {
|
||||
$this->curl = curl_init(sprintf('https://%s:%d', $this->peer, $this->port));
|
||||
if (! $this->curl) {
|
||||
throw new RuntimeException('CURL INIT ERROR: ' . curl_error($this->curl));
|
||||
throw new RuntimeException('CURL INIT FAILED');
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,13 +260,11 @@ class RestApiClient
|
||||
|
||||
public function disconnect()
|
||||
{
|
||||
if ($this->curl !== null) {
|
||||
if (is_resource($this->curl)) {
|
||||
@curl_close($this->curl);
|
||||
}
|
||||
|
||||
$this->curl = null;
|
||||
if ($this->curl) {
|
||||
@curl_close($this->curl);
|
||||
}
|
||||
|
||||
$this->curl = null;
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
|
@ -113,7 +113,7 @@ class RestApiResponse
|
||||
throw new IcingaException('API request failed: ' . $result->status);
|
||||
}
|
||||
} else {
|
||||
throw new IcingaException('API request failed: ' . var_export($result, 1));
|
||||
throw new IcingaException('API request failed: ' . var_export($result, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ abstract class CustomVariable implements IcingaConfigRenderer
|
||||
// TODO: check for specific class/stdClass/interface?
|
||||
return new CustomVariableDictionary($key, $value);
|
||||
} else {
|
||||
throw new LogicException(sprintf('WTF (%s): %s', $key, var_export($value, 1)));
|
||||
throw new LogicException(sprintf('WTF (%s): %s', $key, var_export($value, true)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ class CustomVariableBoolean extends CustomVariable
|
||||
if (! is_bool($value)) {
|
||||
throw new ProgrammingError(
|
||||
'Expected a boolean, got %s',
|
||||
var_export($value, 1)
|
||||
var_export($value, true)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ class CustomVariableNull extends CustomVariable
|
||||
if (! is_null($value)) {
|
||||
throw new ProgrammingError(
|
||||
'Null can only be null, got %s',
|
||||
var_export($value, 1)
|
||||
var_export($value, true)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ class CustomVariableNumber extends CustomVariable
|
||||
if (! is_int($value) && ! is_float($value)) {
|
||||
throw new ProgrammingError(
|
||||
'Expected a number, got %s',
|
||||
var_export($value, 1)
|
||||
var_export($value, true)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ class BackgroundDaemon
|
||||
try {
|
||||
$uuid = \bin2hex(Uuid::uuid4()->getBytes());
|
||||
} catch (Exception $e) {
|
||||
$uuid = 'deadc0de' . \substr(\md5(\getmypid()), 0, 24);
|
||||
$uuid = 'deadc0de' . substr(md5((string) getmypid()), 0, 24);
|
||||
}
|
||||
}
|
||||
$processDetails = new DaemonProcessDetails($uuid);
|
||||
|
@ -20,7 +20,7 @@ class DbDataFormatter
|
||||
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'Got invalid boolean: %s',
|
||||
var_export($value, 1)
|
||||
var_export($value, true)
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -984,7 +984,7 @@ abstract class DbObject
|
||||
$this->table,
|
||||
$this->getLogId(),
|
||||
$e->getMessage(),
|
||||
var_export($this->getProperties(), 1) // TODO: Remove properties
|
||||
var_export($this->getProperties(), true) // TODO: Remove properties
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ class PropertyMangler
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'I can only append to arrays, %s is %s',
|
||||
$key,
|
||||
var_export($current, 1)
|
||||
var_export($current, true)
|
||||
));
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ class PropertyMangler
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'I can only remove strings or from arrays, %s is %s',
|
||||
$key,
|
||||
var_export($current, 1)
|
||||
var_export($current, true)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class Branch
|
||||
$row->uuid = stream_get_contents($row->uuid);
|
||||
}
|
||||
if (strlen($row->uuid) !== 16) {
|
||||
throw new RuntimeException('Valid UUID expected, got ' . var_export($row->uuid, 1));
|
||||
throw new RuntimeException('Valid UUID expected, got ' . var_export($row->uuid, true));
|
||||
}
|
||||
$self->branchUuid = Uuid::fromBytes(Db\DbUtil::binaryResult($row->uuid));
|
||||
$self->name = $row->branch_name;
|
||||
|
@ -31,7 +31,7 @@ class IcingaObjectFilterHelper
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'Numeric ID or IcingaObject expected, got %s',
|
||||
// TODO: just type/class info?
|
||||
var_export($id, 1)
|
||||
var_export($id, true)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ class Migrations
|
||||
public function applyPendingMigrations()
|
||||
{
|
||||
// Ensure we have enough time to migrate
|
||||
ini_set('max_execution_time', 0);
|
||||
ini_set('max_execution_time', '0');
|
||||
|
||||
foreach ($this->getPendingMigrations() as $migration) {
|
||||
$migration->apply($this->connection);
|
||||
|
@ -410,7 +410,7 @@ class BasketSnapshot extends DbObject
|
||||
try {
|
||||
JsonString::encode($object);
|
||||
} catch (JsonEncodeException $singleError) {
|
||||
$dump = var_export($object, 1);
|
||||
$dump = var_export($object, true);
|
||||
if (function_exists('iconv')) {
|
||||
$dump = iconv('UTF-8', 'UTF-8//IGNORE', $dump);
|
||||
}
|
||||
|
@ -44,11 +44,11 @@ class ObjectPurgeHelper
|
||||
// TODO: this is object-specific and to be found in the ::import() function!
|
||||
unset($properties['fields']);
|
||||
$object = $class::fromPlainObject($properties);
|
||||
} elseif (\get_class($object) !== $class) {
|
||||
} elseif (get_class($object) !== $class) {
|
||||
throw new InvalidArgumentException(
|
||||
'Can keep only matching objects, expected "%s", got "%s',
|
||||
$class,
|
||||
\get_class($keep)
|
||||
get_class($object)
|
||||
);
|
||||
}
|
||||
$key = [];
|
||||
|
@ -448,9 +448,9 @@ class IcingaConfig
|
||||
$start = microtime(true);
|
||||
|
||||
MemoryLimit::raiseTo('1024M');
|
||||
ini_set('max_execution_time', 0);
|
||||
ini_set('max_execution_time', '0');
|
||||
// Workaround for https://bugs.php.net/bug.php?id=68606 or similar
|
||||
ini_set('zend.enable_gc', 0);
|
||||
ini_set('zend.enable_gc', '0');
|
||||
|
||||
if (! $this->connection->isPgsql() && $this->db->quote("1\0") !== '\'1\\0\'') {
|
||||
throw new RuntimeException(
|
||||
|
@ -177,7 +177,7 @@ class IcingaConfigHelper
|
||||
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'Unexpected type %s',
|
||||
var_export($value, 1)
|
||||
var_export($value, true)
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ class ImportSourceLdap extends ImportSourceHook
|
||||
|
||||
public static function addSettingsFormFields(QuickForm $form)
|
||||
{
|
||||
Util::addLDAPResourceFormElement($form, 'resource');
|
||||
Util::addLdapResourceFormElement($form, 'resource');
|
||||
$form->addElement('text', 'base', array(
|
||||
'label' => $form->translate('LDAP Search Base'),
|
||||
'description' => $form->translate(
|
||||
|
@ -69,6 +69,7 @@ class ImportSourceRestApi extends ImportSourceHook
|
||||
$data = $result;
|
||||
foreach ($parts as $part) {
|
||||
// un-escape any dots
|
||||
/** @var string $part */
|
||||
$part = preg_replace('~\\\\.~', '.', $part);
|
||||
|
||||
if (property_exists($data, $part)) {
|
||||
|
@ -154,7 +154,7 @@ class Sync
|
||||
protected function raiseLimits()
|
||||
{
|
||||
MemoryLimit::raiseTo('1024M');
|
||||
ini_set('max_execution_time', 0);
|
||||
ini_set('max_execution_time', '0');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ class SyncUtils
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'Data is not nested, cannot access %s: %s',
|
||||
$var,
|
||||
var_export($row, 1)
|
||||
var_export($row, true)
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ class DirectorDatalistEntry extends DbObject
|
||||
} else {
|
||||
throw new RuntimeException(
|
||||
'Expected array or null for allowed_roles, got %s',
|
||||
var_export($roles, 1)
|
||||
var_export($roles, true)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -127,10 +127,8 @@ class IcingaCommand extends IcingaObject implements ObjectWithArguments, ExportI
|
||||
// return $value;
|
||||
}
|
||||
|
||||
if (self::$pluginDir !== null) {
|
||||
if (($pos = strpos($value, self::$pluginDir)) === 0) {
|
||||
$value = substr($value, strlen(self::$pluginDir) + 1);
|
||||
}
|
||||
if (isset($value, self::$pluginDir) && strpos($value, self::$pluginDir) === 0) {
|
||||
$value = substr($value, strlen(self::$pluginDir) + 1);
|
||||
}
|
||||
|
||||
return $value;
|
||||
|
@ -228,7 +228,7 @@ class IcingaObjectGroups implements Iterator, Countable, IcingaConfigRenderer
|
||||
} else {
|
||||
throw new RuntimeException(
|
||||
'Invalid group object: %s',
|
||||
var_export($group, 1)
|
||||
var_export($group, true)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ class IcingaObjectLegacyAssignments
|
||||
$assigns = array();
|
||||
$ignores = array();
|
||||
foreach ($values as $type => $value) {
|
||||
if (strpos($value, '|') !== false || strpos($value, '&' !== false)) {
|
||||
if (strpos($value, '|') !== false || strpos($value, '&') !== false) {
|
||||
$value = '(' . $value . ')';
|
||||
}
|
||||
|
||||
|
@ -239,7 +239,7 @@ class IcingaObjectMultiRelations implements Iterator, Countable, IcingaConfigRen
|
||||
} else {
|
||||
throw new ProgrammingError(
|
||||
'Invalid related object: %s',
|
||||
var_export($relation, 1)
|
||||
var_export($relation, true)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@ class IcingaRelatedObject
|
||||
} else {
|
||||
throw new ProgrammingError(
|
||||
'Related object can be name or object, got: %s',
|
||||
var_export($related, 1)
|
||||
var_export($related, true)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -225,7 +225,7 @@ class IcingaTemplateChoice extends IcingaObject implements ExportInterface
|
||||
} else {
|
||||
throw new ProgrammingError(
|
||||
'Expected array or null for allowed_roles, got %s',
|
||||
var_export($roles, 1)
|
||||
var_export($roles, true)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -479,7 +479,7 @@ class ImportSource extends DbObjectWithSettings implements ExportInterface
|
||||
protected function raiseLimits()
|
||||
{
|
||||
MemoryLimit::raiseTo('1024M');
|
||||
ini_set('max_execution_time', 0);
|
||||
ini_set('max_execution_time', '0');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ class PlainObjectRenderer
|
||||
} elseif (is_string($object)) {
|
||||
return self::renderString($object);
|
||||
} else {
|
||||
return '(UNKNOWN TYPE) ' . var_export($object, 1);
|
||||
return '(UNKNOWN TYPE) ' . var_export($object, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ class PropertyModifierArrayFilter extends PropertyModifierHook
|
||||
default:
|
||||
throw new ConfigurationError(
|
||||
'%s is not a valid value for an ArrayFilter filter_method',
|
||||
var_export($method, 1)
|
||||
var_export($method, true)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ class PropertyModifierExtractFromDN extends PropertyModifierHook
|
||||
default:
|
||||
throw new InvalidPropertyException(
|
||||
'DN part extraction failed for %s',
|
||||
var_export($value, 1)
|
||||
var_export($value, true)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,8 @@ class PropertyModifierGetHostByName extends PropertyModifierHook
|
||||
}
|
||||
|
||||
$host = gethostbyname($value);
|
||||
if (strlen(@inet_pton($host)) !== 4) {
|
||||
$inAddr = inet_pton($host);
|
||||
if (! $inAddr || strlen($inAddr) !== 4) {
|
||||
switch ($this->getSetting('on_failure')) {
|
||||
case 'null':
|
||||
return null;
|
||||
|
@ -128,7 +128,7 @@ class PropertyModifierRejectOrSelect extends PropertyModifierHook
|
||||
default:
|
||||
throw new ConfigurationError(
|
||||
'%s is not a valid value for an ArrayFilter filter_method',
|
||||
var_export($method, 1)
|
||||
var_export($method, true)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ use Icinga\Exception\ProgrammingError;
|
||||
use Icinga\Module\Cube\Hook\IcingaDbActionsHook;
|
||||
use Icinga\Module\Cube\IcingaDb\IcingaDbCube;
|
||||
use Icinga\Module\Cube\IcingaDb\IcingaDbHostStatusCube;
|
||||
use ipl\Stdlib\Filter\Condition;
|
||||
|
||||
class IcingaDbCubeLinks extends IcingaDbActionsHook
|
||||
{
|
||||
@ -25,17 +26,19 @@ class IcingaDbCubeLinks extends IcingaDbActionsHook
|
||||
|
||||
if ($filterChain->count() === 1) {
|
||||
$url = 'director/host/edit?';
|
||||
$params = ['name' => $filterChain->getIterator()->current()->getValue()];
|
||||
/** @var Condition $rule */
|
||||
$rule = $filterChain->getIterator()->current();
|
||||
/** @var string $name */
|
||||
$name = $rule->getValue();
|
||||
$params = ['name' => $name];
|
||||
|
||||
$title = t('Modify a host');
|
||||
$description = sprintf(
|
||||
t('This allows you to modify properties for "%s"'),
|
||||
$filterChain->getIterator()->current()->getValue()
|
||||
);
|
||||
$description = sprintf(t('This allows you to modify properties for "%s"'), $name);
|
||||
} else {
|
||||
$params = null;
|
||||
|
||||
$urlFilter = Filter::matchAny();
|
||||
/** @var Condition $filter */
|
||||
foreach ($filterChain as $filter) {
|
||||
$urlFilter->addFilter(
|
||||
Filter::matchAny(
|
||||
|
@ -176,7 +176,7 @@ class IcingaObjectResolver
|
||||
$object->groups = $groups;
|
||||
}
|
||||
|
||||
$templates = $this->getTemplateNamesById($id);
|
||||
$templates = $this->getTemplateNamesByID($id);
|
||||
if (! empty($templates)) {
|
||||
$object->templates = \array_reverse($templates);
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ use RuntimeException;
|
||||
|
||||
class RestApiClient
|
||||
{
|
||||
/** @var resource */
|
||||
private $curl;
|
||||
|
||||
/** @var string HTTP or HTTPS */
|
||||
@ -287,7 +286,7 @@ class RestApiClient
|
||||
|
||||
if ($statusCode >= 400) {
|
||||
throw new RuntimeException(
|
||||
"Got $statusCode: " . \var_export($res, 1)
|
||||
"Got $statusCode: " . \var_export($res, true)
|
||||
);
|
||||
}
|
||||
|
||||
@ -295,14 +294,14 @@ class RestApiClient
|
||||
}
|
||||
|
||||
/**
|
||||
* @return resource
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function curl()
|
||||
{
|
||||
if ($this->curl === null) {
|
||||
$this->curl = \curl_init(\sprintf('https://%s:%d', $this->host, $this->port));
|
||||
$this->curl = curl_init(sprintf('https://%s:%d', $this->host, $this->port));
|
||||
if (! $this->curl) {
|
||||
throw new RuntimeException('CURL INIT ERROR: ' . \curl_error($this->curl));
|
||||
throw new RuntimeException('CURL INIT FAILED');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,9 @@ class RestApiParams
|
||||
}
|
||||
$exporter->enableHostServices();
|
||||
}
|
||||
/** @var ?string $properties */
|
||||
$properties = $params->shift('properties');
|
||||
if ($properties !== null && strlen($properties)) {
|
||||
if ($properties) {
|
||||
$exporter->filterProperties(preg_split('/\s*,\s*/', $properties, -1, PREG_SPLIT_NO_EMPTY));
|
||||
}
|
||||
$exporter->resolveObjects($resolved);
|
||||
|
@ -33,7 +33,9 @@ class StartupLogRenderer implements ValidHtml
|
||||
// len [stage] + 1
|
||||
$markReplace = ' ^';
|
||||
|
||||
foreach (preg_split('/\n/', $log) as $line) {
|
||||
/** @var string[] $logLines */
|
||||
$logLines = preg_split('/\n/', $log);
|
||||
foreach ($logLines as $line) {
|
||||
if (preg_match('/^\[([\d\s\:\+\-]+)\]\s/', $line, $m)) {
|
||||
$time = $m[1];
|
||||
// TODO: we might use new DateTime($time) and show a special "timeAgo"
|
||||
|
@ -9,6 +9,7 @@ use Icinga\Module\Director\Db\Branch\BranchSupport;
|
||||
use Icinga\Module\Director\Db\Branch\PreferredBranchSupport;
|
||||
use Icinga\Module\Director\Objects\IcingaObject;
|
||||
use Icinga\Module\Director\Web\Widget\NotInBranchedHint;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
trait BranchHelper
|
||||
{
|
||||
@ -22,14 +23,17 @@ trait BranchHelper
|
||||
protected $hasPreferredBranch = null;
|
||||
|
||||
/**
|
||||
* @return false|\Ramsey\Uuid\UuidInterface
|
||||
* @return ?UuidInterface
|
||||
*/
|
||||
protected function getBranchUuid()
|
||||
protected function getBranchUuid(): ?UuidInterface
|
||||
{
|
||||
return $this->getBranch()->getUuid();
|
||||
}
|
||||
|
||||
protected function getBranch()
|
||||
/**
|
||||
* @return Branch
|
||||
*/
|
||||
protected function getBranch(): Branch
|
||||
{
|
||||
if ($this->branch === null) {
|
||||
/** @var ActionController $this */
|
||||
@ -42,7 +46,7 @@ trait BranchHelper
|
||||
/**
|
||||
* @return BranchStore
|
||||
*/
|
||||
protected function getBranchStore()
|
||||
protected function getBranchStore(): BranchStore
|
||||
{
|
||||
if ($this->branchStore === null) {
|
||||
$this->branchStore = new BranchStore($this->db());
|
||||
@ -51,12 +55,15 @@ trait BranchHelper
|
||||
return $this->branchStore;
|
||||
}
|
||||
|
||||
protected function hasBranch()
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function hasBranch(): bool
|
||||
{
|
||||
return $this->getBranchUuid() !== null;
|
||||
}
|
||||
|
||||
protected function enableStaticObjectLoader($table)
|
||||
protected function enableStaticObjectLoader($table): void
|
||||
{
|
||||
if (BranchSupport::existsForTableName($table)) {
|
||||
IcingaObject::setDbObjectStore(new DbObjectStore($this->db(), $this->getBranch()));
|
||||
@ -67,7 +74,7 @@ trait BranchHelper
|
||||
* @param string $subject
|
||||
* @return bool
|
||||
*/
|
||||
protected function showNotInBranch($subject)
|
||||
protected function showNotInBranch($subject): bool
|
||||
{
|
||||
if ($this->getBranch()->isBranch()) {
|
||||
$this->content()->add(new NotInBranchedHint($subject, $this->getBranch(), $this->Auth()));
|
||||
@ -77,7 +84,7 @@ trait BranchHelper
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function hasPreferredBranch()
|
||||
protected function hasPreferredBranch(): bool
|
||||
{
|
||||
if ($this->hasPreferredBranch === null) {
|
||||
$implementation = Branch::optionalHook();
|
||||
|
@ -85,8 +85,9 @@ abstract class ObjectsController extends ActionController
|
||||
} elseif ($request->getActionName() === 'applyrules') {
|
||||
$table->filterObjectType('apply');
|
||||
}
|
||||
/** @var ?string $search */
|
||||
$search = $this->params->get('q');
|
||||
if ($search !== null && \strlen($search) > 0) {
|
||||
if ($search) {
|
||||
$table->search($search);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ class CsrfToken
|
||||
return false;
|
||||
}
|
||||
|
||||
list($seed, $token) = explode('|', $elementValue);
|
||||
list($seed, $token) = explode('|', $token);
|
||||
|
||||
if (!is_numeric($seed)) {
|
||||
return false;
|
||||
|
@ -69,7 +69,7 @@ class DbSelectorForm extends Form
|
||||
$params = [];
|
||||
}
|
||||
|
||||
if (array_key_exists($name, $params)) {
|
||||
if (is_array($params) && array_key_exists($name, $params)) {
|
||||
return $params[$name];
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ abstract class DirectorForm extends QuickForm
|
||||
public static function load()
|
||||
{
|
||||
return new static([
|
||||
'icingaModule' => Icinga::App()->getModuleManager()->getModule('director')
|
||||
'icingaModule' => Icinga::app()->getModuleManager()->getModule('director')
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -791,7 +791,9 @@ abstract class DirectorObjectForm extends DirectorForm
|
||||
return;
|
||||
}
|
||||
|
||||
$post = $values = $this->getRequest()->getPost();
|
||||
/** @var array $post */
|
||||
$post = $this->getRequest()->getPost();
|
||||
$values = $post;
|
||||
|
||||
foreach ($post as $key => $value) {
|
||||
if (preg_match('/^(.+?)_(\d+)__(MOVE_DOWN|MOVE_UP|REMOVE)$/', $key, $m)) {
|
||||
@ -1519,6 +1521,7 @@ abstract class DirectorObjectForm extends DirectorForm
|
||||
return [];
|
||||
}
|
||||
|
||||
/** @var int|string $id */
|
||||
$id = $object->get('id');
|
||||
|
||||
if (array_key_exists($id, $tpl)) {
|
||||
|
@ -28,7 +28,7 @@ class ExtensibleSet extends FormElement
|
||||
if (! is_array($value)) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'ExtensibleSet expects to work with Arrays, got %s',
|
||||
var_export($value, 1)
|
||||
var_export($value, true)
|
||||
));
|
||||
}
|
||||
$value = array_filter($value, 'strlen');
|
||||
|
@ -111,7 +111,7 @@ class ExtensibleSetElement extends BaseHtmlElement
|
||||
if (null !== $value && ! is_array($value)) {
|
||||
throw new ProgrammingError(
|
||||
'Got unexpected value, no array: %s',
|
||||
var_export($value, 1)
|
||||
var_export($value, true)
|
||||
);
|
||||
}
|
||||
|
||||
@ -325,7 +325,7 @@ class ExtensibleSetElement extends BaseHtmlElement
|
||||
} else {
|
||||
return \sprintf(
|
||||
$this->translate('%s (not an Array!)'),
|
||||
\var_export($this->inherited, 1)
|
||||
\var_export($this->inherited, true)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ class BasketSnapshotTable extends ZfQueryBasedTable
|
||||
if (! is_object($summary) && ! is_array($summary)) {
|
||||
throw new RuntimeException(sprintf(
|
||||
'Got invalid basket summary: %s ',
|
||||
var_export($summary, 1)
|
||||
var_export($summary, true)
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ class IcingaObjectInspection extends BaseHtmlElement
|
||||
$this->add(Html::tag('p')->add(Html::sprintf(
|
||||
'The configuration for this object has been rendered by Icinga'
|
||||
. ' Director %s to %s',
|
||||
DateFormatter::timeAgo(strtotime($deployment->start_time, false)),
|
||||
DateFormatter::timeAgo(strtotime($deployment->start_time)),
|
||||
$this->linkToSourceLocation($deployment, $source)
|
||||
)));
|
||||
}
|
||||
|
@ -505,11 +505,6 @@ parameters:
|
||||
count: 1
|
||||
path: library/Director/PropertyModifier/PropertyModifierRejectOrSelect.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method ipl\\\\Stdlib\\\\Filter\\\\Rule\\:\\:getValue\\(\\)\\.$#"
|
||||
count: 3
|
||||
path: library/Director/ProvidedHook/IcingaDbCubeLinks.php
|
||||
|
||||
-
|
||||
message: "#^Access to an undefined property Zend_Controller_Action_HelperBroker\\:\\:\\$viewRenderer\\.$#"
|
||||
count: 1
|
||||
@ -590,11 +585,6 @@ parameters:
|
||||
count: 1
|
||||
path: library/Director/Web/Controller/TemplateController.php
|
||||
|
||||
-
|
||||
message: "#^Undefined variable\\: \\$elementValue$#"
|
||||
count: 1
|
||||
path: library/Director/Web/Form/CsrfToken.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method Icinga\\\\Module\\\\Director\\\\Data\\\\Db\\\\DbObject\\:\\:getShortTableName\\(\\)\\.$#"
|
||||
count: 1
|
||||
|
15
phpstan.neon
15
phpstan.neon
@ -4,8 +4,8 @@ includes:
|
||||
parameters:
|
||||
level: 2
|
||||
|
||||
checkFunctionNameCase: false
|
||||
checkInternalClassCaseSensitivity: false
|
||||
checkFunctionNameCase: true
|
||||
checkInternalClassCaseSensitivity: true
|
||||
treatPhpDocTypesAsCertain: false
|
||||
|
||||
paths:
|
||||
@ -13,15 +13,16 @@ parameters:
|
||||
- library/Director
|
||||
|
||||
ignoreErrors:
|
||||
- '#Unsafe usage of new static\(\)#'
|
||||
- '#. but return statement is missing#'
|
||||
-
|
||||
messages:
|
||||
- '#Unsafe usage of new static\(\)#'
|
||||
- '#. but return statement is missing#'
|
||||
reportUnmatched: false
|
||||
|
||||
scanDirectories:
|
||||
- /icingaweb2
|
||||
- /usr/share/icinga-php
|
||||
- /usr/share/icingaweb2-modules/incubator
|
||||
- /usr/share/icingaweb2-modules/cube
|
||||
- /usr/share/icingaweb2-modules/icingadb
|
||||
- /usr/share/icingaweb2-modules
|
||||
|
||||
excludePaths:
|
||||
- library/Director/CoreBeta
|
||||
|
Loading…
x
Reference in New Issue
Block a user