*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @return void
*/
- protected function __construct () {
+ private function __construct () {
// Call parent constructor
parent::__construct(__CLASS__);
}
* @param $listInstance A list of a Listable
* @return $iteratorInstance An instance a Iterator class
*/
- public static final function createDefaultIterator (Listable $listInstance) {
+ public static final function createDefaultIterator (Listable $listInstance): DefaultIterator {
// Get new instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DEFAULT-ITERATOR: listInstance=%s - CALLED!', $listInstance));
$iteratorInstance = new DefaultIterator();
// Set the list
$iteratorInstance->setListInstance($listInstance);
// Return the prepared instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DEFAULT-ITERATOR: iteratorInstance=%s - EXIT!', $iteratorInstance));
return $iteratorInstance;
}
* @return $current Current value in iteration
* @throws IndexOutOfBoundsException If $indexKey is out of bounds
*/
- public function current () {
+ public function current (): mixed {
// Default is null
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('DEFAULT-ITERATOR: CALLED!');
$current = NULL;
// Is the entry valid?
if (!$this->valid()) {
// Throw an exception here
throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS);
- } // END - if
+ }
// Now get the entry
- $current = $this->getListInstance()->getEntry($this->key());
+ $current = $this->getListInstance()->getEntryByIndex($this->key());
// Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DEFAULT-ITERATOR: current[]=%s - EXIT!', gettype($current)));
return $current;
}
*
* @return $indexKey Current key in iteration
*/
- public function key () {
+ public function key (): int {
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DEFAULT-ITERATOR: this->indexKey=%d - EXIT!', $this->indexKey));
return $this->indexKey;
}
*
* @return void
*/
- public function next () {
+ public function next (): void {
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-HANDLER: CALLED!');
$this->indexKey++;
}
*
* @return void
*/
- public function rewind () {
+ public function rewind (): void {
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-HANDLER: CALLED!');
$this->indexKey = 0;
}
*
* @return $isValid Whether the current entry is there
*/
- public function valid () {
+ public function valid (): bool {
// Check for total active peers and if we are not at the end
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-HANDLER: CALLED!');
$isValid = ($this->key() < $this->getListInstance()->count());
// Return result
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-IO-HANDLER: isValid=%d - EXIT!', intval($isValid)));
return $isValid;
}