Skip to content

Commit

Permalink
Fix phpstan's Variable might not be defined error and add #[\Return…
Browse files Browse the repository at this point in the history
…TypeWillChange] to iterator methods
  • Loading branch information
sukhwinder33445 committed Jun 21, 2023
1 parent 4ab8345 commit c0c9c6d
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ protected function assembleElements()

$decorator = new IcingaFormDecorator();

$object = null;
foreach ($this->getObjects() as $object) {
/** @var Model $object */
// Nasty, but as getObjects() returns everything but an object with a real
Expand Down
1 change: 1 addition & 0 deletions application/forms/RedisConfigForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ public function onSuccess()
));

$useTls = $this->getElement('redis_tls')->isChecked();
$pem = null;
foreach (['ca', 'cert', 'key'] as $name) {
$textarea = $this->getElement('redis_' . $name . '_pem');
if ($useTls && $textarea !== null && ($pem = $textarea->getValue())) {
Expand Down
1 change: 1 addition & 0 deletions library/Icingadb/Common/CommandActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ public function sendCustomNotificationAction()
public function toggleFeaturesAction()
{
$commandObjects = $this->getCommandTargets();
$form = null;
if (count($commandObjects) > 1) {
$this->isGrantedOnCommandTargets('i/am-only-used/to-establish/the-object-auth-cache');
$form = new ToggleObjectFeaturesForm($this->getFeatureStatus());
Expand Down
1 change: 1 addition & 0 deletions library/Icingadb/Compat/UrlMigrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ protected function rewrite(Filter\Rule $filter, array $legacyColumns, Filter\Cha
if ($filter instanceof Filter\Condition) {
$column = $filter->getColumn();

$modelPath = null;
if (isset($legacyColumns[$column])) {
if ($legacyColumns[$column] === self::DROP) {
return false;
Expand Down
1 change: 1 addition & 0 deletions library/Icingadb/Data/CsvResultSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class CsvResultSet extends ResultSet
{
protected $isCacheDisabled = true;

#[\ReturnTypeWillChange]
public function current()
{
return $this->extractKeysAndValues(parent::current());
Expand Down
1 change: 1 addition & 0 deletions library/Icingadb/Data/JsonResultSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class JsonResultSet extends ResultSet
{
protected $isCacheDisabled = true;

#[\ReturnTypeWillChange]
public function current()
{
return $this->createObject(parent::current());
Expand Down
2 changes: 1 addition & 1 deletion library/Icingadb/Hook/CustomVarRendererHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ final public static function prepareForObject(Model $object): Closure
}
}

return function (string $key, $value) use ($hooks, $object) {
return function (string $key, $value) use ($hooks) {
$newKey = $key;
$newValue = $value;
$group = null;
Expand Down
1 change: 1 addition & 0 deletions library/Icingadb/Redis/VolatileStateResults.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public function isRedisUnavailable(): bool
return $this->redis === null;
}

#[ReturnTypeWillChange]
public function current()
{
if ($this->redis && ! $this->updatesApplied && ! $this->isCacheDisabled) {
Expand Down
2 changes: 2 additions & 0 deletions library/Icingadb/Web/Control/ViewModeSwitcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ protected function assemble()
*/
protected function getTitle(string $viewMode): string
{
$active = null;
$inactive = null;
switch ($viewMode) {
case 'minimal':
$active = t('Minimal view active');
Expand Down
4 changes: 4 additions & 0 deletions library/Icingadb/Widget/Detail/DowntimeCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class DowntimeCard extends BaseHtmlElement

protected $tag = 'div';

protected $start;

protected $end;

public function __construct(Downtime $downtime)
{
$this->downtime = $downtime;
Expand Down
1 change: 1 addition & 0 deletions library/Icingadb/Widget/Detail/ObjectDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ protected function getUsersAndUsergroups(): array
);
}

$userQuery = null;
if ($this->isPermittedRoute('users')) {
$userQuery = User::on($this->getDb());
$userQuery->filter($objectFilter);
Expand Down

0 comments on commit c0c9c6d

Please sign in to comment.