Ensure Return Type Compatibility with Internal Classes

This commit is contained in:
Johannes Meyer 2022-01-18 16:35:08 +01:00
parent f2b2893b51
commit c038e84fc2
53 changed files with 221 additions and 421 deletions

View File

@ -122,7 +122,7 @@ class Config implements Countable, Iterator, Selectable
* *
* @return int * @return int
*/ */
public function count() public function count(): int
{ {
return $this->select()->count(); return $this->select()->count();
} }
@ -130,11 +130,11 @@ class Config implements Countable, Iterator, Selectable
/** /**
* Reset the current position of the internal config object * Reset the current position of the internal config object
* *
* @return ConfigObject * @return void
*/ */
public function rewind() public function rewind(): void
{ {
return $this->config->rewind(); $this->config->rewind();
} }
/** /**
@ -142,7 +142,7 @@ class Config implements Countable, Iterator, Selectable
* *
* @return ConfigObject * @return ConfigObject
*/ */
public function current() public function current(): ConfigObject
{ {
return $this->config->current(); return $this->config->current();
} }
@ -152,7 +152,7 @@ class Config implements Countable, Iterator, Selectable
* *
* @return bool * @return bool
*/ */
public function valid() public function valid(): bool
{ {
return $this->config->valid(); return $this->config->valid();
} }
@ -162,7 +162,7 @@ class Config implements Countable, Iterator, Selectable
* *
* @return string * @return string
*/ */
public function key() public function key(): string
{ {
return $this->config->key(); return $this->config->key();
} }
@ -170,11 +170,11 @@ class Config implements Countable, Iterator, Selectable
/** /**
* Advance the position of the current iteration and return the new section * Advance the position of the current iteration and return the new section
* *
* @return ConfigObject * @return void
*/ */
public function next() public function next(): void
{ {
return $this->config->next(); $this->config->next();
} }
/** /**

View File

@ -34,26 +34,17 @@ class TicketPattern implements ArrayAccess
*/ */
protected $pattern; protected $pattern;
/** public function offsetExists($offset): bool
* {@inheritdoc}
*/
public function offsetExists($offset)
{ {
return isset($this->match[$offset]); return isset($this->match[$offset]);
} }
/** public function offsetGet($offset): ?string
* {@inheritdoc}
*/
public function offsetGet($offset)
{ {
return array_key_exists($offset, $this->match) ? $this->match[$offset] : null; return array_key_exists($offset, $this->match) ? $this->match[$offset] : null;
} }
/** public function offsetSet($offset, $value): void
* {@inheritdoc}
*/
public function offsetSet($offset, $value)
{ {
if ($offset === null) { if ($offset === null) {
$this->match[] = $value; $this->match[] = $value;
@ -62,10 +53,7 @@ class TicketPattern implements ArrayAccess
} }
} }
/** public function offsetUnset($offset): void
* {@inheritdoc}
*/
public function offsetUnset($offset)
{ {
unset($this->match[$offset]); unset($this->match[$offset]);
} }

View File

