Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 20 Dec 2020 10:58:54 +0000 (11:58 +0100)
committerRoland Häder <roland@mxchange.org>
Sun, 20 Dec 2020 10:58:54 +0000 (11:58 +0100)
- added type-hints for primitive variables
- added condition-checks for string/int parameter and when condition is not met
  an IAE is being thrown

Signed-off-by: Roland Häder <roland@mxchange.org>
framework/main/classes/class_BaseFrameworkSystem.php
framework/main/classes/factories/stacks/class_FileStackFactory.php
framework/main/classes/factories/xml/class_XmlTemplateEngineFactory.php
framework/main/classes/file_directories/class_BaseFileIo.php
framework/main/classes/helper/class_BaseHelper.php
framework/main/classes/lists/class_BaseList.php
framework/main/classes/registry/class_BaseRegistry.php
framework/main/interfaces/lists/class_Listable.php

index 6810e7244d653fb908b8accf5138b3e2ffdb4190..7c6a73f92d16b56b467dce7136b54cd3719863af 100644 (file)
@@ -618,8 +618,11 @@ Loaded includes:
         * @deprecated  Not fully, as the new Logger facilities are not finished yet.
         */
        public final static function createDebugInstance (string $className, int $lineNumber = NULL) {
-               // Is the instance set?
-               if (!GenericRegistry::getRegistry()->instanceExists('debug')) {
+               // Validate parameter
+               if (empty($className)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "className" is empty');
+               } elseif (!GenericRegistry::getRegistry()->instanceExists('debug')) {
                        // Init debug instance
                        $debugInstance = NULL;
 
index 086dd8172a84522a68f6f0ec5c3add2f6a228a58..e4e5e53ad8f9321b12b50e1a7c02950e98ed7d0d 100644 (file)
@@ -9,6 +9,7 @@ use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
 
 // Import SPL stuff
+use \InvalidArgumentException;
 use \SplFileInfo;
 
 /**
@@ -52,6 +53,16 @@ class FileStackFactory extends BaseFactory {
         * @return      $stackInstance          An instance of a StackableFile class
         */
        public static final function createFileStackInstance (string $prefix, string $stackName) {
+               // Validate parameter
+               //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-FACTORY: prefix=%s,stackName=%s - CALLED!', $prefix, $stackName));
+               if (empty($prefix)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "prefix" is empty');
+               } elseif (empty($stackName)) {
+                       // Throw it again
+                       throw new InvalidArgumentException('Paramter "stackName" is empty');
+               }
+
                // Construct file stack name
                $fileInfoInstance = new SplFileInfo(sprintf('%s%s/%s.%s',
                        FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('root_base_path'),
@@ -73,6 +84,7 @@ class FileStackFactory extends BaseFactory {
                }
 
                // Return the instance
+               //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-FACTORY: stackInstance=%s - EXIT!', $stackInstance->__toString()));
                return $stackInstance;
        }
 
index 039b333a83b1da20d239633d67f00c971f5ee1df..7aafdffbb3b81ca02adb0309923c6f5b6a89bbc0 100644 (file)
@@ -7,6 +7,9 @@ use Org\Mxchange\CoreFramework\Factory\BaseFactory;
 use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
 
+// Import SPL stuff
+use \InvalidArgumentException;
+
 /**
  * A factory class for XML template engines. All instances generated by this
  * factory does have language support disabled and XML-compacting enabled (to
@@ -51,6 +54,13 @@ class XmlTemplateEngineFactory extends BaseFactory {
         * @return      $templateInstance       A template engine instance
         */
        public static final function createXmlTemplateEngineInstance (string $configKey) {
+               // Validate parameter
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('XML-TEMPLATE-ENGINE-FACTORY: configKey=%s - CALLED!', $configKey));
+               if (empty($configKey)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Paramter "configKey" is empty');
+               }
+
                // Do we have an instance in the registry?
                if (GenericRegistry::getRegistry()->instanceExists($configKey)) {
                        // Then use this instance
@@ -73,6 +83,7 @@ class XmlTemplateEngineFactory extends BaseFactory {
                }
 
                // Return the instance
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('XML-TEMPLATE-ENGINE-FACTORY: templateInstance=%s - EXIT!', $templateInstance->__toString()));
                return $templateInstance;
        }
 
index 6036db008de5d709114d3ba7add8fb7350ccb9ee..5eee416303bbe6fa19afe900feac02f19a0292c5 100644 (file)
@@ -184,14 +184,15 @@ abstract class BaseFileIo extends BaseFrameworkSystem implements FilePointer, Cl
                $seekStatus = $this->seek(0, SEEK_END);
 
                // Get position again (which is the end of the file)
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: seekStatus=%d', $seekStatus));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: seekStatus[%s]=%d', gettype($seekStatus), $seekStatus));
                $size = $this->determineSeekPosition();
 
                // Reset seek position to old
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: size[%s]=%d', gettype($size), $size));
                $this->seek($seekPosition);
 
                // Return size
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: size=%s - EXIT!', $size));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: size=%d - EXIT!', $size));
                return $size;
        }
 
