Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 2 Dec 2020 04:34:03 +0000 (05:34 +0100)
committerRoland Häder <roland@mxchange.org>
Wed, 2 Dec 2020 04:34:03 +0000 (05:34 +0100)
- also removed other deprecated exception and replaced it with same as before
- fixed exception constructor invocation

Signed-off-by: Roland Häder <roland@mxchange.org>
framework/main/classes/stacker/class_BaseStacker.php
framework/main/classes/stacker/fifo/class_FiFoStacker.php
framework/main/classes/stacker/file/class_BaseFileStack.php
framework/main/classes/stacker/file/fifo/class_FiFoFileStack.php
framework/main/classes/stacker/filo/class_FiLoStacker.php
framework/main/exceptions/stacker/class_EmptyStackerException.php [deleted file]
framework/main/interfaces/stacker/class_Stackable.php

index 9ba1deec1709a96369795602b49c9c258820a5c7..98e52b39844c4d45010c8e4ddc860655e33a763a 100644 (file)
@@ -106,7 +106,7 @@ abstract class BaseStacker extends BaseFrameworkSystem {
                // Is the stack not yet initialized?
                if (!$this->isStackInitialized($stackerName)) {
                        // Throw an exception
-                       throw new BadMethodCallException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND);
+                       throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_NO_STACKER_FOUND);
                } // END - if
 
                // So, is the stack full?
@@ -127,7 +127,7 @@ abstract class BaseStacker extends BaseFrameworkSystem {
                // Is the stack not yet initialized?
                if (!$this->isStackInitialized($stackerName)) {
                        // Throw an exception
-                       throw new BadMethodCallException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND);
+                       throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_NO_STACKER_FOUND);
                } // END - if
 
                // So, is the stack empty?
@@ -148,7 +148,7 @@ abstract class BaseStacker extends BaseFrameworkSystem {
                // Is the stack not yet initialized?
                if (!$this->isStackInitialized($stackerName)) {
                        // Throw an exception
-                       throw new BadMethodCallException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND);
+                       throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_NO_STACKER_FOUND);
                } // END - if
 
                // Now, count the array of entries
@@ -186,16 +186,16 @@ abstract class BaseStacker extends BaseFrameworkSystem {
         * @param       $stackerName    Name of the stack
         * @return      $value                  Value of last added value
         * @throws      BadMethodCallException  If the named stacker was not found
-        * @throws      EmptyStackerException   If the named stacker is empty
+        * @throws      BadMethodCallException  If the named stacker is empty
         */
        protected function getLastValue (string $stackerName) {
                // Is the stack not yet initialized or full?
                if (!$this->isStackInitialized($stackerName)) {
                        // Throw an exception
-                       throw new BadMethodCallException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND);
+                       throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_NO_STACKER_FOUND);
                } elseif ($this->isStackEmpty($stackerName)) {
                        // Throw an exception
-                       throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
+                       throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
                }
 
                // Now get the last value
@@ -211,16 +211,16 @@ abstract class BaseStacker extends BaseFrameworkSystem {
         * @param       $stackerName    Name of the stack
         * @return      $value                  Value of last added value
         * @throws      BadMethodCallException  If the named stacker was not found
-        * @throws      EmptyStackerException   If the named stacker is empty
+        * @throws      BadMethodCallException  If the named stacker is empty
         */
        protected function getFirstValue (string $stackerName) {
                // Is the stack not yet initialized or full?
                if (!$this->isStackInitialized($stackerName)) {
                        // Throw an exception
-                       throw new BadMethodCallException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND);
+                       throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_NO_STACKER_FOUND);
                } elseif ($this->isStackEmpty($stackerName)) {
                        // Throw an exception
-                       throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
+                       throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
                }
 
                // Now get the first value
@@ -236,16 +236,16 @@ abstract class BaseStacker extends BaseFrameworkSystem {
         * @param       $stackerName    Name of the stack
         * @return      $value                  Value "poped" from array
         * @throws      BadMethodCallException  If the named stacker was not found
-        * @throws      EmptyStackerException   If the named stacker is empty
+        * @throws      BadMethodCallException  If the named stacker is empty
         */
        protected function popLast (string $stackerName) {
                // Is the stack not yet initialized or full?
                if (!$this->isStackInitialized($stackerName)) {
                        // Throw an exception
-                       throw new BadMethodCallException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND);
+                       throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_NO_STACKER_FOUND);
                } elseif ($this->isStackEmpty($stackerName)) {
                        // Throw an exception
-                       throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
+                       throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
                }
 
                // Now, remove the last entry, we don't care about the return value here, see elseif() block above
