// Is it set?
if (is_null($this->getIteratorInstance())) {
// Then instance it
- $iteratorInstance = ObjectFactory::createObjectByConfiguredName('registry_iterator_class', array($this));
+ $iteratorInstance = ObjectFactory::createObjectByConfiguredName('registry_iterator_class', [$this]);
// ... and set it here
$this->setIteratorInstance($iteratorInstance);
* @param $instanceKey The key holding an instance in registry
* @return $exists Whether the key exists in registry
*/
- public function instanceExists ($instanceKey) {
+ public function instanceExists (string $instanceKey) {
// Does this key exists?
$exists = $this->isGenericArrayKeySet('registry', 'instance', $instanceKey);
* @param $objectInstance An instance we shall store
* @return void
*/
- public function addInstance ($instanceKey, Registerable $objectInstance) {
+ public function addInstance (string $instanceKey, Registerable $objectInstance) {
$this->setGenericArrayKey('registry', 'instance', $instanceKey, $objectInstance);
}
* @param $value The value to be stored
* @return void
*/
- public final function addEntry ($key, $value) {
- // Key must not be an array
- assert(!is_array($key));
-
+ public final function addEntry (string $key, $value) {
// Push it
$this->pushValueToGenericArrayKey('registry', 'generic', $key, $value);
}
/**
* Getter for entries or "sub entries"
*
+ * @param $key Key
* @return $entries An array with entries from this registry
*/
- public final function getEntries ($key = NULL) {
- // Key must not be an array
- assert(!is_array($key));
-
+ public final function getEntries (string $key = NULL) {
// Default is whole array
$entries = $this->getGenericArray('registry');
if (!is_null($key)) {
// Then use this entry
$entries = $this->getGenericArrayKey('registry', 'generic', $key);
- } // END - if
+ }
// Return the array
return $entries;
* @param $lookFor The key to look for
* @return $entry An array with all keys
*/
- public function getArrayFromKey ($arrayKey, $lookFor) {
- // Key must not be an array
- assert(!is_array($arrayKey));
-
+ public function getArrayFromKey (string $arrayKey, string $lookFor) {
// Init array
$entry = [];
- // Debug message
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY: Checking arrayKey=' . $arrayKey . ',lookFor=' . $lookFor);
-
// "Walk" over all entries
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY: Checking arrayKey=' . $arrayKey . ',lookFor=' . $lookFor);
foreach ($this->getEntries($arrayKey) as $key => $value) {
- // Debug message
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY: Checking key=' . $key . ',value=' . $value . ',lookFor=' . $lookFor);
-
// If $value matches the $lookFor, we need to look for more entries for this!
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY: Checking key=' . $key . ',value=' . $value . ',lookFor=' . $lookFor);
if ($lookFor == $value) {
// Look for more entries
foreach ($this->getEntries() as $key2 => $value2) {
// Now "walk" through all entries, if an array is returned
if (is_array($value2)) {
- // Debug message
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY: Checking key2=' . $key2 . ',value2()=' . count($value2) . ',lookFor=' . $lookFor);
-
// "Walk" through all of them
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY: Checking key2=' . $key2 . ',value2()=' . count($value2) . ',lookFor=' . $lookFor);
foreach ($value2 as $key3 => $value3) {
// $value3 needs to be an array
assert(is_array($value3));
- // Debug message
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY: Checking key=' . $key . ',key3=' . $key3 . ',isset()=' . isset($value3[$key]) . ' ...');
-
// Both keys must match!
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY: Checking key=' . $key . ',key3=' . $key3 . ',isset()=' . isset($value3[$key]) . ' ...');
if (($key == $key3) || (isset($value3[$key]))) {
- // Debug message
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY: Adding ' . $value3[$key] . ' ...');
-
// Then add it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY: Adding ' . $value3[$key] . ' ...');
$entry[$key3] = $value3[$key];
- } // END - if
- } // END - foreach
- } // END - if
- } // END - foreach
+ }
+ }
+ }
+ }
// Skip further lookups
break;
- } // END - if
- } // END - foreach
-
- // Debug message
- //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY: Returning entry(' . count($entry) . ')=' . print_r($entry, true));
+ }
+ }
// Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY: Returning entry(' . count($entry) . ')=' . print_r($entry, true));
return $entry;
}
* @return $objectInstance An instance we shall store
* @throws NullPointerException If the requested key is not found
*/
- public function getInstance ($instanceKey) {
+ public function getInstance (string $instanceKey) {
// Is the instance there?
if (!$this->instanceExists($instanceKey)) {
// This might happen if a non-registered key was requested
throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
- } // END - if
+ }
// Get the instance
$objectInstance = $this->getGenericArrayKey('registry', 'instance', $instanceKey);
* @param $data An array with data
* @return $registryKey A registry key
*/
- public static function getRegistryKeyFromArray ($prefix, array $data) {
+ public static function getRegistryKeyFromArray (string $prefix, array $data) {
// "Generate" the key
$registryKey = $prefix . self::REGISTRY_KEY_GLUE . implode(self::REGISTRY_KEY_GLUE, $data);
* @param $instanceKey The key holding an instance in registry
* @return $exists Whether the key exists in registry
*/
- function instanceExists ($instanceKey);
+ function instanceExists (string $instanceKey);
/**
* Adds/overwrites a new instance to the registry at the given key
* @param $objectInstance An instance we shall store
* @return void
*/
- function addInstance ($instanceKey, Registerable $objectInstance);
+ function addInstance (string $instanceKey, Registerable $objectInstance);
/**
* Getter for whole generic registry
* @param $value The value to be stored
* @return void
*/
- function addEntry ($key, $value);
+ function addEntry (string $key, $value);
/**
* Getter for entries or "sub entries"
*
* @return $entries An array with entries from this registry
*/
- function getEntries ($key = NULL);
+ function getEntries (string $key = NULL);
/**
* "Getter" for an array of all entries for given key
* @param $lookFor The key to look for
* @return $entry An array with all keys
*/
- function getArrayFromKey ($arrayKey, $lookFor);
+ function getArrayFromKey (string $arrayKey, string $lookFor);
/**
* Gets a registered instance or null if not found
* @return $objectInstance An instance we shall store
* @throws NullPointerException If the requested key is not found
*/
- function getInstance ($instanceKey);
+ function getInstance (string $instanceKey);
}