From 3ccc1cf129da7478efaf565981dc06e8dd615590 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 28 Apr 2011 14:34:37 +0000 Subject: [PATCH] popNamed() does also now return the current stacker's value. --- inc/classes/interfaces/stacker/class_Stackable.php | 6 +++--- inc/classes/main/stacker/fifo/class_FiFoStacker.php | 10 ++++++++-- inc/classes/main/stacker/filo/class_FiLoStacker.php | 10 ++++++++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/inc/classes/interfaces/stacker/class_Stackable.php b/inc/classes/interfaces/stacker/class_Stackable.php index f8ef7fe8..34b6cf18 100644 --- a/inc/classes/interfaces/stacker/class_Stackable.php +++ b/inc/classes/interfaces/stacker/class_Stackable.php @@ -33,17 +33,17 @@ interface Stackable extends FrameworkInterface { function pushNamed ($stackerName, $value); /** - * 'Pops' a value from a named stacker + * 'Pops' a value from a named stacker and returns it's value * * @param $stackerName Name of the stacker - * @return void + * @return $value Value of the current stack entry * @throws NoStackerException If the named stacker was not found * @throws EmptyStackerException If the named stacker is empty */ function popNamed ($stackerName); /** - * Get value from named stacker + * Get value from named stacker but don't "pop" it * * @param $stackerName Name of the stacker * @return $value Value of last added value diff --git a/inc/classes/main/stacker/fifo/class_FiFoStacker.php b/inc/classes/main/stacker/fifo/class_FiFoStacker.php index 5b036a4f..7b33cd9d 100644 --- a/inc/classes/main/stacker/fifo/class_FiFoStacker.php +++ b/inc/classes/main/stacker/fifo/class_FiFoStacker.php @@ -62,16 +62,22 @@ class FiFoStacker extends BaseStacker implements Stackable { } /** - * 'Pops' a value from a named stacker + * 'Pops' a value from a named stacker and returns it's value * * @param $stackerName Name of the stack - * @return void + * @return $value Value of the current stack entry * @throws NoStackerException If the named stacker was not found * @throws EmptyStackerException If the named stacker is empty */ public function popNamed ($stackerName) { + // Get the value + $value = $this->getNamed($stackerName(); + // Call the protected method parent::popFirst($stackerName); + + // Return the value + return $value; } /** diff --git a/inc/classes/main/stacker/filo/class_FiLoStacker.php b/inc/classes/main/stacker/filo/class_FiLoStacker.php index 1d2d94af..81604945 100644 --- a/inc/classes/main/stacker/filo/class_FiLoStacker.php +++ b/inc/classes/main/stacker/filo/class_FiLoStacker.php @@ -62,16 +62,22 @@ class FiLoStacker extends BaseStacker implements Stackable { } /** - * 'Pops' a value from a named stacker + * 'Pops' a value from a named stacker and returns it's value * * @param $stackerName Name of the stack - * @return void + * @return $value Value of the current stack entry * @throws NoStackerException If the named stacker was not found * @throws EmptyStackerException If the named stacker is empty */ public function popNamed ($stackerName) { + // Get the value + $value = $this->getNamed($stackerName(); + // Call the protected method parent::popLast($stackerName); + + // Return the value + return $value; } /** -- 2.39.5