index 7590ff4a520f13d632f7cea410941a2b39c8640a..b44a09912dd7c68902a191449818c3c14b0a880a 100644 (file)
@@ -214,7 +214,13 @@ abstract class BaseHelper extends BaseFrameworkSystem {
         * @throws      NullPointerException    If recovery of requested value instance failed
         */
        public function prefetchValueInstance (string $registryKey, string $extraKey = NULL) {
+               // Validate parameter
                //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('O:'.$registryKey.'/'.$extraKey);
+               if (empty($registryKey)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "registryKey" is empty');
+               }
+
                try {
                        // Get the required instance
                        $this->valueInstance = GenericRegistry::getRegistry()->getInstance($registryKey);
@@ -234,13 +240,13 @@ abstract class BaseHelper extends BaseFrameworkSystem {
                                $this->extraInstance = ObjectFactory::createObjectByConfiguredName($extraKey . '_class', array($this->valueInstance));
                        }
                        //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($extraKey.'='.$this->extraInstance.' - EXTRA!');
-               } // END - if
+               }
 
                // Is the value instance valid?
                if (is_null($this->valueInstance)) {
                        // Get the requested instance
                        $this->valueInstance = ObjectFactory::createObjectByConfiguredName($registryKey . '_class', array($this->extraInstance));
-               } // END - if
+               }
        }
 
        /**
@@ -255,12 +261,15 @@ abstract class BaseHelper extends BaseFrameworkSystem {
         * @throws      HelperGroupAlreadyCreatedException      If the group was already created before
         */
        protected function openGroupByIdContent (string $groupId, string $content, string $tag) {
-               //* DEBUG: */ echo "OPEN:groupId={$groupId},content=<pre>".htmlentities($content)."</pre>\n";
                // Is the group already there?
-               if (isset($this->groups[$groupId])) {
+               //* DEBUG: */ echo "OPEN:groupId={$groupId},content=<pre>".htmlentities($content)."</pre>\n";
+               if (empty($groupId)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "groupId" is empty');
+               } elseif (isset($this->groups[$groupId])) {
                        // Then throw an exception here
                        throw new HelperGroupAlreadyCreatedException(array($this, $groupId), self::EXCEPTION_GROUP_ALREADY_FOUND);
-               } // END - if
+               }
 
                // Count one up
                $this->totalCounter++;
@@ -294,13 +303,13 @@ abstract class BaseHelper extends BaseFrameworkSystem {
                if ($this->ifSubGroupOpenedPreviously()) {
                        // Close it automatically
                        $this->closePreviousSubGroupByContent();
-               } // END - if
+               }
 
                // Check if any group was opened before
                if ($this->ifGroupOpenedPreviously() === false) {
                        // Then throw an exception
                        throw new HelperNoPreviousOpenedGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
-               } // END - if
+               }
 
                // Get previous group
                $groupId = $this->getPreviousGroupId();
