From 8857fa75f5df9434dc2c82da7caa269dc2ac1a48 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 10 Feb 2023 17:13:02 +0100 Subject: [PATCH] Continued: - empty($element) is the culpit here, '0' will be FALSE, 0 will be false and all needs to be true, so let's check $element === '' and it is solved --- .../classes/class_BaseFrameworkSystem.php | 32 +++++++++---------- .../classes/stacker/class_BaseStacker.php | 4 +-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/framework/main/classes/class_BaseFrameworkSystem.php b/framework/main/classes/class_BaseFrameworkSystem.php index 194ee491..41648caa 100644 --- a/framework/main/classes/class_BaseFrameworkSystem.php +++ b/framework/main/classes/class_BaseFrameworkSystem.php @@ -1037,7 +1037,7 @@ Loaded includes: } elseif (empty($key)) { // Throw IAE throw new InvalidArgumentException('Parameter "key" is empty'); - } elseif (empty($element)) { + } elseif ($element === '') { // Throw IAE throw new InvalidArgumentException('Parameter "element" is empty'); } @@ -1058,7 +1058,7 @@ Loaded includes: * @return $isset Whether the given key is set * @throws InvalidArgumentException If a parameter is not valid */ - protected final function isGenericArrayKeySet (string $keyGroup, string $subGroup, $key) { + protected final function isGenericArrayKeySet (string $keyGroup, string $subGroup, string $key) { // Check parameter if (empty($keyGroup)) { // Throw IAE @@ -1141,7 +1141,7 @@ Loaded includes: * @return void * @throws InvalidArgumentException If a parameter is not valid */ - protected final function unsetGenericArrayKey (string $keyGroup, string $subGroup, $key) { + protected final function unsetGenericArrayKey (string $keyGroup, string $subGroup, string $key) { // Check parameter //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key); if (empty($keyGroup)) { @@ -1181,7 +1181,7 @@ Loaded includes: } elseif (empty($key)) { // Throw IAE throw new InvalidArgumentException('Parameter "key" is empty'); - } elseif (empty($element)) { + } elseif ($element === '') { // Throw IAE throw new InvalidArgumentException('Parameter "element" is empty'); } @@ -1247,7 +1247,7 @@ Loaded includes: } elseif (empty($key)) { // Throw IAE throw new InvalidArgumentException('Parameter "key" is empty'); - } elseif (empty($element)) { + } elseif ($element === '') { // Throw IAE throw new InvalidArgumentException('Parameter "element" is empty'); } @@ -1347,7 +1347,7 @@ Loaded includes: } elseif (empty($key)) { // Throw IAE throw new InvalidArgumentException('Parameter "key" is empty'); - } elseif (empty($element)) { + } elseif ($element === '') { // Throw IAE throw new InvalidArgumentException('Parameter "element" is empty'); } elseif (($forceInit === false) && ($this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element))) { @@ -1369,7 +1369,7 @@ Loaded includes: * @return $count Number of array elements * @throws InvalidArgumentException If a parameter is not valid */ - protected final function pushValueToGenericArrayKey (string $keyGroup, string $subGroup, $key, $value) { + protected final function pushValueToGenericArrayKey (string $keyGroup, string $subGroup, string $key, $value) { // Check parameter //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, true)); if (empty($keyGroup)) { @@ -1418,7 +1418,7 @@ Loaded includes: } elseif (empty($key)) { // Throw IAE throw new InvalidArgumentException('Parameter "key" is empty'); - } elseif (empty($element)) { + } elseif ($element === '') { // Throw IAE throw new InvalidArgumentException('Parameter "element" is empty'); } elseif (!$this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) { @@ -1445,7 +1445,7 @@ Loaded includes: * @throws InvalidArgumentException If a parameter is not valid * @throws BadMethodCallException If key/sub group isn't there but this method is invoked */ - protected final function popGenericArrayElement (string $keyGroup, string $subGroup, $key) { + protected final function popGenericArrayElement (string $keyGroup, string $subGroup, string $key) { // Check parameter //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key); if (empty($keyGroup)) { @@ -1481,7 +1481,7 @@ Loaded includes: * @throws InvalidArgumentException If a parameter is not valid * @throws BadMethodCallException If key/sub group isn't there but this method is invoked */ - protected final function shiftGenericArrayElement (string $keyGroup, string $subGroup, $key) { + protected final function shiftGenericArrayElement (string $keyGroup, string $subGroup, string $key) { // Check parameter //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key); if (empty($keyGroup)) { @@ -1575,7 +1575,7 @@ Loaded includes: * @throws InvalidArgumentException If a parameter is not valid * @throws BadMethodCallException If key/sub group isn't there but this method is invoked */ - protected final function countGenericArrayElements (string $keyGroup, string $subGroup, $key) { + protected final function countGenericArrayElements (string $keyGroup, string $subGroup, string $key) { // Check parameter //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key); if (empty($keyGroup)) { @@ -1637,7 +1637,7 @@ Loaded includes: * @throws InvalidArgumentException If a parameter is not valid * @throws BadMethodCallException If key/sub group isn't there but this method is invoked */ - protected final function setGenericArrayKey (string $keyGroup, string $subGroup, $key, $value) { + protected final function setGenericArrayKey (string $keyGroup, string $subGroup, string $key, $value) { // Check parameters //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, true)); if (empty($keyGroup)) { @@ -1668,7 +1668,7 @@ Loaded includes: * @throws InvalidArgumentException If a parameter is not valid * @throws BadMethodCallException If key/sub group isn't there but this method is invoked */ - protected final function getGenericArrayKey (string $keyGroup, string $subGroup, $key) { + protected final function getGenericArrayKey (string $keyGroup, string $subGroup, string $key) { // Check parameters //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key); if (empty($keyGroup)) { @@ -1712,7 +1712,7 @@ Loaded includes: } elseif (empty($key)) { // Throw IAE throw new InvalidArgumentException('Parameter "key" is empty'); - } elseif (empty($element)) { + } elseif ($element === '') { // Throw IAE throw new InvalidArgumentException('Parameter "element" is empty'); } elseif (!$this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) { @@ -1747,7 +1747,7 @@ Loaded includes: } elseif (empty($key)) { // Throw IAE throw new InvalidArgumentException('Parameter "key" is empty'); - } elseif (empty($element)) { + } elseif ($element === '') { // Throw IAE throw new InvalidArgumentException('Parameter "element" is empty'); } elseif (!$this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) { @@ -1793,7 +1793,7 @@ Loaded includes: * @param $key Key to check * @return $isValid Whether given sub group is valid */ - protected final function isValidGenericArrayKey (string $keyGroup, string $subGroup, $key) { + protected final function isValidGenericArrayKey (string $keyGroup, string $subGroup, string $key) { // Check parameters //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key); if (empty($keyGroup)) { diff --git a/framework/main/classes/stacker/class_BaseStacker.php b/framework/main/classes/stacker/class_BaseStacker.php index 38b7b25c..a8e63bce 100644 --- a/framework/main/classes/stacker/class_BaseStacker.php +++ b/framework/main/classes/stacker/class_BaseStacker.php @@ -269,8 +269,8 @@ abstract class BaseStacker extends BaseFrameworkSystem { // Calculate last index $lastIndex = $this->getStackCount($stackerName) - 1; + // Now get the last value - /* 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 @@ -302,7 +302,7 @@ abstract class BaseStacker extends BaseFrameworkSystem { } // Now get the first value - $value = $this->getGenericArrayElement('stacks', $stackerName, 'entries', 0); + $value = $this->getGenericArrayElement('stacks', $stackerName, 'entries', '0'); // Return it /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-STACKER: value[]=%s - EXIT!', gettype($value))); -- 2.39.2