From 290bdec43738f28498ecd4322ec04b86dccc40ac Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 23 Jun 2013 19:51:09 +0000 Subject: [PATCH] Fixed more methods, value from shiftGenericArrayElement/popGenericArrayElement should be returned instead ignored --- inc/classes/main/class_BaseFrameworkSystem.php | 7 +++++-- inc/classes/main/stacker/class_BaseStacker.php | 18 +++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index 80d861d3..b48b030c 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -2181,6 +2181,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } // END - if // Return it + //* DEBUG: */ print(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' returning!' . PHP_EOL); return $this->genericArray[$keyGroup][$subGroup]; } @@ -2194,6 +2195,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ protected final function unsetGenericArrayElement ($keyGroup, $subGroup, $key) { // Remove it + //* DEBUG: */ print(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' unset!' . PHP_EOL); unset($this->genericArray[$keyGroup][$subGroup][$key]); } @@ -2233,6 +2235,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } // END - if // Initialize it + //* DEBUG: */ print(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . PHP_EOL); $this->genericArray[$keyGroup][$subGroup][$key] = array(); } @@ -2253,7 +2256,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } // END - if // Then push it - //* DEBUG: */ print(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value=' . $value . PHP_EOL); + //* DEBUG: */ print(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, TRUE) . PHP_EOL); $count = array_push($this->genericArray[$keyGroup][$subGroup][$key], $value); // Return count @@ -2283,7 +2286,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Return value //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE)); - //* DEBUG: */ print(__METHOD__ . ': value[' . gettype($value) . ']=' . $value . PHP_EOL); + //* DEBUG: */ print(__METHOD__ . ': value[' . gettype($value) . ']=' . print_r($value, TRUE) . PHP_EOL); return $value; } diff --git a/inc/classes/main/stacker/class_BaseStacker.php b/inc/classes/main/stacker/class_BaseStacker.php index d2817580..d5917bb5 100644 --- a/inc/classes/main/stacker/class_BaseStacker.php +++ b/inc/classes/main/stacker/class_BaseStacker.php @@ -171,7 +171,7 @@ class BaseStacker extends BaseFrameworkSystem { // Throw an exception throw new NoStackerException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND); } elseif ($this->isStackEmpty($stackerName)) { - //Throw an exception + // Throw an exception throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); } @@ -196,12 +196,12 @@ class BaseStacker extends BaseFrameworkSystem { // Throw an exception throw new NoStackerException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND); } elseif ($this->isStackEmpty($stackerName)) { - //Throw an exception + // Throw an exception throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); } // Now get the first value - $value = $this->popGenericArrayElement('stacks', $stackerName, 'entries', 0); + $value = $this->getGenericArrayElement('stacks', $stackerName, 'entries', 0); // Return it return $value; @@ -211,7 +211,7 @@ class BaseStacker extends BaseFrameworkSystem { * "Pops" last entry from stack * * @param $stackerName Name of the stack - * @return void + * @return $value Value "poped" from array * @throws NoStackerException If the named stacker was not found * @throws EmptyStackerException If the named stacker is empty */ @@ -221,19 +221,19 @@ class BaseStacker extends BaseFrameworkSystem { // Throw an exception throw new NoStackerException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND); } elseif ($this->isStackEmpty($stackerName)) { - //Throw an exception + // Throw an exception throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); } // Now, remove the last entry, we don't care about the return value here, see elseif() block above - $this->popGenericArrayElement('stacks', $stackerName, 'entries'); + return $this->popGenericArrayElement('stacks', $stackerName, 'entries'); } /** * "Pops" first entry from stack * * @param $stackerName Name of the stack - * @return void + * @return $value Value "shifted" from array * @throws NoStackerException If the named stacker was not found * @throws EmptyStackerException If the named stacker is empty */ @@ -243,12 +243,12 @@ class BaseStacker extends BaseFrameworkSystem { // Throw an exception throw new NoStackerException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND); } elseif ($this->isStackEmpty($stackerName)) { - //Throw an exception + // Throw an exception throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); } // Now, remove the last entry, we don't care about the return value here, see elseif() block above - $this->shiftGenericArrayElement('stacks', $stackerName, 'entries'); + return $this->shiftGenericArrayElement('stacks', $stackerName, 'entries'); } } -- 2.39.5