From: Roland Häder Date: Mon, 18 Nov 2024 06:47:34 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=core.git Continued: - added debug/trace lines - pad with zeros only hexadecimal strings that are shorter than $maxLength, if set - rewind() does NOT have a returned type, if you count 'void' as a non-type ;-) --- diff --git a/framework/main/classes/iterator/default/class_DefaultIterator.php b/framework/main/classes/iterator/default/class_DefaultIterator.php index ba05b58b..11fb2603 100644 --- a/framework/main/classes/iterator/default/class_DefaultIterator.php +++ b/framework/main/classes/iterator/default/class_DefaultIterator.php @@ -56,12 +56,14 @@ class DefaultIterator extends BaseIterator implements Iterator, Registerable { */ public static final function createDefaultIterator (Listable $listInstance) { // 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; } @@ -73,6 +75,7 @@ class DefaultIterator extends BaseIterator implements Iterator, Registerable { */ public function current () { // Default is null + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('DEFAULT-ITERATOR: CALLED!'); $current = NULL; // Is the entry valid? @@ -85,6 +88,7 @@ class DefaultIterator extends BaseIterator implements Iterator, Registerable { $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; } @@ -94,6 +98,7 @@ class DefaultIterator extends BaseIterator implements Iterator, Registerable { * @return $indexKey Current key in iteration */ public function key () { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DEFAULT-ITERATOR: this->indexKey=%d - EXIT!', $this->indexKey)); return $this->indexKey; } @@ -103,6 +108,7 @@ class DefaultIterator extends BaseIterator implements Iterator, Registerable { * @return void */ public function next () { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-HANDLER: CALLED!'); $this->indexKey++; } @@ -112,6 +118,7 @@ class DefaultIterator extends BaseIterator implements Iterator, Registerable { * @return void */ public function rewind () { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-HANDLER: CALLED!'); $this->indexKey = 0; } @@ -122,9 +129,11 @@ class DefaultIterator extends BaseIterator implements Iterator, Registerable { */ public function valid () { // 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; } diff --git a/framework/main/classes/iterator/file/class_FileIterator.php b/framework/main/classes/iterator/file/class_FileIterator.php index face6a39..fba4e5d0 100644 --- a/framework/main/classes/iterator/file/class_FileIterator.php +++ b/framework/main/classes/iterator/file/class_FileIterator.php @@ -130,7 +130,7 @@ class FileIterator extends BaseIterator implements SeekableIterator { /** * Rewinds to the beginning of the file * - * @return $status Status of this operation + * @return void */ public function rewind () { // Call file instance diff --git a/framework/main/classes/utils/strings/class_StringUtils.php b/framework/main/classes/utils/strings/class_StringUtils.php index 972035c1..47b30d0a 100644 --- a/framework/main/classes/utils/strings/class_StringUtils.php +++ b/framework/main/classes/utils/strings/class_StringUtils.php @@ -341,13 +341,15 @@ final class StringUtils extends BaseFrameworkSystem { * situations more leading zeros are wanted, so check for both * conditions. */ - if ($maxLength > 0) { + //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('STRING-UTILS: hex=%s,hex()=%d,maxLength=%d - BEFORE!', $hex, strlen($hex) % 2, $maxLength)); + if ($maxLength > 0 && strlen($hex) < $maxLength) { // Prepend more zeros $hex = str_pad($hex, $maxLength, '0', STR_PAD_LEFT); } elseif ((strlen($hex) % 2) != 0) { // Only make string's length dividable by 2 $hex = '0' . $hex; } + //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('STRING-UTILS: hex=%s,hex()=%d - AFTER!', $hex, strlen($hex) % 2)); // Return the hexadecimal string //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: sign=%s,hex=%s - EXIT!', $sign, $hex)); diff --git a/framework/main/interfaces/io/pointer/io/class_InputOutputPointer.php b/framework/main/interfaces/io/pointer/io/class_InputOutputPointer.php index 23b1dbca..d6464c8b 100644 --- a/framework/main/interfaces/io/pointer/io/class_InputOutputPointer.php +++ b/framework/main/interfaces/io/pointer/io/class_InputOutputPointer.php @@ -32,7 +32,7 @@ interface InputOutputPointer extends InputPointer, OutputPointer { /** * Rewinds to the beginning of the file * - * @return $status Status of this operation + * @return void */ function rewind ();