Skip to content

Commit

Permalink
Some more fixes to make phpstan happy
Browse files Browse the repository at this point in the history
  • Loading branch information
nilmerg committed Mar 14, 2024
1 parent 66877a6 commit 2a9c06e
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 23 deletions.
9 changes: 3 additions & 6 deletions application/clicommands/MigrateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,9 +496,8 @@ public function dashboardAction(): void
);

$changed = false;
/** @var ConfigObject $dashboardConfig */
/** @var ConfigObject<string> $dashboardConfig */
foreach ($dashboardsConfig->getConfigObject() as $name => $dashboardConfig) {
/** @var ?string $dashboardUrlString */
$dashboardUrlString = $dashboardConfig->get('url');
if ($dashboardUrlString !== null) {
$dashBoardUrl = Url::fromPath($dashboardUrlString, [], new Request());
Expand Down Expand Up @@ -595,9 +594,8 @@ public function filterAction(): void
private function transformNavigationItems(Config $config, string $owner, int &$rc): bool
{
$updated = false;
/** @var ConfigObject $newConfigObject */
/** @var ConfigObject<string> $newConfigObject */
foreach ($config->getConfigObject() as $section => $newConfigObject) {
/** @var string $configOwner */
$configOwner = $newConfigObject->get('owner') ?? '';
if ($configOwner && $configOwner !== $owner) {
continue;
Expand Down Expand Up @@ -686,9 +684,8 @@ private function migrateNavigationItems(Config $config, string $owner, string $p
$newConfig = $config->getConfigFile() === $path ? $config : $this->readFromIni($path, $rc);

$updated = false;
/** @var ConfigObject $configObject */
/** @var ConfigObject<string> $configObject */
foreach ($config->getConfigObject() as $configObject) {
/** @var string $configOwner */
$configOwner = $configObject->get('owner') ?? '';
if ($configOwner && $configOwner !== $owner) {
continue;
Expand Down
4 changes: 2 additions & 2 deletions library/Icingadb/Command/Transport/CommandTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static function getConfig(): Config
/**
* Create a transport from config
*
* @param ConfigObject $config
* @param ConfigObject<string> $config
*
* @return ApiCommandTransport
*
Expand All @@ -59,7 +59,7 @@ public static function getConfig(): Config
public static function createTransport(ConfigObject $config): ApiCommandTransport
{
$config = clone $config;
switch (strtolower($config->transport)) {
switch (strtolower($config->transport ?? '')) {
case ApiCommandTransport::TRANSPORT:
$transport = new ApiCommandTransport();
break;
Expand Down
15 changes: 8 additions & 7 deletions library/Icingadb/Compat/CompatObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,14 @@ protected function getDataView()
*/
private function getBoolType($value)
{
switch ($value) {
case false:
return 0;
case true:
return 1;
case 'sticky':
return 2;
if ($value === 'sticky') {
return 2;
}

if (is_string($value)) {
return null;
}

return (int) $value;
}
}
4 changes: 2 additions & 2 deletions library/Icingadb/Widget/ItemTable/BaseHostGroupItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Icinga\Module\Icingadb\Widget\ItemTable;

use Icinga\Module\Icingadb\Common\Links;
use Icinga\Module\Icingadb\Model\Hostgroup;
use Icinga\Module\Icingadb\Model\Hostgroupsummary;
use ipl\Html\Attributes;
use ipl\Html\BaseHtmlElement;
use ipl\Html\HtmlElement;
Expand All @@ -18,7 +18,7 @@
/**
* Hostgroup item of a hostgroup list. Represents one database row.
*
* @property Hostgroup $item
* @property Hostgroupsummary $item
* @property HostgroupTable $table
*/
abstract class BaseHostGroupItem extends BaseTableRowItem
Expand Down
4 changes: 2 additions & 2 deletions library/Icingadb/Widget/ItemTable/BaseServiceGroupItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Icinga\Module\Icingadb\Widget\ItemTable;

use Icinga\Module\Icingadb\Common\Links;
use Icinga\Module\Icingadb\Model\Servicegroup;
use Icinga\Module\Icingadb\Model\ServicegroupSummary;
use ipl\Html\Attributes;
use ipl\Html\BaseHtmlElement;
use ipl\Html\HtmlElement;
Expand All @@ -18,7 +18,7 @@
/**
* Servicegroup item of a servicegroup list. Represents one database row.
*
* @property Servicegroup $item
* @property ServicegroupSummary $item
* @property ServicegroupTable $table
*/
abstract class BaseServiceGroupItem extends BaseTableRowItem
Expand Down
4 changes: 2 additions & 2 deletions library/Icingadb/Widget/ItemTable/HostgroupTableRow.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Icinga\Module\Icingadb\Widget\ItemTable;

use Icinga\Module\Icingadb\Model\Hostgroup;
use Icinga\Module\Icingadb\Model\Hostgroupsummary;
use Icinga\Module\Icingadb\Widget\Detail\HostStatistics;
use Icinga\Module\Icingadb\Widget\Detail\ServiceStatistics;
use ipl\Html\BaseHtmlElement;
Expand All @@ -13,7 +13,7 @@
/**
* Hostgroup table row of a hostgroup table. Represents one database row.
*
* @property Hostgroup $item
* @property Hostgroupsummary $item
* @property HostgroupTable $table
*/
class HostgroupTableRow extends BaseHostGroupItem
Expand Down
4 changes: 2 additions & 2 deletions library/Icingadb/Widget/ItemTable/ServicegroupTableRow.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

namespace Icinga\Module\Icingadb\Widget\ItemTable;

use Icinga\Module\Icingadb\Model\Servicegroup;
use Icinga\Module\Icingadb\Model\ServicegroupSummary;
use Icinga\Module\Icingadb\Widget\Detail\ServiceStatistics;
use ipl\Html\BaseHtmlElement;
use ipl\Stdlib\Filter;

/**
* Servicegroup item of a servicegroup list. Represents one database row.
*
* @property Servicegroup $item
* @property ServicegroupSummary $item
* @property ServicegroupTable $table
*/
class ServicegroupTableRow extends BaseServiceGroupItem
Expand Down

0 comments on commit 2a9c06e

Please sign in to comment.