Some global cleanups:
authorRoland Häder <roland@mxchange.org>
Tue, 8 Nov 2011 07:54:39 +0000 (07:54 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 8 Nov 2011 07:54:39 +0000 (07:54 +0000)
- getInstance() in BaseRegistry (non-static) conflicted with many classe
  (static) where it was as singleton getter implemented
- $selfInstance is better that $thisInstance

application/hub/class_ApplicationHelper.php
application/hub/config.php
application/hub/data.php
application/hub/init.php
application/hub/loader.php
application/hub/main/factories/socket/class_SocketFactory.php
application/hub/main/tools/class_HubTools.php
application/hub/starter.php
index.php

index 49d16fde65a3a7a41b9517234035ae22cf88b080..2e7e74e9a5d9fa7c18acbc3c4b36c941b9ecb4b1 100644 (file)
@@ -57,7 +57,7 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica
        /**
         * An instance of this class
         */
-       private static $thisInstance = NULL;
+       private static $selfInstance = NULL;
 
        /**
         * Private constructor
@@ -72,16 +72,16 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica
        /**
         * Getter for an instance of this class
         *
-        * @return      $thisInstance   An instance of this class
+        * @return      $selfInstance   An instance of this class
         */
-       public static final function getInstance () {
+       public static final function getSelfInstance () {
                // Is the instance there?
-               if (is_null(self::$thisInstance)) {
-                       self::$thisInstance = new ApplicationHelper();
+               if (is_null(self::$selfInstance)) {
+                       self::$selfInstance = new ApplicationHelper();
                } // END - if
 
                // Return the instance
-               return self::$thisInstance;
+               return self::$selfInstance;
        }
 
        /**
index c792d729b07a68c77e1e0928310347f08ed65b49..79d812e482df4d8aa9c3025acd5713a22a0a8c2f 100644 (file)
@@ -22,7 +22,7 @@
  */
 
 // Some hub-specific configuration like port hostname where we will listen, etc.
-$cfg = FrameworkConfiguration::getInstance();
+$cfg = FrameworkConfiguration::getSelfInstance();
 
 // CFG: NODE-LISTEN-ADDR
 $cfg->setConfigEntry('node_listen_addr', '0.0.0.0');
index b023dc256e13a923e1b1e42cff4374792208bf7c..3eb6ad9d8b783d257d37e97415601cc945a4ad6c 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 // Get config instance
-$cfg = FrameworkConfiguration::getInstance();
+$cfg = FrameworkConfiguration::getSelfInstance();
 
 // Get an instance of the helper
 $app = call_user_func_array(
index 8ecef8e7b7ba7f57ffe858a151f616f81f20f168..3377c48fb8bcd13f5f516ad5c8c1b1986ba9a63f 100644 (file)
@@ -25,7 +25,7 @@
  */
 
 // Get config instance
-$cfg = FrameworkConfiguration::getInstance();
+$cfg = FrameworkConfiguration::getSelfInstance();
 
 // Initialize output system
 require($cfg->getConfigEntry('base_path') . 'inc/output.php');
index 731629b1a95c7e693e120bb78f09ea9d86b082be..6e12a58af374b2605b5a3863915633ac36c6cfcd 100644 (file)
  */
 
 // Get config instance
-$cfg = FrameworkConfiguration::getInstance();
+$cfg = FrameworkConfiguration::getSelfInstance();
 
 // Load all classes for the application
 foreach ($lowerClasses as $class) {
        // Try to load the application classes
-       ClassLoader::getInstance()->scanClassPath(sprintf("%s/%s/%s", $cfg->getConfigEntry('application_path'), $cfg->getConfigEntry('app_name'), $class));
+       ClassLoader::getSelfInstance()->scanClassPath(sprintf("%s/%s/%s", $cfg->getConfigEntry('application_path'), $cfg->getConfigEntry('app_name'), $class));
 } // END - foreach
 
 // Clean up the global namespace
index 53b748b82275382931cfc28ece2ab2901d546c12..a3eae6e97fe26d3149f65497d6e6635614b8fec5 100644 (file)
@@ -53,7 +53,7 @@ class SocketFactory extends BaseHubHelper {
                        $socketResource = $containerInstance->getSocketResource();
                } else {
                        // Construct configuration entry for object factory and get it
-                       $className = FrameworkConfiguration::getInstance()->getConfigEntry($protocolName . '_connection_helper_class');
+                       $className = FrameworkConfiguration::getSelfInstance()->getConfigEntry($protocolName . '_connection_helper_class');
 
                        // And call the static method
                        $socketResource = call_user_func($className . '::createConnectionFromPackageData', $packageData);
index 4c439ffe0fe159bdcb6ae01e87c5a53eac014657..2313a61623b303899f5f2604673101c7d78c2ba2 100644 (file)
@@ -59,7 +59,7 @@ class HubTools extends BaseFrameworkSystem {
         *
         * @retuen      $selfInstance   An instance of this class
         */
-       public static final function getInstance () {
+       public static final function getSelfInstance () {
                // Is the instance set
                if (is_null(self::$selfInstance)) {
                        // Then set it
@@ -118,7 +118,7 @@ class HubTools extends BaseFrameworkSystem {
         */
        public static function resolveSessionId ($sessionId) {
                // Get an own instance
-               $selfInstance = self::getInstance();
+               $selfInstance = self::getSelfInstance();
 
                // Default is direct ip:port
                $recipient = $sessionId;
@@ -171,9 +171,9 @@ class HubTools extends BaseFrameworkSystem {
         */
        public static function determineOwnExternalIp () {
                // Is the external_ip config entry set?
-               if (FrameworkConfiguration::getInstance()->getConfigEntry('external_ip') != '') {
+               if (FrameworkConfiguration::getSelfInstance()->getConfigEntry('external_ip') != '') {
                        // Use it as external ip
-                       $ip = FrameworkConfiguration::getInstance()->getConfigEntry('external_ip');
+                       $ip = FrameworkConfiguration::getSelfInstance()->getConfigEntry('external_ip');
                } else {
                        // Determine own external ip by connecting to my (coder) server at 188.138.90.169
                        $ip = ConsoleTools::determineExternalIp();
index c8060ae0249a12d1ef5380927a33300c2988e9ca..3c9768e0ee6287ecf5524bc509109e267cf0a700 100644 (file)
@@ -26,7 +26,7 @@
 // maining the application
 $app = call_user_func_array(
        array(
-               FrameworkConfiguration::getInstance()->getConfigEntry('app_helper_class'), 'getInstance'
+               FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_helper_class'), 'getInstance'
        ), array()
 );
 
@@ -35,23 +35,23 @@ if ((empty($app)) || (is_null($app))) {
        // Something went wrong!
        ApplicationEntryPoint::app_die(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because the helper class <span class=\"class_name\">%s</span> is not loaded.",
                $application,
-               FrameworkConfiguration::getInstance()->getConfigEntry('app_helper_class')
+               FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_helper_class')
        ));
 } elseif (!is_object($app)) {
        // No object!
        ApplicationEntryPoint::app_die(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because &#39;app&#39; is not an object.",
                $application
        ));
-} elseif (!method_exists($app, FrameworkConfiguration::getInstance()->getConfigEntry('entry_method'))) {
+} elseif (!method_exists($app, FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method'))) {
        // Method not found!
        ApplicationEntryPoint::app_die(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because the method <span class=\"method_name\">%s</span> is missing.",
                $application,
-               FrameworkConfiguration::getInstance()->getConfigEntry('entry_method')
+               FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method')
        ));
 }
 
 // Call user function
-call_user_func_array(array($app, FrameworkConfiguration::getInstance()->getConfigEntry('entry_method')), array());
+call_user_func_array(array($app, FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method')), array());
 
 // [EOF]
 ?>
index fea50278e467080d96bc7d9c1d2e0400b1af9929..66a45e537db557b1c3bb771a5bb1828b1207d247 100644 (file)
--- a/index.php
+++ b/index.php
@@ -73,7 +73,7 @@ final class ApplicationEntryPoint {
                } // END - if
 
                // Get config instance
-               $configInstance = FrameworkConfiguration::getInstance();
+               $configInstance = FrameworkConfiguration::getSelfInstance();
 
                // Do we have debug installation?
                if (($configInstance->getConfigEntry('product_install_mode') == 'productive') || ($silentMode === true)) {
@@ -82,14 +82,14 @@ final class ApplicationEntryPoint {
                } // END - if
 
                // Get some instances
-               $tpl = FrameworkConfiguration::getInstance()->getConfigEntry('web_template_class');
-               $languageInstance = LanguageSystem::getInstance();
+               $tpl = FrameworkConfiguration::getSelfInstance()->getConfigEntry('web_template_class');
+               $languageInstance = LanguageSystem::getSelfInstance();
 
                // Initialize template instance here to avoid warnings in IDE
                $templateInstance = NULL;
 
                // Get response instance
-               $responseInstance = ApplicationHelper::getInstance()->getResponseInstance();
+               $responseInstance = ApplicationHelper::getSelfInstance()->getResponseInstance();
 
                // Is the template engine loaded?
                if ((class_exists($tpl)) && (is_object($languageInstance))) {
@@ -133,7 +133,7 @@ final class ApplicationEntryPoint {
                        // Is the class there?
                        if (class_exists('ApplicationHelper')) {
                                // Get application instance
-                               $applicationInstance = ApplicationHelper::getInstance();
+                               $applicationInstance = ApplicationHelper::getSelfInstance();
 
                                // Assign application data
                                $templateInstance->assignApplicationData($applicationInstance);
@@ -146,7 +146,7 @@ final class ApplicationEntryPoint {
                                $templateInstance->assignVariable('code', $code);
                                $templateInstance->assignVariable('extra', $extraData);
                                $templateInstance->assignVariable('backtrace', $backtrace);
-                               $templateInstance->assignVariable('total_includes', ClassLoader::getInstance()->getTotal());
+                               $templateInstance->assignVariable('total_includes', ClassLoader::getSelfInstance()->getTotal());
                                $templateInstance->assignVariable('total_objects', ObjectFactory::getTotal());
                                $templateInstance->assignVariable('title', $languageInstance->getMessage('emergency_exit_title'));