From: Roland Häder Date: Fri, 22 Aug 2025 03:28:12 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ed839e14c88b1468008f52f527b2dbec89688d79;p=core.git Continued: - invoking getIteratorInstance() and then checking its type is "abusive" to a getter method, let's use isIteratorInstanceSet() instead --- diff --git a/framework/main/classes/registry/class_BaseRegistry.php b/framework/main/classes/registry/class_BaseRegistry.php index b09f2e4e..a259a0da 100644 --- a/framework/main/classes/registry/class_BaseRegistry.php +++ b/framework/main/classes/registry/class_BaseRegistry.php @@ -70,18 +70,19 @@ abstract class BaseRegistry extends BaseFrameworkSystem implements Register, Reg * @return $iteratorInstance An instance of a Iterator class */ public function getIterator (array $onlyRegistries = []): Traversable { - // Get iterator + // Trace message /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-REGISTRY: onlyRegistries()=%d - CALLED!', count($onlyRegistries))); - $iteratorInstance = $this->getIteratorInstance(); // Is it set? - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-REGISTRY: iteratorInstance[]=%s', gettype($iteratorInstance))); - if (is_null($iteratorInstance)) { + if (!$this->isIteratorInstanceSet()) { // Then instance it $iteratorInstance = ObjectFactory::createObjectByConfiguredName('registry_iterator_class', [$this]); // ... and set it here $this->setIteratorInstance($iteratorInstance); + } else { + // Get iterator oinstance + $iteratorInstance = $this->getIteratorInstance(); } // Init iterator instance diff --git a/framework/main/interfaces/registry/object/class_ObjectRegister.php b/framework/main/interfaces/registry/object/class_ObjectRegister.php index cdc9b8cb..0bd9867e 100644 --- a/framework/main/interfaces/registry/object/class_ObjectRegister.php +++ b/framework/main/interfaces/registry/object/class_ObjectRegister.php @@ -51,7 +51,7 @@ interface ObjectRegister extends Register { * * @return $instanceRegistry The whole instance registry array */ - function getInstanceRegistry (); + function getInstanceRegistry (): array; /** * Gets a registered instance or null if not found