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
*/
public function count()
public function count(): int
{
return $this->select()->count();
}
@ -130,11 +130,11 @@ class Config implements Countable, Iterator, Selectable
/**
* 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
*/
public function current()
public function current(): ConfigObject
{
return $this->config->current();
}
@ -152,7 +152,7 @@ class Config implements Countable, Iterator, Selectable
*
* @return bool
*/
public function valid()
public function valid(): bool
{
return $this->config->valid();
}
@ -162,7 +162,7 @@ class Config implements Countable, Iterator, Selectable
*
* @return string
*/
public function key()
public function key(): string
{
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
*
* @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;
/**
* {@inheritdoc}
*/
public function offsetExists($offset)
public function offsetExists($offset): bool
{
return isset($this->match[$offset]);
}
/**
* {@inheritdoc}
*/
public function offsetGet($offset)
public function offsetGet($offset): ?string
{
return array_key_exists($offset, $this->match) ? $this->match[$offset] : null;
}
/**
* {@inheritdoc}
*/
public function offsetSet($offset, $value)
public function offsetSet($offset, $value): void
{
if ($offset === null) {
$this->match[] = $value;
@ -62,10 +53,7 @@ class TicketPattern implements ArrayAccess
}
}
/**
* {@inheritdoc}
*/
public function offsetUnset($offset)
public function offsetUnset($offset): void
{
unset($this->match[$offset]);
}

View File

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

View File

@ -184,12 +184,12 @@ class AuthChain implements Authenticatable, Iterator
/**
* Rewind the chain
*
* @return ConfigObject
* @return void
*/
public function rewind()
public function rewind(): void
{
$this->currentBackend = null;
return $this->config->rewind();
$this->config->rewind();
}
/**
@ -197,7 +197,7 @@ class AuthChain implements Authenticatable, Iterator
*
* @return UserBackendInterface
*/
public function current()
public function current(): UserBackendInterface
{
return $this->currentBackend;
}
@ -207,7 +207,7 @@ class AuthChain implements Authenticatable, Iterator
*
* @return string
*/
public function key()
public function key(): string
{
return $this->config->key();
}
@ -215,11 +215,11 @@ class AuthChain implements Authenticatable, Iterator
/**
* 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
*/
public function valid()
public function valid(): bool
{
if (! $this->config->valid()) {
// 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
*
* @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
*/
#[\ReturnTypeWillChange]
public function current()
{
return current($this->data);
@ -72,7 +73,7 @@ class ConfigObject extends ArrayDatasource implements Iterator, ArrayAccess
*
* @return bool
*/
public function valid()
public function valid(): bool
{
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 mixed
* @return string
*/
public function key()
public function key(): string
{
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
*
* @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
*/
public function offsetExists($key)
public function offsetExists($key): bool
{
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
*
* @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)
{
return $this->get($key);
@ -178,7 +180,7 @@ class ConfigObject extends ArrayDatasource implements Iterator, ArrayAccess
*
* @throws ProgrammingError If the key is null
*/
public function offsetSet($key, $value)
public function offsetSet($key, $value): void
{
if ($key === null) {
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
*/
public function offsetUnset($key)
public function offsetUnset($key): void
{
unset($this->$key);
}

View File

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

View File

@ -165,7 +165,7 @@ class SimpleQuery implements QueryInterface, Queryable, Iterator
/**
* Start or rewind the iteration
*/
public function rewind()
public function rewind(): void
{
if ($this->iterator === null) {
$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
*
* @return object
* @return mixed
*/
#[\ReturnTypeWillChange]
public function current()
{
return $this->iterator->current();
@ -196,7 +197,7 @@ class SimpleQuery implements QueryInterface, Queryable, Iterator
*
* @return bool
*/
public function valid()
public function valid(): bool
{
$valid = $this->iterator->valid();
if ($valid && $this->peekAhead && $this->hasLimit() && $this->iteratorPosition + 1 === $this->getLimit()) {
@ -221,6 +222,7 @@ class SimpleQuery implements QueryInterface, Queryable, Iterator
*
* @return mixed
*/
#[\ReturnTypeWillChange]
public function 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
*/
public function next()
public function next(): void
{
$this->iterator->next();
$this->iteratorPosition += 1;
@ -648,7 +650,7 @@ class SimpleQuery implements QueryInterface, Queryable, Iterator
*
* @return int
*/
public function count()
public function count(): int
{
$query = clone $this;
$query->limit(0, 0);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -690,7 +690,7 @@ class RepositoryQuery implements QueryInterface, SortRules, FilterColumns, Itera
*
* @return int
*/
public function count()
public function count(): int
{
return $this->query->count();
}
@ -708,7 +708,7 @@ class RepositoryQuery implements QueryInterface, SortRules, FilterColumns, Itera
/**
* Start or rewind the iteration
*/
public function rewind()
public function rewind(): void
{
if ($this->iterator === null) {
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
*
* @return object
* @return mixed
*/
#[\ReturnTypeWillChange]
public function current()
{
$row = $this->iterator->current();
@ -763,7 +764,7 @@ class RepositoryQuery implements QueryInterface, SortRules, FilterColumns, Itera
*
* @return bool
*/
public function valid()
public function valid(): bool
{
if (! $this->iterator->valid()) {
Benchmark::measure('Query result iteration finished');
@ -778,6 +779,7 @@ class RepositoryQuery implements QueryInterface, SortRules, FilterColumns, Itera
*
* @return mixed
*/
#[\ReturnTypeWillChange]
public function 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
*/
public function next()
public function next(): void
{
$this->iterator->next();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -403,7 +403,7 @@ EOT;
*
* @see Countable
*/
public function count()
public function count(): int
{
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
*
* @param string $helperName The helper name
* @return Zend_Controller_Action_Helper_Abstract
*/
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 array
* @return Traversable
*/
public function getIterator()
public function getIterator(): Traversable
{
return new ArrayObject($this->_helpersByPriority);
}
@ -97,9 +96,9 @@ class Zend_Controller_Action_HelperBroker_PriorityStack implements IteratorAggre
* offsetExists()
*
* @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)) {
return array_key_exists($priorityOrHelperName, $this->_helpersByNameRef);
@ -112,9 +111,9 @@ class Zend_Controller_Action_HelperBroker_PriorityStack implements IteratorAggre
* offsetGet()
*
* @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)) {
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 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;
@ -161,16 +159,14 @@ class Zend_Controller_Action_HelperBroker_PriorityStack implements IteratorAggre
}
krsort($this->_helpersByPriority); // always make sure priority and LIFO are both enforced
return $this;
}
/**
* offsetUnset()
*
* @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)) {
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->_helpersByPriority[$priority]);
return $this;
}
/**
@ -195,7 +190,7 @@ class Zend_Controller_Action_HelperBroker_PriorityStack implements IteratorAggre
*
* @return int
*/
public function count()
public function count(): int
{
return count($this->_helpersByPriority);
}

View File

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

View File

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

View File

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

View File

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

View File

@ -86,6 +86,7 @@ class Zend_Paginator_SerializableLimitIterator extends LimitIterator implements
* @param int $offset
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
$currentOffset = $this->key();
@ -102,7 +103,7 @@ class Zend_Paginator_SerializableLimitIterator extends LimitIterator implements
* @param int $offset
* @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
*/
public function offsetExists($offset)
public function offsetExists($offset): bool
{
if ($offset > 0 && $offset < $this->_count) {
try {
@ -136,7 +137,7 @@ class Zend_Paginator_SerializableLimitIterator extends LimitIterator implements
*
* @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
* @return void
*/
public function offsetSet($index, $value)
public function offsetSet($index, $value): void
{
if (!$this->_isValid($value)) {
$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;
}
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]);
if ('offsetSet' == $action) {
return $this->offsetSet($index, $item);
$this->offsetSet($index, $item);
return $this;
}
$this->$action($item);
@ -254,7 +255,7 @@ class Zend_View_Helper_HeadMeta extends Zend_View_Helper_Placeholder_Container_S
* @return void
* @throws Zend_View_Exception
*/
public function offsetSet($index, $value)
public function offsetSet($index, $value): void
{
if (!$this->_isValid($value)) {
$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;
}
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
* @throws Zend_View_Exception
*/
public function offsetUnset($index)
public function offsetUnset($index): void
{
if (!in_array($index, $this->getContainer()->getKeys())) {
$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;
}
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
* @return void
*/
public function offsetSet($index, $value)
public function offsetSet($index, $value): void
{
if (!$this->_isValid($value)) {
$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;
}
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
* @return void
*/
public function offsetSet($index, $value)
public function offsetSet($index, $value): void
{
if (!$this->_isValid($value)) {
$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;
}
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
*/
public function count()
public function count(): int
{
$container = $this->getContainer();
return count($container);
@ -270,7 +270,7 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi
* @param string|int $offset
* @return bool
*/
public function offsetExists($offset)
public function offsetExists($offset): bool
{
return $this->getContainer()->offsetExists($offset);
}
@ -281,6 +281,7 @@ abstract class Zend_View_Helper_Placeholder_Container_Standalone extends Zend_Vi
* @param string|int $offset
* @return mixed
*/
#[\ReturnTypeWillChange]
public function 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
* @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
* @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
*/
public function getIterator()
public function getIterator(): Traversable
{
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
* through this filter
*/
public function accept()
public function accept(): bool
{
$section = $this->current();
/** @var \Icinga\Module\Doc\DocSection $section */
@ -51,18 +51,12 @@ class DocSectionFilterIterator extends RecursiveFilterIterator implements Counta
return false;
}
/**
* {@inheritdoc}
*/
public function getChildren()
public function getChildren(): self
{
return new static($this->getInnerIterator()->getChildren(), $this->chapter);
}
/**
* {@inheritdoc}
*/
public function count()
public function count(): int
{
return iterator_count($this);
}

View File

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

View File

@ -3,16 +3,11 @@
namespace Icinga\Module\Doc\Renderer;
use Icinga\Web\View;
use Icinga\Data\Tree\TreeNodeIterator;
use RecursiveIteratorIterator;
/**
* TOC renderer
*
* @method TreeNodeIterator getInnerIterator() {
* {@inheritdoc}
* }
*/
class DocTocRenderer extends DocRenderer
{
@ -47,41 +42,26 @@ class DocTocRenderer extends DocRenderer
parent::__construct($iterator, RecursiveIteratorIterator::SELF_FIRST);
}
/**
* {@inheritdoc}
*/
public function beginIteration()
public function beginIteration(): void
{
$this->content[] = sprintf('<nav role="navigation"><%s class="%s">', static::HTML_LIST_TAG, static::CSS_CLASS);
}
/**
* {@inheritdoc}
*/
public function endIteration()
public function endIteration(): void
{
$this->content[] = sprintf('</%s></nav>', static::HTML_LIST_TAG);
}
/**
* {@inheritdoc}
*/
public function beginChildren()
public function beginChildren(): void
{
$this->content[] = sprintf('<%s class="%s">', static::HTML_LIST_TAG, static::CSS_CLASS);
}
/**
* {@inheritdoc}
*/
public function endChildren()
public function endChildren(): void
{
$this->content[] = sprintf('</%s>', static::HTML_LIST_TAG);
}
/**
* {@inheritdoc}
*/
public function render()
{
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
*
* @method TreeNodeIterator getInnerIterator() {
* {@inheritdoc}
* }
*/
class DocSearchIterator extends RecursiveFilterIterator
{
@ -48,7 +44,7 @@ class DocSearchIterator extends RecursiveFilterIterator
* @return bool Whether the current element of the iterator is acceptable
* through this filter
*/
public function accept()
public function accept(): bool
{
$section = $this->current();
/** @var $section \Icinga\Module\Doc\DocSection */
@ -84,10 +80,7 @@ class DocSearchIterator extends RecursiveFilterIterator
return $this->search;
}
/**
* {@inheritdoc}
*/
public function getChildren()
public function getChildren(): self
{
return new static($this->getInnerIterator()->getChildren(), $this->search);
}

View File

@ -22,10 +22,7 @@ class ColumnFilterIterator extends FilterIterator
parent::__construct(new ArrayIterator($columns));
}
/**
* {@inheritdoc}
*/
public function accept()
public function accept(): bool
{
$column = $this->current();
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_]+)$~';
public function current()
public function current(): object
{
$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\Web\Request;
use Icinga\Web\Url;
use Traversable;
/**
* A read-only view of an underlying query
@ -58,7 +59,7 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite
*
* @return IdoQuery
*/
public function getIterator()
public function getIterator(): Traversable
{
return $this->getQuery();
}
@ -499,7 +500,7 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite
*
* @return int
*/
public function count()
public function count(): int
{
return $this->query->count();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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