Director: some PHP 8.1-related changes

This commit is contained in:
Thomas Gelf 2021-11-28 11:13:08 +01:00
parent ac575858dc
commit 82656de2c2
8 changed files with 24 additions and 5 deletions

View File

@ -93,7 +93,8 @@ class SyncPropertyForm extends DirectorObjectForm
$this->setElementValue('use_filter', $useFilter = 'n'); $this->setElementValue('use_filter', $useFilter = 'n');
} }
} else { } else {
$useFilter = strlen($this->getObject()->filter_expression) ? 'y' : 'n'; $expression = $this->getObject()->filter_expression;
$useFilter = ($expression === null || strlen($expression) === 0) ? 'n' : 'y';
$this->setElementValue('use_filter', $useFilter); $this->setElementValue('use_filter', $useFilter);
} }

View File

@ -284,7 +284,7 @@ class IcingaConfigHelper
return null; return null;
} }
if (ctype_digit($interval)) { if (is_int($interval) || ctype_digit($interval)) {
return (int) $interval; return (int) $interval;
} }

View File

@ -184,7 +184,7 @@ class Sync
$this->hasPropertyDisabled = true; $this->hasPropertyDisabled = true;
} }
if (! strlen($prop->get('filter_expression'))) { if ($prop->get('filter_expression') === null || strlen($prop->get('filter_expression')) === 0) {
continue; continue;
} }

View File

@ -30,11 +30,13 @@ class IcingaArguments implements Iterator, Countable, IcingaConfigRenderer
$this->object = $object; $this->object = $object;
} }
#[\ReturnTypeWillChange]
public function count() public function count()
{ {
return count($this->arguments); return count($this->arguments);
} }
#[\ReturnTypeWillChange]
public function rewind() public function rewind()
{ {
$this->position = 0; $this->position = 0;
@ -45,6 +47,7 @@ class IcingaArguments implements Iterator, Countable, IcingaConfigRenderer
return $this->modified; return $this->modified;
} }
#[\ReturnTypeWillChange]
public function current() public function current()
{ {
if (! $this->valid()) { if (! $this->valid()) {
@ -54,16 +57,19 @@ class IcingaArguments implements Iterator, Countable, IcingaConfigRenderer
return $this->arguments[$this->idx[$this->position]]; return $this->arguments[$this->idx[$this->position]];
} }
#[\ReturnTypeWillChange]
public function key() public function key()
{ {
return $this->idx[$this->position]; return $this->idx[$this->position];
} }
#[\ReturnTypeWillChange]
public function next() public function next()
{ {
++$this->position; ++$this->position;
} }
#[\ReturnTypeWillChange]
public function valid() public function valid()
{ {
return array_key_exists($this->position, $this->idx); return array_key_exists($this->position, $this->idx);

View File

@ -57,11 +57,13 @@ class IcingaObjectMultiRelations implements Iterator, Countable, IcingaConfigRen
return $this->relations; return $this->relations;
} }
#[\ReturnTypeWillChange]
public function count() public function count()
{ {
return count($this->relations); return count($this->relations);
} }
#[\ReturnTypeWillChange]
public function rewind() public function rewind()
{ {
$this->position = 0; $this->position = 0;
@ -72,6 +74,7 @@ class IcingaObjectMultiRelations implements Iterator, Countable, IcingaConfigRen
return $this->modified; return $this->modified;
} }
#[\ReturnTypeWillChange]
public function current() public function current()
{ {
if (! $this->valid()) { if (! $this->valid()) {
@ -81,16 +84,19 @@ class IcingaObjectMultiRelations implements Iterator, Countable, IcingaConfigRen
return $this->relations[$this->idx[$this->position]]; return $this->relations[$this->idx[$this->position]];
} }
#[\ReturnTypeWillChange]
public function key() public function key()
{ {
return $this->idx[$this->position]; return $this->idx[$this->position];
} }
#[\ReturnTypeWillChange]
public function next() public function next()
{ {
++$this->position; ++$this->position;
} }
#[\ReturnTypeWillChange]
public function valid() public function valid()
{ {
return array_key_exists($this->position, $this->idx); return array_key_exists($this->position, $this->idx);

View File

@ -30,11 +30,13 @@ class IcingaTimePeriodRanges implements Iterator, Countable, IcingaConfigRendere
$this->object = $object; $this->object = $object;
} }
#[\ReturnTypeWillChange]
public function count() public function count()
{ {
return count($this->ranges); return count($this->ranges);
} }
#[\ReturnTypeWillChange]
public function rewind() public function rewind()
{ {
$this->position = 0; $this->position = 0;
@ -45,6 +47,7 @@ class IcingaTimePeriodRanges implements Iterator, Countable, IcingaConfigRendere
return $this->modified; return $this->modified;
} }
#[\ReturnTypeWillChange]
public function current() public function current()
{ {
if (! $this->valid()) { if (! $this->valid()) {
@ -54,16 +57,19 @@ class IcingaTimePeriodRanges implements Iterator, Countable, IcingaConfigRendere
return $this->ranges[$this->idx[$this->position]]; return $this->ranges[$this->idx[$this->position]];
} }
#[\ReturnTypeWillChange]
public function key() public function key()
{ {
return $this->idx[$this->position]; return $this->idx[$this->position];
} }
#[\ReturnTypeWillChange]
public function next() public function next()
{ {
++$this->position; ++$this->position;
} }
#[\ReturnTypeWillChange]
public function valid() public function valid()
{ {
return array_key_exists($this->position, $this->idx); return array_key_exists($this->position, $this->idx);

View File

@ -31,7 +31,7 @@ class DatafieldCategoryTable extends ZfQueryBasedTable
['name' => $row->category_name] ['name' => $row->category_name]
)]; )];
if (strlen($row->description)) { if ($row->description !== null && strlen($row->description)) {
$main[] = Html::tag('br'); $main[] = Html::tag('br');
$main[] = Html::tag('small', $row->description); $main[] = Html::tag('small', $row->description);
} }

View File

@ -25,7 +25,7 @@ class ImportSourceDetails extends HtmlDocument
{ {
$source = $this->source; $source = $this->source;
$description = $source->get('description'); $description = $source->get('description');
if (strlen($description)) { if ($description !== null && strlen($description)) {
$this->add(Html::tag('p', null, $description)); $this->add(Html::tag('p', null, $description));
} }