Some more fixes to make phpstan happy

This commit is contained in:
Johannes Meyer 2024-03-14 14:52:30 +01:00
parent 66877a6ed0
commit 2a9c06e7f6
7 changed files with 21 additions and 23 deletions

View file

@ -496,9 +496,8 @@ class MigrateCommand extends Command
);
$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());
@ -595,9 +594,8 @@ class MigrateCommand extends Command
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;
@ -686,9 +684,8 @@ class MigrateCommand extends Command
$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;

View file

@ -50,7 +50,7 @@ class CommandTransport implements CommandTransportInterface
/**
* Create a transport from config
*
* @param ConfigObject $config
* @param ConfigObject<string> $config
*
* @return ApiCommandTransport
*
@ -59,7 +59,7 @@ class CommandTransport implements CommandTransportInterface
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;

View file

@ -361,13 +361,14 @@ trait CompatObject
*/
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;
}
}

View file

@ -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;
@ -18,7 +18,7 @@ use ipl\Web\Widget\Link;
/**
* Hostgroup item of a hostgroup list. Represents one database row.
*
* @property Hostgroup $item
* @property Hostgroupsummary $item
* @property HostgroupTable $table
*/
abstract class BaseHostGroupItem extends BaseTableRowItem

View file

@ -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;
@ -18,7 +18,7 @@ use ipl\Web\Widget\Link;
/**
* Servicegroup item of a servicegroup list. Represents one database row.
*
* @property Servicegroup $item
* @property ServicegroupSummary $item
* @property ServicegroupTable $table
*/
abstract class BaseServiceGroupItem extends BaseTableRowItem

View file

@ -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;
@ -13,7 +13,7 @@ use ipl\Stdlib\Filter;
/**
* Hostgroup table row of a hostgroup table. Represents one database row.
*
* @property Hostgroup $item
* @property Hostgroupsummary $item
* @property HostgroupTable $table
*/
class HostgroupTableRow extends BaseHostGroupItem

View file

@ -4,7 +4,7 @@
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;
@ -12,7 +12,7 @@ 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