Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 20 Dec 2020 11:22:12 +0000 (12:22 +0100)
committerRoland Häder <roland@mxchange.org>
Sun, 20 Dec 2020 11:22:12 +0000 (12:22 +0100)
- NULL is no longer allowed as "empty" strings for $groupName are not allowed
- this whole thing was a bit complicated core and now still is buth with no NULL

Signed-off-by: Roland Häder <roland@mxchange.org>
framework/main/classes/lists/class_BaseList.php

index acad90d533ff99bbc5051f10799f33957dd108d4..6ec8ac4e19ad0299d0adaa747ede31dd35dacaf1 100644 (file)
@@ -101,7 +101,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
         */
        public function isGroupSet (string $groupName) {
                // Validate parameter
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName);
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: groupName=' . $groupName);
                if (empty($groupName)) {
                        // Throw IAE
                        throw new InvalidArgumentException('Parameter "groupName" is empty');
@@ -120,7 +120,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
         */
        public function addGroup (string $groupName) {
                // Validate parameter
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: groupName=' . $groupName . ' - CALLED!');
                if (empty($groupName)) {
                        // Throw IAE
                        throw new InvalidArgumentException('Parameter "groupName" is empty');
@@ -131,7 +131,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
 
                // Add the group which is a simple array
                $this->listGroups[$groupName] = ObjectFactory::createObjectByConfiguredName('list_group_class');
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ' - EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: groupName=' . $groupName . ' - EXIT!');
        }
 
        /**
@@ -145,7 +145,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
         */
        public function addInstance (string $groupName, string $subGroup, Visitable $visitableInstance) {
                // Validate parameter
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName  . ',subGroup=' . $subGroup . ',visitableInstance=' . $visitableInstance->__toString() . ' - CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: groupName=' . $groupName  . ',subGroup=' . $subGroup . ',visitableInstance=' . $visitableInstance->__toString() . ' - CALLED!');
                if (empty($groupName)) {
                        // Throw IAE
                        throw new InvalidArgumentException('Parameter "groupName" is empty');
@@ -167,7 +167,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
                $hash = $this->generateHash($groupName, $subGroup, $visitableInstance);
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',this->listGroups[' . $groupName . ']=' . $this->listGroups[$groupName]->__toString());
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this->listGroups[' . $groupName . ']=' . $this->listGroups[$groupName]->__toString());
 
                // Add the hash to the index
                array_push($this->listIndex, $hash);
@@ -176,7 +176,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
                $this->listEntries[$hash] = $visitableInstance;
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName  . ',subGroup=' . $subGroup . ' - EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: groupName=' . $groupName  . ',subGroup=' . $subGroup . ' - EXIT!');
        }
 
        /**
@@ -186,13 +186,13 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
         * @return      $array  The requested array
         * @throws      NoListGroupException    If the given group is not found
         */
-       public final function getArrayFromList ($groupName) {
+       public final function getArrayFromList (string $groupName) {
                // Is the group there?
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName[' . gettype($groupName) . ']=' . $groupName . ' - CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: groupName[' . gettype($groupName) . ']=' . $groupName . ' - CALLED!');
                if (empty($groupName)) {
                        // Throw IAE
                        throw new InvalidArgumentException('Parameter "groupName" is empty');
-               } elseif ((!is_null($groupName)) && (!$this->isGroupSet($groupName))) {
+               } elseif (!$this->isGroupSet($groupName)) {
                        // Throw the exception here
                        throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND);
                }
@@ -203,7 +203,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
                // Is there another list?
                if (!is_null($groupName)) {
                        // Then get it as well
-                       $array = $this->listGroups[$groupName]->getArrayFromList(NULL);
+                       $array = $this->listGroups[$groupName]->getArrayFromList('__');
                }
 
                // Walk through all entries
@@ -218,7 +218,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
                }
 
                // Return it
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName[' . gettype($groupName) . ']=' . $groupName . ',[]=' . count($array) . ' - EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: groupName[' . gettype($groupName) . ']=' . $groupName . ',[]=' . count($array) . ' - EXIT!');
                return $array;
        }
 
@@ -232,7 +232,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
         */
        public function addEntry (string $groupName, $entry) {
                // Is the group already added?
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: groupName=' . $groupName . ' - CALLED!');
                if (empty($groupName)) {
                        // Throw IAE
                        throw new InvalidArgumentException('Parameter "groupName" is empty');
@@ -245,19 +245,19 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
                $hash = $this->generateHash($groupName, $groupName, $entry);
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ',entry=' . print_r($entry, true) . ', hash=' . $hash);
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: groupName=' . $groupName . ',entry=' . print_r($entry, true) . ', hash=' . $hash);
 
                // Add the hash to the index
                array_push($this->listIndex, $hash);
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ',listEntries()=' . count($this->listEntries));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: groupName=' . $groupName . ',listEntries()=' . count($this->listEntries));
 
                // Now add the entry to the list
                $this->listEntries[$hash] = $entry;
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ',listEntries()=' . count($this->listEntries) . ' - EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: groupName=' . $groupName . ',listEntries()=' . count($this->listEntries) . ' - EXIT!');
        }
 
        /**
@@ -270,7 +270,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
         */
        public function removeEntry (string $groupName, $entry) {
                // Is the group already added?
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: groupName=' . $groupName . ' - CALLED!');
                if (empty($groupName)) {
                        // Throw IAE
                        throw new InvalidArgumentException('Parameter "groupName" is empty');
@@ -283,7 +283,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
                $hash = $this->generateHash($groupName, $groupName, $entry);
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ',entry=' . $entry . ', hash=' . $hash);
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: groupName=' . $groupName . ',entry=' . $entry . ', hash=' . $hash);
 
                // Remove it from the list ...
                unset($this->listEntries[$hash]);
@@ -292,7 +292,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
                unset($this->listIndex[array_search($hash, $this->listIndex)]);
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ' - EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: groupName=' . $groupName . ' - EXIT!');
        }
 
        /**