Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions application/controllers/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public function diffAction()
'left',
$leftSum,
['class' => ['autosubmit', 'config-diff']],
[null => $this->translate('- please choose -')] + $configs
['' => $this->translate('- please choose -')] + $configs
)),
Link::create(
Icon::create('flapping'),
Expand All @@ -406,7 +406,7 @@ public function diffAction()
'right',
$rightSum,
['class' => ['autosubmit', 'config-diff']],
[null => $this->translate('- please choose -')] + $configs
['' => $this->translate('- please choose -')] + $configs
)),
])
);
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/HostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,9 @@ public function servicesroAction()

/**
* @param IcingaHost $host
* @param IcingaHost|null $affectedHost
* @param ?IcingaHost $affectedHost
*/
protected function addHostServiceSetTables(IcingaHost $host, IcingaHost $affectedHost = null, $roService = null)
protected function addHostServiceSetTables(IcingaHost $host, ?IcingaHost $affectedHost = null, $roService = null)
{
$db = $this->db();
if ($affectedHost === null) {
Expand Down
2 changes: 1 addition & 1 deletion application/forms/DeploymentLinkForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected function canDeploy()
return $this->auth->hasPermission(Permission::DEPLOY);
}

public function render(Zend_View_Interface $view = null)
public function render(?Zend_View_Interface $view = null)
{
if (! $this->canDeploy()) {
return '';
Expand Down
2 changes: 1 addition & 1 deletion application/forms/DirectorDatafieldForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public function onSuccess()
protected function enumDataTypes()
{
$hooks = Hook::all('Director\\DataType');
$enum = [null => $this->translate('- please choose -')];
$enum = ['' => $this->translate('- please choose -')];
/** @var DataTypeHook $hook */
foreach ($hooks as $hook) {
$enum[get_class($hook)] = $hook->getName();
Expand Down
2 changes: 1 addition & 1 deletion application/forms/DirectorJobForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected function getJobClass($class = null)
$class = $this->getSentOrObjectValue('job_class');
}

if (array_key_exists($class, $this->enumJobTypes())) {
if ($class !== null && array_key_exists($class, $this->enumJobTypes())) {
return $class;
}

Expand Down
4 changes: 2 additions & 2 deletions application/forms/IcingaCommandForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function setup()
$this->addElement('select', 'methods_execute', array(
'label' => $this->translate('Command type'),
'multiOptions' => array(
null => '- please choose -',
'' => '- please choose -',
$this->translate('Plugin commands') => array(
'PluginCheck' => 'Plugin Check Command',
'PluginNotification' => 'Notification Plugin Command',
Expand Down Expand Up @@ -121,7 +121,7 @@ protected function enumAllowedTemplates()
return array();
}

$id = $object->get('id');
$id = $object->get('id') ?? ''; // NULL is not allowed as array key

if (array_key_exists($id, $tpl)) {
unset($tpl[$id]);
Expand Down
6 changes: 3 additions & 3 deletions application/forms/SelfServiceSettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function setup()
. ' where your Windows nodes should fetch the Agent installer'
),
'multiOptions' => [
null => $this->translate('- no automatic installation -'),
'' => $this->translate('- no automatic installation -'),
// TODO: not yet
// 'director' => $this->translate('Download via the Icinga Director'),
'icinga' => $this->translate('Download from packages.icinga.com'),
Expand Down Expand Up @@ -249,11 +249,11 @@ protected function eventuallyConfiguredEnum($name, $enum)
$default = $this->settings->getDefaultValue($key);
if ($default === null) {
return [
null => $this->translate('- please choose -')
'' => $this->translate('- please choose -')
] + $enum;
} else {
return [
null => sprintf($this->translate('%s (default)'), $enum[$default])
'' => sprintf($this->translate('%s (default)'), $enum[$default])
] + $enum;
}
}
Expand Down
2 changes: 1 addition & 1 deletion application/forms/SettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ protected function eventuallyConfiguredEnum($name, $enum)
$default = $this->translate('- please choose -');
}

return [null => $default] + $enum;
return ['' => $default] + $enum;
}

public function setSettings(Settings $settings)
Expand Down
28 changes: 14 additions & 14 deletions application/views/helpers/FormDataFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ protected function renderFilterExpression(FilterExpression $filter)
}

/**
* @param FilterExpression|null $filter
* @param ?FilterExpression $filter
* @return Boolean|string
* @throws Zend_Form_Exception
*/
protected function element(FilterExpression $filter = null)
protected function element(?FilterExpression $filter = null)
{
if ($filter) {
// TODO: Make this configurable
Expand Down Expand Up @@ -244,11 +244,11 @@ protected function selectGroup($type, FilterExpression $filter)
}

/**
* @param FilterExpression|null $filter
* @param ?FilterExpression $filter
* @return Boolean
* @throws Zend_Form_Exception
*/
protected function boolean(FilterExpression $filter = null)
protected function boolean(?FilterExpression $filter = null)
{
$value = $filter === null ? '' : $filter->getExpression();

Expand All @@ -270,12 +270,12 @@ protected function columnIsJson(FilterExpression $filter)
}

/**
* @param FilterExpression|null $filter
* @param string $suggestionContext
* @param ?FilterExpression $filter
* @param string $suggestionContext
*
* @return mixed
*/
protected function text(FilterExpression $filter = null, $suggestionContext = null)
protected function text(?FilterExpression $filter = null, $suggestionContext = null)
{
$attr = null;
if ($suggestionContext !== null) {
Expand Down Expand Up @@ -326,7 +326,7 @@ protected function arrayForSelect($array, $flip = false)
return $res;
}

protected function elementId($field, Filter $filter = null)
protected function elementId($field, ?Filter $filter = null)
{
$prefix = $this->fieldName . '[id_';
$suffix = '][' . $field . ']';
Expand All @@ -335,10 +335,10 @@ protected function elementId($field, Filter $filter = null)
}

/**
* @param FilterChain|null $filter
* @param ?FilterChain $filter
* @return mixed
*/
protected function selectOperator(FilterChain $filter = null)
protected function selectOperator(?FilterChain $filter = null)
{
$ops = [
'AND' => 'AND',
Expand All @@ -354,7 +354,7 @@ protected function selectOperator(FilterChain $filter = null)
);
}

protected function selectSign(FilterExpression $filter = null)
protected function selectSign(?FilterExpression $filter = null)
{
$signs = [
'=' => '=',
Expand Down Expand Up @@ -401,7 +401,7 @@ protected function selectSign(FilterExpression $filter = null)
);
}

public function setColumns(array $columns = null)
public function setColumns(?array $columns = null)
{
$this->cachedColumnSelect = $columns ? $this->arrayForSelect($columns) : null;
return $this;
Expand All @@ -417,7 +417,7 @@ protected function setSuggestionContext($context)
$this->suggestionContext = $context;
}

protected function selectColumn(FilterExpression $filter = null)
protected function selectColumn(?FilterExpression $filter = null)
{
$active = $filter === null ? null : $filter->getColumn();
if ($filter && $this->columnIsJson($filter)) {
Expand Down Expand Up @@ -464,7 +464,7 @@ protected function selectColumn(FilterExpression $filter = null)
protected function optionalEnum($enum)
{
return array_merge(
array(null => $this->view->translate('- please choose -')),
['' => $this->view->translate('- please choose -')],
$enum
);
}
Expand Down
2 changes: 1 addition & 1 deletion library/Director/Daemon/BackgroundDaemon.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
/** @var bool */
protected $shuttingDown = false;

public function run(LoopInterface $loop = null)
public function run(?LoopInterface $loop = null)
{
if ($ownLoop = ($loop === null)) {
$loop = Loop::create();
Expand Down Expand Up @@ -204,7 +204,7 @@
$this->reloading = true;
Logger::info('Going gown for reload now');
$this->setState('reloading the main process');
$this->daemonDb->disconnect()->then(function () {

Check failure on line 207 in library/Director/Daemon/BackgroundDaemon.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.4 on ubuntu-latest

Call to method then() on an unknown class React\Promise\ExtendedPromiseInterface.

Check failure on line 207 in library/Director/Daemon/BackgroundDaemon.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Call to method then() on an unknown class React\Promise\ExtendedPromiseInterface.

Check failure on line 207 in library/Director/Daemon/BackgroundDaemon.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Call to method then() on an unknown class React\Promise\ExtendedPromiseInterface.
Process::restart();
});
}
Expand Down
8 changes: 4 additions & 4 deletions library/Director/Data/Db/DbObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -909,11 +909,11 @@ public function propertyIsBoolean($property)
/**
* Store object to database
*
* @param DbConnection $db
* @param ?DbConnection $db
* @return bool Whether storing succeeded. Always true, throws otherwise
* @throws DuplicateKeyException
*/
public function store(DbConnection $db = null)
public function store(?DbConnection $db = null)
{
if ($db !== null) {
$this->setConnection($db);
Expand Down Expand Up @@ -1181,11 +1181,11 @@ protected function onClone()

/**
* @param array $properties
* @param DbConnection|null $connection
* @param ?DbConnection $connection
*
* @return static
*/
public static function create($properties = array(), DbConnection $connection = null)
public static function create($properties = array(), ?DbConnection $connection = null)
{
$obj = new static();
if ($connection !== null) {
Expand Down
2 changes: 1 addition & 1 deletion library/Director/Data/Db/DbObjectStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class DbObjectStore
/** @var ?Branch */
protected $branch;

public function __construct(Db $connection, Branch $branch = null)
public function __construct(Db $connection, ?Branch $branch = null)
{
$this->connection = $connection;
$this->branch = $branch;
Expand Down
2 changes: 1 addition & 1 deletion library/Director/Data/Db/DbObjectTypeRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static function shortTypeForObject(DbObject $object)
return $object->getTableName();
}

public static function newObject($type, $properties = [], Db $db = null)
public static function newObject($type, $properties = [], ?Db $db = null)
{
/** @var DbObject $class fake hint for the IDE, it's a string */
$class = self::classByType($type);
Expand Down
4 changes: 2 additions & 2 deletions library/Director/Data/HostServiceLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ protected function fetchAllServicesForHost(IcingaHost $host)
* Duplicates Logic in HostController
*
* @param IcingaHost $host
* @param IcingaHost|null $affectedHost
* @param ?IcingaHost $affectedHost
* @return IcingaServiceSetServiceTable[]
*/
protected function getHostServiceSetTables(IcingaHost $host, IcingaHost $affectedHost = null)
protected function getHostServiceSetTables(IcingaHost $host, ?IcingaHost $affectedHost = null)
{
$tables = [];
$db = $this->connection;
Expand Down
2 changes: 1 addition & 1 deletion library/Director/DataType/DataTypeDirectorObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function getFormElement($name, QuickForm $form)
$params = ['multiOptions' => $enum];
} else {
$params = ['multiOptions' => [
null => $form->translate('- please choose -'),
'' => $form->translate('- please choose -')
] + $enum];
$elementType = 'select';
}
Expand Down
2 changes: 1 addition & 1 deletion library/Director/DataType/DataTypeSqlQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getFormElement($name, QuickForm $form)
$params = ['multiOptions' => $data];
} else {
$params = ['multiOptions' => [
null => $form->translate('- please choose -'),
'' => $form->translate('- please choose -')
] + $data];
$type = 'select';
}
Expand Down
2 changes: 1 addition & 1 deletion library/Director/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected function setClientTimezoneForPgsql()
$db->query($db->quoteInto('SET TIME ZONE INTERVAL ? HOUR TO MINUTE', $this->getTimezoneOffset()));
}

public function countActivitiesSinceLastDeployedConfig(IcingaObject $object = null)
public function countActivitiesSinceLastDeployedConfig(?IcingaObject $object = null)
{
$db = $this->db();

Expand Down
4 changes: 2 additions & 2 deletions library/Director/Db/Branch/BranchedObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ protected static function loadOptional(
Db $connection,
$table,
UuidInterface $uuid,
UuidInterface $branchUuid = null
?UuidInterface $branchUuid = null
) {
$class = DbObjectTypeRegistry::classByType($table);
if ($row = static::optionalTableRowByUuid($connection, $table, $uuid)) {
Expand Down Expand Up @@ -360,7 +360,7 @@ public static function exists(
Db $connection,
$table,
UuidInterface $uuid,
UuidInterface $branchUuid = null
?UuidInterface $branchUuid = null
) {
if (static::optionalTableRowByUuid($connection, $table, $uuid)) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion library/Director/Db/Branch/PlainObjectPropertyDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class PlainObjectPropertyDiff
{
public static function calculate(array $old = null, array $new = null)
public static function calculate(?array $old = null, ?array $new = null)
{
if ($new === null) {
throw new \RuntimeException('Cannot diff for delete');
Expand Down
4 changes: 2 additions & 2 deletions library/Director/Db/Branch/UuidLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public static function findServiceUuid(
Branch $branch,
?string $objectType = null,
$key = null,
IcingaHost $host = null,
IcingaServiceSet $set = null
?IcingaHost $host = null,
?IcingaServiceSet $set = null
) {
$db = $connection->getDbAdapter();
$query = $db->select()->from('icinga_service', 'uuid');
Expand Down
2 changes: 1 addition & 1 deletion library/Director/Db/IcingaObjectFilterHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static function filterByTemplate(
$template,
$tableAlias = 'o',
$inheritanceType = self::INHERIT_DIRECT,
UuidInterface $branchuuid = null
?UuidInterface $branchuuid = null
) {
$i = $tableAlias . 'i';
$o = $tableAlias;
Expand Down
2 changes: 1 addition & 1 deletion library/Director/Deployment/ConditionalDeployment.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ConditionalDeployment implements LoggerAwareInterface
/** @var ?string */
protected $noDeploymentReason = null;

public function __construct(Db $connection, CoreApi $api = null)
public function __construct(Db $connection, ?CoreApi $api = null)
{
$this->setLogger(new NullLogger());
$this->db = $connection;
Expand Down
2 changes: 1 addition & 1 deletion library/Director/DirectorObject/Lookup/ServiceFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ServiceFinder
/** @var \Icinga\Module\Director\Db */
protected $db;

public function __construct(IcingaHost $host, Auth $auth = null)
public function __construct(IcingaHost $host, ?Auth $auth = null)
{
$this->host = $host;
$this->auth = $auth;
Expand Down
2 changes: 1 addition & 1 deletion library/Director/IcingaConfig/IcingaConfigHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ public static function isValidMacroName($name)
&& ! preg_match('/\.$/', $name);
}

public static function renderStringWithVariables($string, array $whiteList = null)
public static function renderStringWithVariables($string, ?array $whiteList = null)
{
$len = strlen($string);
$start = false;
Expand Down
2 changes: 1 addition & 1 deletion library/Director/Import/ImportSourceDirectorObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static function addSettingsFormFields(QuickForm $form)
$form->addElement('select', 'object_type', [
'label' => $form->translate('Object Type'),
'multiOptions' => [
null => $form->translate('All Object Types'),
'' => $form->translate('All Object Types'),
'object' => $form->translate('Objects'),
'template' => $form->translate('Templates'),
'external_object' => $form->translate('External Objects'),
Expand Down
2 changes: 1 addition & 1 deletion library/Director/Import/Sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Sync
* @param SyncRule $rule
* @param ?DbObjectStore $store
*/
public function __construct(SyncRule $rule, DbObjectStore $store = null)
public function __construct(SyncRule $rule, ?DbObjectStore $store = null)
{
$this->rule = $rule;
$this->db = $rule->getConnection();
Expand Down
Loading
Loading