@@ -313,7 +322,7 @@ abstract class BaseHelper extends BaseFrameworkSystem {
                                $groupId,
                                $this->groups[$groupId]['tag']
                        );
-               } // END - if
+               }
 
                // Add content to it and mark it as closed
                $this->groups[$groupId]['content'] .= sprintf(
@@ -344,10 +353,13 @@ abstract class BaseHelper extends BaseFrameworkSystem {
        protected function openSubGroupByIdContent (string $subGroupId, string $content, string $tag) {
                //* DEBUG: */ echo "OPEN:subGroupId={$subGroupId},content=".htmlentities($content)."<br />\n";
                // Is the group already there?
-               if (isset($this->subGroups[$subGroupId])) {
+               if (empty($subGroupId)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "subGroupId" is empty');
+               } elseif (isset($this->subGroups[$subGroupId])) {
                        // Then throw an exception here
                        throw new HelperSubGroupAlreadyCreatedException(array($this, $subGroupId), self::EXCEPTION_SUB_GROUP_ALREADY_FOUND);
-               } // END - if
+               }
 
                // Count one up
                $this->totalCounter++;
@@ -375,7 +387,7 @@ abstract class BaseHelper extends BaseFrameworkSystem {
                if ($this->ifSubGroupOpenedPreviously() === false) {
                        // Then throw an exception
                        throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
-               } // END - if
+               }
 
                // Get previous sub group
                $subGroupId = $this->getPreviousSubGroupId();
@@ -384,7 +396,7 @@ abstract class BaseHelper extends BaseFrameworkSystem {
                if ((empty($content)) && (!empty($this->subGroups[$subGroupId]['tag']))) {
                        // Get it from opener
                        $content = sprintf('<!-- sub-group %s auto-closed //--></%s>', $subGroupId, $this->subGroups[$subGroupId]['tag']);
-               } // END - if
+               }
 
                // Add content to it and mark it as closed
                $this->subGroups[$subGroupId]['content'] .= sprintf('<!-- sub-group %s closed (length: %s, tag: %s) //-->%s' . PHP_EOL, $subGroupId, strlen($content), $this->subGroups[$subGroupId]['tag'], $content);
@@ -409,7 +421,7 @@ abstract class BaseHelper extends BaseFrameworkSystem {
                if (isset($this->groups['header'])) {
                        // Then add it
                        $content .= $this->groups['header']['content'] . PHP_EOL;
-               } // END - if
+               }
 
                // Initiate content
                $content .= $this->getContent();
@@ -431,13 +443,13 @@ abstract class BaseHelper extends BaseFrameworkSystem {
                                // Something went wrong
                                $this->debugInstance(__METHOD__ . '(): Something unexpected happened here.');
                        }
-               } // END - for
+               }
 
                // Is footer content there?
                if (isset($this->groups['footer'])) {
                        // Then add it
                        $content .= $this->groups['footer']['content'] . PHP_EOL;
-               } // END - if
+               }
 
                // Return it
                //* DEBUG: */ echo "content=<pre>".htmlentities($content)."</pre> (".strlen($content).")<br />\n";
@@ -473,7 +485,7 @@ abstract class BaseHelper extends BaseFrameworkSystem {
                if (is_null($this->getValueInstance())) {
                        // Throws an exception here
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } // END - if
+               }
 
                // Is the field set?
                if ($this->getValueInstance()->isFieldSet($fieldName)) {
index 5cf4c15c19c005a2c9c05e59a7a60f7ca3b0c473..acad90d533ff99bbc5051f10799f33957dd108d4 100644 (file)
@@ -10,6 +10,7 @@ use Org\Mxchange\CoreFramework\Traits\Iterator\IteratorTrait;
 use Org\Mxchange\CoreFramework\Visitor\Visitable;
 
 // Import SPL stuff
+use \InvalidArgumentException;
 use \IteratorAggregate;
 use \Countable;
 
@@ -99,7 +100,14 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
         * @return      $isset          Whether the group is valid
         */
        public function isGroupSet (string $groupName) {
+               // Validate parameter
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName);
+               if (empty($groupName)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "groupName" is empty');
+               }
+
+               // Check on existence ...
                return isset($this->listGroups[$groupName]);
        }
 
