]> git.mxchange.org Git - core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 6 Dec 2020 10:03:35 +0000 (11:03 +0100)
committerRoland Häder <roland@mxchange.org>
Sun, 6 Dec 2020 10:03:35 +0000 (11:03 +0100)
- added type-hints for primitive variables
- still a lot is left for refacturing ...

Signed-off-by: Roland Häder <roland@mxchange.org>
12 files changed:
framework/main/classes/factories/stacks/class_FileStackFactory.php
framework/main/classes/factories/xml/class_XmlTemplateEngineFactory.php
framework/main/classes/filter/payment/class_PaymentDiscoveryFilter.php
framework/main/classes/lists/class_BaseList.php
framework/main/classes/mailer/class_BaseMailer.php
framework/main/classes/menu/class_BaseMenu.php
framework/main/classes/registry/class_BaseRegistry.php
framework/main/classes/resolver/action/class_BaseActionResolver.php
framework/main/classes/resolver/command/class_BaseCommandResolver.php
framework/main/classes/template/image/class_ImageTemplateEngine.php
framework/main/classes/template/xml/class_BaseXmlTemplateEngine.php
framework/main/interfaces/registry/class_Register.php

index cc2060d85e9676134f9f517a049316f5e4b961c9..7e4e11848334c1449e36171ed893fc70585fc7d7 100644 (file)
@@ -50,7 +50,7 @@ class FileStackFactory extends ObjectFactory {
         * @param       $stackName                      Name of the stack
         * @return      $stackInstance          An instance of a StackableFile class
         */
-       public static final function createFileStackInstance ($prefix, $stackName) {
+       public static final function createFileStackInstance (string $prefix, string $stackName) {
                // Construct file stack name
                $fileInfoInstance = new SplFileInfo(sprintf('%s%s/%s.%s',
                        FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('root_base_path'),
index 30ff41db5df6fc1cc2e2736028129b80fa74f813..172550a6259ad4bc375c70582a8aefcacd9f320b 100644 (file)
@@ -49,7 +49,7 @@ class XmlTemplateEngineFactory extends ObjectFactory {
         * @param       $configEntry            Config entry name for the template engine
         * @return      $templateInstance       A template engine instance
         */
-       public static final function createXmlTemplateEngineInstance ($configEntry) {
+       public static final function createXmlTemplateEngineInstance (string $configEntry) {
                // Do we have an instance in the registry?
                if (GenericRegistry::getRegistry()->instanceExists($configEntry)) {
                        // Then use this instance
index 1588a795525fae1bdd3d28652117bdcd063beca9..b653dfb746fbf5aa87c38457a651524a0bae4eed 100644 (file)
@@ -117,7 +117,7 @@ class PaymentDiscoveryFilter extends BaseFilter implements Filterable {
                // Try to get real discovery class
                try {
                        // Get an instance from the object factory
-                       $discoveryInstance = ObjectFactory::createObjectByConfiguredName($this->getActionName() . '_payment_discovery', array($this));
+                       $discoveryInstance = ObjectFactory::createObjectByConfiguredName($this->getActionName() . '_payment_discovery', [$this]);
 
                        // Call the discovery method
                        $discoveryInstance->discover($requestInstance);
index b31350285775b6a942a698543f741fe1183f5a14..2a8595b18b912873ae210d4f357635940e83341d 100644 (file)
@@ -82,7 +82,7 @@ abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate
                // Is the instance set?
                if (is_null($iteratorInstance)) {
                        // Prepare a default iterator
-                       $iteratorInstance = ObjectFactory::createObjectByConfiguredName('default_iterator_class', array($this));
+                       $iteratorInstance = ObjectFactory::createObjectByConfiguredName('default_iterator_class', [$this]);
 
                        // Set it here
                        $this->setIteratorInstance($iteratorInstance);
index 5e10bc195c5c89c921d0cf76abda83b41882a120..885c32418fcb2adde3f2c3001d1721195b00a62d 100644 (file)
@@ -127,7 +127,7 @@ abstract class BaseMailer extends BaseFrameworkSystem {
         * @param       $valueInstance  An object instance which can provide "field values"
         * @return      void
         */
-       public final function addValueInstance ($variableName, FrameworkInterface $valueInstance) {
+       public final function addValueInstance (string $variableName, FrameworkInterface $valueInstance) {
                $this->setGenericArrayElement('recipients', $this->getTemplateName(), 'values', $variableName, $valueInstance);
        }
 
index f73d34e0b3118bfd7cadc399ee41b29151faa67b..60b92f0bdc51e265d0ba6f52ca5644f43473a798 100644 (file)
@@ -56,7 +56,7 @@ abstract class BaseMenu extends BaseFrameworkSystem {
         */
        public function renderMenu () {
                // Initialize the menu system by preparing it's template instance
-               $templateInstance = ObjectFactory::createObjectByConfiguredName('menu_template_class', array($this));
+               $templateInstance = ObjectFactory::createObjectByConfiguredName('menu_template_class', [$this]);
 
                // Set it for later use
                $this->setTemplateInstance($templateInstance);
@@ -71,7 +71,7 @@ abstract class BaseMenu extends BaseFrameworkSystem {
                if (empty($command)) {
                        // Use default page as none has been specified
                        $command = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('default_' . ApplicationHelper::getSelfInstance()->getAppShortName() . '_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_command');
-               } // END - if
+               }
 
                // Load the menu template for this page
                try {
index d784706376bfa19a72a089da3e76b359bc4038e8..f71e35c3b5549c8cb9520f90ca3e68ca3aad416b 100644 (file)
@@ -67,7 +67,7 @@ abstract class BaseRegistry extends BaseFrameworkSystem implements Register, Reg
                // 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);
@@ -89,7 +89,7 @@ abstract class BaseRegistry extends BaseFrameworkSystem implements Register, Reg
         * @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);
 
@@ -104,7 +104,7 @@ abstract class BaseRegistry extends BaseFrameworkSystem implements Register, Reg
         * @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);
        }
 
@@ -134,10 +134,7 @@ abstract class BaseRegistry extends BaseFrameworkSystem implements Register, Reg
         * @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);
        }
@@ -145,12 +142,10 @@ abstract class BaseRegistry extends BaseFrameworkSystem implements Register, Reg
        /**
         * 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');
 
@@ -158,7 +153,7 @@ abstract class BaseRegistry extends BaseFrameworkSystem implements Register, Reg
                if (!is_null($key)) {
                        // Then use this entry
                        $entries = $this->getGenericArrayKey('registry', 'generic', $key);
-               } // END - if
+               }
 
                // Return the array
                return $entries;
@@ -171,59 +166,44 @@ abstract class BaseRegistry extends BaseFrameworkSystem implements Register, Reg
         * @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;
        }
 
@@ -234,12 +214,12 @@ abstract class BaseRegistry extends BaseFrameworkSystem implements Register, Reg
         * @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);
@@ -257,7 +237,7 @@ abstract class BaseRegistry extends BaseFrameworkSystem implements Register, Reg
         * @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);
 
index 3578fb3df7b36f57034b7fbbd7f6ab02f5aa2c65..443b11479702c561cd4cfe0b0389d91fc19176c1 100644 (file)
@@ -131,7 +131,7 @@ abstract class BaseActionResolver extends BaseResolver {
                $this->setClassName($className);
 
                // Initiate the action
-               $actionInstance = ObjectFactory::createObjectByName($this->getClassName(), array($this));
+               $actionInstance = ObjectFactory::createObjectByName($this->getClassName(), [$this]);
 
                // Return the result
                return $actionInstance;
index 9d5177aa4575fe5eb5c4b5e3bc1c55c52d86f84b..8287891f8b113c14f2107c707447b5a2adce4897 100644 (file)
@@ -103,7 +103,7 @@ abstract class BaseCommandResolver extends BaseResolver {
                }
 
                // Initiate the command
-               $commandInstance = ObjectFactory::createObjectByName($this->getClassName(), array($this));
+               $commandInstance = ObjectFactory::createObjectByName($this->getClassName(), [$this]);
 
                // Return the result
                return $commandInstance;
index 925c96bf30305ef2e278fabf9a2cff3c8a2c331a..da1faf41195fe8aaae867e8b9fd5394f74a35abe 100644 (file)
@@ -298,7 +298,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl
                $className = StringUtils::convertToClassName($imageType.'_image');
 
                // And try to initiate it
-               $this->setImageInstance(ObjectFactory::createObjectByName($className, array($this)));
+               $this->setImageInstance(ObjectFactory::createObjectByName($className, [$this]));
 
                // Set current main node to type
                $this->currMainNode = 'type';
index 253e0a8ab74c7a0514df467b58de7cca47c1c401..39026824d24d0ac83af528fe3c53e6315040045a 100644 (file)
@@ -374,7 +374,7 @@ abstract class BaseXmlTemplateEngine extends BaseTemplateEngine implements Compi
                }
 
                // Get a XmlParser instance
-               $parserInstance = ObjectFactory::createObjectByConfiguredName('xml_parser_class', array($this));
+               $parserInstance = ObjectFactory::createObjectByConfiguredName('xml_parser_class', [$this]);
 
                // Check if XML compacting is enabled
                if ($this->isXmlCompactingEnabled()) {
index 03622cd95a366d135b39efcd030c7ba7f1b323dd..26b5ef481f9cc4aed1acd2b9e056956666dc119c 100644 (file)
@@ -34,7 +34,7 @@ interface Register extends FrameworkInterface {
         * @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
@@ -43,7 +43,7 @@ interface Register extends FrameworkInterface {
         * @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
@@ -67,14 +67,14 @@ interface Register extends FrameworkInterface {
         * @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
@@ -83,7 +83,7 @@ interface Register extends FrameworkInterface {
         * @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
@@ -92,6 +92,6 @@ interface Register extends FrameworkInterface {
         * @return      $objectInstance         An instance we shall store
         * @throws      NullPointerException    If the requested key is not found
         */
-       function getInstance ($instanceKey);
+       function getInstance (string $instanceKey);
 
 }