Skip to content
Open
1 change: 0 additions & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ jobs:
with:
databases: true
php-extensions: ldap
phpunit-version: 9.6
dependencies: |
{
"./icinga-php/ipl" : "https://github.com/Icinga/icinga-php-library.git#snapshot/nightly",
Expand Down
2 changes: 1 addition & 1 deletion application/clicommands/WebCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function stopAction()
{
// TODO: No, that's NOT what we want
$prog = readlink('/proc/self/exe');
`killall $prog`;
shell_exec("killall $prog");
}

protected function forkAndExit()
Expand Down
3 changes: 2 additions & 1 deletion application/forms/Config/Resource/DbResourceForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use Icinga\Application\Platform;
use Icinga\Web\Form;
use Pdo\Mysql;

/**
* Form class for adding/modifying database resources
Expand Down Expand Up @@ -177,7 +178,7 @@ public function createElements(array $formData)
)
);
if (isset($formData['use_ssl']) && $formData['use_ssl']) {
if (defined('\PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT')) {
if (defined(Mysql::class . '::ATTR_SSL_VERIFY_SERVER_CERT')) {
$this->addElement(
'checkbox',
'ssl_do_not_verify_server_cert',
Expand Down
14 changes: 7 additions & 7 deletions application/forms/RepositoryForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ public function shouldDelete()
/**
* 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;
Expand All @@ -159,12 +159,12 @@ public function add(array $data = null)
/**
* 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;
Expand Down
4 changes: 2 additions & 2 deletions library/Icinga/Application/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
25 changes: 13 additions & 12 deletions library/Icinga/Application/Hook/AuditHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -60,13 +61,13 @@ public static function logActivity($type, $message, array $data = null, $identit
/**
* 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
Expand Down
4 changes: 2 additions & 2 deletions library/Icinga/Application/Hook/DbMigrationHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ public function getLatestMigrations(int $limit): array
* 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();
Expand Down
1 change: 1 addition & 0 deletions library/Icinga/Application/Hook/Ticket/TicketPattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function offsetExists($offset): bool

public function offsetGet($offset): ?string
{
$offset = $offset ?? '';
return array_key_exists($offset, $this->match) ? $this->match[$offset] : null;
}

Expand Down
8 changes: 4 additions & 4 deletions library/Icinga/Application/MigrationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function applyByName(string $module): bool
*
* @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(
Expand Down Expand Up @@ -164,7 +164,7 @@ public function apply(DbMigrationHook $hook, array $elevateConfig = null): bool
*
* @return bool
*/
public function applyAll(array $elevateConfig = null): bool
public function applyAll(?array $elevateConfig = null): bool
{
$default = DbMigrationHook::DEFAULT_MODULE;
if ($this->hasMigrations($default)) {
Expand Down Expand Up @@ -218,7 +218,7 @@ public function getRequiredDatabasePrivileges(): array
*
* @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;
Expand Down Expand Up @@ -324,7 +324,7 @@ protected function load(): void
*/
protected function checkRequiredPrivileges(
Sql\Connection $conn,
array $elevateConfig = null,
?array $elevateConfig = null,
bool $canIssueGrants = false
): bool {
if ($elevateConfig) {
Expand Down
4 changes: 2 additions & 2 deletions library/Icinga/Application/Modules/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -641,11 +641,11 @@ public function listInstalledModules()
/**
* 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) {
Expand Down
4 changes: 2 additions & 2 deletions library/Icinga/Authentication/AuthChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions library/Icinga/Authentication/User/DbUserBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ public function insert($table, array $bind, array $types = array())
/**
* 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');
Expand Down
22 changes: 11 additions & 11 deletions library/Icinga/Authentication/User/LdapUserBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,14 @@ protected function retrieveShadowExpire($value)
/**
* 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);
Expand All @@ -356,15 +356,15 @@ public function requireTable($table, RepositoryQuery $query = null)
/**
* 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) {
Expand Down
12 changes: 6 additions & 6 deletions library/Icinga/Authentication/User/UserBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@ protected static function getCustomUserBackend($identifier)
/**
* 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();
Expand All @@ -181,7 +181,7 @@ public static function create($name, ConfigObject $backendConfig = null)
$name = $backendConfig->name;
}

if (! ($backendType = strtolower($backendConfig->backend))) {
if ($backendConfig->backend === null || ! ($backendType = strtolower($backendConfig->backend))) {
throw new ConfigurationError(
'Authentication configuration for user backend "%s" is missing the \'backend\' directive',
$name
Expand Down
14 changes: 7 additions & 7 deletions library/Icinga/Authentication/UserGroup/DbUserGroupBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ public function insert($table, array $bind, array $types = array())
/**
* 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);
Expand All @@ -155,10 +155,10 @@ public function update($table, array $bind, Filter $filter = null, array $types
/**
* 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);
Expand Down
22 changes: 11 additions & 11 deletions library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -661,14 +661,14 @@ protected function retrieveUserName($dn)
/**
* 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);
Expand All @@ -683,15 +683,15 @@ public function requireTable($table, RepositoryQuery $query = null)
/**
* 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) {
Expand Down
8 changes: 4 additions & 4 deletions library/Icinga/Chart/Graph/BarGraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion library/Icinga/Chart/Graph/LineGraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function __construct(
array $dataset,
array &$graphs,
$order,
array $tooltips = null
?array $tooltips = null
) {
usort($dataset, array($this, 'sortByX'));
$this->dataset = $dataset;
Expand Down
Loading
Loading