@@ -258,16 +258,16 @@ abstract class BaseStacker extends BaseFrameworkSystem {
         * @param       $stackerName    Name of the stack
         * @return      $value                  Value "shifted" from array
         * @throws      BadMethodCallException  If the named stacker was not found
-        * @throws      EmptyStackerException   If the named stacker is empty
+        * @throws      BadMethodCallException  If the named stacker is empty
         */
        protected function popFirst (string $stackerName) {
                // Is the stack not yet initialized or full?
                if (!$this->isStackInitialized($stackerName)) {
                        // Throw an exception
-                       throw new BadMethodCallException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND);
+                       throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_NO_STACKER_FOUND);
                } elseif ($this->isStackEmpty($stackerName)) {
                        // Throw an exception
-                       throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
+                       throw new BadMethodCallException(sprintf('stackerName=%s not yet initialized but method called.', $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
                }
 
                // Now, remove the last entry, we don't care about the return value here, see elseif() block above
index 6cc71a951b516d0e2041f86265aae88c9df1b8bd..8e553e7fd7aa68eb78daa3d746bb68da89971248 100644 (file)
@@ -59,7 +59,7 @@ class FiFoStacker extends BaseStacker implements Stackable {
         * @return      void
         * @throws      StackerFullException    If the stack is full
         */
-       public function pushNamed ($stackerName, $value) {
+       public function pushNamed (string $stackerName, $value) {
                // Call the protected method
                parent::addValue($stackerName, $value);
        }
@@ -70,9 +70,9 @@ class FiFoStacker extends BaseStacker implements Stackable {
         * @param       $stackerName    Name of the stack
         * @return      $value                  Value of the current stack entry
         * @throws      BadMethodCallException  If the named stacker was not found
-        * @throws      EmptyStackerException   If the named stacker is empty
+        * @throws      BadMethodCallException  If the named stacker is empty
         */
-       public function popNamed ($stackerName) {
+       public function popNamed (string $stackerName) {
                // Get the value
                $value = $this->getNamed($stackerName);
 
@@ -89,9 +89,9 @@ class FiFoStacker extends BaseStacker implements Stackable {
         * @param       $stackerName    Name of the stack
         * @return      $value                  Value of last added value
         * @throws      BadMethodCallException  If the named stacker was not found
-        * @throws      EmptyStackerException   If the named stacker is empty
+        * @throws      BadMethodCallException  If the named stacker is empty
         */
-       public function getNamed ($stackerName) {
+       public function getNamed (string $stackerName) {
                // Call the protected method
                return parent::getFirstValue($stackerName);
        }
index d990a375f07525492bbb8f9c84fa98afe85bef0d..7ea25c11285fdb6602113575a57d7c33066094d6 100644 (file)
@@ -322,13 +322,13 @@ abstract class BaseFileStack extends BaseStacker {
         *
         * @param       $stackerName    Name of the stack
         * @return      $value                  Value of last added value
-        * @throws      EmptyStackerException   If the stack is empty
+        * @throws      BadMethodCallException  If the stack is empty
         */
        protected function getLastValue (string $stackerName) {
                // Is the stack not yet initialized or full?
                if ($this->isStackEmpty($stackerName)) {
                        // Throw an exception
-                       throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
+                       throw new BadMethodCallException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
                } // END - if
 
                // Now get the last value
@@ -344,13 +344,13 @@ abstract class BaseFileStack extends BaseStacker {
         *
         * @param       $stackerName    Name of the stack
         * @return      $value                  Value of last added value
-        * @throws      EmptyStackerException   If the stack is empty
+        * @throws      BadMethodCallException  If the stack is empty
         */
        protected function getFirstValue (string $stackerName) {
                // Is the stack not yet initialized or full?
                if ($this->isStackEmpty($stackerName)) {
                        // Throw an exception
-                       throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
+                       throw new BadMethodCallException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
                } // END - if
 
                // Now get the first value
@@ -366,13 +366,13 @@ abstract class BaseFileStack extends BaseStacker {
         *
         * @param       $stackerName    Name of the stack
         * @return      $value                  Value "poped" from array
-        * @throws      EmptyStackerException   If the stack is empty
+        * @throws      BadMethodCallException  If the stack is empty
         */
        protected function popLast (string $stackerName) {
                // Is the stack not yet initialized or full?
                if ($this->isStackEmpty($stackerName)) {
                        // Throw an exception
-                       throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
+                       throw new BadMethodCallException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
                } // END - if
 
                // Now, remove the last entry, we don't care about the return value here, see elseif() block above
@@ -385,13 +385,13 @@ abstract class BaseFileStack extends BaseStacker {
         *
         * @param       $stackerName    Name of the stack
         * @return      $value                  Value "shifted" from array
-        * @throws      EmptyStackerException   If the named stacker is empty
+        * @throws      BadMethodCallException  If the named stacker is empty
         */
        protected function popFirst (string $stackerName) {
                // Is the stack not yet initialized or full?
                if ($this->isStackEmpty($stackerName)) {
                        // Throw an exception
-                       throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
+                       throw new BadMethodCallException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
                } // END - if
 
                // Now, remove the last entry, we don't care about the return value here, see elseif() block above
index 57c69249745194f68ac0b05fe311c94b0d03748d..466c7e1c8df645686cef4c6891bbb28a1d74f36e 100644 (file)
@@ -70,7 +70,7 @@ class FiFoFileStack extends BaseFileStack implements StackableFile, Calculatable
         * @return      void
         * @throws      StackerFullException    If the stack is full
         */
-       public function pushNamed ($stackerName, $value) {
+       public function pushNamed (string $stackerName, $value) {
                // Call the protected method
                parent::addValue($stackerName, $value);
        }
@@ -81,9 +81,9 @@ class FiFoFileStack extends BaseFileStack implements StackableFile, Calculatable
         * @param       $stackerName    Name of the stack
         * @return      $value                  Value of the current stack entry
         * @throws      BadMethodCallException  If the named stacker was not found
-        * @throws      EmptyStackerException   If the named stacker is empty
+        * @throws      BadMethodCallException  If the named stacker is empty
         */
-       public function popNamed ($stackerName) {
+       public function popNamed (string $stackerName) {
                // Get the value
                $value = $this->getNamed($stackerName);
 
@@ -100,9 +100,9 @@ class FiFoFileStack extends BaseFileStack implements StackableFile, Calculatable
         * @param       $stackerName    Name of the stack
         * @return      $value                  Value of last added value
         * @throws      BadMethodCallException  If the named stacker was not found
-        * @throws      EmptyStackerException   If the named stacker is empty
+        * @throws      BadMethodCallException  If the named stacker is empty
         */
-       public function getNamed ($stackerName) {
+       public function getNamed (string $stackerName) {
                // Call the protected method
                return parent::getFirstValue($stackerName);
        }
index 4b8237df4514910e877b21b7f8aa5b8ba1c2d72d..d48f0f5d091ed5b3de1758bcf3cf8bf01e1baefa 100644 (file)
@@ -59,7 +59,7 @@ class FiLoStacker extends BaseStacker implements Stackable {
         * @return      void
         * @throws      StackerFullException    If the stack is full
         */
-       public function pushNamed ($stackerName, $value) {
+       public function pushNamed (string $stackerName, $value) {
                // Call the protected method
                parent::addValue($stackerName, $value);
        }
@@ -70,9 +70,9 @@ class FiLoStacker extends BaseStacker implements Stackable {
         * @param       $stackerName    Name of the stack
         * @return      $value                  Value of the current stack entry
         * @throws      BadMethodCallException  If the named stacker was not found
-        * @throws      EmptyStackerException   If the named stacker is empty
+        * @throws      BadMethodCallException  If the named stacker is empty
         */
-       public function popNamed ($stackerName) {
+       public function popNamed (string $stackerName) {
                // Get the value
                $value = $this->getNamed($stackerName);
 
@@ -89,9 +89,9 @@ class FiLoStacker extends BaseStacker implements Stackable {
         * @param       $stackerName    Name of the stack
         * @return      $value                  Value of last added value
         * @throws      BadMethodCallException  If the named stacker was not found
-        * @throws      EmptyStackerException   If the named stacker is empty
+        * @throws      BadMethodCallException  If the named stacker is empty
         */
-       public function getNamed ($stackerName) {
+       public function getNamed (string $stackerName) {
                // Call the protected method
                return parent::getLastValue($stackerName);
        }
diff --git a/framework/main/exceptions/stacker/class_EmptyStackerException.php b/framework/main/exceptions/stacker/class_EmptyStackerException.php
deleted file mode 100644 (file)
index 0841561..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Deprecated;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Generic\FrameworkException;
-
-/**
- * Thrown if a stacker is empty
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- * @deprecated Don't use this anymore
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class EmptyStackerException extends FrameworkException {
-       /**
-        * The super constructor for all exceptions
-        *
-        * @param               $messageArray   Error message array
-        * @param               $code                   Error code
-        * @return      void
-        */
-       public function __construct (array $messageArray, int $code) {
-               // Construct message
-               $message = sprintf('[%s:%d] Stacker %s is empty.',
-                       $messageArray[0]->__toString(),
-                       $this->getLine(),
-                       $messageArray[1]
-               );
-
-               // Call parent exception constructor
-               parent::__construct($message, $code);
-       }
-
-}
index aebbd9f878f257f2612960b95b6aa05dd3874925..402aed93201f8ff00ae85e0192e4933a539234a9 100644 (file)
@@ -44,7 +44,7 @@ interface Stackable extends FrameworkInterface {
         * @param       $stackerName    Name of the stacker
         * @return      $value                  Value of the current stack entry
         * @throws      BadMethodCallException  If the named stacker was not found
-        * @throws      EmptyStackerException   If the named stacker is empty
+        * @throws      BadMethodCallException  If the named stacker is empty
         */
        function popNamed (string $stackerName);
 
@@ -54,7 +54,7 @@ interface Stackable extends FrameworkInterface {
         * @param       $stackerName    Name of the stacker
         * @return      $value                  Value of last added value
         * @throws      BadMethodCallException  If the named stacker was not found
-        * @throws      EmptyStackerException   If the named stacker is empty
+        * @throws      BadMethodCallException  If the named stacker is empty
         */
        function getNamed (string $stackerName);