*
* @return $criteriaInstance An instance of this criteria
*/
- public static final function createSearchCriteria () {
+ public static final function createSearchCriteria (): SearchCriteria {
// Get a new instance
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('SEARCH-CRITERIA: CALLED!');
$criteriaInstance = new SearchCriteria();
* @return void
* @throws InvalidArgumentException If a paramter has an invalid value
*/
- public final function setConfiguredLimit (string $configKey) {
+ public final function setConfiguredLimit (string $configKey): void {
// Check parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SEARCH-CRITERIA: configKey=%s - CALLED!', $configKey));
if (empty($configKey)) {
*
* @return $limit Search limit
*/
- public final function getLimit () {
+ public final function getLimit (): int {
return $this->limit;
}
* @return void
* @todo Find a nice casting here. (int) allows until and including 32766.
*/
- public final function setSkip (int $skip) {
+ public final function setSkip (int $skip): void {
$this->skip = $skip;
}
*
* @return $skip Search skip
*/
- public final function getSkip () {
+ public final function getSkip (): int {
return $this->skip;
}
* @throws InvalidArgumentException If a parameter is invalid
* @throws UnexpectedValueException If $searchChoice is not an array
*/
- public function isCriteriaMatching (string $key, $value, string $separator = ',') {
+ public function isCriteriaMatching (string $key, $value, string $separator = ','): bool {
// $key/$value cannot be array/NULL/bool, value can be NULL but then NULL must be loocked for
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SEARCH-CRITERIA: key=%s,value[]=%s,separator=%s - CALLED!', $key, gettype($value), $separator));
if (empty($key)) {
throw new InvalidArgumentException('Parameter "separator" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
}
- // "Explode" value
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SEARCH-CRITERIA: Invoking explode("%s",value[]=%s) ...', $separator, gettype($value)));
- $valueArray = explode($separator, $value);
+ // Init aray
+ $valueArray = [];
+
+ // Is type of value not null?
+ if (!is_null($value)) {
+ // "Explode" value
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SEARCH-CRITERIA: Invoking explode("%s",value[]=%s) ...', $separator, gettype($value)));
+ $valueArray = explode($separator, $value);
+ }
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('SEARCH-CRITERIA: valueArray()=%d', count($valueArray)));
// Get 'default' search value
* @return $resultInstance An instance of this class
* @throws InvalidArgumentException If a parameter is invalid
*/
- public static final function createCachedDatabaseResult (array $resultArray) {
+ public static final function createCachedDatabaseResult (array $resultArray): CachedDatabaseResult {
// Misses an element?
//* DEBUG-DIE: */ die(sprintf('[%s:%d]: resultArray=%s', __METHOD__, __LINE__, print_r($resultArray, true)));
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: resultArray()=%d - CALLED!', count($resultArray)));
* @param $resultArray The array holding the result from query
* @return void
*/
- protected final function setResultArray (array $resultArray) {
+ protected final function setResultArray (array $resultArray): void {
$this->resultArray = $resultArray;
}
* @param $updateInstance An instance of an Updateable criteria
* @return void
*/
- private function updateCurrentEntryByCriteria (LocalUpdateCriteria $updateInstance) {
+ private function updateCurrentEntryByCriteria (LocalUpdateCriteria $updateInstance): void {
// Get the current entry key
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: updateInstance=%s - CALLED!', $updateInstance->__toString()));
$entryKey = $this->key();
*
* @return $nextValid Whether the next entry is valid
*/
- public function next () {
- // Default is not valid
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: CALLED!');
- $nextValid = false;
-
+ public function next (): void {
// Increase position
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: CALLED!');
$this->currentPos++;
// Is the result valid?
if ($this->valid()) {
// Next entry found, so cache it
$this->currentRow = $this->resultArray[BaseDatabaseResult::RESULT_NAME_ROWS][$this->currentPos];
- $nextValid = true;
}
- // Return the result
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: nextValid=%d - EXIT!', intval($nextValid)));
- return $nextValid;
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: EXIT!');
}
/**
* @return void
* @throws OutOfBoundsException If the position is not seekable
*/
- public function seek (int $seekPosition) {
+ public function seek (int $seekPosition): void {
// Validate parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: seekPosition=%d - CALLED!', $seekPosition));
if ($seekPosition < 0) {
*
* @return $current Current element to give back
*/
- public function current () {
+ public function current (): mixed {
// Default is not found
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: CALLED!');
$current = NULL;
*
* @return $isValid Whether the next/rewind entry is valid
*/
- public function valid () {
+ public function valid (): bool {
// Check if all is fine ...
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: this->currentPos=%d - CALLED!', $this->currentPos));
$isValid = ($this->ifStatusIsOkay() && isset($this->resultArray[BaseDatabaseResult::RESULT_NAME_ROWS][$this->currentPos]) && isset($this->resultArray[BaseDatabaseResult::RESULT_NAME_ROWS][0]));
/**
* Returns count of entries
*
- * @return $isValid Whether the next/rewind entry is valid
+ * @return $count Count of total rows
*/
- public function count () {
+ public function count (): int {
// Count rows
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: CALLED!');
$count = count($this->resultArray[BaseDatabaseResult::RESULT_NAME_ROWS]);
*
* @return $ifStatusOkay Whether the status of the query was okay
*/
- public function ifStatusIsOkay () {
+ public function ifStatusIsOkay (): bool {
// Check all conditions
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: this->currentPos=%d - CALLED!', $this->currentPos));
$ifStatusOkay = (isset($this->resultArray[BaseDatabaseResult::RESULT_NAME_STATUS]) && $this->resultArray[BaseDatabaseResult::RESULT_NAME_STATUS] === BaseDatabaseBackend::RESULT_OKAY);
*
* @return $currentPos Key from iterator
*/
- public function key () {
+ public function key (): int {
// Return current array position
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: this->currentPos=%d - CALLED!', $this->currentPos));
return $this->currentPos;
*
* @return void
*/
- public function rewind () {
+ public function rewind (): void {
// Reset both current array position and current row
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: this->currentPos=%d - CALLED!', $this->currentPos));
$this->resetCurrentPosition();
*
* @return void
*/
- private function resetCurrentPosition () {
+ private function resetCurrentPosition (): void {
// Reset position
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: CALLED!');
$this->currentPos = ($this->count() > 0 ? 0 : -1);
* @return void
* @throws ResultUpdateException If no result was updated
*/
- public function add2UpdateQueue (LocalUpdateCriteria $updateInstance) {
+ public function add2UpdateQueue (LocalUpdateCriteria $updateInstance): void {
// Rewind the pointer
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: updateInstance=%s - CALLED!', $updateInstance->__toString()));
$this->rewind();
* @param $rows Number of affected rows
* @return void
*/
- public final function setAffectedRows (int $rows) {
+ public final function setAffectedRows (int $rows): void {
$this->affectedRows = $rows;
}
*
* @return $rows Number of affected rows
*/
- public final function getAffectedRows () {
+ public final function getAffectedRows (): int {
return $this->affectedRows;
}
*
* @return $needsUpdate Whether we have out-dated entries
*/
- public function ifDataNeedsFlush () {
+ public function ifDataNeedsFlush (): bool {
// Check if records are out-dated
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CACHED-DATABASE-RESULT: CALLED!');
$needsUpdate = (count($this->outDated) > 0);
* @param $criteriaInstance An instance of a StoreableCriteria class
* @return void
*/
- public function addElementsToDataSet (StoreableCriteria $criteriaInstance) {
+ public function addElementsToDataSet (StoreableCriteria $criteriaInstance): void {
// Walk only through out-dated columns
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: criteriaInstance=%s - CALLED!', $criteriaInstance->__toString()));
foreach ($this->outDated as $key => $dummy) {
* @return $found Whether the key was found or not
* @throws InvalidArgumentException If a parameter is invalid
*/
- public function find (string $key) {
+ public function find (string $key): bool {
// Check parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: key=%s - CALLED!', $key));
if (empty($key)) {
* @throws InvalidArgumentException If a parameter is invalid
* @todo Find a caching way without modifying the result array
*/
- public function solveResultIndex (string $databaseColumn, DatabaseFrontend $frontendInstance, array $callback) {
+ public function solveResultIndex (string $databaseColumn, DatabaseFrontend $frontendInstance, array $callback): void {
// Check parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CACHED-DATABASE-RESULT: databaseColumn=%s,frontendInstance=%s,callback()=%d - CALLED!', $databaseColumn, $frontendInstance->__toString(), count($callback)));
if (empty($key)) {
* @throws FileNotFoundException If the file does not exist
* @return void
*/
- public static final function createFrameworkRawFileInputPointer (SplFileInfo $fileInstance) {
+ public static final function createFrameworkRawFileInputPointer (SplFileInfo $fileInstance): FrameworkRawFileInputPointer {
// Some pre-sanity checks...
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-INPUT-POINTER: fileInstance[%s]=%s - CALLED!', get_class($fileInstance), $fileInstance->__toString()));
if (!FrameworkBootstrap::isReachableFilePath($fileInstance)) {
* @return void
* @throws UnsupportedOperationException If this method is called
*/
- public function analyzeFileStructure () {
+ public function analyzeFileStructure (): void {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return void
* @throws UnsupportedOperationException If this method is called
*/
- public function next () {
+ public function next (): void {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return $isValid Whether the next entry is valid
* @throws UnsupportedOperationException If this method is called
*/
- public function valid () {
+ public function valid (): bool {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return $key Current key in iteration
* @throws UnsupportedOperationException If this method is called
*/
- public function key () {
+ public function key (): int {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @param $fileName The file name we shall pass to fopen()
* @throws FileIoException If the file is not reachable
* @throws FileReadProtectedException If the file cannot be read from
- * @return void
+ * @return An instance of a FrameworkTextFileInputPointer class
*/
- public static final function createFrameworkTextFileInputPointer (SplFileInfo $fileInstance) {
+ public static final function createFrameworkTextFileInputPointer (SplFileInfo $fileInstance): FrameworkTextFileInputPointer {
// Check parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-INPUT-POINTER: fileInstance[%s]=%s - CALLED!', get_class($fileInstance), $fileInstance->__toString()));
if (!FrameworkBootstrap::isReachableFilePath($fileInstance)) {
* @return void
* @throws UnsupportedOperationException If this method is called
*/
- public function analyzeFileStructure () {
+ public function analyzeFileStructure (): void {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return void
* @throws UnsupportedOperationException If this method is called
*/
- public function next () {
+ public function next (): void {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return $isValid Whether the next entry is valid
* @throws UnsupportedOperationException If this method is called
*/
- public function valid () {
+ public function valid (): bool {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return $key Current key in iteration
* @throws UnsupportedOperationException If this method is called
*/
- public function key () {
+ public function key (): int {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @throws PathWriteProtectedException If PHP cannot write to an existing path
* @throws FileIoException If fopen() returns not a file resource
*/
- public static final function createFrameworkFileInputOutputPointer (SplFileInfo $fileInstance) {
+ public static final function createFrameworkFileInputOutputPointer (SplFileInfo $fileInstance): FrameworkFileInputOutputPointer {
// Some pre-sanity checks...
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-INPUT-OUTPUT-POINTER: fileInstance[%s]=%s - CALLED!', get_class($fileInstance), $fileInstance));
if (!FrameworkBootstrap::isReachableFilePath($fileInstance)) {
*
* @return void
*/
- public function rewind () {
+ public function rewind (): void {
/// Rewind the pointer
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-INPUT-OUTPUT-POINTER: CALLED!');
$this->getFileObject()->rewind();
* @return void
* @throws UnsupportedOperationException If this method is called
*/
- public function analyzeFileStructure () {
+ public function analyzeFileStructure (): void {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return void
* @throws UnsupportedOperationException If this method is called
*/
- public function next () {
+ public function next (): void {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return $isValid Whether the next entry is valid
* @throws UnsupportedOperationException If this method is called
*/
- public function valid () {
+ public function valid (): bool {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return $key Current key in iteration
* @throws UnsupportedOperationException If this method is called
*/
- public function key () {
+ public function key (): int {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return $fileSize Size of currently loaded file
* @throws UnexpectedValueException If $fileData does not contain "size"
*/
- public function getFileSize () {
+ public function getFileSize (): int {
// Get file's data
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-INPUT-OUTPUT-POINTER: CALLED!');
$fileData = $this->getFileObject()->fstat();
*
* @param $fileInstance An instance of a SplFileInfo class
* @param $mode The output mode ('w', 'a' are valid)
- * @return void
+ * @return An instance of a FrameworkRawFileOutputPointer class
* @throws InvalidArgumentException If parameter mode is empty
* @throws FileIoException If fopen() returns not a file resource
*/
- public static final function createFrameworkRawFileOutputPointer (SplFileInfo $fileInstance, string $mode) {
+ public static final function createFrameworkRawFileOutputPointer (SplFileInfo $fileInstance, string $mode): FrameworkRawFileOutputPointer {
// Is the parameter valid?
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-OUTPUT-POINTER: fileInstance=%s,mode=%s - CALLED!', $fileInstance->__toString(), $mode));
if (empty($mode)) {
* @return mixed Number of writes bytes or false on error
* @throws UnsupportedOperationException If this method is called
*/
- public function writeAtPosition (int $seedPosition, string $data) {
+ public function writeAtPosition (int $seedPosition, string $data): void {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return void
* @throws UnsupportedOperationException If this method is called
*/
- public function next () {
+ public function next (): void {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return $isValid Whether the next entry is valid
* @throws UnsupportedOperationException If this method is called
*/
- public function valid () {
+ public function valid (): bool {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return $key Current key in iteration
* @throws UnsupportedOperationException If this method is called
*/
- public function key () {
+ public function key (): int {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @param $mode The output mode ('w', 'a' are valid)
* @throws InvalidArgumentException If mode is empty
* @throws FileIoException If fopen() returns not a file resource
- * @return void
+ * @return FrameworkTextFileOutputPointer An instance of a FrameworkTextFileOutputPointer class
*/
- public static final function createFrameworkTextFileOutputPointer (SplFileInfo $fileInstance, string $mode) {
+ public static final function createFrameworkTextFileOutputPointer (SplFileInfo $fileInstance, string $mode): FrameworkTextFileOutputPointer {
// Some pre-sanity checks...
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TEXT-FILE-OUTPUT-POINTER: fileInstance[%s]=%s,mode=%s - CALLED!', get_class($fileInstance), $fileInstance->__toString(), $mode));
if (empty($mode)) {
* @return void
* @throws UnsupportedOperationException If this method is called
*/
- public function analyzeFileStructure () {
+ public function analyzeFileStructure (): void {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return void
* @throws UnsupportedOperationException If this method is called
*/
- public function next () {
+ public function next (): void {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return $isValid Whether the next entry is valid
* @throws UnsupportedOperationException If this method is called
*/
- public function valid () {
+ public function valid (): bool {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return $key Current key in iteration
* @throws UnsupportedOperationException If this method is called
*/
- public function key () {
+ public function key (): int {
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @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();
* @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;
*
* @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());
* @param $binaryFileInstance An instance of a BinaryFile class
* @return $iteratorInstance An instance of a Iterator class
*/
- public final static function createFileIterator (BinaryFile $binaryFileInstance) {
+ public final static function createFileIterator (BinaryFile $binaryFileInstance): FileIterator {
// Get new instance
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: binaryFileInstance=%s - CALLED!', $binaryFileInstance->__toString()));
$iteratorInstance = new FileIterator();
* @return $current Currently read data
* @throws BadMethodCallException If valid() is FALSE
*/
- public function current () {
+ public function current (): mixed {
// Is condition given?
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
if (!$this->valid()) {
* @return $key Current key in iteration
* @throws BadMethodCallException If valid() is FALSE
*/
- public function key () {
+ public function key (): int {
// Is condition given?
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
if (!$this->valid()) {
*
* @return void
*/
- public function next () {
+ public function next (): void {
// Call file instance
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
$this->getBinaryFileInstance()->next();
*
* @return void
*/
- public function rewind () {
+ public function rewind (): void {
// Call file instance
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
$this->getBinaryFileInstance()->rewind();
*
* @return $isValid Whether the next entry is valid
*/
- public function valid () {
+ public function valid (): bool {
// Call file instance
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
$isValid = $this->getBinaryFileInstance()->valid();
* @return void
* @throws OutOfBoundsException If the position is not seekable
*/
- public function seek (int $seekPosition) {
+ public function seek (int $seekPosition): void {
// Validate parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: seekPosition=%d,whence=%d - CALLED!', $seekPosition, $whence));
if ($seekPosition < 0) {
* @param $registryInstance An instance of a Register class
* @return $iteratorInstance An instance of a Iterator class
*/
- public final static function createRegistryIterator (Register $registryInstance) {
+ public final static function createRegistryIterator (Register $registryInstance): RegistryIterator {
// Get new instance
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('REGISTRY-ITERATOR: registryInstance=%s - CALLED!', $registryInstance->__toString()));
$iteratorInstance = new RegistryIterator();
* @param $onlyRegistries Array with keys only being iterated over
* @return void
*/
- private function setOnlyRegistries (array $onlyRegistries) {
+ private function setOnlyRegistries (array $onlyRegistries): void {
$this->onlyRegistries = $onlyRegistries;
}
* @throws LogicException If a registry entry does not implement Registerable
* @throws NullPointerException If criteriaKey or criteriaMethod is not set but a call-back instance is set
*/
- public function initIterator (array $onlyRegistries = []) {
+ public function initIterator (array $onlyRegistries = []): void {
// Set it in this registry
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('REGISTRY-ITERATOR: onlyRegistries()=%d - CALLED!', count($onlyRegistries)));
$this->setOnlyRegistries($onlyRegistries);
*
* @return $registryKeys Registry keys
*/
- public final function getRegistryKeys () {
+ public final function getRegistryKeys (): array {
// Return it
return $this->registryKeys;
}
* @return $current Current value in iteration
* @throws NullPointerException If current key points to a non-existing entry in searched registries
*/
- public function current () {
+ public function current (): mixed {
// Default is null
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('REGISTRY-ITERATOR[%s]: CALLED!', $this->key()));
//* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: this->key(%d)[%s]=%s,this->valid=%d,this->registryKeys=%s', __METHOD__, __LINE__, strlen($this->key()), gettype($this->key()), $this->key(), intval($this->valid()), print_r($this->registryKeys, TRUE)));
*
* @return $key Current key in iteration
*/
- public function key () {
+ public function key (): int {
// Return it
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('REGISTRY-ITERATOR: this->key=%s EXIT!', $this->key));
return $this->key;
* @throws BadMethodCallException If $this->valid() returns FALSE
* @throws UnexpectedValueException If $registryType is not changed
*/
- public function next () {
+ public function next (): void {
// Is valid() still TRUE?
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('REGISTRY-ITERATOR[%s]: CALLED!', $this->key()));
//* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: this->key(%d)[%s]=%s,this->valid=%d,this->registryKeys=%s', __METHOD__, __LINE__, strlen($this->key()), gettype($this->key()), $this->key(), intval($this->valid()), print_r($this->registryKeys, TRUE)));
* @return void
* @throws BadMethodCallException If $this->key is already the first element
*/
- public function rewind () {
+ public function rewind (): void {
// Is current key first key?
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('REGISTRY-ITERATOR[%s]: CALLED!', $this->key()));
//* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: this->key(%d)[%s]=%s,this->valid=%d,this->registryKeys=%s', __METHOD__, __LINE__, strlen($this->key()), gettype($this->key()), $this->key(), intval($this->valid()), print_r($this->registryKeys, TRUE)));
*
* @return $valid Whether the current key is still valid
*/
- public function valid () {
+ public function valid (): bool {
// Is the element there?
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('REGISTRY-ITERATOR[%s]: CALLED!', $this->key()));
//* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: this->key(%d)[%s]=%s,this->registryKeys=%s', __METHOD__, __LINE__, strlen($this->key()), gettype($this->key()), $this->key(), print_r($this->registryKeys, TRUE)));
use \InvalidArgumentException;
use \IteratorAggregate;
use \Countable;
+use \Traversable;
/**
* A general list class
*
* @return $iteratorInstance An instance of a Iterator class
*/
- public function getIterator () {
+ public function getIterator (): Traversable {
// Get iterator from here
$iteratorInstance = $this->getIteratorInstance();
* @param $groupName Group to check if found in list
* @return $isset Whether the group is valid
*/
- public function isGroupSet (string $groupName) {
+ public function isGroupSet (string $groupName): bool {
// Validate parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-LIST: groupName=%s - CALLED!', $groupName));
if (empty($groupName)) {
* @return void
* @throws BadMethodCallException If the given group is already added
*/
- public function addGroup (string $groupName) {
+ public function addGroup (string $groupName): void {
// Validate parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-LIST: groupName=%s - CALLED!', $groupName));
if (empty($groupName)) {
* @return void
* @throws BadMethodCallException If the given group is not found
*/
- public function addInstance (string $groupName, string $subGroup, Visitable $visitableInstance) {
+ public function addInstance (string $groupName, string $subGroup, Visitable $visitableInstance): void {
// Validate parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: groupName=' . $groupName . ',subGroup=' . $subGroup . ',visitableInstance=' . $visitableInstance->__toString() . ' - CALLED!');
if (empty($groupName)) {
* @return $array The requested array
* @throws BadMethodCallException If the given group is not found
*/
- public final function getArrayFromList (string $groupName) {
+ public final function getArrayFromList (string $groupName): array {
// Is the group there?
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: groupName[' . gettype($groupName) . ']=' . $groupName . ' - CALLED!');
if (empty($groupName)) {
* @return void
* @throws BadMethodCallException If the given group is not found
*/
- public function addEntry (string $groupName, $entry) {
+ public function addEntry (string $groupName, $entry): void {
// Is the group already added?
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: groupName=' . $groupName . ' - CALLED!');
if (empty($groupName)) {
* @return void
* @throws BadMethodCallException If the given group is not found
*/
- public function removeEntry (string $groupName, $entry) {
+ public function removeEntry (string $groupName, $entry): void {
// Is the group already added?
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: groupName=' . $groupName . ' - CALLED!');
if (empty($groupName)) {
* @param $entry An entry of any type
* @return $hash The generated
*/
- private function generateHash (string $groupName, string $subGroup, $entry) {
+ private function generateHash (string $groupName, string $subGroup, $entry): string {
// Created entry, 'null' is default
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: groupName=' . $groupName . ',subGroup=' . $subGroup . ',entry[]=' . gettype($entry) . ' - CALLED!');
$entry2 = 'null';
* @param $groupNames An array with existing list groups
* @return void
*/
- protected function clearGroups (array $groupNames) {
+ protected function clearGroups (array $groupNames): void {
// Walk through all groups
foreach ($groupNames as $groupName) {
// Clear this group
* @param $groupName Name of an existing group to clear
* @return void
*/
- protected function clearGroup (string $groupName) {
+ protected function clearGroup (string $groupName): void {
// Does this group exist?
if (empty($groupName)) {
// Throw IAE
*
* @return $count All entries in this list
*/
- public final function count () {
+ public final function count (): int {
return count($this->listIndex);
}
* @param $hash The hash we should validate
* @return $isValid Whether the given hash is valid
*/
- public final function isHashValid (string $hash) {
+ public final function isHashValid (string $hash): bool {
// Validate parameter
if (empty($hash)) {
// Throw IAE
* @param $hashIndex Index holding the hash
* @return $hash The hash
*/
- public final function getHashByIndex (int $hashIndex) {
+ public final function getHashByIndex (int $hashIndex): string {
// Get it ...
$hash = $this->listIndex[$hashIndex];
* @return $entries The array with all entries
* @throws BadMethodCallException If the specified group is invalid
*/
- public function getArrayFromProtocolInstance (string $groupName) {
+ public function getArrayFromProtocolInstance (string $groupName): array {
// Is the group valid?
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-LIST: groupName=%s - CALLED!', $groupName));
if (empty($groupName)) {
* @return void
* @throws InvalidListHashException If the solved hash index is invalid
*/
- public function updateCurrentEntryByHash (string $hash, array $entryArray) {
+ public function updateCurrentEntryByHash (string $hash, array $entryArray): void {
// Is the hash valid?
if (empty($hash)) {
// Throw IAE
// Import SPL stuff
use \InvalidArgumentExeption;
use \IteratorAggregate;
+use \Traversable;
use \UnexpectedValueException;
/**
* @param $onlyRegistries Only iterate on these sub-registry keys, default is all
* @return $iteratorInstance An instance of a Iterator class
*/
- public function getIterator (array $onlyRegistries = []) {
+ public function getIterator (array $onlyRegistries = []): Traversable {
// Get iterator
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-REGISTRY: onlyRegistries()=%d - CALLED!', count($onlyRegistries)));
$iteratorInstance = $this->getIteratorInstance();
$this->extraNumber = ($this->prime * $this->prime / pow(pi(), 2));
// Seed mt_rand()
- mt_srand((double) sqrt(microtime(true) * 100000000 * $this->extraNumber));
+ mt_srand((int) sqrt(microtime(true) * 100000000 * $this->extraNumber));
// Set the server IP to cluster
$serverIp = 'cluster';
*
* @return void
*/
- function rewind ();
+ function rewind (): void;
/**
* Advances to next "block" of bytes
*
* @return void
*/
- function next ();
+ function next (): void;
/**
* Checks wether the current entry is valid (not at the end of the file).
*
* @return $isValid Whether the next entry is valid
*/
- function valid ();
+ function valid (): bool;
/**
* Gets current seek position ("key").
*
* @return $key Current key in iteration
*/
- function key ();
+ function key (): int;
}