@@ -111,9 +119,12 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
         * @throws      ListGroupAlreadyAddedException  If the given group is already added
         */
        public function addGroup (string $groupName) {
+               // Validate parameter
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!');
-               // Is the group already added?
-               if ($this->isGroupSet($groupName)) {
+               if (empty($groupName)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "groupName" is empty');
+               } elseif ($this->isGroupSet($groupName)) {
                        // Throw the exception here
                        throw new ListGroupAlreadyAddedException(array($this, $groupName), self::EXCEPTION_GROUP_ALREADY_ADDED);
                }
@@ -133,11 +144,15 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
         * @throws      NoListGroupException    If the given group is not found
         */
        public function addInstance (string $groupName, string $subGroup, Visitable $visitableInstance) {
-               // Debug message
+               // Validate parameter
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName  . ',subGroup=' . $subGroup . ',visitableInstance=' . $visitableInstance->__toString() . ' - CALLED!');
-
-               // Is the group there?
-               if (!$this->isGroupSet($groupName)) {
+               if (empty($groupName)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "groupName" is empty');
+               } elseif (empty($subGroup)) {
+                       // Throw it again
+                       throw new InvalidArgumentException('Parameter "subGroup" is empty');
+               } elseif (!$this->isGroupSet($groupName)) {
                        // Throw the exception here
                        throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND);
                }
@@ -167,35 +182,34 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
        /**
         * Gets an array from given list
         *
-        * @param       $list   The requested list
+        * @param       $groupName      The requested list
         * @return      $array  The requested array
         * @throws      NoListGroupException    If the given group is not found
         */
-       public final function getArrayFromList ($list) {
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',list[' . gettype($list) . ']=' . $list . ' - CALLED!');
-
+       public final function getArrayFromList ($groupName) {
                // Is the group there?
-               if ((!is_null($list)) && (!$this->isGroupSet($list))) {
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName[' . gettype($groupName) . ']=' . $groupName . ' - CALLED!');
+               if (empty($groupName)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "groupName" is empty');
+               } elseif ((!is_null($groupName)) && (!$this->isGroupSet($groupName))) {
                        // Throw the exception here
-                       throw new NoListGroupException(array($this, $list), self::EXCEPTION_GROUP_NOT_FOUND);
+                       throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND);
                }
 
                // Init array
                $array = [];
 
                // Is there another list?
-               if (!is_null($list)) {
+               if (!is_null($groupName)) {
                        // Then get it as well
-                       $array = $this->listGroups[$list]->getArrayFromList(NULL);
+                       $array = $this->listGroups[$groupName]->getArrayFromList(NULL);
                }
 
                // Walk through all entries
                foreach ($this->listIndex as $hash) {
-                       // Debug message
-                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: hash=' . $hash);
-
                        // Is the list entry set?
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: hash=' . $hash);
                        if ($this->isHashValid($hash)) {
                                // Add it
                                array_push($array, $this->listEntries[$hash]);
@@ -203,10 +217,8 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
                        }
                }
 
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',list[' . gettype($list) . ']=' . $list . ',[]=' . count($array) . ' - EXIT!');
-
                // Return it
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName[' . gettype($groupName) . ']=' . $groupName . ',[]=' . count($array) . ' - EXIT!');
                return $array;
        }
 
@@ -219,11 +231,12 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
         * @throws      NoListGroupException    If the given group is not found
         */
        public function addEntry (string $groupName, $entry) {
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!');
-
                // Is the group already added?
-               if (!$this->isGroupSet($groupName)) {
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!');
+               if (empty($groupName)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "groupName" is empty');
+               } elseif (!$this->isGroupSet($groupName)) {
                        // Throw the exception here
                        throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND);
                }
@@ -256,11 +269,12 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
         * @throws      NoListGroupException    If the given group is not found
         */
        public function removeEntry (string $groupName, $entry) {
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!');
-
                // Is the group already added?
-               if (!$this->isGroupSet($groupName)) {
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!');
+               if (empty($groupName)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "groupName" is empty');
+               } elseif (!$this->isGroupSet($groupName)) {
                        // Throw the exception here
                        throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND);
                }
@@ -351,7 +365,10 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
         */
        protected function clearGroup (string $groupName) {
                // Does this group exist?
-               if (!$this->isGroupSet($groupName)) {
+               if (empty($groupName)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "groupName" is empty');
+               } elseif (!$this->isGroupSet($groupName)) {
                        // Throw the exception here
                        throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND);
                }
@@ -379,7 +396,13 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
         * @param       $hash           The hash we should validate
         * @return      $isValid        Whether the given hash is valid
         */
-       public final function isHashValid ($hash) {
+       public final function isHashValid (string $hash) {
+               // Validate parameter
+               if (empty($hash)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "hash" is empty');
+               }
+
                // Check it
                $isValid = ((in_array($hash, $this->listIndex)) && (isset($this->listEntries[$hash])));
 
@@ -434,7 +457,10 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
         */
        public function getArrayFromProtocolInstance (string $groupName) {
                // Is the group valid?
-               if (!$this->isGroupSet($groupName)) {
+               if (empty($groupName)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "groupName" is empty');
+               } elseif (!$this->isGroupSet($groupName)) {
                        // Throw the exception here
                        throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND);
                }
@@ -478,9 +504,12 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
         * @return      void
         * @throws      InvalidListHashException        If the solved hash index is invalid
         */
-       public function updateCurrentEntryByHash ($hash, array $entryArray) {
+       public function updateCurrentEntryByHash (string $hash, array $entryArray) {
                // Is the hash valid?
-               if (!$this->isHashValid($hash)) {
+               if (empty($hash)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "hash" is empty');
+               } elseif (!$this->isHashValid($hash)) {
                        // Throw an exception here, hashIndex is unknown at this point
                        throw new InvalidListHashException(array($this, $hash, -999), self::EXCEPTION_INVALID_HASH);
                }
index 8d8a76abc8243fd4a622de0613c852b4f7a3a68e..bb04f70affc395b86eac628c144b82a40f02e85a 100644 (file)
@@ -9,6 +9,7 @@ use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
 use Org\Mxchange\CoreFramework\Traits\Iterator\IteratorTrait;
 
 // Import SPL stuff
+use \InvalidArgumentExeption;
 use \IteratorAggregate;
 
 /**
@@ -105,6 +106,13 @@ abstract class BaseRegistry extends BaseFrameworkSystem implements Register, Reg
         * @return      void
         */
        public function addInstance (string $instanceKey, Registerable $objectInstance) {
+               // Validate parameter
+               if (empty($instanceKey)) {
+                       // Throw IAE
+                       throw new InvalidArgumentExeption('Parameter "instanceKey" is empty');
+               }
+
+               // Set entry in generic array
                $this->setGenericArrayKey('registry', 'instance', $instanceKey, $objectInstance);
        }
 
index 4844d0a40fe8cb030832331eee9374d151ca5723..639686bf9101688ce82b0887d17e080b8e4d754e 100644 (file)
@@ -78,7 +78,7 @@ interface Listable extends FrameworkInterface, IteratorAggregate {
         * @return      void
         * @throws      InvalidListHashException        If the solved hash index is invalid
         */
-       function updateCurrentEntryByHash ($hash, array $entryArray);
+       function updateCurrentEntryByHash (string $hash, array $entryArray);
 
        /**
         * "Getter" for an iterator instance of this list