X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=framework%2Fmain%2Fclasses%2Flists%2Fclass_BaseList.php;h=08d60de88167a0d48da4e269b983e8dc52424830;hb=498e6b065ce47804bff4e1073592a2cc8e28f8ef;hp=bb58363627f216a7fff2c56cc2c68282b760f1d7;hpb=2882b57ca6f372b822f96034ff2fe6aafd7daeb8;p=core.git diff --git a/framework/main/classes/lists/class_BaseList.php b/framework/main/classes/lists/class_BaseList.php index bb583636..08d60de8 100644 --- a/framework/main/classes/lists/class_BaseList.php +++ b/framework/main/classes/lists/class_BaseList.php @@ -17,7 +17,7 @@ use \Countable; * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team + * @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 * @@ -43,17 +43,17 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate /** * List groups array */ - private $listGroups = array(); + private $listGroups = []; /** * List entries array */ - private $listEntries = array(); + private $listEntries = []; /** * List index array */ - private $listIndex = array(); + private $listIndex = []; /** * Protected constructor @@ -61,7 +61,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate * @param $className Name of the class * @return void */ - protected function __construct ($className) { + protected function __construct (string $className) { // Call parent constructor parent::__construct($className); } @@ -95,7 +95,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate * @return $isset Whether the group is valid */ public function isGroupSet ($groupName) { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName); return isset($this->listGroups[$groupName]); } @@ -107,7 +107,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate * @throws ListGroupAlreadyAddedException If the given group is already added */ public function addGroup ($groupName) { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!'); // Is the group already added? if ($this->isGroupSet($groupName)) { // Throw the exception here @@ -116,7 +116,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('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ' - EXIT!'); } /** @@ -130,7 +130,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate */ public function addInstance ($groupName, $subGroup, Visitable $visitableInstance) { // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ',subGroup=' . $subGroup . ',visitableInstance=' . $visitableInstance->__toString() . ' - CALLED!'); + //* 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)) { @@ -148,7 +148,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate $hash = $this->generateHash($groupName, $subGroup, $visitableInstance); // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',this->listGroups[' . $groupName . ']=' . $this->listGroups[$groupName]->__toString()); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',this->listGroups[' . $groupName . ']=' . $this->listGroups[$groupName]->__toString()); // Add the hash to the index array_push($this->listIndex, $hash); @@ -157,7 +157,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate $this->listEntries[$hash] = $visitableInstance; // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ',subGroup=' . $subGroup . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ',subGroup=' . $subGroup . ' - EXIT!'); } /** @@ -169,7 +169,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate */ public final function getArrayFromList ($list) { // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',list[' . gettype($list) . ']=' . $list . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',list[' . gettype($list) . ']=' . $list . ' - CALLED!'); // Is the group there? if ((!is_null($list)) && (!$this->isGroupSet($list))) { @@ -178,7 +178,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate } // END - if // Init array - $array = array(); + $array = []; // Is there another list? if (!is_null($list)) { @@ -189,18 +189,18 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate // Walk through all entries foreach ($this->listIndex as $hash) { // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: hash=' . $hash); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: hash=' . $hash); // Is the list entry set? if ($this->isHashValid($hash)) { // Add it array_push($array, $this->listEntries[$hash]); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: hash=' . $hash . ',array(' . count($array) . ')=' . print_r($array, true) . ' - ADDED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: hash=' . $hash . ',array(' . count($array) . ')=' . print_r($array, true) . ' - ADDED!'); } // END - if } // END - foreach // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',list[' . gettype($list) . ']=' . $list . ',array()=' . count($array) . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',list[' . gettype($list) . ']=' . $list . ',[]=' . count($array) . ' - EXIT!'); // Return it return $array; @@ -216,7 +216,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate */ public function addEntry ($groupName, $entry) { // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!'); // Is the group already added? if (!$this->isGroupSet($groupName)) { @@ -228,19 +228,19 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate $hash = $this->generateHash($groupName, $groupName, $entry); // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ',entry=' . print_r($entry, true) . ', hash=' . $hash); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',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('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ',listEntries()=' . count($this->listEntries)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',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('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ',listEntries()=' . count($this->listEntries) . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ',listEntries()=' . count($this->listEntries) . ' - EXIT!'); } /** @@ -253,7 +253,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate */ public function removeEntry ($groupName, $entry) { // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!'); // Is the group already added? if (!$this->isGroupSet($groupName)) { @@ -265,7 +265,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate $hash = $this->generateHash($groupName, $groupName, $entry); // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ',entry=' . $entry . ', hash=' . $hash); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ',entry=' . $entry . ', hash=' . $hash); // Remove it from the list ... unset($this->listEntries[$hash]); @@ -274,7 +274,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('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ' - EXIT!'); } /** @@ -309,7 +309,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate $entry2 = $this->getCallbackInstance()->generateListHashFromEntry($entry); } else { // Unsupported type detected - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST[' . __METHOD__ . ':' . __LINE__ . ']: Entry type ' . gettype($entry) . ' is unsupported (this->callbackInstance=' . $this->getCallbackInstance() . ').'); + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: Entry type ' . gettype($entry) . ' is unsupported (this->callbackInstance=' . $this->getCallbackInstance() . ').'); // At least take all keys from array $entry2 = gettype($entry) . ':' . implode(':', array_keys($entry)); @@ -356,8 +356,8 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate $this->listGroups[$groupName]->clearList(); // Clear this list - $this->listIndex = array(); - $this->listEntries = array(); + $this->listIndex = []; + $this->listEntries = []; } /** @@ -436,7 +436,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate } // END - if // Init the entries' array - $entries = array(); + $entries = []; // Get an iterator $iteratorInstance = $this->listGroups[$groupName]->getIterator();