From: Roland Häder Date: Fri, 10 Feb 2023 16:06:20 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6380c49c9c2d02092126514dfc30eb1354d8cac8;p=core.git Continued: - enabled debug lines - added one more --- diff --git a/framework/main/classes/stacker/class_BaseStacker.php b/framework/main/classes/stacker/class_BaseStacker.php index b9f80972..38b7b25c 100644 --- a/framework/main/classes/stacker/class_BaseStacker.php +++ b/framework/main/classes/stacker/class_BaseStacker.php @@ -67,7 +67,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { */ public function initStack (string $stackerName, bool $forceReInit = false) { // Validate parameter - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s,forceReInit=%d - CALLED!', $stackerName, intval($forceReInit))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s,forceReInit=%d - CALLED!', $stackerName, intval($forceReInit))); if (empty($stackerName)) { // No empty stack name throw new InvalidArgumentException('Parameter "stackerName" is empty'); @@ -81,7 +81,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { $this->cachedMaxStackSizes[$stackerName] = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry(sprintf('stacker_%s_max_size', $stackerName)); // Trace message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-STACKER: EXIT!'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-STACKER: EXIT!'); } /** @@ -92,7 +92,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { */ public function initStacks (array $stacks, bool $forceReInit = false) { // Validate parameter - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stacks()=%d,forceReInit=%d - CALLED!', count($stacks), intval($forceReInit))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stacks()=%d,forceReInit=%d - CALLED!', count($stacks), intval($forceReInit))); if (count($stacks) == 0) { // No empty stack name throw new InvalidArgumentException('Array "stacks" is empty'); @@ -101,12 +101,12 @@ abstract class BaseStacker extends BaseFrameworkSystem { // "Walk" through all (more will be added as needed foreach ($stacks as $stackerName) { // Init this stack - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: Calling this->initStack(%s,%d) ...', $stackerName, intval($forceReInit))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: Calling this->initStack(%s,%d) ...', $stackerName, intval($forceReInit))); $this->initStack($stackerName, $forceReInit); } // Trace message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-STACKER: EXIT!'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-STACKER: EXIT!'); } /** @@ -118,7 +118,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { */ public function isStackInitialized (string $stackerName) { // Validate parameter - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName)); if (empty($stackerName)) { // No empty stack name throw new InvalidArgumentException('Parameter "stackerName" is empty'); @@ -128,7 +128,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { $isInitialized = ($this->isValidGenericArrayKey('stacks', $stackerName, 'entries')); // Return result - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: isInitialized=%d - EXIT!', intval($isInitialized))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: isInitialized=%d - EXIT!', intval($isInitialized))); return $isInitialized; } @@ -142,7 +142,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { */ protected function isStackFull (string $stackerName) { // Validate parameter - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName)); if (empty($stackerName)) { // No empty stack name throw new InvalidArgumentException('Parameter "stackerName" is empty'); @@ -155,7 +155,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { $isFull = (($this->getStackCount($stackerName)) == $this->cachedMaxStackSizes[$stackerName]); // Return result - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: isFull=%d - EXIT!', intval($isFull))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: isFull=%d - EXIT!', intval($isFull))); return $isFull; } @@ -169,7 +169,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { */ public function isStackEmpty (string $stackerName) { // Validate parameter - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName)); if (empty($stackerName)) { // No empty stack name throw new InvalidArgumentException('Parameter "stackerName" is empty'); @@ -182,7 +182,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { $isEmpty = (($this->getStackCount($stackerName)) == 0); // Return result - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: isEmpty=%d - EXIT!', intval($isEmpty))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: isEmpty=%d - EXIT!', intval($isEmpty))); return $isEmpty; } @@ -196,7 +196,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { */ public function getStackCount (string $stackerName) { // Validate parameter - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName)); if (empty($stackerName)) { // No empty stack name throw new InvalidArgumentException('Parameter "stackerName" is empty'); @@ -209,7 +209,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { $count = $this->countGenericArrayElements('stacks', $stackerName, 'entries'); // Return result - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: count=%d - EXIT!', $count)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: count=%d - EXIT!', $count)); return $count; } @@ -225,7 +225,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { */ protected function addValueToStack (string $stackerName, $value) { // Validate parameter - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s,value[]=%s - CALLED!', $stackerName, gettype($value))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s,value[]=%s - CALLED!', $stackerName, gettype($value))); if (empty($stackerName)) { // No empty stack name throw new InvalidArgumentException('Parameter "stackerName" is empty'); @@ -241,7 +241,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { $this->pushValueToGenericArrayKey('stacks', $stackerName, 'entries', $value); // Trace message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-STACKER: EXIT!'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-STACKER: EXIT!'); } /** @@ -255,7 +255,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { */ protected function getLastValue (string $stackerName) { // Validate parameter - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName)); if (empty($stackerName)) { // No empty stack name throw new InvalidArgumentException('Parameter "stackerName" is empty'); @@ -267,11 +267,14 @@ abstract class BaseStacker extends BaseFrameworkSystem { throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); } + // Calculate last index + $lastIndex = $this->getStackCount($stackerName) - 1; // Now get the last value - $value = $this->getGenericArrayElement('stacks', $stackerName, 'entries', $this->getStackCount($stackerName) - 1); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: Invoking this->getGenericArrayElement(stacks,%s,%d) ...', $stackerName, $lastIndex)); + $value = $this->getGenericArrayElement('stacks', $stackerName, 'entries', $lastIndex); // Return it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: value[]=%s - EXIT!', gettype($value))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: value[]=%s - EXIT!', gettype($value))); return $value; } @@ -286,7 +289,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { */ protected function getFirstValue (string $stackerName) { // Validate parameter - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName)); if (empty($stackerName)) { // No empty stack name throw new InvalidArgumentException('Parameter "stackerName" is empty'); @@ -302,7 +305,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { $value = $this->getGenericArrayElement('stacks', $stackerName, 'entries', 0); // Return it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: value[]=%s - EXIT!', gettype($value))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: value[]=%s - EXIT!', gettype($value))); return $value; } @@ -317,7 +320,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { */ protected function popLast (string $stackerName) { // Validate parameter - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName)); if (empty($stackerName)) { // No empty stack name throw new InvalidArgumentException('Parameter "stackerName" is empty'); @@ -333,7 +336,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { $value = $this->popGenericArrayElement('stacks', $stackerName, 'entries'); // Return it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: value[]=%s - EXIT!', gettype($value))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: value[]=%s - EXIT!', gettype($value))); return $value; } @@ -348,7 +351,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { */ protected function popFirst (string $stackerName) { // Validate parameter - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: stackerName=%s - CALLED!', $stackerName)); if (empty($stackerName)) { // No empty stack name throw new InvalidArgumentException('Parameter "stackerName" is empty'); @@ -364,7 +367,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { $value = $this->shiftGenericArrayElement('stacks', $stackerName, 'entries'); // Return it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: value[]=%s - EXIT!', gettype($value))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: value[]=%s - EXIT!', gettype($value))); return $value; }