From 76a44f7f1b907c63484c751f1fcf19730c553b7d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 26 Jan 2025 18:14:01 +0100 Subject: [PATCH] Continued: - added return type-hints --- .../criteria/search/class_SearchCriteria.php | 24 +++++---- .../result/class_CachedDatabaseResult.php | 51 +++++++++---------- .../class_FrameworkRawFileInputPointer.php | 10 ++-- .../class_FrameworkTextFileInputPointer.php | 12 ++--- .../class_FrameworkFileInputOutputPointer.php | 14 ++--- .../class_FrameworkRawFileOutputPointer.php | 12 ++--- .../class_FrameworkTextFileOutputPointer.php | 12 ++--- .../default/class_DefaultIterator.php | 12 ++--- .../iterator/file/class_FileIterator.php | 14 ++--- .../registry/class_RegistryIterator.php | 18 +++---- .../main/classes/lists/class_BaseList.php | 31 +++++------ .../classes/registry/class_BaseRegistry.php | 3 +- .../rng/class_RandomNumberGenerator.php | 2 +- .../pointer/io/class_InputOutputPointer.php | 8 +-- 14 files changed, 113 insertions(+), 110 deletions(-) diff --git a/framework/main/classes/criteria/search/class_SearchCriteria.php b/framework/main/classes/criteria/search/class_SearchCriteria.php index 7234fb23..30d49d5b 100644 --- a/framework/main/classes/criteria/search/class_SearchCriteria.php +++ b/framework/main/classes/criteria/search/class_SearchCriteria.php @@ -67,7 +67,7 @@ class SearchCriteria extends BaseCriteria implements LocalSearchCriteria { * * @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(); @@ -95,7 +95,7 @@ class SearchCriteria extends BaseCriteria implements LocalSearchCriteria { * @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)) { @@ -119,7 +119,7 @@ class SearchCriteria extends BaseCriteria implements LocalSearchCriteria { * * @return $limit Search limit */ - public final function getLimit () { + public final function getLimit (): int { return $this->limit; } @@ -130,7 +130,7 @@ class SearchCriteria extends BaseCriteria implements LocalSearchCriteria { * @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; } @@ -139,7 +139,7 @@ class SearchCriteria extends BaseCriteria implements LocalSearchCriteria { * * @return $skip Search skip */ - public final function getSkip () { + public final function getSkip (): int { return $this->skip; } @@ -154,7 +154,7 @@ class SearchCriteria extends BaseCriteria implements LocalSearchCriteria { * @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)) { @@ -168,9 +168,15 @@ class SearchCriteria extends BaseCriteria implements LocalSearchCriteria { 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 diff --git a/framework/main/classes/database/result/class_CachedDatabaseResult.php b/framework/main/classes/database/result/class_CachedDatabaseResult.php index c79eabfd..4296044a 100644 --- a/framework/main/classes/database/result/class_CachedDatabaseResult.php +++ b/framework/main/classes/database/result/class_CachedDatabaseResult.php @@ -95,7 +95,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul * @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))); @@ -135,7 +135,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul * @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; } @@ -145,7 +145,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul * @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(); @@ -170,24 +170,19 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul * * @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!'); } /** @@ -197,7 +192,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul * @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) { @@ -224,7 +219,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul * * @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; @@ -245,7 +240,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul * * @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])); @@ -258,9 +253,9 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul /** * 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]); @@ -275,7 +270,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul * * @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); @@ -290,7 +285,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul * * @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; @@ -301,7 +296,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul * * @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(); @@ -317,7 +312,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul * * @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); @@ -346,7 +341,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul * @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(); @@ -407,7 +402,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul * @param $rows Number of affected rows * @return void */ - public final function setAffectedRows (int $rows) { + public final function setAffectedRows (int $rows): void { $this->affectedRows = $rows; } @@ -416,7 +411,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul * * @return $rows Number of affected rows */ - public final function getAffectedRows () { + public final function getAffectedRows (): int { return $this->affectedRows; } @@ -434,7 +429,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul * * @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); @@ -450,7 +445,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul * @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) { @@ -474,7 +469,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul * @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)) { @@ -531,7 +526,7 @@ class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResul * @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)) { diff --git a/framework/main/classes/file_directories/input/raw/class_FrameworkRawFileInputPointer.php b/framework/main/classes/file_directories/input/raw/class_FrameworkRawFileInputPointer.php index 4ba33c57..734b97b7 100644 --- a/framework/main/classes/file_directories/input/raw/class_FrameworkRawFileInputPointer.php +++ b/framework/main/classes/file_directories/input/raw/class_FrameworkRawFileInputPointer.php @@ -63,7 +63,7 @@ class FrameworkRawFileInputPointer extends BaseFileIo implements InputPointer { * @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)) { @@ -171,7 +171,7 @@ class FrameworkRawFileInputPointer extends BaseFileIo implements InputPointer { * @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); } @@ -181,7 +181,7 @@ class FrameworkRawFileInputPointer extends BaseFileIo implements InputPointer { * @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); } @@ -192,7 +192,7 @@ class FrameworkRawFileInputPointer extends BaseFileIo implements InputPointer { * @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); } @@ -202,7 +202,7 @@ class FrameworkRawFileInputPointer extends BaseFileIo implements InputPointer { * @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); } diff --git a/framework/main/classes/file_directories/input/text/class_FrameworkTextFileInputPointer.php b/framework/main/classes/file_directories/input/text/class_FrameworkTextFileInputPointer.php index 1805d7c8..31182978 100644 --- a/framework/main/classes/file_directories/input/text/class_FrameworkTextFileInputPointer.php +++ b/framework/main/classes/file_directories/input/text/class_FrameworkTextFileInputPointer.php @@ -58,9 +58,9 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer { * @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)) { @@ -164,7 +164,7 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer { * @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); } @@ -174,7 +174,7 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer { * @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); } @@ -185,7 +185,7 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer { * @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); } @@ -195,7 +195,7 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer { * @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); } diff --git a/framework/main/classes/file_directories/io/class_FrameworkFileInputOutputPointer.php b/framework/main/classes/file_directories/io/class_FrameworkFileInputOutputPointer.php index 2a03a011..88972151 100644 --- a/framework/main/classes/file_directories/io/class_FrameworkFileInputOutputPointer.php +++ b/framework/main/classes/file_directories/io/class_FrameworkFileInputOutputPointer.php @@ -65,7 +65,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP * @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)) { @@ -181,7 +181,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP * * @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(); @@ -269,7 +269,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP * @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); } @@ -279,7 +279,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP * @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); } @@ -290,7 +290,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP * @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); } @@ -300,7 +300,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP * @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); } @@ -310,7 +310,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP * @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(); diff --git a/framework/main/classes/file_directories/output/raw/class_FrameworkRawFileOutputPointer.php b/framework/main/classes/file_directories/output/raw/class_FrameworkRawFileOutputPointer.php index 6d2c3a26..25634755 100644 --- a/framework/main/classes/file_directories/output/raw/class_FrameworkRawFileOutputPointer.php +++ b/framework/main/classes/file_directories/output/raw/class_FrameworkRawFileOutputPointer.php @@ -53,11 +53,11 @@ class FrameworkRawFileOutputPointer extends BaseFileIo implements OutputPointer * * @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)) { @@ -137,7 +137,7 @@ class FrameworkRawFileOutputPointer extends BaseFileIo implements OutputPointer * @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); } @@ -147,7 +147,7 @@ class FrameworkRawFileOutputPointer extends BaseFileIo implements OutputPointer * @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); } @@ -158,7 +158,7 @@ class FrameworkRawFileOutputPointer extends BaseFileIo implements OutputPointer * @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); } @@ -168,7 +168,7 @@ class FrameworkRawFileOutputPointer extends BaseFileIo implements OutputPointer * @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); } diff --git a/framework/main/classes/file_directories/output/text/class_FrameworkTextFileOutputPointer.php b/framework/main/classes/file_directories/output/text/class_FrameworkTextFileOutputPointer.php index f6587257..fa968671 100644 --- a/framework/main/classes/file_directories/output/text/class_FrameworkTextFileOutputPointer.php +++ b/framework/main/classes/file_directories/output/text/class_FrameworkTextFileOutputPointer.php @@ -56,9 +56,9 @@ class FrameworkTextFileOutputPointer extends BaseFileIo implements OutputPointer * @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)) { @@ -121,7 +121,7 @@ class FrameworkTextFileOutputPointer extends BaseFileIo implements OutputPointer * @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); } @@ -143,7 +143,7 @@ class FrameworkTextFileOutputPointer extends BaseFileIo implements OutputPointer * @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); } @@ -154,7 +154,7 @@ class FrameworkTextFileOutputPointer extends BaseFileIo implements OutputPointer * @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); } @@ -164,7 +164,7 @@ class FrameworkTextFileOutputPointer extends BaseFileIo implements OutputPointer * @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); } diff --git a/framework/main/classes/iterator/default/class_DefaultIterator.php b/framework/main/classes/iterator/default/class_DefaultIterator.php index 11fb2603..0ee6110f 100644 --- a/framework/main/classes/iterator/default/class_DefaultIterator.php +++ b/framework/main/classes/iterator/default/class_DefaultIterator.php @@ -54,7 +54,7 @@ class DefaultIterator extends BaseIterator implements Iterator, Registerable { * @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(); @@ -73,7 +73,7 @@ class DefaultIterator extends BaseIterator implements Iterator, Registerable { * @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; @@ -97,7 +97,7 @@ class DefaultIterator extends BaseIterator implements Iterator, Registerable { * * @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; } @@ -107,7 +107,7 @@ class DefaultIterator extends BaseIterator implements Iterator, Registerable { * * @return void */ - public function next () { + public function next (): void { //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-HANDLER: CALLED!'); $this->indexKey++; } @@ -117,7 +117,7 @@ class DefaultIterator extends BaseIterator implements Iterator, Registerable { * * @return void */ - public function rewind () { + public function rewind (): void { //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-HANDLER: CALLED!'); $this->indexKey = 0; } @@ -127,7 +127,7 @@ class DefaultIterator extends BaseIterator implements Iterator, Registerable { * * @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()); diff --git a/framework/main/classes/iterator/file/class_FileIterator.php b/framework/main/classes/iterator/file/class_FileIterator.php index fba4e5d0..02554538 100644 --- a/framework/main/classes/iterator/file/class_FileIterator.php +++ b/framework/main/classes/iterator/file/class_FileIterator.php @@ -56,7 +56,7 @@ class FileIterator extends BaseIterator implements SeekableIterator { * @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(); @@ -75,7 +75,7 @@ class FileIterator extends BaseIterator implements SeekableIterator { * @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()) { @@ -97,7 +97,7 @@ class FileIterator extends BaseIterator implements SeekableIterator { * @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()) { @@ -118,7 +118,7 @@ class FileIterator extends BaseIterator implements SeekableIterator { * * @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(); @@ -132,7 +132,7 @@ class FileIterator extends BaseIterator implements SeekableIterator { * * @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(); @@ -147,7 +147,7 @@ class FileIterator extends BaseIterator implements SeekableIterator { * * @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(); @@ -164,7 +164,7 @@ class FileIterator extends BaseIterator implements SeekableIterator { * @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) { diff --git a/framework/main/classes/iterator/registry/class_RegistryIterator.php b/framework/main/classes/iterator/registry/class_RegistryIterator.php index 731c61ac..b38d21f1 100644 --- a/framework/main/classes/iterator/registry/class_RegistryIterator.php +++ b/framework/main/classes/iterator/registry/class_RegistryIterator.php @@ -83,7 +83,7 @@ class RegistryIterator extends BaseIterator implements IteratableRegistry { * @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(); @@ -102,7 +102,7 @@ class RegistryIterator extends BaseIterator implements IteratableRegistry { * @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; } @@ -114,7 +114,7 @@ class RegistryIterator extends BaseIterator implements IteratableRegistry { * @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); @@ -200,7 +200,7 @@ class RegistryIterator extends BaseIterator implements IteratableRegistry { * * @return $registryKeys Registry keys */ - public final function getRegistryKeys () { + public final function getRegistryKeys (): array { // Return it return $this->registryKeys; } @@ -211,7 +211,7 @@ class RegistryIterator extends BaseIterator implements IteratableRegistry { * @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))); @@ -263,7 +263,7 @@ class RegistryIterator extends BaseIterator implements IteratableRegistry { * * @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; @@ -276,7 +276,7 @@ class RegistryIterator extends BaseIterator implements IteratableRegistry { * @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))); @@ -329,7 +329,7 @@ class RegistryIterator extends BaseIterator implements IteratableRegistry { * @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))); @@ -361,7 +361,7 @@ class RegistryIterator extends BaseIterator implements IteratableRegistry { * * @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))); diff --git a/framework/main/classes/lists/class_BaseList.php b/framework/main/classes/lists/class_BaseList.php index 061733a4..608c6ecb 100644 --- a/framework/main/classes/lists/class_BaseList.php +++ b/framework/main/classes/lists/class_BaseList.php @@ -14,6 +14,7 @@ use \BadMethodCallException; use \InvalidArgumentException; use \IteratorAggregate; use \Countable; +use \Traversable; /** * A general list class @@ -85,7 +86,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate * * @return $iteratorInstance An instance of a Iterator class */ - public function getIterator () { + public function getIterator (): Traversable { // Get iterator from here $iteratorInstance = $this->getIteratorInstance(); @@ -108,7 +109,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate * @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)) { @@ -127,7 +128,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate * @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)) { @@ -152,7 +153,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate * @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)) { @@ -193,7 +194,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate * @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)) { @@ -238,7 +239,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate * @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)) { @@ -276,7 +277,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate * @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)) { @@ -311,7 +312,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate * @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'; @@ -359,7 +360,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate * @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 @@ -373,7 +374,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate * @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 @@ -396,7 +397,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate * * @return $count All entries in this list */ - public final function count () { + public final function count (): int { return count($this->listIndex); } @@ -406,7 +407,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate * @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 @@ -426,7 +427,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate * @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]; @@ -465,7 +466,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate * @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)) { @@ -513,7 +514,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate * @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 diff --git a/framework/main/classes/registry/class_BaseRegistry.php b/framework/main/classes/registry/class_BaseRegistry.php index b334bfae..3757c282 100644 --- a/framework/main/classes/registry/class_BaseRegistry.php +++ b/framework/main/classes/registry/class_BaseRegistry.php @@ -11,6 +11,7 @@ use Org\Mxchange\CoreFramework\Traits\Iterator\IteratorTrait; // Import SPL stuff use \InvalidArgumentExeption; use \IteratorAggregate; +use \Traversable; use \UnexpectedValueException; /** @@ -68,7 +69,7 @@ abstract class BaseRegistry extends BaseFrameworkSystem implements Register, Reg * @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(); diff --git a/framework/main/classes/rng/class_RandomNumberGenerator.php b/framework/main/classes/rng/class_RandomNumberGenerator.php index 7b83f9d0..5031f705 100644 --- a/framework/main/classes/rng/class_RandomNumberGenerator.php +++ b/framework/main/classes/rng/class_RandomNumberGenerator.php @@ -113,7 +113,7 @@ class RandomNumberGenerator extends BaseFrameworkSystem { $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'; diff --git a/framework/main/interfaces/io/pointer/io/class_InputOutputPointer.php b/framework/main/interfaces/io/pointer/io/class_InputOutputPointer.php index d6464c8b..6c22f6c0 100644 --- a/framework/main/interfaces/io/pointer/io/class_InputOutputPointer.php +++ b/framework/main/interfaces/io/pointer/io/class_InputOutputPointer.php @@ -34,14 +34,14 @@ interface InputOutputPointer extends InputPointer, OutputPointer { * * @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). @@ -49,13 +49,13 @@ interface InputOutputPointer extends InputPointer, OutputPointer { * * @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; } -- 2.39.5