@ -6,6 +6,7 @@ namespace Icinga\Application;
use ArrayIterator; use ArrayIterator;
use IteratorAggregate; use IteratorAggregate;
use Icinga\Application\Libraries\Library; use Icinga\Application\Libraries\Library;
use Traversable;
class Libraries implements IteratorAggregate class Libraries implements IteratorAggregate
{ {
@ -17,7 +18,7 @@ class Libraries implements IteratorAggregate
* *
* @return ArrayIterator * @return ArrayIterator
*/ */
public function getIterator() public function getIterator(): Traversable
{ {
return new ArrayIterator($this->libraries); return new ArrayIterator($this->libraries);
} }

View File

@ -184,12 +184,12 @@ class AuthChain implements Authenticatable, Iterator
/** /**
* Rewind the chain * Rewind the chain
* *
* @return ConfigObject * @return void
*/ */
public function rewind() public function rewind(): void
{ {
$this->currentBackend = null; $this->currentBackend = null;
return $this->config->rewind(); $this->config->rewind();
} }
/** /**
@ -197,7 +197,7 @@ class AuthChain implements Authenticatable, Iterator
* *
* @return UserBackendInterface * @return UserBackendInterface
*/ */
public function current() public function current(): UserBackendInterface
{ {
return $this->currentBackend; return $this->currentBackend;
} }
@ -207,7 +207,7 @@ class AuthChain implements Authenticatable, Iterator
* *
* @return string * @return string
*/ */
public function key() public function key(): string
{ {
return $this->config->key(); return $this->config->key();
} }
@ -215,11 +215,11 @@ class AuthChain implements Authenticatable, Iterator
/** /**
* Move forward to the next user backend config * Move forward to the next user backend config
* *
* @return ConfigObject * @return void
*/ */
public function next() public function next(): void
{ {
return $this->config->next(); $this->config->next();
} }
/** /**
@ -228,7 +228,7 @@ class AuthChain implements Authenticatable, Iterator
* *
* @return bool * @return bool
*/ */
public function valid() public function valid(): bool
{ {
if (! $this->config->valid()) { if (! $this->config->valid()) {
// Stop when there are no more backends to check // Stop when there are no more backends to check

View File

@ -50,11 +50,11 @@ class ConfigObject extends ArrayDatasource implements Iterator, ArrayAccess
/** /**
* Reset the current position of $this->data * Reset the current position of $this->data
* *
* @return mixed * @return void
*/ */
public function rewind() public function rewind(): void
{ {
return reset($this->data); reset($this->data);
} }
/** /**
@ -62,6 +62,7 @@ class ConfigObject extends ArrayDatasource implements Iterator, ArrayAccess
* *
* @return mixed * @return mixed
*/ */
#[\ReturnTypeWillChange]
public function current() public function current()
{ {
return current($this->data); return current($this->data);
@ -72,7 +73,7 @@ class ConfigObject extends ArrayDatasource implements Iterator, ArrayAccess
* *
* @return bool * @return bool
*/ */
public function valid() public function valid(): bool
{ {
return key($this->data) !== null; return key($this->data) !== null;
} }
@ -80,9 +81,9 @@ class ConfigObject extends ArrayDatasource implements Iterator, ArrayAccess
/** /**
* Return the section's or property's name of the current iteration * Return the section's or property's name of the current iteration
* *
* @return mixed * @return string
*/ */
public function key() public function key(): string
{ {
return key($this->data); return key($this->data);
} }
@ -90,11 +91,11 @@ class ConfigObject extends ArrayDatasource implements Iterator, ArrayAccess
/** /**
* Advance the position of the current iteration and return the new section's or property's value * Advance the position of the current iteration and return the new section's or property's value
* *
* @return mixed * @return void
*/ */
public function next() public function next(): void
{ {
return next($this->data); next($this->data);
} }
/** /**
@ -153,7 +154,7 @@ class ConfigObject extends ArrayDatasource implements Iterator, ArrayAccess
* *
* @return bool * @return bool
*/ */
public function offsetExists($key) public function offsetExists($key): bool
{ {
return isset($this->$key); return isset($this->$key);
} }
@ -163,8 +164,9 @@ class ConfigObject extends ArrayDatasource implements Iterator, ArrayAccess
* *
* @param string $key The name of the property or section * @param string $key The name of the property or section
* *
* @return mixed|NULL The value or NULL in case $key does not exist * @return ?mixed The value or NULL in case $key does not exist
*/ */
#[\ReturnTypeWillChange]
public function offsetGet($key) public function offsetGet($key)
{ {
return $this->get($key); return $this->get($key);
@ -178,7 +180,7 @@ class ConfigObject extends ArrayDatasource implements Iterator, ArrayAccess
* *
* @throws ProgrammingError If the key is null * @throws ProgrammingError If the key is null
*/ */
public function offsetSet($key, $value) public function offsetSet($key, $value): void
{ {
if ($key === null) { if ($key === null) {
throw new ProgrammingError('Appending values without an explicit key is not supported'); throw new ProgrammingError('Appending values without an explicit key is not supported');
@ -192,7 +194,7 @@ class ConfigObject extends ArrayDatasource implements Iterator, ArrayAccess
* *
* @param string $key The property or section to remove * @param string $key The property or section to remove
*/ */
public function offsetUnset($key) public function offsetUnset($key): void
{ {
unset($this->$key); unset($this->$key);
} }

View File

@ -410,7 +410,7 @@ class DbQuery extends SimpleQuery
* *
* @return int * @return int
*/ */
public function count() public function count(): int
{ {
if ($this->count === null) { if ($this->count === null) {
$this->count = parent::count(); $this->count = parent::count();

View File

@ -165,7 +165,7 @@ class SimpleQuery implements QueryInterface, Queryable, Iterator
/** /**
* Start or rewind the iteration * Start or rewind the iteration
*/ */
public function rewind() public function rewind(): void
{ {
if ($this->iterator === null) { if ($this->iterator === null) {
$iterator = $this->ds->query($this); $iterator = $this->ds->query($this);
@ -184,8 +184,9 @@ class SimpleQuery implements QueryInterface, Queryable, Iterator
/** /**
* Fetch and return the current row of this query's result * Fetch and return the current row of this query's result
* *
* @return object * @return mixed
*/ */
#[\ReturnTypeWillChange]
public function current() public function current()
{ {
return $this->iterator->current(); return $this->iterator->current();
@ -196,7 +197,7 @@ class SimpleQuery implements QueryInterface, Queryable, Iterator
* *
* @return bool * @return bool
*/ */
public function valid() public function valid(): bool
{ {
$valid = $this->iterator->valid(); $valid = $this->iterator->valid();
if ($valid && $this->peekAhead && $this->hasLimit() && $this->iteratorPosition + 1 === $this->getLimit()) { if ($valid && $this->peekAhead && $this->hasLimit() && $this->iteratorPosition + 1 === $this->getLimit()) {
@ -221,6 +222,7 @@ class SimpleQuery implements QueryInterface, Queryable, Iterator
* *
* @return mixed * @return mixed
*/ */
#[\ReturnTypeWillChange]
public function key() public function key()
{ {
return $this->iterator->key(); return $this->iterator->key();
@ -229,7 +231,7 @@ class SimpleQuery implements QueryInterface, Queryable, Iterator
/** /**
* Advance to the next row of this query's result * Advance to the next row of this query's result
*/ */
public function next() public function next(): void
{ {
$this->iterator->next(); $this->iterator->next();
$this->iteratorPosition += 1; $this->iteratorPosition += 1;
@ -648,7 +650,7 @@ class SimpleQuery implements QueryInterface, Queryable, Iterator
* *
* @return int * @return int
*/ */
public function count() public function count(): int
{ {
$query = clone $this; $query = clone $this;
$query->limit(0, 0); $query->limit(0, 0);

View File

@ -5,6 +5,7 @@ namespace Icinga\Data\Tree;
use IteratorAggregate; use IteratorAggregate;
use LogicException; use LogicException;
use Traversable;
/** /**
* A simple tree * A simple tree
@ -80,10 +81,9 @@ class SimpleTree implements IteratorAggregate
} }
/** /**
* {@inheritdoc}
* @return TreeNodeIterator * @return TreeNodeIterator
*/ */
public function getIterator() public function getIterator(): Traversable
{ {
return new TreeNodeIterator($this->sentinel); return new TreeNodeIterator($this->sentinel);
} }

View File

@ -28,59 +28,37 @@ class TreeNodeIterator implements RecursiveIterator
$this->children = new ArrayIterator($node->getChildren()); $this->children = new ArrayIterator($node->getChildren());
} }
/** public function current(): TreeNode
* {@inheritdoc}
*/
public function current()
{ {
return $this->children->current(); return $this->children->current();
} }
/** public function key(): int
* {@inheritdoc}
*/
public function key()
{ {
return $this->children->key(); return $this->children->key();
} }
/** public function next(): void
* {@inheritdoc}
*/
public function next()
{ {
$this->children->next(); $this->children->next();
} }
/** public function rewind(): void
* {@inheritdoc}
*/
public function rewind()
{ {
$this->children->rewind(); $this->children->rewind();
} }
/** public function valid(): bool
* {@inheritdoc}
*/
public function valid()
{ {
return $this->children->valid(); return $this->children->valid();
} }
/** public function hasChildren(): bool
* {@inheritdoc}
*/
public function hasChildren()
{ {
return $this->current()->hasChildren(); return $this->current()->hasChildren();
} }
/** public function getChildren(): TreeNodeIterator
* {@inheritdoc}
* @return TreeNodeIterator
*/
public function getChildren()
{ {
return new static($this->current()); return new static($this->current());
} }

View File

@ -11,6 +11,7 @@ use Icinga\Exception\NotWritableError;
use InvalidArgumentException; use InvalidArgumentException;
use RecursiveDirectoryIterator; use RecursiveDirectoryIterator;
use RecursiveIteratorIterator; use RecursiveIteratorIterator;
use Traversable;
use UnexpectedValueException; use UnexpectedValueException;
/** /**
@ -35,7 +36,7 @@ class LocalFileStorage implements StorageInterface
$this->baseDir = rtrim($baseDir, DIRECTORY_SEPARATOR); $this->baseDir = rtrim($baseDir, DIRECTORY_SEPARATOR);
} }
public function getIterator() public function getIterator(): Traversable
{ {
try { try {
return new RecursiveIteratorIterator( return new RecursiveIteratorIterator(

View File

@ -19,7 +19,7 @@ interface StorageInterface extends IteratorAggregate
* *
* @throws NotReadableError If the file list can't be read * @throws NotReadableError If the file list can't be read
*/ */
public function getIterator(); public function getIterator(): Traversable;
/** /**
* Return whether the given file exists * Return whether the given file exists

View File

@ -44,7 +44,7 @@ class FileIterator extends EnumeratingFilterIterator
* *
* @return array * @return array
*/ */
public function current() public function current(): array
{ {
return $this->currentData; return $this->currentData;
} }
@ -56,7 +56,7 @@ class FileIterator extends EnumeratingFilterIterator
* *
* @throws FileReaderException If PHP failed parsing the PCRE pattern * @throws FileReaderException If PHP failed parsing the PCRE pattern
*/ */
public function accept() public function accept(): bool
{ {
$data = array(); $data = array();
$matched = preg_match( $matched = preg_match(

View File

@ -89,7 +89,7 @@ class FileReader implements Selectable, Countable
* *
* @return int * @return int
*/ */
public function count() public function count(): int
{ {
if ($this->count === null) { if ($this->count === null) {
$this->count = iterator_count($this->iterate()); $this->count = iterator_count($this->iterate());

View File

@ -30,7 +30,7 @@ class LogFileIterator implements Iterator
/** /**
* Value for static::current() * Value for static::current()
* *
* @var string * @var array
*/ */
protected $current; protected $current;
@ -68,40 +68,31 @@ class LogFileIterator implements Iterator
$this->fields = $fields; $this->fields = $fields;
} }
public function rewind() public function rewind(): void
{ {
$this->file->rewind(); $this->file->rewind();
$this->index = 0; $this->index = 0;
$this->nextMessage(); $this->nextMessage();
} }
public function next() public function next(): void
{ {
$this->file->next(); $this->file->next();
++$this->index; ++$this->index;
$this->nextMessage(); $this->nextMessage();
} }
/** public function current(): array
* @return string
*/
public function current()
{ {
return $this->current; return $this->current;
} }
/** public function key(): int
* @return int
*/
public function key()
{ {
return $this->index; return $this->index;
} }
/** public function valid(): bool
* @return boolean
*/
public function valid()
{ {
return $this->valid; return $this->valid;
} }

View File

@ -690,7 +690,7 @@ class RepositoryQuery implements QueryInterface, SortRules, FilterColumns, Itera
* *
* @return int * @return int
*/ */
public function count() public function count(): int
{ {
return $this->query->count(); return $this->query->count();
} }
@ -708,7 +708,7 @@ class RepositoryQuery implements QueryInterface, SortRules, FilterColumns, Itera
/** /**
* Start or rewind the iteration * Start or rewind the iteration
*/ */
public function rewind() public function rewind(): void
{ {
if ($this->iterator === null) { if ($this->iterator === null) {
if (! $this->hasOrder()) { if (! $this->hasOrder()) {
@ -735,8 +735,9 @@ class RepositoryQuery implements QueryInterface, SortRules, FilterColumns, Itera
/** /**
* Fetch and return the current row of this query's result * Fetch and return the current row of this query's result
* *
* @return object * @return mixed
*/ */
#[\ReturnTypeWillChange]
public function current() public function current()
{ {
$row = $this->iterator->current(); $row = $this->iterator->current();
@ -763,7 +764,7 @@ class RepositoryQuery implements QueryInterface, SortRules, FilterColumns, Itera
* *
* @return bool * @return bool
*/ */
public function valid() public function valid(): bool
{ {
if (! $this->iterator->valid()) { if (! $this->iterator->valid()) {
Benchmark::measure('Query result iteration finished'); Benchmark::measure('Query result iteration finished');
@ -778,6 +779,7 @@ class RepositoryQuery implements QueryInterface, SortRules, FilterColumns, Itera
* *
* @return mixed * @return mixed
*/ */
#[\ReturnTypeWillChange]
public function key() public function key()
{ {
return $this->iterator->key(); return $this->iterator->key();
@ -786,7 +788,7 @@ class RepositoryQuery implements QueryInterface, SortRules, FilterColumns, Itera
/** /**
* Advance to the next row of this query's result * Advance to the next row of this query's result
*/ */
public function next() public function next(): void
{ {
$this->iterator->next(); $this->iterator->next();
} }

View File

@ -49,7 +49,7 @@ class Preferences implements Countable
* *
* @return int The number of preferences * @return int The number of preferences
*/ */
public function count() public function count(): int
{ {
return count($this->preferences); return count($this->preferences);
} }

View File

@ -50,7 +50,7 @@ class DirectoryIterator implements RecursiveIterator
/** /**
* Current key * Current key
* *
* @var string * @var string|false
*/ */
private $key; private $key;
@ -122,35 +122,23 @@ class DirectoryIterator implements RecursiveIterator
return is_dir($path) && is_readable($path); return is_dir($path) && is_readable($path);
} }
/** public function hasChildren(): bool
* {@inheritdoc}
*/
public function hasChildren()
{ {
return static::isReadable($this->current); return static::isReadable($this->current);
} }
/** public function getChildren(): DirectoryIterator
* {@inheritdoc}
*/
public function getChildren()
{ {
return new static($this->current, $this->extension, $this->flags); return new static($this->current, $this->extension, $this->flags);
} }
#[\ReturnTypeWillChange]
/**
* {@inheritdoc}
*/
public function current() public function current()
{ {
return $this->current; return $this->current;
} }
/** public function next(): void
* {@inheritdoc}
*/
public function next()
{ {
do { do {
$this->files->next(); $this->files->next();
@ -200,26 +188,18 @@ class DirectoryIterator implements RecursiveIterator
$this->key = $file; $this->key = $file;
} }
/** #[\ReturnTypeWillChange]
* {@inheritdoc}
*/
public function key() public function key()
{ {
return $this->key; return $this->key;
} }
/** public function valid(): bool
* {@inheritdoc}
*/
public function valid()
{ {
return $this->current !== false; return $this->current !== false;
} }
/** public function rewind(): void
* {@inheritdoc}
*/
public function rewind()
{ {
if ($this->files === null) { if ($this->files === null) {
$files = scandir($this->path); $files = scandir($this->path);

View File

@ -17,19 +17,13 @@ abstract class EnumeratingFilterIterator extends FilterIterator
*/ */
private $index; private $index;
/** public function rewind(): void
* @return void
*/
public function rewind()
{ {
parent::rewind(); parent::rewind();
$this->index = 0; $this->index = 0;
} }
/** public function key(): int
* @return int
*/
public function key()
{ {
return $this->index++; return $this->index++;
} }

View File

@ -114,9 +114,7 @@ class File extends SplFileObject
} }
} }
/** #[\ReturnTypeWillChange]
* @see SplFileObject::fwrite()
*/
public function fwrite($str, $length = null) public function fwrite($str, $length = null)
{ {
$this->assertOpenForWriting(); $this->assertOpenForWriting();
@ -126,10 +124,7 @@ class File extends SplFileObject
return $retVal; return $retVal;
} }
/** public function ftruncate($size): bool
* @see SplFileObject::ftruncate()
*/
public function ftruncate($size)
{ {
$this->assertOpenForWriting(); $this->assertOpenForWriting();
$this->setupErrorHandler(); $this->setupErrorHandler();
@ -138,9 +133,7 @@ class File extends SplFileObject
return $retVal; return $retVal;
} }
/** #[\ReturnTypeWillChange]
* @see SplFileObject::ftell()
*/
public function ftell() public function ftell()
{ {
$this->setupErrorHandler(); $this->setupErrorHandler();
@ -149,10 +142,7 @@ class File extends SplFileObject
return $retVal; return $retVal;
} }
/** public function flock($operation, &$wouldblock = null): bool
* @see SplFileObject::flock()
*/
public function flock($operation, &$wouldblock = null)
{ {
$this->setupErrorHandler(); $this->setupErrorHandler();
$retVal = parent::flock($operation, $wouldblock); $retVal = parent::flock($operation, $wouldblock);
@ -160,9 +150,7 @@ class File extends SplFileObject
return $retVal; return $retVal;
} }
/** #[\ReturnTypeWillChange]
* @see SplFileObject::fgetc()
*/
public function fgetc() public function fgetc()
{ {
$this->setupErrorHandler(); $this->setupErrorHandler();
@ -171,10 +159,7 @@ class File extends SplFileObject
return $retVal; return $retVal;
} }
/** public function fflush(): bool
* @see SplFileObject::fflush()
*/
public function fflush()
{ {
$this->setupErrorHandler(); $this->setupErrorHandler();
$retVal = parent::fflush(); $retVal = parent::fflush();

View File

@ -5,6 +5,7 @@ namespace Icinga\Web;
use ArrayIterator; use ArrayIterator;
use IteratorAggregate; use IteratorAggregate;
use Traversable;
/** /**
* Maintain a set of cookies * Maintain a set of cookies
@ -23,7 +24,7 @@ class CookieSet implements IteratorAggregate
* *
* @return ArrayIterator An iterator for traversing the cookies in this set * @return ArrayIterator An iterator for traversing the cookies in this set
*/ */
public function getIterator() public function getIterator(): Traversable
{ {
return new ArrayIterator($this->cookies); return new ArrayIterator($this->cookies);
} }

View File

@ -47,59 +47,37 @@ class DomNodeIterator implements RecursiveIterator
$this->children = new IteratorIterator($node->childNodes); $this->children = new IteratorIterator($node->childNodes);
} }
/** public function current(): ?DOMNode
* {@inheritdoc}
*/
public function current()
{ {
return $this->children->current(); return $this->children->current();
} }
/** public function key(): int
* {@inheritdoc}
*/
public function key()
{ {
return $this->children->key(); return $this->children->key();
} }
/** public function next(): void
* {@inheritdoc}
*/
public function next()
{ {
$this->children->next(); $this->children->next();
} }
/** public function rewind(): void
* {@inheritdoc}
*/
public function rewind()
{ {
$this->children->rewind(); $this->children->rewind();
} }
/** public function valid(): bool
* {@inheritdoc}
*/
public function valid()
{ {
return $this->children->valid(); return $this->children->valid();
} }
/** public function hasChildren(): bool
* {@inheritdoc}
*/
public function hasChildren()
{ {
return $this->current()->hasChildNodes(); return $this->current()->hasChildNodes();
} }
/** public function getChildren(): DomNodeIterator
* {@inheritdoc}
* @return DomNodeIterator
*/
public function getChildren()
{ {
return new static($this->current()); return new static($this->current());
} }

View File

@ -67,50 +67,32 @@ class Navigation implements ArrayAccess, Countable, IteratorAggregate
*/ */
protected $layout; protected $layout;
/** public function offsetExists($offset): bool
* {@inheritdoc}
*/
public function offsetExists($offset)
{ {
return isset($this->items[$offset]); return isset($this->items[$offset]);
} }
/** public function offsetGet($offset): ?NavigationItem
* {@inheritdoc}
*/
public function offsetGet($offset)
{ {
return isset($this->items[$offset]) ? $this->items[$offset] : null; return $this->items[$offset] ?? null;
} }
/** public function offsetSet($offset, $value): void
* {@inheritdoc}
*/
public function offsetSet($offset, $value)
{ {
$this->items[$offset] = $value; $this->items[$offset] = $value;
} }
/** public function offsetUnset($offset): void
* {@inheritdoc}
*/
public function offsetUnset($offset)
{ {
unset($this->items[$offset]); unset($this->items[$offset]);
} }
/** public function count(): int
* {@inheritdoc}
*/
public function count()
{ {
return count($this->items); return count($this->items);
} }
/** public function getIterator(): Traversable
* {@inheritdoc}
*/
public function getIterator()
{ {
$this->order(); $this->order();
return new ArrayIterator($this->items); return new ArrayIterator($this->items);

View File

@ -13,6 +13,7 @@ use Icinga\Exception\IcingaException;
use Icinga\Exception\ProgrammingError; use Icinga\Exception\ProgrammingError;
use Icinga\Web\Navigation\Renderer\NavigationItemRenderer; use Icinga\Web\Navigation\Renderer\NavigationItemRenderer;
use Icinga\Web\Url; use Icinga\Web\Url;
use Traversable;
/** /**
* A navigation item * A navigation item
@ -171,9 +172,9 @@ class NavigationItem implements IteratorAggregate
} }
/** /**
* {@inheritdoc} * @return Navigation
*/ */
public function getIterator() public function getIterator(): Traversable
{ {
return $this->getChildren(); return $this->getChildren();
} }

View File

@ -165,52 +165,32 @@ class NavigationRenderer implements RecursiveIterator, NavigationRendererInterfa
return $this; return $this;
} }
/** public function getChildren(): NavigationRenderer
* {@inheritdoc}
*/
public function getChildren()
{ {
return new static($this->current()->getChildren(), $this->skipOuterElement); return new static($this->current()->getChildren(), $this->skipOuterElement);
} }
/** public function hasChildren(): bool
* {@inheritdoc}
*/
public function hasChildren()
{ {
return $this->current()->hasChildren(); return $this->current()->hasChildren();
} }
/** public function current(): NavigationItem
* {@inheritdoc}
*
* @return NavigationItem
*/
public function current()
{ {
return $this->iterator->current(); return $this->iterator->current();
} }
/** public function key(): int
* {@inheritdoc}
*/
public function key()
{ {
return $this->iterator->key(); return $this->iterator->key();
} }
/** public function next(): void
* {@inheritdoc}
*/
public function next()
{ {
$this->iterator->next(); $this->iterator->next();
} }
/** public function rewind(): void
* {@inheritdoc}
*/
public function rewind()
{ {
$this->iterator->rewind(); $this->iterator->rewind();
if (! $this->skipOuterElement) { if (! $this->skipOuterElement) {
@ -218,10 +198,7 @@ class NavigationRenderer implements RecursiveIterator, NavigationRendererInterfa
} }
} }
/** public function valid(): bool
* {@inheritdoc}
*/
public function valid()
{ {
$valid = $this->iterator->valid(); $valid = $this->iterator->valid();
if (! $this->skipOuterElement && !$valid) { if (! $this->skipOuterElement && !$valid) {

View File

@ -121,34 +121,22 @@ class RecursiveNavigationRenderer extends RecursiveIteratorIterator implements N
return $this->getInnerIterator()->getHeading(); return $this->getInnerIterator()->getHeading();
} }
/** public function beginIteration(): void
* {@inheritdoc}
*/
public function beginIteration()
{ {
$this->content[] = $this->getInnerIterator()->beginMarkup(); $this->content[] = $this->getInnerIterator()->beginMarkup();
} }
/** public function endIteration(): void
* {@inheritdoc}
*/
public function endIteration()
{ {
$this->content[] = $this->getInnerIterator()->endMarkup(); $this->content[] = $this->getInnerIterator()->endMarkup();
} }
/** public function beginChildren(): void
* {@inheritdoc}
*/
public function beginChildren()
{ {
$this->content[] = $this->getInnerIterator()->beginChildrenMarkup($this->getDepth() + 1); $this->content[] = $this->getInnerIterator()->beginChildrenMarkup($this->getDepth() + 1);
} }
/** public function endChildren(): void
* {@inheritdoc}
*/
public function endChildren()
{ {
$this->content[] = $this->getInnerIterator()->endChildrenMarkup(); $this->content[] = $this->getInnerIterator()->endChildrenMarkup();
$this->content[] = $this->getInnerIterator()->endItemMarkup(); $this->content[] = $this->getInnerIterator()->endItemMarkup();

View File

@ -73,7 +73,7 @@ class QueryAdapter implements Zend_Paginator_Adapter_Interface
* *
* @return int * @return int
*/ */
public function count() public function count(): int
{ {
if ($this->count === null) { if ($this->count === null) {
$this->count = $this->query->count(); $this->count = $this->query->count();

View File

@ -7,6 +7,7 @@ use Exception;
use ArrayIterator; use ArrayIterator;
use Icinga\Exception\IcingaException; use Icinga\Exception\IcingaException;
use IteratorAggregate; use IteratorAggregate;
use Traversable;
/** /**
* Container for session values * Container for session values
@ -32,7 +33,7 @@ class SessionNamespace implements IteratorAggregate
* *
* @return ArrayIterator * @return ArrayIterator
*/ */
public function getIterator() public function getIterator(): Traversable
{ {
return new ArrayIterator($this->getAll()); return new ArrayIterator($this->getAll());
} }

View File

@ -403,7 +403,7 @@ EOT;
* *
* @see Countable * @see Countable
*/ */
public function count() public function count(): int
{ {
return count($this->tabs); return count($this->tabs);
} }

View File

@ -64,11 +64,10 @@ class Zend_Controller_Action_HelperBroker_PriorityStack implements IteratorAggre
* Magic property overloading for unsetting if helper is exists by name * Magic property overloading for unsetting if helper is exists by name
* *
* @param string $helperName The helper name * @param string $helperName The helper name
* @return Zend_Controller_Action_Helper_Abstract
*/ */
public function __unset($helperName) public function __unset($helperName)
{ {
return $this->offsetUnset($helperName); $this->offsetUnset($helperName);
} }
/** /**
@ -86,9 +85,9 @@ class Zend_Controller_Action_HelperBroker_PriorityStack implements IteratorAggre
/** /**
* Return something iterable * Return something iterable
* *
* @return array * @return Traversable
*/ */
public function getIterator() public function getIterator(): Traversable
{ {
return new ArrayObject($this->_helpersByPriority); return new ArrayObject($this->_helpersByPriority);
} }
@ -97,9 +96,9 @@ class Zend_Controller_Action_HelperBroker_PriorityStack implements IteratorAggre
* offsetExists() * offsetExists()
* *
* @param int|string $priorityOrHelperName * @param int|string $priorityOrHelperName
* @return Zend_Controller_Action_HelperBroker_PriorityStack * @return bool
*/ */
public function offsetExists($priorityOrHelperName) public function offsetExists($priorityOrHelperName): bool
{ {
if (is_string($priorityOrHelperName)) { if (is_string($priorityOrHelperName)) {
return array_key_exists($priorityOrHelperName, $this->_helpersByNameRef); return array_key_exists($priorityOrHelperName, $this->_helpersByNameRef);
@ -112,9 +111,9 @@ class Zend_Controller_Action_HelperBroker_PriorityStack implements IteratorAggre
* offsetGet() * offsetGet()
* *
* @param int|string $priorityOrHelperName * @param int|string $priorityOrHelperName
* @return Zend_Controller_Action_HelperBroker_PriorityStack * @return Zend_Controller_Action_Helper_Abstract
*/ */
public function offsetGet($priorityOrHelperName) public function offsetGet($priorityOrHelperName): Zend_Controller_Action_Helper_Abstract
{ {
if (!$this->offsetExists($priorityOrHelperName)) { if (!$this->offsetExists($priorityOrHelperName)) {
throw new Zend_Controller_Action_Exception('A helper with priority ' . $priorityOrHelperName . ' does not exist.'); throw new Zend_Controller_Action_Exception('A helper with priority ' . $priorityOrHelperName . ' does not exist.');
@ -132,9 +131,8 @@ class Zend_Controller_Action_HelperBroker_PriorityStack implements IteratorAggre
* *
* @param int $priority * @param int $priority
* @param Zend_Controller_Action_Helper_Abstract $helper * @param Zend_Controller_Action_Helper_Abstract $helper
* @return Zend_Controller_Action_HelperBroker_PriorityStack
*/ */
public function offsetSet($priority, $helper) public function offsetSet($priority, $helper): void
{ {
$priority = (int) $priority; $priority = (int) $priority;
@ -161,16 +159,14 @@ class Zend_Controller_Action_HelperBroker_PriorityStack implements IteratorAggre
} }
krsort($this->_helpersByPriority); // always make sure priority and LIFO are both enforced krsort($this->_helpersByPriority); // always make sure priority and LIFO are both enforced
return $this;
} }
/** /**
* offsetUnset() * offsetUnset()
* *
* @param int|string $priorityOrHelperName Priority integer or the helper name * @param int|string $priorityOrHelperName Priority integer or the helper name
* @return Zend_Controller_Action_HelperBroker_PriorityStack
*/ */
public function offsetUnset($priorityOrHelperName) public function offsetUnset($priorityOrHelperName): void
{ {
if (!$this->offsetExists($priorityOrHelperName)) { if (!$this->offsetExists($priorityOrHelperName)) {
throw new Zend_Controller_Action_Exception('A helper with priority or name ' . $priorityOrHelperName . ' does not exist.'); throw new Zend_Controller_Action_Exception('A helper with priority or name ' . $priorityOrHelperName . ' does not exist.');
@ -187,7 +183,6 @@ class Zend_Controller_Action_HelperBroker_PriorityStack implements IteratorAggre
unset($this->_helpersByNameRef[$helperName]); unset($this->_helpersByNameRef[$helperName]);
unset($this->_helpersByPriority[$priority]); unset($this->_helpersByPriority[$priority]);
return $this;
} }
/** /**
@ -195,7 +190,7 @@ class Zend_Controller_Action_HelperBroker_PriorityStack implements IteratorAggre
* *
* @return int * @return int
*/ */
public function count() public function count(): int
{ {
return count($this->_helpersByPriority); return count($this->_helpersByPriority);
} }

View File

@ -252,7 +252,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega
* *
* @return IteratorIterator * @return IteratorIterator
*/ */
public function getIterator() public function getIterator(): Traversable
{ {
return new IteratorIterator($this->_stmt); return new IteratorIterator($this->_stmt);
} }

View File

@ -3246,6 +3246,7 @@ class Zend_Form implements Iterator, Countable, Zend_Validate_Interface
* @throws Zend_Form_Exception * @throws Zend_Form_Exception
* @return Zend_Form_Element|Zend_Form_DisplayGroup|Zend_Form * @return Zend_Form_Element|Zend_Form_DisplayGroup|Zend_Form
*/ */
#[\ReturnTypeWillChange]
public function current() public function current()
{ {
$this->_sort(); $this->_sort();
@ -3268,7 +3269,7 @@ class Zend_Form implements Iterator, Countable, Zend_Validate_Interface
* *
* @return string * @return string
*/ */
public function key() public function key(): string
{ {
$this->_sort(); $this->_sort();
return key($this->_order); return key($this->_order);
@ -3279,7 +3280,7 @@ class Zend_Form implements Iterator, Countable, Zend_Validate_Interface
* *
* @return void * @return void
*/ */
public function next() public function next(): void
{ {
$this->_sort(); $this->_sort();
next($this->_order); next($this->_order);
@ -3290,7 +3291,7 @@ class Zend_Form implements Iterator, Countable, Zend_Validate_Interface
* *
* @return void * @return void
*/ */
public function rewind() public function rewind(): void
{ {
$this->_sort(); $this->_sort();
reset($this->_order); reset($this->_order);
@ -3301,7 +3302,7 @@ class Zend_Form implements Iterator, Countable, Zend_Validate_Interface
* *
* @return bool * @return bool
*/ */
public function valid() public function valid(): bool
{ {
$this->_sort(); $this->_sort();
return (current($this->_order) !== false); return (current($this->_order) !== false);
@ -3312,7 +3313,7 @@ class Zend_Form implements Iterator, Countable, Zend_Validate_Interface
* *
* @return int * @return int
*/ */
public function count() public function count(): int
{ {
return count($this->_order); return count($this->_order);
} }

View File

@ -1036,7 +1036,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable
* *
* @return Zend_Form_Element * @return Zend_Form_Element
*/ */
public function current() public function current(): Zend_Form_Element
{ {
$this->_sort(); $this->_sort();
current($this->_elementOrder); current($this->_elementOrder);
@ -1049,7 +1049,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable
* *
* @return string * @return string
*/ */
public function key() public function key(): string
{ {
$this->_sort(); $this->_sort();
return key($this->_elementOrder); return key($this->_elementOrder);
@ -1060,7 +1060,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable
* *
* @return void * @return void
*/ */
public function next() public function next(): void
{ {
$this->_sort(); $this->_sort();
next($this->_elementOrder); next($this->_elementOrder);
@ -1071,7 +1071,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable
* *
* @return void * @return void
*/ */
public function rewind() public function rewind(): void
{ {
$this->_sort(); $this->_sort();
reset($this->_elementOrder); reset($this->_elementOrder);
@ -1082,7 +1082,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable
* *
* @return bool * @return bool
*/ */
public function valid() public function valid(): bool
{ {
$this->_sort(); $this->_sort();
return (current($this->_elementOrder) !== false); return (current($this->_elementOrder) !== false);
@ -1093,7 +1093,7 @@ class Zend_Form_DisplayGroup implements Iterator,Countable
* *
* @return int * @return int
*/ */
public function count() public function count(): int
{ {
return count($this->_elements); return count($this->_elements);
} }

View File

@ -510,7 +510,7 @@ class Zend_Paginator implements Countable, IteratorAggregate
* *
* @return integer * @return integer
*/ */
public function count() public function count(): int
{ {
if (!$this->_pageCount) { if (!$this->_pageCount) {
$this->_pageCount = $this->_calculatePageCount(); $this->_pageCount = $this->_calculatePageCount();
@ -812,7 +812,7 @@ class Zend_Paginator implements Countable, IteratorAggregate
* *
* @return Traversable * @return Traversable
*/ */
public function getIterator() public function getIterator(): Traversable
{ {
return $this->getCurrentItems(); return $this->getCurrentItems();
} }

View File

@ -86,6 +86,7 @@ class Zend_Paginator_SerializableLimitIterator extends LimitIterator implements
* @param int $offset * @param int $offset
* @return mixed * @return mixed
*/ */
#[\ReturnTypeWillChange]
public function offsetGet($offset) public function offsetGet($offset)
{ {
$currentOffset = $this->key(); $currentOffset = $this->key();
@ -102,7 +103,7 @@ class Zend_Paginator_SerializableLimitIterator extends LimitIterator implements
* @param int $offset * @param int $offset
* @param mixed $value * @param mixed $value
*/ */
public function offsetSet($offset, $value) public function offsetSet($offset, $value): void
{ {
} }
@ -111,7 +112,7 @@ class Zend_Paginator_SerializableLimitIterator extends LimitIterator implements
* *
* @param int $offset * @param int $offset
*/ */
public function offsetExists($offset) public function offsetExists($offset): bool
{ {
if ($offset > 0 && $offset < $this->_count) { if ($offset > 0 && $offset < $this->_count) {
try { try {
@ -136,7 +137,7 @@ class Zend_Paginator_SerializableLimitIterator extends LimitIterator implements
* *
* @param int $offset * @param int $offset
*/ */
public function offsetUnset($offset) public function offsetUnset($offset): void
{ {
} }
} }

View File

@ -230,7 +230,7 @@ class Zend_View_Helper_HeadLink extends Zend_View_Helper_Placeholder_Container_S
* @param array $value * @param array $value
* @return void * @return void
*/ */
public function offsetSet($index, $value) public function offsetSet($index, $value): void
{ {
if (!$this->_isValid($value)) { if (!$this->_isValid($value)) {
$e = new Zend_View_Exception('offsetSet() expects a data token; please use one of the custom offsetSet*() methods'); $e = new Zend_View_Exception('offsetSet() expects a data token; please use one of the custom offsetSet*() methods');
@ -238,7 +238,7 @@ class Zend_View_Helper_HeadLink extends Zend_View_Helper_Placeholder_Container_S
throw $e; throw $e;
} }
return $this->getContainer()->offsetSet($index, $value); $this->getContainer()->offsetSet($index, $value);
} }
/** /**

View File

@ -168,7 +168,8 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S
$item = $this->createData($type, $args[0], $args[1], $args[2]); $item = $this->createData($type, $args[0], $args[1], $args[2]);
if ('offsetSet' == $action) { if ('offsetSet' == $action) {
return $this->offsetSet($index, $item); $this->offsetSet($index, $item);
return $this;
} }
$this->$action($item); $this->$action($item);
@ -254,7 +255,7 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S
* @return void * @return void
* @throws Zend_View_Exception * @throws Zend_View_Exception
*/ */
public function offsetSet($index, $value) public function offsetSet($index, $value): void
{ {
if (!$this->_isValid($value)) { if (!$this->_isValid($value)) {
$e = new Zend_View_Exception('Invalid value passed to offsetSet; please use offsetSetName() or offsetSetHttpEquiv()'); $e = new Zend_View_Exception('Invalid value passed to offsetSet; please use offsetSetName() or offsetSetHttpEquiv()');
@ -262,7 +263,7 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S
throw $e; throw $e;
} }
return $this->getContainer()->offsetSet($index, $value); $this->getContainer()->offsetSet($index, $value);
} }
/** /**
@ -272,7 +273,7 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S
* @return void * @return void
* @throws Zend_View_Exception * @throws Zend_View_Exception
*/ */
public function offsetUnset($index) public function offsetUnset($index): void
{ {
if (!in_array($index, $this->getContainer()->getKeys())) { if (!in_array($index, $this->getContainer()->getKeys())) {
$e = new Zend_View_Exception('Invalid index passed to offsetUnset()'); $e = new Zend_View_Exception('Invalid index passed to offsetUnset()');
@ -280,7 +281,7 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S
throw $e; throw $e;
} }
return $this->getContainer()->offsetUnset($index); $this->getContainer()->offsetUnset($index);
} }
/** /**

View File

@ -363,7 +363,7 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container
* @param mixed $value * @param mixed $value
* @return void * @return void
*/ */
public function offsetSet($index, $value) public function offsetSet($index, $value): void
{ {
if (!$this->_isValid($value)) { if (!$this->_isValid($value)) {
$e = new Zend_View_Exception('Invalid argument passed to offsetSet(); please use one of the helper methods, offsetSetScript() or offsetSetFile()'); $e = new Zend_View_Exception('Invalid argument passed to offsetSet(); please use one of the helper methods, offsetSetScript() or offsetSetFile()');
@ -371,7 +371,7 @@ class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container
throw $e; throw $e;
} }
return $this->getContainer()->offsetSet($index, $value); $this->getContainer()->offsetSet($index, $value);
} }
/** /**

View File

@ -217,7 +217,7 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_
* @param mixed $value * @param mixed $value
* @return void * @return void
*/ */
public function offsetSet($index, $value) public function offsetSet($index, $value): void
{ {
if (!$this->_isValid($value)) { if (!$this->_isValid($value)) {
$e = new Zend_View_Exception('Invalid value passed to offsetSet; please use offsetSetStyle()'); $e = new Zend_View_Exception('Invalid value passed to offsetSet; please use offsetSetStyle()');
@ -225,7 +225,7 @@ class Zend_View_Helper_HeadStyle extends Zend_View_Helper_Placeholder_Container_
throw $e; throw $e;
} }
return $this->getContainer()->offsetSet($index, $value); $this->getContainer()->offsetSet($index, $value);
} }
/** /**

View File

@ -258,7 +258,7 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi
* *
* @return int * @return int
*/ */
public function count() public function count(): int
{ {
$container = $this->getContainer(); $container = $this->getContainer();
return count($container); return count($container);
@ -270,7 +270,7 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi
* @param string|int $offset * @param string|int $offset
* @return bool * @return bool
*/ */
public function offsetExists($offset) public function offsetExists($offset): bool
{ {
return $this->getContainer()->offsetExists($offset); return $this->getContainer()->offsetExists($offset);
} }
@ -281,6 +281,7 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi
* @param string|int $offset * @param string|int $offset
* @return mixed * @return mixed
*/ */
#[\ReturnTypeWillChange]
public function offsetGet($offset) public function offsetGet($offset)
{ {
return $this->getContainer()->offsetGet($offset); return $this->getContainer()->offsetGet($offset);
@ -293,9 +294,9 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi
* @param mixed $value * @param mixed $value
* @return void * @return void
*/ */
public function offsetSet($offset, $value) public function offsetSet($offset, $value): void
{ {
return $this->getContainer()->offsetSet($offset, $value); $this->getContainer()->offsetSet($offset, $value);
} }
/** /**
@ -304,9 +305,9 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi
* @param string|int $offset * @param string|int $offset
* @return void * @return void
*/ */
public function offsetUnset($offset) public function offsetUnset($offset): void
{ {
return $this->getContainer()->offsetUnset($offset); $this->getContainer()->offsetUnset($offset);
} }
/** /**
@ -314,7 +315,7 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi
* *
* @return Iterator * @return Iterator
*/ */
public function getIterator() public function getIterator(): Traversable
{ {
return $this->getContainer()->getIterator(); return $this->getContainer()->getIterator();
} }

View File

@ -41,7 +41,7 @@ class DocSectionFilterIterator extends RecursiveFilterIterator implements Counta
* @return bool Whether the current element of the iterator is acceptable * @return bool Whether the current element of the iterator is acceptable
* through this filter * through this filter
*/ */
public function accept() public function accept(): bool
{ {
$section = $this->current(); $section = $this->current();
/** @var \Icinga\Module\Doc\DocSection $section */ /** @var \Icinga\Module\Doc\DocSection $section */
@ -51,18 +51,12 @@ class DocSectionFilterIterator extends RecursiveFilterIterator implements Counta
return false; return false;
} }
/** public function getChildren(): self
* {@inheritdoc}
*/
public function getChildren()
{ {
return new static($this->getInnerIterator()->getChildren(), $this->chapter); return new static($this->getInnerIterator()->getChildren(), $this->chapter);
} }
/** public function count(): int
* {@inheritdoc}
*/
public function count()
{ {
return iterator_count($this); return iterator_count($this);
} }

View File

@ -9,10 +9,6 @@ use Icinga\Module\Doc\Search\DocSearchMatch;
/** /**
* Renderer for doc searches * Renderer for doc searches
*
* @method DocSearchIterator getInnerIterator() {
* @{inheritdoc}
* }
*/ */
class DocSearchRenderer extends DocRenderer class DocSearchRenderer extends DocRenderer
{ {
@ -33,45 +29,30 @@ class DocSearchRenderer extends DocRenderer
parent::__construct($iterator, RecursiveIteratorIterator::SELF_FIRST); parent::__construct($iterator, RecursiveIteratorIterator::SELF_FIRST);
} }
/** public function beginIteration(): void
* {@inheritdoc}
*/
public function beginIteration()
{ {
$this->content[] = '<nav role="navigation"><ul class="toc">'; $this->content[] = '<nav role="navigation"><ul class="toc">';
} }
/** public function endIteration(): void
* {@inheritdoc}
*/
public function endIteration()
{ {
$this->content[] = '</ul></nav>'; $this->content[] = '</ul></nav>';
} }
/** public function beginChildren(): void
* {@inheritdoc}
*/
public function beginChildren()
{ {
if ($this->getInnerIterator()->getMatches()) { if ($this->getInnerIterator()->getMatches()) {
$this->content[] = '<ul class="toc">'; $this->content[] = '<ul class="toc">';
} }
} }
/** public function endChildren(): void
* {@inheritdoc}
*/
public function endChildren()
{ {
if ($this->getInnerIterator()->getMatches()) { if ($this->getInnerIterator()->getMatches()) {
$this->content[] = '</ul>'; $this->content[] = '</ul>';
} }
} }
/**
* {@inheritdoc}
*/
public function render() public function render()
{ {
foreach ($this as $section) { foreach ($this as $section) {

View File

@ -3,16 +3,11 @@
namespace Icinga\Module\Doc\Renderer; namespace Icinga\Module\Doc\Renderer;
use Icinga\Web\View;
use Icinga\Data\Tree\TreeNodeIterator; use Icinga\Data\Tree\TreeNodeIterator;
use RecursiveIteratorIterator; use RecursiveIteratorIterator;
/** /**
* TOC renderer * TOC renderer
*
* @method TreeNodeIterator getInnerIterator() {
* {@inheritdoc}
* }
*/ */
class DocTocRenderer extends DocRenderer class DocTocRenderer extends DocRenderer
{ {
@ -47,41 +42,26 @@ class DocTocRenderer extends DocRenderer
parent::__construct($iterator, RecursiveIteratorIterator::SELF_FIRST); parent::__construct($iterator, RecursiveIteratorIterator::SELF_FIRST);
} }
/** public function beginIteration(): void
* {@inheritdoc}
*/
public function beginIteration()
{ {
$this->content[] = sprintf('<nav role="navigation"><%s class="%s">', static::HTML_LIST_TAG, static::CSS_CLASS); $this->content[] = sprintf('<nav role="navigation"><%s class="%s">', static::HTML_LIST_TAG, static::CSS_CLASS);
} }
/** public function endIteration(): void
* {@inheritdoc}
*/
public function endIteration()
{ {
$this->content[] = sprintf('</%s></nav>', static::HTML_LIST_TAG); $this->content[] = sprintf('</%s></nav>', static::HTML_LIST_TAG);
} }
/** public function beginChildren(): void
* {@inheritdoc}
*/
public function beginChildren()
{ {
$this->content[] = sprintf('<%s class="%s">', static::HTML_LIST_TAG, static::CSS_CLASS); $this->content[] = sprintf('<%s class="%s">', static::HTML_LIST_TAG, static::CSS_CLASS);
} }
/** public function endChildren(): void
* {@inheritdoc}
*/
public function endChildren()
{ {
$this->content[] = sprintf('</%s>', static::HTML_LIST_TAG); $this->content[] = sprintf('</%s>', static::HTML_LIST_TAG);
} }
/**
* {@inheritdoc}
*/
public function render() public function render()
{ {
if ($this->getInnerIterator()->isEmpty()) { if ($this->getInnerIterator()->isEmpty()) {

View File

@ -9,10 +9,6 @@ use Icinga\Data\Tree\TreeNodeIterator;
/** /**
* Iterator over doc sections that match a given search criteria * Iterator over doc sections that match a given search criteria
*
* @method TreeNodeIterator getInnerIterator() {
* {@inheritdoc}
* }
*/ */
class DocSearchIterator extends RecursiveFilterIterator class DocSearchIterator extends RecursiveFilterIterator
{ {
@ -48,7 +44,7 @@ class DocSearchIterator extends RecursiveFilterIterator
* @return bool Whether the current element of the iterator is acceptable * @return bool Whether the current element of the iterator is acceptable
* through this filter * through this filter
*/ */
public function accept() public function accept(): bool
{ {
$section = $this->current(); $section = $this->current();
/** @var $section \Icinga\Module\Doc\DocSection */ /** @var $section \Icinga\Module\Doc\DocSection */
@ -84,10 +80,7 @@ class DocSearchIterator extends RecursiveFilterIterator
return $this->search; return $this->search;
} }
/** public function getChildren(): self
* {@inheritdoc}
*/
public function getChildren()
{ {
return new static($this->getInnerIterator()->getChildren(), $this->search); return new static($this->getInnerIterator()->getChildren(), $this->search);
} }

View File

@ -22,10 +22,7 @@ class ColumnFilterIterator extends FilterIterator
parent::__construct(new ArrayIterator($columns)); parent::__construct(new ArrayIterator($columns));
} }
/** public function accept(): bool
* {@inheritdoc}
*/
public function accept()
{ {
$column = $this->current(); $column = $this->current();
return ! ($column instanceof Zend_Db_Expr || $column === '(NULL)'); return ! ($column instanceof Zend_Db_Expr || $column === '(NULL)');

View File

@ -10,7 +10,7 @@ class CustomvarProtectionIterator extends IteratorIterator
{ {
const IS_CV_RE = '~^_(host|service)_([a-zA-Z0-9_]+)$~'; const IS_CV_RE = '~^_(host|service)_([a-zA-Z0-9_]+)$~';
public function current() public function current(): object
{ {
$row = parent::current(); $row = parent::current();

View File

@ -17,6 +17,7 @@ use Icinga\Module\Monitoring\Backend\Ido\Query\IdoQuery;
use Icinga\Module\Monitoring\Backend\MonitoringBackend; use Icinga\Module\Monitoring\Backend\MonitoringBackend;
use Icinga\Web\Request; use Icinga\Web\Request;
use Icinga\Web\Url; use Icinga\Web\Url;
use Traversable;
/** /**
* A read-only view of an underlying query * A read-only view of an underlying query
@ -58,7 +59,7 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite
* *
* @return IdoQuery * @return IdoQuery
*/ */
public function getIterator() public function getIterator(): Traversable
{ {
return $this->getQuery(); return $this->getQuery();
} }
@ -499,7 +500,7 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite
* *
* @return int * @return int
*/ */
public function count() public function count(): int
{ {
return $this->query->count(); return $this->query->count();
} }

View File

@ -9,6 +9,7 @@ use Icinga\Data\Filter\Filter;
use Icinga\Data\Filterable; use Icinga\Data\Filterable;
use IteratorAggregate; use IteratorAggregate;
use Icinga\Module\Monitoring\Backend\MonitoringBackend; use Icinga\Module\Monitoring\Backend\MonitoringBackend;
use Traversable;
abstract class ObjectList implements Countable, IteratorAggregate, Filterable abstract class ObjectList implements Countable, IteratorAggregate, Filterable
{ {
@ -118,10 +119,7 @@ abstract class ObjectList implements Countable, IteratorAggregate, Filterable
return $this->objects; return $this->objects;
} }
/** public function count(): int
* @return int
*/
public function count()
{ {
if ($this->count === null) { if ($this->count === null) {
$this->count = (int) $this->backend $this->count = (int) $this->backend
@ -135,7 +133,7 @@ abstract class ObjectList implements Countable, IteratorAggregate, Filterable
return $this->count; return $this->count;
} }
public function getIterator() public function getIterator(): Traversable
{ {
if ($this->objects === null) { if ($this->objects === null) {
$this->fetch(); $this->fetch();

View File

@ -5,6 +5,7 @@ namespace Icinga\Module\Monitoring\Plugin;
use ArrayIterator; use ArrayIterator;
use IteratorAggregate; use IteratorAggregate;
use Traversable;
class PerfdataSet implements IteratorAggregate class PerfdataSet implements IteratorAggregate
{ {
@ -47,7 +48,7 @@ class PerfdataSet implements IteratorAggregate
* *
* @return ArrayIterator * @return ArrayIterator
*/ */
public function getIterator() public function getIterator(): Traversable
{ {
return new ArrayIterator($this->asArray()); return new ArrayIterator($this->asArray());
} }

View File

@ -12,6 +12,7 @@ use Icinga\Data\Filter\Filter;
use Icinga\Web\Hook; use Icinga\Web\Hook;
use Icinga\Web\Session\SessionNamespace; use Icinga\Web\Session\SessionNamespace;
use Icinga\Module\Monitoring\DataView\DataView; use Icinga\Module\Monitoring\DataView\DataView;
use Traversable;
/** /**
* Represents a set of events in a specific range of time * Represents a set of events in a specific range of time
@ -100,7 +101,7 @@ class TimeLine implements IteratorAggregate
* *
* @return ArrayIterator * @return ArrayIterator
*/ */
public function getIterator() public function getIterator(): Traversable
{ {
return new ArrayIterator($this->toArray()); return new ArrayIterator($this->toArray());
} }

View File

@ -207,7 +207,7 @@ class TimeRange implements Iterator
/** /**
* Reset the iterator to its initial state * Reset the iterator to its initial state
*/ */
public function rewind() public function rewind(): void
{ {
$this->current = clone $this->start; $this->current = clone $this->start;
} }
@ -217,7 +217,7 @@ class TimeRange implements Iterator
* *
* @return bool * @return bool
*/ */
public function valid() public function valid(): bool
{ {
if ($this->negative) { if ($this->negative) {
return $this->current > $this->end; return $this->current > $this->end;
@ -231,7 +231,7 @@ class TimeRange implements Iterator
* *
* @return StdClass * @return StdClass
*/ */
public function current() public function current(): object
{ {
return $this->getTimeframe($this->current); return $this->getTimeframe($this->current);
} }
@ -241,7 +241,7 @@ class TimeRange implements Iterator
* *
* @return int * @return int
*/ */
public function key() public function key(): int
{ {
return $this->current->getTimestamp(); return $this->current->getTimestamp();
} }
@ -249,7 +249,7 @@ class TimeRange implements Iterator
/** /**
* Advance the iterator position by one * Advance the iterator position by one
*/ */
public function next() public function next(): void
{ {
$this->applyInterval($this->current, 0); $this->applyInterval($this->current, 0);
} }

View File

@ -5,6 +5,7 @@ namespace Icinga\Module\Setup;
use LogicException; use LogicException;
use RecursiveIterator; use RecursiveIterator;
use Traversable;
/** /**
* Container to store and handle requirements * Container to store and handle requirements
@ -258,7 +259,7 @@ class RequirementSet implements RecursiveIterator
* *
* @return bool * @return bool
*/ */
public function hasChildren() public function hasChildren(): bool
{ {
$current = $this->current(); $current = $this->current();
return $current instanceof static; return $current instanceof static;
@ -267,9 +268,9 @@ class RequirementSet implements RecursiveIterator
/** /**
* Return a iterator for the current nested set of requirements * Return a iterator for the current nested set of requirements
* *
* @return RecursiveIterator * @return ?RecursiveIterator
*/ */
public function getChildren() public function getChildren(): ?RecursiveIterator
{ {
return $this->current(); return $this->current();
} }
@ -277,7 +278,7 @@ class RequirementSet implements RecursiveIterator
/** /**
* Rewind the iterator to its first element * Rewind the iterator to its first element
*/ */
public function rewind() public function rewind(): void
{ {
reset($this->requirements); reset($this->requirements);
} }
@ -287,7 +288,7 @@ class RequirementSet implements RecursiveIterator
* *
* @return bool * @return bool
*/ */
public function valid() public function valid(): bool
{ {
return $this->key() !== null; return $this->key() !== null;
} }
@ -297,6 +298,7 @@ class RequirementSet implements RecursiveIterator
* *
* @return Requirement|RequirementSet * @return Requirement|RequirementSet
*/ */
#[\ReturnTypeWillChange]
public function current() public function current()
{ {
return current($this->requirements); return current($this->requirements);
@ -307,7 +309,7 @@ class RequirementSet implements RecursiveIterator
* *
* @return int * @return int
*/ */
public function key() public function key(): int
{ {
return key($this->requirements); return key($this->requirements);
} }
@ -315,7 +317,7 @@ class RequirementSet implements RecursiveIterator
/** /**
* Advance the iterator to the next element * Advance the iterator to the next element
*/ */
public function next() public function next(): void
{ {
next($this->requirements); next($this->requirements);
} }

View File

@ -7,17 +7,17 @@ use RecursiveIteratorIterator;
class RequirementsRenderer extends RecursiveIteratorIterator class RequirementsRenderer extends RecursiveIteratorIterator
{ {
public function beginIteration() public function beginIteration(): void
{ {
$this->tags[] = '<ul class="requirements">'; $this->tags[] = '<ul class="requirements">';
} }
public function endIteration() public function endIteration(): void
{ {
$this->tags[] = '</ul>'; $this->tags[] = '</ul>';
} }
public function beginChildren() public function beginChildren(): void
{ {
$this->tags[] = '<li>'; $this->tags[] = '<li>';
$currentSet = $this->getSubIterator(); $currentSet = $this->getSubIterator();
@ -25,7 +25,7 @@ class RequirementsRenderer extends RecursiveIteratorIterator
$this->tags[] = '<ul class="set-state ' . $state . '">'; $this->tags[] = '<ul class="set-state ' . $state . '">';
} }
public function endChildren() public function endChildren(): void
{ {
$this->tags[] = '</ul>'; $this->tags[] = '</ul>';
$this->tags[] = '</li>'; $this->tags[] = '</li>';

View File

@ -6,6 +6,7 @@ namespace Icinga\Module\Setup;
use ArrayIterator; use ArrayIterator;
use IteratorAggregate; use IteratorAggregate;
use Icinga\Module\Setup\Exception\SetupException; use Icinga\Module\Setup\Exception\SetupException;
use Traversable;
/** /**
* Container for multiple configuration steps * Container for multiple configuration steps
@ -21,7 +22,7 @@ class Setup implements IteratorAggregate
$this->steps = array(); $this->steps = array();
} }
public function getIterator() public function getIterator(): Traversable
{ {
return new ArrayIterator($this->getSteps()); return new ArrayIterator($this->getSteps());
} }