From ea0ce32bc9e073bcf30d11f0872e1bcdef458823 Mon Sep 17 00:00:00 2001 From: Bastian Lederer Date: Thu, 20 Nov 2025 13:44:24 +0100 Subject: [PATCH] Change implicit nullable type declaration to explicit Since PHP 8.4 implicitly nullable parameter types are deprecated. Normalize scoped PHPDoc for nullable-parameter updates: use `?Type` instead of `Type|null`, remove column alignment, and indent continuation lines with 2 spaces. Co-authored-by: "Eric Lippmann " --- application/forms/RepositoryForm.php | 14 +-- library/Icinga/Application/Config.php | 4 +- library/Icinga/Application/Hook/AuditHook.php | 25 ++-- .../Application/Hook/DbMigrationHook.php | 4 +- .../Icinga/Application/MigrationManager.php | 8 +- .../Icinga/Application/Modules/Manager.php | 4 +- library/Icinga/Authentication/AuthChain.php | 4 +- .../Authentication/User/DbUserBackend.php | 8 +- .../Authentication/User/LdapUserBackend.php | 22 ++-- .../Authentication/User/UserBackend.php | 10 +- .../UserGroup/DbUserGroupBackend.php | 14 +-- .../UserGroup/LdapUserGroupBackend.php | 22 ++-- library/Icinga/Chart/Graph/BarGraph.php | 8 +- library/Icinga/Chart/Graph/LineGraph.php | 2 +- library/Icinga/Cli/Loader.php | 6 +- library/Icinga/Data/Db/DbConnection.php | 24 ++-- library/Icinga/Data/Db/DbQuery.php | 2 +- library/Icinga/Data/PivotTable.php | 12 +- library/Icinga/Data/Queryable.php | 8 +- library/Icinga/Data/Reducible.php | 8 +- library/Icinga/Data/SimpleQuery.php | 8 +- library/Icinga/Data/Tree/SimpleTree.php | 6 +- library/Icinga/Data/Updatable.php | 10 +- .../Icinga/Protocol/Ldap/LdapConnection.php | 96 +++++++-------- library/Icinga/Protocol/Ldap/LdapQuery.php | 2 +- library/Icinga/Repository/DbRepository.php | 82 ++++++------- library/Icinga/Repository/IniRepository.php | 24 ++-- library/Icinga/Repository/Repository.php | 112 +++++++++--------- library/Icinga/Repository/RepositoryQuery.php | 16 +-- library/Icinga/Web/Controller.php | 28 ++--- library/Icinga/Web/Form.php | 12 +- library/Icinga/Web/Form/Decorator/Help.php | 6 +- .../Icinga/Web/Navigation/NavigationItem.php | 6 +- .../Renderer/BadgeNavigationItemRenderer.php | 6 +- .../Renderer/NavigationItemRenderer.php | 10 +- library/Icinga/Web/Response/JsonResponse.php | 6 +- library/Icinga/Web/Session.php | 6 +- library/Icinga/Web/Session/PhpSession.php | 14 +-- .../Icinga/Web/View/Helper/IcingaCheckbox.php | 2 +- library/Icinga/Web/Widget/Chart/InlinePie.php | 6 +- library/Icinga/Web/Widget/Dashboard/Pane.php | 4 +- library/Icinga/Web/Widget/FilterEditor.php | 16 +-- .../Web/Widget/ItemList/MigrationList.php | 2 +- library/Icinga/Web/Widget/SortBox.php | 24 ++-- library/Icinga/Web/Wizard.php | 12 +- .../application/forms/AdminAccountPage.php | 6 +- modules/setup/library/Setup/Utils/DbTool.php | 42 +++---- .../Icinga/Application/Hook/AuditHookTest.php | 2 +- 48 files changed, 388 insertions(+), 387 deletions(-) diff --git a/application/forms/RepositoryForm.php b/application/forms/RepositoryForm.php index 8e4665d80..6bea3d8ac 100644 --- a/application/forms/RepositoryForm.php +++ b/application/forms/RepositoryForm.php @@ -145,11 +145,11 @@ abstract class RepositoryForm extends Form /** * Add a new entry * - * @param array $data The defaults to use, if any + * @param ?array $data The defaults to use, if any * - * @return $this + * @return $this */ - public function add(array $data = null) + public function add(?array $data = null) { $this->mode = static::MODE_INSERT; $this->data = $data; @@ -159,12 +159,12 @@ abstract class RepositoryForm extends Form /** * Edit an entry * - * @param string $name The entry's name - * @param array $data The entry's current data + * @param string $name The entry's name + * @param ?array $data The entry's current data * - * @return $this + * @return $this */ - public function edit($name, array $data = null) + public function edit($name, ?array $data = null) { $this->mode = static::MODE_UPDATE; $this->identifier = $name; diff --git a/library/Icinga/Application/Config.php b/library/Icinga/Application/Config.php index 80fe3b87c..3e5eed66f 100644 --- a/library/Icinga/Application/Config.php +++ b/library/Icinga/Application/Config.php @@ -68,9 +68,9 @@ class Config implements Countable, Iterator, Selectable /** * Create a new config * - * @param ConfigObject $config The config object to handle + * @param ?ConfigObject $config The config object to handle */ - public function __construct(ConfigObject $config = null) + public function __construct(?ConfigObject $config = null) { $this->config = $config !== null ? $config : new ConfigObject(); } diff --git a/library/Icinga/Application/Hook/AuditHook.php b/library/Icinga/Application/Hook/AuditHook.php index e6209da3f..9e9d5425c 100644 --- a/library/Icinga/Application/Hook/AuditHook.php +++ b/library/Icinga/Application/Hook/AuditHook.php @@ -16,13 +16,14 @@ abstract class AuditHook * * Propagates the given message details to all known hook implementations. * - * @param string $type An arbitrary name identifying the type of activity - * @param string $message A detailed description possibly referencing parameters in $data - * @param array $data Additional information (How this is stored or used is up to each implementation) - * @param string $identity An arbitrary name identifying the responsible subject, defaults to the current user - * @param int $time A timestamp defining when the activity occurred, defaults to now + * @param string $type An arbitrary name identifying the type of activity + * @param string $message A detailed description possibly referencing parameters in $data + * @param ?array $data Additional information (How this is stored or used is up to each implementation) + * @param string $identity An arbitrary name identifying the responsible subject, + * defaults to the current user + * @param int $time A timestamp defining when the activity occurred, defaults to now */ - public static function logActivity($type, $message, array $data = null, $identity = null, $time = null) + public static function logActivity($type, $message, ?array $data = null, $identity = null, $time = null) { if (! Hook::has('audit')) { return; @@ -60,13 +61,13 @@ abstract class AuditHook /** * Log a message to the audit log * - * @param int $time A timestamp defining when the activity occurred - * @param string $identity An arbitrary name identifying the responsible subject - * @param string $type An arbitrary name identifying the type of activity - * @param string $message A detailed description of the activity - * @param array $data Additional activity information + * @param int $time A timestamp defining when the activity occurred + * @param string $identity An arbitrary name identifying the responsible subject + * @param string $type An arbitrary name identifying the type of activity + * @param string $message A detailed description of the activity + * @param ?array $data Additional activity information */ - abstract public function logMessage($time, $identity, $type, $message, array $data = null); + abstract public function logMessage($time, $identity, $type, $message, ?array $data = null); /** * Substitute the given message with its accompanying data diff --git a/library/Icinga/Application/Hook/DbMigrationHook.php b/library/Icinga/Application/Hook/DbMigrationHook.php index f34bc0dbe..479ee0e0a 100644 --- a/library/Icinga/Application/Hook/DbMigrationHook.php +++ b/library/Icinga/Application/Hook/DbMigrationHook.php @@ -196,11 +196,11 @@ abstract class DbMigrationHook implements Countable * Apply all pending migrations of this hook * * @param ?Connection $conn Use the provided database connection to apply the migrations. - * Is only used to elevate database users with insufficient privileges. + * Is only used to elevate database users with insufficient privileges. * * @return bool Whether the migration(s) have been successfully applied */ - final public function run(Connection $conn = null): bool + final public function run(?Connection $conn = null): bool { if (! $conn) { $conn = $this->getDb(); diff --git a/library/Icinga/Application/MigrationManager.php b/library/Icinga/Application/MigrationManager.php index 9d3289618..790d93123 100644 --- a/library/Icinga/Application/MigrationManager.php +++ b/library/Icinga/Application/MigrationManager.php @@ -131,7 +131,7 @@ final class MigrationManager implements Countable * * @return bool */ - public function apply(DbMigrationHook $hook, array $elevateConfig = null): bool + public function apply(DbMigrationHook $hook, ?array $elevateConfig = null): bool { if ($hook->isModule() && $this->hasMigrations(DbMigrationHook::DEFAULT_MODULE)) { Logger::error( @@ -164,7 +164,7 @@ final class MigrationManager implements Countable * * @return bool */ - public function applyAll(array $elevateConfig = null): bool + public function applyAll(?array $elevateConfig = null): bool { $default = DbMigrationHook::DEFAULT_MODULE; if ($this->hasMigrations($default)) { @@ -218,7 +218,7 @@ final class MigrationManager implements Countable * * @return bool */ - public function validateDatabasePrivileges(array $elevateConfig = null, bool $canIssueGrant = false): bool + public function validateDatabasePrivileges(?array $elevateConfig = null, bool $canIssueGrant = false): bool { if (! $this->hasPendingMigrations()) { return true; @@ -324,7 +324,7 @@ final class MigrationManager implements Countable */ protected function checkRequiredPrivileges( Sql\Connection $conn, - array $elevateConfig = null, + ?array $elevateConfig = null, bool $canIssueGrants = false ): bool { if ($elevateConfig) { diff --git a/library/Icinga/Application/Modules/Manager.php b/library/Icinga/Application/Modules/Manager.php index 55d074d70..ca7ed3418 100644 --- a/library/Icinga/Application/Modules/Manager.php +++ b/library/Icinga/Application/Modules/Manager.php @@ -641,11 +641,11 @@ class Manager /** * Detect installed modules from every path provided in modulePaths * - * @param array $availableDirs Installed modules location + * @param ?array $availableDirs Installed modules location * * @return $this */ - public function detectInstalledModules(array $availableDirs = null) + public function detectInstalledModules(?array $availableDirs = null) { $modulePaths = $availableDirs !== null ? $availableDirs : $this->modulePaths; foreach ($modulePaths as $basedir) { diff --git a/library/Icinga/Authentication/AuthChain.php b/library/Icinga/Authentication/AuthChain.php index 39468e3cf..d1381533e 100644 --- a/library/Icinga/Authentication/AuthChain.php +++ b/library/Icinga/Authentication/AuthChain.php @@ -85,9 +85,9 @@ class AuthChain implements Authenticatable, Iterator /** * Create a new authentication chain from config * - * @param Config $config User backends configuration + * @param ?Config $config User backends configuration */ - public function __construct(Config $config = null) + public function __construct(?Config $config = null) { if ($config === null) { try { diff --git a/library/Icinga/Authentication/User/DbUserBackend.php b/library/Icinga/Authentication/User/DbUserBackend.php index 4b37b51f2..593498488 100644 --- a/library/Icinga/Authentication/User/DbUserBackend.php +++ b/library/Icinga/Authentication/User/DbUserBackend.php @@ -134,11 +134,11 @@ class DbUserBackend extends DbRepository implements UserBackendInterface, Inspec /** * Update table rows with the given data, optionally limited by using a filter * - * @param string $table - * @param array $bind - * @param Filter $filter + * @param string $table + * @param array $bind + * @param ?Filter $filter */ - public function update($table, array $bind, Filter $filter = null, array $types = array()) + public function update($table, array $bind, ?Filter $filter = null, array $types = array()) { $this->requireTable($table); $bind['last_modified'] = date('Y-m-d H:i:s'); diff --git a/library/Icinga/Authentication/User/LdapUserBackend.php b/library/Icinga/Authentication/User/LdapUserBackend.php index 6a2cacff8..f376992e5 100644 --- a/library/Icinga/Authentication/User/LdapUserBackend.php +++ b/library/Icinga/Authentication/User/LdapUserBackend.php @@ -334,14 +334,14 @@ class LdapUserBackend extends LdapRepository implements UserBackendInterface, Do /** * Validate that the requested table exists * - * @param string $table The table to validate - * @param RepositoryQuery $query An optional query to pass as context + * @param string $table The table to validate + * @param ?RepositoryQuery $query An optional query to pass as context * - * @return string + * @return string * - * @throws ProgrammingError In case the given table does not exist + * @throws ProgrammingError In case the given table does not exist */ - public function requireTable($table, RepositoryQuery $query = null) + public function requireTable($table, ?RepositoryQuery $query = null) { if ($query !== null) { $query->getQuery()->setBase($this->baseDn); @@ -356,15 +356,15 @@ class LdapUserBackend extends LdapRepository implements UserBackendInterface, Do /** * Validate that the given column is a valid query target and return it or the actual name if it's an alias * - * @param string $table The table where to look for the column or alias - * @param string $name The name or alias of the column to validate - * @param RepositoryQuery $query An optional query to pass as context + * @param string $table The table where to look for the column or alias + * @param string $name The name or alias of the column to validate + * @param ?RepositoryQuery $query An optional query to pass as context * - * @return string The given column's name + * @return string The given column's name * - * @throws QueryException In case the given column is not a valid query column + * @throws QueryException In case the given column is not a valid query column */ - public function requireQueryColumn($table, $name, RepositoryQuery $query = null) + public function requireQueryColumn($table, $name, ?RepositoryQuery $query = null) { $column = parent::requireQueryColumn($table, $name, $query); if ($name === 'user_name' && $query !== null) { diff --git a/library/Icinga/Authentication/User/UserBackend.php b/library/Icinga/Authentication/User/UserBackend.php index 423b2788d..919112f4c 100644 --- a/library/Icinga/Authentication/User/UserBackend.php +++ b/library/Icinga/Authentication/User/UserBackend.php @@ -159,14 +159,14 @@ class UserBackend implements ConfigAwareFactory /** * Create and return a user backend with the given name and given configuration applied to it * - * @param string $name - * @param ConfigObject $backendConfig + * @param string $name + * @param ?ConfigObject $backendConfig * - * @return UserBackendInterface + * @return UserBackendInterface * - * @throws ConfigurationError + * @throws ConfigurationError */ - public static function create($name, ConfigObject $backendConfig = null) + public static function create($name, ?ConfigObject $backendConfig = null) { if ($backendConfig === null) { self::assertBackendsExist(); diff --git a/library/Icinga/Authentication/UserGroup/DbUserGroupBackend.php b/library/Icinga/Authentication/UserGroup/DbUserGroupBackend.php index d42f275d1..0f78623eb 100644 --- a/library/Icinga/Authentication/UserGroup/DbUserGroupBackend.php +++ b/library/Icinga/Authentication/UserGroup/DbUserGroupBackend.php @@ -142,11 +142,11 @@ class DbUserGroupBackend extends DbRepository implements Inspectable, UserGroupB /** * Update table rows with the given data, optionally limited by using a filter * - * @param string $table - * @param array $bind - * @param Filter $filter + * @param string $table + * @param array $bind + * @param ?Filter $filter */ - public function update($table, array $bind, Filter $filter = null, array $types = array()) + public function update($table, array $bind, ?Filter $filter = null, array $types = array()) { $bind['last_modified'] = date('Y-m-d H:i:s'); parent::update($table, $bind, $filter); @@ -155,10 +155,10 @@ class DbUserGroupBackend extends DbRepository implements Inspectable, UserGroupB /** * Delete table rows, optionally limited by using a filter * - * @param string $table - * @param Filter $filter + * @param string $table + * @param ?Filter $filter */ - public function delete($table, Filter $filter = null) + public function delete($table, ?Filter $filter = null) { if ($table === 'group') { parent::delete('group_membership', $filter); diff --git a/library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php b/library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php index e78242ec4..38e8f05cc 100644 --- a/library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php +++ b/library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php @@ -661,14 +661,14 @@ class LdapUserGroupBackend extends LdapRepository implements Inspectable, UserGr /** * Validate that the requested table exists * - * @param string $table The table to validate - * @param RepositoryQuery $query An optional query to pass as context + * @param string $table The table to validate + * @param ?RepositoryQuery $query An optional query to pass as context * - * @return string + * @return string * - * @throws ProgrammingError In case the given table does not exist + * @throws ProgrammingError In case the given table does not exist */ - public function requireTable($table, RepositoryQuery $query = null) + public function requireTable($table, ?RepositoryQuery $query = null) { if ($query !== null) { $query->getQuery()->setBase($this->groupBaseDn); @@ -683,15 +683,15 @@ class LdapUserGroupBackend extends LdapRepository implements Inspectable, UserGr /** * Validate that the given column is a valid query target and return it or the actual name if it's an alias * - * @param string $table The table where to look for the column or alias - * @param string $name The name or alias of the column to validate - * @param RepositoryQuery $query An optional query to pass as context + * @param string $table The table where to look for the column or alias + * @param string $name The name or alias of the column to validate + * @param ?RepositoryQuery $query An optional query to pass as context * - * @return string The given column's name + * @return string The given column's name * - * @throws QueryException In case the given column is not a valid query column + * @throws QueryException In case the given column is not a valid query column */ - public function requireQueryColumn($table, $name, RepositoryQuery $query = null) + public function requireQueryColumn($table, $name, ?RepositoryQuery $query = null) { $column = parent::requireQueryColumn($table, $name, $query); if (($name === 'user_name' || $name === 'group_name') && $query !== null) { diff --git a/library/Icinga/Chart/Graph/BarGraph.php b/library/Icinga/Chart/Graph/BarGraph.php index be142bf4b..22baf428e 100644 --- a/library/Icinga/Chart/Graph/BarGraph.php +++ b/library/Icinga/Chart/Graph/BarGraph.php @@ -53,15 +53,15 @@ class BarGraph extends Styleable implements Drawable /** * Create a new BarGraph with the given dataset * - * @param array $dataSet An array of data points - * @param int $order The graph number displayed by this BarGraph - * @param array $tooltips The tooltips to display for each value + * @param array $dataSet An array of data points + * @param int $order The graph number displayed by this BarGraph + * @param ?array $tooltips The tooltips to display for each value */ public function __construct( array $dataSet, array &$graphs, $order, - array $tooltips = null + ?array $tooltips = null ) { $this->order = $order; $this->dataSet = $dataSet; diff --git a/library/Icinga/Chart/Graph/LineGraph.php b/library/Icinga/Chart/Graph/LineGraph.php index 21f930abd..5be420991 100644 --- a/library/Icinga/Chart/Graph/LineGraph.php +++ b/library/Icinga/Chart/Graph/LineGraph.php @@ -73,7 +73,7 @@ class LineGraph extends Styleable implements Drawable array $dataset, array &$graphs, $order, - array $tooltips = null + ?array $tooltips = null ) { usort($dataset, array($this, 'sortByX')); $this->dataset = $dataset; diff --git a/library/Icinga/Cli/Loader.php b/library/Icinga/Cli/Loader.php index 5e63f3fe6..4bff4001c 100644 --- a/library/Icinga/Cli/Loader.php +++ b/library/Icinga/Cli/Loader.php @@ -182,7 +182,7 @@ class Loader } } - public function parseParams(Params $params = null) + public function parseParams(?Params $params = null) { if ($params === null) { $params = $this->app->getParams(); @@ -235,13 +235,13 @@ class Loader return $this; } - public function handleParams(Params $params = null) + public function handleParams(?Params $params = null) { $this->parseParams($params); $this->dispatch(); } - public function dispatch(Params $overrideParams = null) + public function dispatch(?Params $overrideParams = null) { if ($this->commandName === null) { fwrite(STDERR, $this->docs()->usage($this->moduleName)); diff --git a/library/Icinga/Data/Db/DbConnection.php b/library/Icinga/Data/Db/DbConnection.php index fc6814db3..02e5a3242 100644 --- a/library/Icinga/Data/Db/DbConnection.php +++ b/library/Icinga/Data/Db/DbConnection.php @@ -72,9 +72,9 @@ class DbConnection implements Selectable, Extensible, Updatable, Reducible, Insp /** * Create a new connection object * - * @param ConfigObject $config + * @param ?ConfigObject $config */ - public function __construct(ConfigObject $config = null) + public function __construct(?ConfigObject $config = null) { $this->config = $config; $this->connect(); @@ -428,14 +428,14 @@ class DbConnection implements Selectable, Extensible, Updatable, Reducible, Insp * Pass an array with a column name (the same as in $bind) and a PDO::PARAM_* constant as value * as fourth parameter $types to define a different type than string for a particular column. * - * @param string $table - * @param array $bind - * @param Filter $filter - * @param array $types + * @param string $table + * @param array $bind + * @param ?Filter $filter + * @param array $types * - * @return int The number of affected rows + * @return int The number of affected rows */ - public function update($table, array $bind, Filter $filter = null, array $types = array()) + public function update($table, array $bind, ?Filter $filter = null, array $types = array()) { $set = array(); foreach ($bind as $column => $value) { @@ -464,12 +464,12 @@ class DbConnection implements Selectable, Extensible, Updatable, Reducible, Insp /** * Delete table rows, optionally limited by using a filter * - * @param string $table - * @param Filter $filter + * @param string $table + * @param ?Filter $filter * - * @return int The number of affected rows + * @return int The number of affected rows */ - public function delete($table, Filter $filter = null) + public function delete($table, ?Filter $filter = null) { return $this->dbAdapter->delete($table, $filter ? $this->renderFilter($filter) : ''); } diff --git a/library/Icinga/Data/Db/DbQuery.php b/library/Icinga/Data/Db/DbQuery.php index ff1d131fb..b0bb5f260 100644 --- a/library/Icinga/Data/Db/DbQuery.php +++ b/library/Icinga/Data/Db/DbQuery.php @@ -101,7 +101,7 @@ class DbQuery extends SimpleQuery return $this; } - public function from($target, array $fields = null) + public function from($target, ?array $fields = null) { parent::from($target, $fields); $this->select->from($this->target, array()); diff --git a/library/Icinga/Data/PivotTable.php b/library/Icinga/Data/PivotTable.php index 6c7f80691..7287b69ea 100644 --- a/library/Icinga/Data/PivotTable.php +++ b/library/Icinga/Data/PivotTable.php @@ -122,11 +122,11 @@ class PivotTable implements Sortable /** * Set the filter to apply on the query for the x-axis * - * @param Filter $filter + * @param ?Filter $filter * - * @return $this + * @return $this */ - public function setXAxisFilter(Filter $filter = null) + public function setXAxisFilter(?Filter $filter = null) { $this->xAxisFilter = $filter; return $this; @@ -135,11 +135,11 @@ class PivotTable implements Sortable /** * Set the filter to apply on the query for the y-axis * - * @param Filter $filter + * @param ?Filter $filter * - * @return $this + * @return $this */ - public function setYAxisFilter(Filter $filter = null) + public function setYAxisFilter(?Filter $filter = null) { $this->yAxisFilter = $filter; return $this; diff --git a/library/Icinga/Data/Queryable.php b/library/Icinga/Data/Queryable.php index 75cdc986e..ffa8aef2c 100644 --- a/library/Icinga/Data/Queryable.php +++ b/library/Icinga/Data/Queryable.php @@ -11,10 +11,10 @@ interface Queryable /** * Set the target and fields to query * - * @param string $target - * @param array $fields + * @param string $target + * @param ?array $fields * - * @return Fetchable + * @return Fetchable */ - public function from($target, array $fields = null); + public function from($target, ?array $fields = null); } diff --git a/library/Icinga/Data/Reducible.php b/library/Icinga/Data/Reducible.php index 6ece17ec0..0ec220989 100644 --- a/library/Icinga/Data/Reducible.php +++ b/library/Icinga/Data/Reducible.php @@ -14,10 +14,10 @@ interface Reducible /** * Delete entries in the given target, optionally limiting the affected entries by using a filter * - * @param string $target - * @param Filter $filter + * @param string $target + * @param ?Filter $filter * - * @throws StatementException + * @throws StatementException */ - public function delete($target, Filter $filter = null); + public function delete($target, ?Filter $filter = null); } diff --git a/library/Icinga/Data/SimpleQuery.php b/library/Icinga/Data/SimpleQuery.php index 1ef0c275b..f0bc175d5 100644 --- a/library/Icinga/Data/SimpleQuery.php +++ b/library/Icinga/Data/SimpleQuery.php @@ -239,12 +239,12 @@ class SimpleQuery implements QueryInterface, Queryable, Iterator * * Query will return all available columns if none are given here. * - * @param mixed $target - * @param array $fields + * @param mixed $target + * @param ?array $fields * - * @return $this + * @return $this */ - public function from($target, array $fields = null) + public function from($target, ?array $fields = null) { $this->target = $target; if ($fields !== null) { diff --git a/library/Icinga/Data/Tree/SimpleTree.php b/library/Icinga/Data/Tree/SimpleTree.php index e89f58929..1ad02cb5f 100644 --- a/library/Icinga/Data/Tree/SimpleTree.php +++ b/library/Icinga/Data/Tree/SimpleTree.php @@ -37,12 +37,12 @@ class SimpleTree implements IteratorAggregate /** * Add a child node * - * @param TreeNode $child - * @param TreeNode $parent + * @param TreeNode $child + * @param ?TreeNode $parent * * @return $this */ - public function addChild(TreeNode $child, TreeNode $parent = null) + public function addChild(TreeNode $child, ?TreeNode $parent = null) { if ($parent === null) { $parent = $this->sentinel; diff --git a/library/Icinga/Data/Updatable.php b/library/Icinga/Data/Updatable.php index ff70b993a..8a3ea8a60 100644 --- a/library/Icinga/Data/Updatable.php +++ b/library/Icinga/Data/Updatable.php @@ -14,11 +14,11 @@ interface Updatable /** * Update the target with the given data and optionally limit the affected entries by using a filter * - * @param string $target - * @param array $data - * @param Filter $filter + * @param string $target + * @param array $data + * @param ?Filter $filter * - * @throws StatementException + * @throws StatementException */ - public function update($target, array $data, Filter $filter = null); + public function update($target, array $data, ?Filter $filter = null); } diff --git a/library/Icinga/Protocol/Ldap/LdapConnection.php b/library/Icinga/Protocol/Ldap/LdapConnection.php index 406dca186..948178b2e 100644 --- a/library/Icinga/Protocol/Ldap/LdapConnection.php +++ b/library/Icinga/Protocol/Ldap/LdapConnection.php @@ -416,12 +416,12 @@ class LdapConnection implements Selectable, Inspectable /** * Retrieve an array containing all rows of the result set * - * @param LdapQuery $query The query returning the result set - * @param array $fields Request these attributes instead of the ones registered in the given query + * @param LdapQuery $query The query returning the result set + * @param ?array $fields Request these attributes instead of the ones registered in the given query * - * @return array + * @return array */ - public function fetchAll(LdapQuery $query, array $fields = null) + public function fetchAll(LdapQuery $query, ?array $fields = null) { $this->bind(); @@ -435,12 +435,12 @@ class LdapConnection implements Selectable, Inspectable /** * Fetch the first row of the result set * - * @param LdapQuery $query The query returning the result set - * @param array $fields Request these attributes instead of the ones registered in the given query + * @param LdapQuery $query The query returning the result set + * @param ?array $fields Request these attributes instead of the ones registered in the given query * - * @return mixed + * @return mixed */ - public function fetchRow(LdapQuery $query, array $fields = null) + public function fetchRow(LdapQuery $query, ?array $fields = null) { $clonedQuery = clone $query; $clonedQuery->limit(1); @@ -452,14 +452,14 @@ class LdapConnection implements Selectable, Inspectable /** * Fetch the first column of all rows of the result set as an array * - * @param LdapQuery $query The query returning the result set - * @param array $fields Request these attributes instead of the ones registered in the given query + * @param LdapQuery $query The query returning the result set + * @param ?array $fields Request these attributes instead of the ones registered in the given query * - * @return array + * @return array * - * @throws ProgrammingError In case no attribute is being requested + * @throws ProgrammingError In case no attribute is being requested */ - public function fetchColumn(LdapQuery $query, array $fields = null) + public function fetchColumn(LdapQuery $query, ?array $fields = null) { if ($fields === null) { $fields = $query->getColumns(); @@ -485,12 +485,12 @@ class LdapConnection implements Selectable, Inspectable /** * Fetch the first column of the first row of the result set * - * @param LdapQuery $query The query returning the result set - * @param array $fields Request these attributes instead of the ones registered in the given query + * @param LdapQuery $query The query returning the result set + * @param ?array $fields Request these attributes instead of the ones registered in the given query * - * @return string + * @return string */ - public function fetchOne(LdapQuery $query, array $fields = null) + public function fetchOne(LdapQuery $query, ?array $fields = null) { $row = $this->fetchRow($query, $fields); if ($row === false) { @@ -521,14 +521,14 @@ class LdapConnection implements Selectable, Inspectable * * The first column is the key, the second column is the value. * - * @param LdapQuery $query The query returning the result set - * @param array $fields Request these attributes instead of the ones registered in the given query + * @param LdapQuery $query The query returning the result set + * @param ?array $fields Request these attributes instead of the ones registered in the given query * - * @return array + * @return array * - * @throws ProgrammingError In case there are less than two attributes being requested + * @throws ProgrammingError In case there are less than two attributes being requested */ - public function fetchPairs(LdapQuery $query, array $fields = null) + public function fetchPairs(LdapQuery $query, ?array $fields = null) { if ($fields === null) { $fields = $query->getColumns(); @@ -567,12 +567,12 @@ class LdapConnection implements Selectable, Inspectable /** * Fetch an LDAP entry by its DN * - * @param string $dn - * @param array|null $fields + * @param string $dn + * @param ?array $fields * * @return StdClass|bool */ - public function fetchByDn($dn, array $fields = null) + public function fetchByDn($dn, ?array $fields = null) { return $this->select() ->from('*', $fields) @@ -721,14 +721,14 @@ class LdapConnection implements Selectable, Inspectable /** * Run the given LDAP query and return the resulting entries * - * @param LdapQuery $query The query to fetch results with - * @param array $fields Request these attributes instead of the ones registered in the given query + * @param LdapQuery $query The query to fetch results with + * @param ?array $fields Request these attributes instead of the ones registered in the given query * - * @return array + * @return array * - * @throws LdapException In case an error occured while fetching the results + * @throws LdapException In case an error occured while fetching the results */ - protected function runQuery(LdapQuery $query, array $fields = null) + protected function runQuery(LdapQuery $query, ?array $fields = null) { $limit = $query->getLimit(); $offset = $query->hasOffset() ? $query->getOffset() : 0; @@ -852,15 +852,15 @@ class LdapConnection implements Selectable, Inspectable * * This utilizes paged search requests as defined in RFC 2696. * - * @param LdapQuery $query The query to fetch results with - * @param array $fields Request these attributes instead of the ones registered in the given query - * @param int $pageSize The maximum page size, defaults to self::PAGE_SIZE + * @param LdapQuery $query The query to fetch results with + * @param ?array $fields Request these attributes instead of the ones registered in the given query + * @param int $pageSize The maximum page size, defaults to self::PAGE_SIZE * - * @return array + * @return array * - * @throws LdapException In case an error occured while fetching the results + * @throws LdapException In case an error occured while fetching the results */ - protected function runPagedQuery(LdapQuery $query, array $fields = null, $pageSize = null) + protected function runPagedQuery(LdapQuery $query, ?array $fields = null, $pageSize = null) { if ($pageSize === null) { $pageSize = static::PAGE_SIZE; @@ -1202,11 +1202,11 @@ class LdapConnection implements Selectable, Inspectable /** * Prepare and establish a connection with the LDAP server * - * @param ?Inspection $info Optional inspection to fill with diagnostic info + * @param ?Inspection $info Optional inspection to fill with diagnostic info * - * @throws LdapException In case the connection is not possible + * @throws LdapException In case the connection is not possible */ - protected function prepareNewConnection(Inspection $info = null) + protected function prepareNewConnection(?Inspection $info = null) { if (! isset($info)) { $info = new Inspection(''); @@ -1249,19 +1249,19 @@ class LdapConnection implements Selectable, Inspectable /** * Perform a LDAP search and return the result or false on error * - * @param LdapQuery $query - * @param array $attributes An array of the required attributes - * @param int $attrsonly Should be set to 1 if only attribute types are wanted - * @param int $sizelimit Enables you to limit the count of entries fetched - * @param int $timelimit Sets the number of seconds how long is spend on the search - * @param int $deref - * @param array $controls LDAP Controls to send with the request (Only supported with PHP v7.3+) + * @param LdapQuery $query + * @param ?array $attributes An array of the required attributes + * @param int $attrsonly Should be set to 1 if only attribute types are wanted + * @param int $sizelimit Enables you to limit the count of entries fetched + * @param int $timelimit Sets the number of seconds how long is spend on the search + * @param int $deref + * @param array $controls LDAP Controls to send with the request (Only supported with PHP v7.3+) * - * @throws LogicException If the LDAP query search scope is unsupported + * @throws LogicException If the LDAP query search scope is unsupported */ public function ldapSearch( LdapQuery $query, - array $attributes = null, + ?array $attributes = null, $attrsonly = 0, $sizelimit = 0, $timelimit = 0, diff --git a/library/Icinga/Protocol/Ldap/LdapQuery.php b/library/Icinga/Protocol/Ldap/LdapQuery.php index f4e198626..57ac84302 100644 --- a/library/Icinga/Protocol/Ldap/LdapQuery.php +++ b/library/Icinga/Protocol/Ldap/LdapQuery.php @@ -178,7 +178,7 @@ class LdapQuery extends SimpleQuery * * {@inheritdoc} This creates an objectClass filter. */ - public function from($target, array $fields = null) + public function from($target, ?array $fields = null) { $this->where('objectClass', $target); return parent::from($target, $fields); diff --git a/library/Icinga/Repository/DbRepository.php b/library/Icinga/Repository/DbRepository.php index 3f8b604f0..49de6c2f2 100644 --- a/library/Icinga/Repository/DbRepository.php +++ b/library/Icinga/Repository/DbRepository.php @@ -415,14 +415,14 @@ abstract class DbRepository extends Repository implements Extensible, Updatable, * Pass an array with a column name (the same as in $bind) and a PDO::PARAM_* constant as value * as fourth parameter $types to define a different type than string for a particular column. * - * @param string $table - * @param array $bind - * @param Filter $filter - * @param array $types + * @param string $table + * @param array $bind + * @param ?Filter $filter + * @param array $types * - * @return int The number of affected rows + * @return int The number of affected rows */ - public function update($table, array $bind, Filter $filter = null, array $types = array()) + public function update($table, array $bind, ?Filter $filter = null, array $types = array()) { $realTable = $this->clearTableAlias($this->requireTable($table)); @@ -441,12 +441,12 @@ abstract class DbRepository extends Repository implements Extensible, Updatable, /** * Delete table rows, optionally limited by using a filter * - * @param string $table - * @param Filter $filter + * @param string $table + * @param ?Filter $filter * - * @return int The number of affected rows + * @return int The number of affected rows */ - public function delete($table, Filter $filter = null) + public function delete($table, ?Filter $filter = null) { $realTable = $this->clearTableAlias($this->requireTable($table)); @@ -627,17 +627,17 @@ abstract class DbRepository extends Repository implements Extensible, Updatable, * If a query column or a filter column, which is part of a query filter, needs to be converted, * you'll need to pass $query, otherwise the column is considered a statement column. * - * @param string $table The datasource's table - * @param string $name The alias or column name for which to return a conversion method - * @param string $context The context of the conversion: persist or retrieve - * @param RepositoryQuery $query If given the column is considered a query column, - * statement column otherwise + * @param string $table The datasource's table + * @param string $name The alias or column name for which to return a conversion method + * @param string $context The context of the conversion: persist or retrieve + * @param ?RepositoryQuery $query If given the column is considered a query column, + * statement column otherwise * - * @return string + * @return string * - * @throws ProgrammingError In case a conversion rule is found but not any conversion method + * @throws ProgrammingError In case a conversion rule is found but not any conversion method */ - protected function getConverter($table, $name, $context, RepositoryQuery $query = null) + protected function getConverter($table, $name, $context, ?RepositoryQuery $query = null) { if ($name instanceof Zend_Db_Expr) { return; @@ -668,15 +668,15 @@ abstract class DbRepository extends Repository implements Extensible, Updatable, * * This will prepend the datasource's table prefix and will apply the table's alias, if any. * - * @param string $table The table to validate - * @param RepositoryQuery $query An optional query to pass as context - * (unused by the base implementation) + * @param string $table The table to validate + * @param ?RepositoryQuery $query An optional query to pass as context + * (unused by the base implementation) * - * @return array|string + * @return array|string * - * @throws ProgrammingError In case the given table does not exist + * @throws ProgrammingError In case the given table does not exist */ - public function requireTable($table, RepositoryQuery $query = null) + public function requireTable($table, ?RepositoryQuery $query = null) { $virtualTable = null; $statementColumns = $this->getStatementColumns(); @@ -740,17 +740,17 @@ abstract class DbRepository extends Repository implements Extensible, Updatable, * Attempts to join the given column from a different table if its association to the given table cannot be * verified. * - * @param string $table The table where to look for the column or alias - * @param string $name The name or alias of the column to validate - * @param RepositoryQuery $query An optional query to pass as context, - * if not given no join will be attempted + * @param string $table The table where to look for the column or alias + * @param string $name The name or alias of the column to validate + * @param ?RepositoryQuery $query An optional query to pass as context, + * if not given no join will be attempted * - * @return string The given column's name + * @return string The given column's name * - * @throws QueryException In case the given column is not a valid query column - * @throws ProgrammingError In case the given column is not found in $table and cannot be joined in + * @throws QueryException In case the given column is not a valid query column + * @throws ProgrammingError In case the given column is not found in $table and cannot be joined in */ - public function requireQueryColumn($table, $name, RepositoryQuery $query = null) + public function requireQueryColumn($table, $name, ?RepositoryQuery $query = null) { if ($name instanceof Zend_Db_Expr) { return $name; @@ -789,18 +789,18 @@ abstract class DbRepository extends Repository implements Extensible, Updatable, * verified. In case of a PostgreSQL connection and if a COLLATE SQL-instruction is part of the resolved column, * this applies LOWER() on the column and, if given, strtolower() on the filter's expression. * - * @param string $table The table where to look for the column or alias - * @param string $name The name or alias of the column to validate - * @param RepositoryQuery $query An optional query to pass as context, - * if not given the column is considered being used for a statement filter - * @param FilterExpression $filter An optional filter to pass as context + * @param string $table The table where to look for the column or alias + * @param string $name The name or alias of the column to validate + * @param ?RepositoryQuery $query An optional query to pass as context, + * if not given the column is considered being used for a statement filter + * @param ?FilterExpression $filter An optional filter to pass as context * - * @return string The given column's name + * @return string The given column's name * - * @throws QueryException In case the given column is not a valid filter column - * @throws ProgrammingError In case the given column is not found in $table and cannot be joined in + * @throws QueryException In case the given column is not a valid filter column + * @throws ProgrammingError In case the given column is not found in $table and cannot be joined in */ - public function requireFilterColumn($table, $name, RepositoryQuery $query = null, FilterExpression $filter = null) + public function requireFilterColumn($table, $name, ?RepositoryQuery $query = null, ?FilterExpression $filter = null) { if ($name instanceof Zend_Db_Expr) { return $name; diff --git a/library/Icinga/Repository/IniRepository.php b/library/Icinga/Repository/IniRepository.php index 2519d03c6..5817259cd 100644 --- a/library/Icinga/Repository/IniRepository.php +++ b/library/Icinga/Repository/IniRepository.php @@ -59,11 +59,11 @@ abstract class IniRepository extends Repository implements Extensible, Updatable /** * Create a new INI repository object * - * @param Config|null $ds The data source to use + * @param ?Config $ds The data source to use * - * @throws ProgrammingError In case the given data source does not provide a valid key column + * @throws ProgrammingError In case the given data source does not provide a valid key column */ - public function __construct(Config $ds = null) + public function __construct(?Config $ds = null) { parent::__construct($ds); // First! Due to init(). @@ -263,13 +263,13 @@ abstract class IniRepository extends Repository implements Extensible, Updatable /** * Update the target with the given data and optionally limit the affected entries by using a filter * - * @param string $target - * @param array $data - * @param Filter $filter + * @param string $target + * @param array $data + * @param ?Filter $filter * - * @throws StatementException In case the operation has failed + * @throws StatementException In case the operation has failed */ - public function update($target, array $data, Filter $filter = null) + public function update($target, array $data, ?Filter $filter = null) { $ds = $this->getDataSource($target); $newData = $this->requireStatementColumns($target, $data); @@ -338,12 +338,12 @@ abstract class IniRepository extends Repository implements Extensible, Updatable /** * Delete entries in the given target, optionally limiting the affected entries by using a filter * - * @param string $target - * @param Filter $filter + * @param string $target + * @param ?Filter $filter * - * @throws StatementException In case the operation has failed + * @throws StatementException In case the operation has failed */ - public function delete($target, Filter $filter = null) + public function delete($target, ?Filter $filter = null) { $ds = $this->getDataSource($target); diff --git a/library/Icinga/Repository/Repository.php b/library/Icinga/Repository/Repository.php index 404f1f65a..fcd81dd38 100644 --- a/library/Icinga/Repository/Repository.php +++ b/library/Icinga/Repository/Repository.php @@ -216,10 +216,10 @@ abstract class Repository implements Selectable /** * Create a new repository object * - * @param Selectable|null $ds The datasource to use. - * Only pass null if you have overridden {@link getDataSource()}! + * @param ?Selectable $ds The datasource to use. + * Only pass null if you have overridden {@link getDataSource()}! */ - public function __construct(Selectable $ds = null) + public function __construct(?Selectable $ds = null) { $this->ds = $ds; $this->aliasTableMap = array(); @@ -694,11 +694,11 @@ abstract class Repository implements Selectable /** * Return a new query for the given columns * - * @param array $columns The desired columns, if null all columns will be queried + * @param ?array $columns The desired columns, if null all columns will be queried * - * @return RepositoryQuery + * @return RepositoryQuery */ - public function select(array $columns = null) + public function select(?array $columns = null) { $query = new RepositoryQuery($this); $query->from($this->getBaseTable(), $columns); @@ -733,16 +733,16 @@ abstract class Repository implements Selectable /** * Convert a value supposed to be transmitted to the data source * - * @param string $table The table where to persist the value - * @param string $name The alias or column name - * @param mixed $value The value to convert - * @param RepositoryQuery $query An optional query to pass as context - * (Directly passed through to $this->getConverter) + * @param string $table The table where to persist the value + * @param string $name The alias or column name + * @param mixed $value The value to convert + * @param ?RepositoryQuery $query An optional query to pass as context + * (Directly passed through to $this->getConverter) * - * @return mixed If conversion was possible, the converted value, - * otherwise the unchanged value + * @return mixed If conversion was possible, the converted value, + * otherwise the unchanged value */ - public function persistColumn($table, $name, $value, RepositoryQuery $query = null) + public function persistColumn($table, $name, $value, ?RepositoryQuery $query = null) { $converter = $this->getConverter($table, $name, 'persist', $query); if ($converter !== null) { @@ -755,16 +755,16 @@ abstract class Repository implements Selectable /** * Convert a value which was fetched from the data source * - * @param string $table The table the value has been fetched from - * @param string $name The alias or column name - * @param mixed $value The value to convert - * @param RepositoryQuery $query An optional query to pass as context - * (Directly passed through to $this->getConverter) + * @param string $table The table the value has been fetched from + * @param string $name The alias or column name + * @param mixed $value The value to convert + * @param ?RepositoryQuery $query An optional query to pass as context + * (Directly passed through to $this->getConverter) * - * @return mixed If conversion was possible, the converted value, - * otherwise the unchanged value + * @return mixed If conversion was possible, the converted value, + * otherwise the unchanged value */ - public function retrieveColumn($table, $name, $value, RepositoryQuery $query = null) + public function retrieveColumn($table, $name, $value, ?RepositoryQuery $query = null) { $converter = $this->getConverter($table, $name, 'retrieve', $query); if ($converter !== null) { @@ -777,17 +777,17 @@ abstract class Repository implements Selectable /** * Return the name of the conversion method for the given alias or column name and context * - * @param string $table The datasource's table - * @param string $name The alias or column name for which to return a conversion method - * @param string $context The context of the conversion: persist or retrieve - * @param RepositoryQuery $query An optional query to pass as context - * (unused by the base implementation) + * @param string $table The datasource's table + * @param string $name The alias or column name for which to return a conversion method + * @param string $context The context of the conversion: persist or retrieve + * @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 + * @throws ProgrammingError In case a conversion rule is found but not any conversion method */ - protected function getConverter($table, $name, $context, RepositoryQuery $query = null) + protected function getConverter($table, $name, $context, ?RepositoryQuery $query = null) { $conversionRules = $this->getConversionRules(); if (! isset($conversionRules[$table])) { @@ -950,15 +950,15 @@ abstract class Repository implements Selectable /** * Validate that the requested table exists and resolve it's real name if necessary * - * @param string $table The table to validate - * @param RepositoryQuery $query An optional query to pass as context - * (unused by the base implementation) + * @param string $table The table to validate + * @param ?RepositoryQuery $query An optional query to pass as context + * (unused by the base implementation) * - * @return string The table's name, may differ from the given one + * @return string The table's name, may differ from the given one * - * @throws ProgrammingError In case the given table does not exist + * @throws ProgrammingError In case the given table does not exist */ - public function requireTable($table, RepositoryQuery $query = null) + public function requireTable($table, ?RepositoryQuery $query = null) { $queryColumns = $this->getQueryColumns(); if (! isset($queryColumns[$table])) { @@ -976,15 +976,15 @@ abstract class Repository implements Selectable /** * Recurse the given filter, require each column for the given table and convert all values * - * @param string $table The table being filtered - * @param Filter $filter The filter to recurse - * @param RepositoryQuery $query An optional query to pass as context - * (Directly passed through to $this->requireFilterColumn) - * @param bool $clone Whether to clone $filter first + * @param string $table The table being filtered + * @param Filter $filter The filter to recurse + * @param ?RepositoryQuery $query An optional query to pass as context + * (Directly passed through to $this->requireFilterColumn) + * @param bool $clone Whether to clone $filter first * - * @return Filter The udpated filter + * @return Filter The udpated filter */ - public function requireFilter($table, Filter $filter, RepositoryQuery $query = null, $clone = true) + public function requireFilter($table, Filter $filter, ?RepositoryQuery $query = null, $clone = true) { if ($clone) { $filter = clone $filter; @@ -1124,15 +1124,15 @@ abstract class Repository implements Selectable /** * Validate that the given column is a valid query target and return it or the actual name if it's an alias * - * @param string $table The table where to look for the column or alias - * @param string $name The name or alias of the column to validate - * @param RepositoryQuery $query An optional query to pass as context (unused by the base implementation) + * @param string $table The table where to look for the column or alias + * @param string $name The name or alias of the column to validate + * @param ?RepositoryQuery $query An optional query to pass as context (unused by the base implementation) * - * @return string The given column's name + * @return string The given column's name * - * @throws QueryException In case the given column is not a valid query column + * @throws QueryException In case the given column is not a valid query column */ - public function requireQueryColumn($table, $name, RepositoryQuery $query = null) + public function requireQueryColumn($table, $name, ?RepositoryQuery $query = null) { if (($column = $this->resolveQueryColumnAlias($table, $name)) !== null) { $alias = $name; @@ -1171,16 +1171,16 @@ abstract class Repository implements Selectable /** * Validate that the given column is a valid filter target and return it or the actual name if it's an alias * - * @param string $table The table where to look for the column or alias - * @param string $name The name or alias of the column to validate - * @param RepositoryQuery $query An optional query to pass as context (unused by the base implementation) - * @param FilterExpression $filter An optional filter to pass as context (unused by the base implementation) + * @param string $table The table where to look for the column or alias + * @param string $name The name or alias of the column to validate + * @param ?RepositoryQuery $query An optional query to pass as context (unused by the base implementation) + * @param ?FilterExpression $filter An optional filter to pass as context (unused by the base implementation) * - * @return string The given column's name + * @return string The given column's name * - * @throws QueryException In case the given column is not a valid filter column + * @throws QueryException In case the given column is not a valid filter column */ - public function requireFilterColumn($table, $name, RepositoryQuery $query = null, FilterExpression $filter = null) + public function requireFilterColumn($table, $name, ?RepositoryQuery $query = null, ?FilterExpression $filter = null) { if (($column = $this->resolveQueryColumnAlias($table, $name)) !== null) { $alias = $name; diff --git a/library/Icinga/Repository/RepositoryQuery.php b/library/Icinga/Repository/RepositoryQuery.php index 84f7c6e2a..3445eea20 100644 --- a/library/Icinga/Repository/RepositoryQuery.php +++ b/library/Icinga/Repository/RepositoryQuery.php @@ -102,12 +102,12 @@ class RepositoryQuery implements QueryInterface, SortRules, FilterColumns, Itera * * This notifies the repository about each desired query column. * - * @param mixed $target The target from which to fetch the columns - * @param array $columns If null or an empty array, all columns will be fetched + * @param mixed $target The target from which to fetch the columns + * @param ?array $columns If null or an empty array, all columns will be fetched * - * @return $this + * @return $this */ - public function from($target, array $columns = null) + public function from($target, ?array $columns = null) { $this->query = $this->repository->getDataSource($target)->select(); $this->query->from($this->repository->requireTable($target, $this)); @@ -146,12 +146,12 @@ class RepositoryQuery implements QueryInterface, SortRules, FilterColumns, Itera * * This notifies the repository about each desired query column. * - * @param mixed $target The target where to look for each column - * @param array $desiredColumns Pass null or an empty array to require all query columns + * @param mixed $target The target where to look for each column + * @param ?array $desiredColumns Pass null or an empty array to require all query columns * - * @return array The desired columns indexed by their respective alias + * @return array The desired columns indexed by their respective alias */ - protected function prepareQueryColumns($target, array $desiredColumns = null) + protected function prepareQueryColumns($target, ?array $desiredColumns = null) { $this->customAliases = array(); if (empty($desiredColumns)) { diff --git a/library/Icinga/Web/Controller.php b/library/Icinga/Web/Controller.php index aeabd1291..6f3520059 100644 --- a/library/Icinga/Web/Controller.php +++ b/library/Icinga/Web/Controller.php @@ -113,14 +113,14 @@ class Controller extends ModuleActionController * * The widget is set on the `sortBox' view property only if the current view has not been requested as compact * - * @param array $columns An array containing the sort columns, with the - * submit value as the key and the label as the value - * @param Sortable $query Query to apply the user chosen sort rules on - * @param array $defaults An array containing default sort directions for specific columns + * @param array $columns An array containing the sort columns, with the + * submit value as the key and the label as the value + * @param ?Sortable $query Query to apply the user chosen sort rules on + * @param ?array $defaults An array containing default sort directions for specific columns * - * @return $this + * @return $this */ - protected function setupSortControl(array $columns, Sortable $query = null, array $defaults = null) + protected function setupSortControl(array $columns, ?Sortable $query = null, ?array $defaults = null) { $request = $this->getRequest(); $sortBox = SortBox::create('sortbox-' . $request->getActionName(), $columns, $defaults); @@ -219,20 +219,20 @@ class Controller extends ModuleActionController * $filterable->getSearchColumns() is called to provide the respective columns if $filterColumns or $searchColumns * is not given. * - * @param Filterable $filterable The filterable to create a filter editor for - * @param array $filterColumns The filter columns to offer to the user - * @param array $searchColumns The search columns to utilize for quick searches - * @param array $preserveParams The url parameters to preserve + * @param Filterable $filterable The filterable to create a filter editor for + * @param ?array $filterColumns The filter columns to offer to the user + * @param ?array $searchColumns The search columns to utilize for quick searches + * @param ?array $preserveParams The url parameters to preserve * - * @return $this + * @return $this * * @todo Preserving and ignoring parameters should be configurable (another two method params? property magic?) */ protected function setupFilterControl( Filterable $filterable, - array $filterColumns = null, - array $searchColumns = null, - array $preserveParams = null + ?array $filterColumns = null, + ?array $searchColumns = null, + ?array $preserveParams = null ) { $defaultPreservedParams = array( 'limit', // setupPaginationControl() diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 926b59493..7457c9474 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -1149,11 +1149,11 @@ class Form extends Zend_Form * Redirects to the url set with setRedirectUrl() upon success. See onSuccess() * and onRequest() wherewith you can customize the processing logic. * - * @param Request $request The request to be processed + * @param ?Request $request The request to be processed * - * @return Request The request supposed to be processed + * @return Request The request supposed to be processed */ - public function handleRequest(Request $request = null) + public function handleRequest(?Request $request = null) { if ($request === null) { $request = $this->getRequest(); @@ -1546,11 +1546,11 @@ class Form extends Zend_Form /** * Render this form * - * @param Zend_View_Interface $view The view context to use + * @param ?Zend_View_Interface $view The view context to use * - * @return string + * @return string */ - public function render(Zend_View_Interface $view = null) + public function render(?Zend_View_Interface $view = null) { $this->create(); return parent::render($view); diff --git a/library/Icinga/Web/Form/Decorator/Help.php b/library/Icinga/Web/Form/Decorator/Help.php index 9e30e863c..a9adff5e7 100644 --- a/library/Icinga/Web/Form/Decorator/Help.php +++ b/library/Icinga/Web/Form/Decorator/Help.php @@ -43,11 +43,11 @@ class Help extends Zend_Form_Decorator_Abstract /** * Return the id used to identify the description associated with the decorated element * - * @param Zend_Form_Element $element The element for which to generate a id + * @param ?Zend_Form_Element $element The element for which to generate a id * - * @return string + * @return string */ - public function getDescriptionId(Zend_Form_Element $element = null) + public function getDescriptionId(?Zend_Form_Element $element = null) { if ($this->descriptionId === null) { $element = $element ?: $this->getElement(); diff --git a/library/Icinga/Web/Navigation/NavigationItem.php b/library/Icinga/Web/Navigation/NavigationItem.php index 8aaf7b888..ecec1ba9f 100644 --- a/library/Icinga/Web/Navigation/NavigationItem.php +++ b/library/Icinga/Web/Navigation/NavigationItem.php @@ -149,10 +149,10 @@ class NavigationItem implements IteratorAggregate /** * Create a new NavigationItem * - * @param string $name - * @param array $properties + * @param string $name + * @param ?array $properties */ - public function __construct($name, array $properties = null) + public function __construct($name, ?array $properties = null) { $this->setName($name); $this->children = new Navigation(); diff --git a/library/Icinga/Web/Navigation/Renderer/BadgeNavigationItemRenderer.php b/library/Icinga/Web/Navigation/Renderer/BadgeNavigationItemRenderer.php index 8510f7070..851945c46 100644 --- a/library/Icinga/Web/Navigation/Renderer/BadgeNavigationItemRenderer.php +++ b/library/Icinga/Web/Navigation/Renderer/BadgeNavigationItemRenderer.php @@ -88,11 +88,11 @@ abstract class BadgeNavigationItemRenderer extends NavigationItemRenderer /** * Render the given navigation item as HTML anchor with a badge * - * @param NavigationItem $item + * @param ?NavigationItem $item * - * @return string + * @return string */ - public function render(NavigationItem $item = null) + public function render(?NavigationItem $item = null) { if ($item === null) { $item = $this->getItem(); diff --git a/library/Icinga/Web/Navigation/Renderer/NavigationItemRenderer.php b/library/Icinga/Web/Navigation/Renderer/NavigationItemRenderer.php index 2f7e22482..a26f3d431 100644 --- a/library/Icinga/Web/Navigation/Renderer/NavigationItemRenderer.php +++ b/library/Icinga/Web/Navigation/Renderer/NavigationItemRenderer.php @@ -47,9 +47,9 @@ class NavigationItemRenderer /** * Create a new NavigationItemRenderer * - * @param array $options + * @param ?array $options */ - public function __construct(array $options = null) + public function __construct(?array $options = null) { if (! empty($options)) { $this->setOptions($options); @@ -161,11 +161,11 @@ class NavigationItemRenderer /** * Render the given navigation item as HTML anchor * - * @param NavigationItem $item + * @param ?NavigationItem $item * - * @return string + * @return string */ - public function render(NavigationItem $item = null) + public function render(?NavigationItem $item = null) { if ($item !== null) { $this->setItem($item); diff --git a/library/Icinga/Web/Response/JsonResponse.php b/library/Icinga/Web/Response/JsonResponse.php index 025e88db0..f92772a01 100644 --- a/library/Icinga/Web/Response/JsonResponse.php +++ b/library/Icinga/Web/Response/JsonResponse.php @@ -188,11 +188,11 @@ class JsonResponse extends Response /** * Set the data for successful API requests * - * @param array $successData + * @param ?array $successData * - * @return $this + * @return $this */ - public function setSuccessData(array $successData = null) + public function setSuccessData(?array $successData = null) { $this->successData = $successData; $this->status = static::STATUS_SUCCESS; diff --git a/library/Icinga/Web/Session.php b/library/Icinga/Web/Session.php index 40df89f9e..b1caa3f73 100644 --- a/library/Icinga/Web/Session.php +++ b/library/Icinga/Web/Session.php @@ -22,11 +22,11 @@ class Session /** * Create the session * - * @param BaseSession $session + * @param ?BaseSession $session * - * @return BaseSession + * @return BaseSession */ - public static function create(BaseSession $session = null) + public static function create(?BaseSession $session = null) { if ($session === null) { self::$session = PhpSession::create(); diff --git a/library/Icinga/Web/Session/PhpSession.php b/library/Icinga/Web/Session/PhpSession.php index 36dd84e9d..5aafc900f 100644 --- a/library/Icinga/Web/Session/PhpSession.php +++ b/library/Icinga/Web/Session/PhpSession.php @@ -36,14 +36,14 @@ class PhpSession extends Session /** * Create a new PHPSession object using the provided options (if any) * - * @param array $options An optional array of ini options to set + * @param ?array $options An optional array of ini options to set * - * @return static + * @return static * - * @throws ConfigurationError + * @throws ConfigurationError * @see http://php.net/manual/en/session.configuration.php */ - public static function create(array $options = null) + public static function create(?array $options = null) { return version_compare(PHP_VERSION, '7.2.0') < 0 ? new self($options) : new Php72Session($options); } @@ -51,12 +51,12 @@ class PhpSession extends Session /** * Create a new PHPSession object using the provided options (if any) * - * @param array $options An optional array of ini options to set + * @param ?array $options An optional array of ini options to set * - * @throws ConfigurationError + * @throws ConfigurationError * @see http://php.net/manual/en/session.configuration.php */ - public function __construct(array $options = null) + public function __construct(?array $options = null) { $defaultCookieOptions = array( 'use_trans_sid' => false, diff --git a/library/Icinga/Web/View/Helper/IcingaCheckbox.php b/library/Icinga/Web/View/Helper/IcingaCheckbox.php index 07cf01fee..71a817fb3 100644 --- a/library/Icinga/Web/View/Helper/IcingaCheckbox.php +++ b/library/Icinga/Web/View/Helper/IcingaCheckbox.php @@ -5,7 +5,7 @@ namespace Icinga\Web\View\Helper; class IcingaCheckbox extends \Zend_View_Helper_FormCheckbox { - public function icingaCheckbox($name, $value = null, $attribs = null, array $checkedOptions = null) + public function icingaCheckbox($name, $value = null, $attribs = null, ?array $checkedOptions = null) { if (! isset($attribs['id'])) { $attribs['id'] = $this->view->protectId('icingaCheckbox_' . $name); diff --git a/library/Icinga/Web/Widget/Chart/InlinePie.php b/library/Icinga/Web/Widget/Chart/InlinePie.php index 21b4ca490..94b122a08 100644 --- a/library/Icinga/Web/Widget/Chart/InlinePie.php +++ b/library/Icinga/Web/Widget/Chart/InlinePie.php @@ -151,11 +151,11 @@ class InlinePie extends AbstractWidget /** * Set the colors used by the slices of the pie chart. * - * @param array $colors + * @param ?array $colors * - * @return $this + * @return $this */ - public function setColors(array $colors = null) + public function setColors(?array $colors = null) { $this->colors = $colors; diff --git a/library/Icinga/Web/Widget/Dashboard/Pane.php b/library/Icinga/Web/Widget/Dashboard/Pane.php index c8b14c5a1..d39bf359e 100644 --- a/library/Icinga/Web/Widget/Dashboard/Pane.php +++ b/library/Icinga/Web/Widget/Dashboard/Pane.php @@ -161,10 +161,10 @@ class Pane extends UserWidget /** * Removes all or a given list of dashlets from this pane * - * @param array $dashlets Optional list of dashlet titles + * @param ?array $dashlets Optional list of dashlet titles * @return Pane $this */ - public function removeDashlets(array $dashlets = null) + public function removeDashlets(?array $dashlets = null) { if ($dashlets === null) { $this->dashlets = array(); diff --git a/library/Icinga/Web/Widget/FilterEditor.php b/library/Icinga/Web/Widget/FilterEditor.php index 85c915f64..6ff0ef7ba 100644 --- a/library/Icinga/Web/Widget/FilterEditor.php +++ b/library/Icinga/Web/Widget/FilterEditor.php @@ -94,11 +94,11 @@ class FilterEditor extends AbstractWidget /** * Set columns to search in * - * @param array $searchColumns + * @param ?array $searchColumns * * @return $this */ - public function setSearchColumns(array $searchColumns = null) + public function setSearchColumns(?array $searchColumns = null) { $this->searchColumns = $searchColumns; return $this; @@ -512,7 +512,7 @@ class FilterEditor extends AbstractWidget } } - protected function text(Filter $filter = null) + protected function text(?Filter $filter = null) { $value = $filter === null ? '' : $filter->getExpression(); if (is_array($value)) { @@ -554,7 +554,7 @@ class FilterEditor extends AbstractWidget return $res; } - protected function elementId($prefix, Filter $filter = null) + protected function elementId($prefix, ?Filter $filter = null) { if ($filter === null) { return $prefix . '_new_' . ($this->addTo ?: '0'); @@ -563,7 +563,7 @@ class FilterEditor extends AbstractWidget } } - protected function selectOperator(Filter $filter = null) + protected function selectOperator(?Filter $filter = null) { $ops = array( 'AND' => 'AND', @@ -579,7 +579,7 @@ class FilterEditor extends AbstractWidget ); } - protected function selectSign(Filter $filter = null) + protected function selectSign(?Filter $filter = null) { $signs = array( '=' => '=', @@ -598,13 +598,13 @@ class FilterEditor extends AbstractWidget ); } - public function setColumns(array $columns = null) + public function setColumns(?array $columns = null) { $this->cachedColumnSelect = $columns ? $this->arrayForSelect($columns) : null; return $this; } - protected function selectColumn(Filter $filter = null) + protected function selectColumn(?Filter $filter = null) { $active = $filter === null ? null : $filter->getColumn(); diff --git a/library/Icinga/Web/Widget/ItemList/MigrationList.php b/library/Icinga/Web/Widget/ItemList/MigrationList.php index 43699d3e5..f24b07846 100644 --- a/library/Icinga/Web/Widget/ItemList/MigrationList.php +++ b/library/Icinga/Web/Widget/ItemList/MigrationList.php @@ -35,7 +35,7 @@ class MigrationList extends BaseItemList * * @param ?MigrationForm $form */ - public function __construct($data, MigrationForm $form = null) + public function __construct($data, ?MigrationForm $form = null) { parent::__construct($data); diff --git a/library/Icinga/Web/Widget/SortBox.php b/library/Icinga/Web/Widget/SortBox.php index 72b6f587c..18335c580 100644 --- a/library/Icinga/Web/Widget/SortBox.php +++ b/library/Icinga/Web/Widget/SortBox.php @@ -66,11 +66,11 @@ class SortBox extends AbstractWidget /** * Create a SortBox with the entries from $sortFields * - * @param string $name The name for the SortBox - * @param array $sortFields An array containing the columns and their labels to be displayed in the SortBox - * @param array $sortDefaults An array containing default sort directions for specific columns + * @param string $name The name for the SortBox + * @param array $sortFields An array containing the columns and their labels to be displayed in the SortBox + * @param ?array $sortDefaults An array containing default sort directions for specific columns */ - public function __construct($name, array $sortFields, array $sortDefaults = null) + public function __construct($name, array $sortFields, ?array $sortDefaults = null) { $this->name = $name; $this->sortFields = $sortFields; @@ -80,13 +80,13 @@ class SortBox extends AbstractWidget /** * Create a SortBox * - * @param string $name The name for the SortBox - * @param array $sortFields An array containing the columns and their labels to be displayed in the SortBox - * @param array $sortDefaults An array containing default sort directions for specific columns + * @param string $name The name for the SortBox + * @param array $sortFields An array containing the columns and their labels to be displayed in the SortBox + * @param ?array $sortDefaults An array containing default sort directions for specific columns * - * @return SortBox + * @return SortBox */ - public static function create($name, array $sortFields, array $sortDefaults = null) + public static function create($name, array $sortFields, ?array $sortDefaults = null) { return new static($name, $sortFields, $sortDefaults); } @@ -154,11 +154,11 @@ class SortBox extends AbstractWidget /** * Apply the sort rules from the given or current request on the query * - * @param Request $request + * @param ?Request $request * - * @return $this + * @return $this */ - public function handleRequest(Request $request = null) + public function handleRequest(?Request $request = null) { if ($this->query !== null) { if ($request === null) { diff --git a/library/Icinga/Web/Wizard.php b/library/Icinga/Web/Wizard.php index 9a1b8b67d..b52584475 100644 --- a/library/Icinga/Web/Wizard.php +++ b/library/Icinga/Web/Wizard.php @@ -254,11 +254,11 @@ class Wizard * Validate the request data using the current page, update the wizard's * position and redirect to the page's redirect url upon success. * - * @param Request $request The request to be processed + * @param ?Request $request The request to be processed * - * @return Request The request supposed to be processed + * @return Request The request supposed to be processed */ - public function handleRequest(Request $request = null) + public function handleRequest(?Request $request = null) { $page = $this->getCurrentPage(); @@ -377,11 +377,11 @@ class Wizard /** * Return the direction of this wizard using the given request * - * @param Request $request The request to use + * @param ?Request $request The request to use * - * @return int The direction @see Wizard::FORWARD @see Wizard::BACKWARD @see Wizard::NO_CHANGE + * @return int The direction @see Wizard::FORWARD @see Wizard::BACKWARD @see Wizard::NO_CHANGE */ - protected function getDirection(Request $request = null) + protected function getDirection(?Request $request = null) { if ($this->parent) { return $this->parent->getDirection($request); diff --git a/modules/setup/application/forms/AdminAccountPage.php b/modules/setup/application/forms/AdminAccountPage.php index b33749efc..65ea4e5a4 100644 --- a/modules/setup/application/forms/AdminAccountPage.php +++ b/modules/setup/application/forms/AdminAccountPage.php @@ -85,11 +85,11 @@ class AdminAccountPage extends Form /** * Set the user group backend configuration to use * - * @param array $config + * @param ?array $config * - * @return $this + * @return $this */ - public function setGroupConfig(array $config = null) + public function setGroupConfig(?array $config = null) { $this->groupConfig = $config; return $this; diff --git a/modules/setup/library/Setup/Utils/DbTool.php b/modules/setup/library/Setup/Utils/DbTool.php index 7578462b7..285b9dce8 100644 --- a/modules/setup/library/Setup/Utils/DbTool.php +++ b/modules/setup/library/Setup/Utils/DbTool.php @@ -545,15 +545,15 @@ class DbTool /** * Return whether the given privileges were granted * - * @param array $privileges An array of strings with the required privilege names - * @param array $context An array describing the context for which the given privileges need to apply. - * Only one or more table names are currently supported - * @param string $username The login name for which to check the privileges, - * if NULL the current login is used + * @param array $privileges An array of strings with the required privilege names + * @param ?array $context An array describing the context for which the given privileges need to apply. + * Only one or more table names are currently supported + * @param string $username The login name for which to check the privileges, + * if NULL the current login is used * - * @return ?bool + * @return ?bool */ - public function checkPrivileges(array $privileges, array $context = null, $username = null) + public function checkPrivileges(array $privileges, ?array $context = null, $username = null) { if ($this->config['db'] === 'mysql') { return $this->checkMysqlPrivileges($privileges, false, $context, $username); @@ -730,18 +730,18 @@ EOD; /** * Check whether the current user has the given privileges * - * @param array $privileges The privilege names - * @param bool $requireGrants Only return true when all privileges can be granted to others - * @param array $context An array describing the context for which the given privileges need to apply. - * Only one or more table names are currently supported - * @param string $username The login name to which the passed privileges need to be granted + * @param array $privileges The privilege names + * @param bool $requireGrants Only return true when all privileges can be granted to others + * @param ?array $context An array describing the context for which the given privileges need to apply. + * Only one or more table names are currently supported + * @param string $username The login name to which the passed privileges need to be granted * - * @return bool + * @return bool */ protected function checkMysqlPrivileges( array $privileges, $requireGrants = false, - array $context = null, + ?array $context = null, $username = null ) { $mysqlPrivileges = array_intersect($privileges, array_keys($this->mysqlGrantContexts)); @@ -835,18 +835,18 @@ EOD; * Note that database and table specific privileges (i.e. not SUPER, CREATE and CREATEROLE) are ignored * in case no connection to the database defined in the resource configuration has been established * - * @param array $privileges The privilege names - * @param bool $requireGrants Only return true when all privileges can be granted to others - * @param array $context An array describing the context for which the given privileges need to apply. - * Only one or more table names are currently supported - * @param string $username The login name to which the passed privileges need to be granted + * @param array $privileges The privilege names + * @param bool $requireGrants Only return true when all privileges can be granted to others + * @param ?array $context An array describing the context for which the given privileges need to apply. + * Only one or more table names are currently supported + * @param string $username The login name to which the passed privileges need to be granted * - * @return bool + * @return bool */ public function checkPgsqlPrivileges( array $privileges, $requireGrants = false, - array $context = null, + ?array $context = null, $username = null ) { $privilegesGranted = true; diff --git a/test/php/library/Icinga/Application/Hook/AuditHookTest.php b/test/php/library/Icinga/Application/Hook/AuditHookTest.php index 14ca43792..d68b58198 100644 --- a/test/php/library/Icinga/Application/Hook/AuditHookTest.php +++ b/test/php/library/Icinga/Application/Hook/AuditHookTest.php @@ -8,7 +8,7 @@ use Icinga\Test\BaseTestCase; class TestAuditHook extends AuditHook { - public function logMessage($time, $identity, $type, $message, array $data = null) + public function logMessage($time, $identity, $type, $message, ?array $data = null) { // TODO: Implement logMessage() method. }