]> git.mxchange.org Git - core.git/commitdiff
Continued: master
authorRoland Häder <roland@mxchange.org>
Mon, 18 Nov 2024 06:47:34 +0000 (07:47 +0100)
committerRoland Häder <roland@mxchange.org>
Mon, 18 Nov 2024 06:47:34 +0000 (07:47 +0100)
- 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 ;-)

framework/main/classes/iterator/default/class_DefaultIterator.php
framework/main/classes/iterator/file/class_FileIterator.php
framework/main/classes/utils/strings/class_StringUtils.php
framework/main/interfaces/io/pointer/io/class_InputOutputPointer.php

index ba05b58b23b7fd77d8c61e4830cfd5515933e7b8..11fb2603c2f9b7ffbf393704a37454c36f8867d0 100644 (file)
@@ -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;
        }
 
index face6a395ece52246f7481c2551e40118d0d6d90..fba4e5d08d4eca988f1bc15dbf27da16a9d0c24d 100644 (file)
@@ -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
index 972035c12e0b827bc14a177fdc97b2166d078d56..47b30d0a32e68b6f84b2dcb10e09ce1950379a21 100644 (file)
@@ -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));
index 23b1dbca9d71b53616fc5420b54628cc99e591b8..d6464c8b4cd7e65fce1f49aee5808b0fb5c8735f 100644 (file)
@@ -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 ();