From: Roland Häder Date: Tue, 8 Nov 2011 06:35:06 +0000 (+0000) Subject: Static method getInstance() conflicts with getInstance() in class BaseRegistry, X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=768cc231b262ebeaa5aec373d9b7d97cc6b6ac95;p=core.git Static method getInstance() conflicts with getInstance() in class BaseRegistry, better it gets renamed to something else. --- diff --git a/inc/classes.php b/inc/classes.php index ac3940a4..6084add1 100644 --- a/inc/classes.php +++ b/inc/classes.php @@ -32,7 +32,7 @@ $lowerClasses = array( ); // Cache loader instance -$loaderInstance = ClassLoader::getInstance(); +$loaderInstance = ClassLoader::getSelfInstance(); // Load all classes foreach ($lowerClasses as $className) { diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index 34c10efe..fcd7dab7 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -313,7 +313,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Set configuration instance if no registry ... if (!$this instanceof Register) { // ... because registries doesn't need to be configured - $this->setConfigInstance(FrameworkConfiguration::getInstance()); + $this->setConfigInstance(FrameworkConfiguration::getSelfInstance()); } // END - if // Is the startup time set? (0 cannot be true anymore) @@ -893,7 +893,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { ApplicationEntryPoint::app_die(sprintf("
%s debug output:
%s
\nLoaded includes:
%s
", $this->__toString(), $content, - ClassLoader::getInstance()->getPrintableIncludeList() + ClassLoader::getSelfInstance()->getPrintableIncludeList() )); } diff --git a/inc/classes/main/console/class_ConsoleTools.php b/inc/classes/main/console/class_ConsoleTools.php index 825f5fa9..e43c9694 100644 --- a/inc/classes/main/console/class_ConsoleTools.php +++ b/inc/classes/main/console/class_ConsoleTools.php @@ -127,7 +127,7 @@ class ConsoleTools extends BaseFrameworkSystem { } // Set it in configuration - FrameworkConfiguration::getInstance()->setServerAddress($ip); + FrameworkConfiguration::getSelfInstance()->setServerAddress($ip); } /** diff --git a/inc/classes/main/crypto/class_CryptoHelper.php b/inc/classes/main/crypto/class_CryptoHelper.php index 0c626bba..61df3149 100644 --- a/inc/classes/main/crypto/class_CryptoHelper.php +++ b/inc/classes/main/crypto/class_CryptoHelper.php @@ -75,7 +75,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable { * * @return $selfInstance An instance of this crypto helper class */ - public static final function getInstance () { + public static final function getSelfInstance () { // Is no instance there? if (is_null(self::$selfInstance)) { // Then get a new one diff --git a/inc/classes/main/factories/objects/class_ObjectFactory.php b/inc/classes/main/factories/objects/class_ObjectFactory.php index b84f55a2..c089ba32 100644 --- a/inc/classes/main/factories/objects/class_ObjectFactory.php +++ b/inc/classes/main/factories/objects/class_ObjectFactory.php @@ -81,7 +81,7 @@ class ObjectFactory extends BaseFactory { */ public static final function createObjectByConfiguredName ($configEntry, array $args=array()) { // Read the configuration entry - $className = FrameworkConfiguration::getInstance()->getConfigEntry($configEntry); + $className = FrameworkConfiguration::getSelfInstance()->getConfigEntry($configEntry); // Send this to the other factory... $objectInstance = self::createObjectByName($className, $args); diff --git a/inc/classes/main/language/class_LanguageSystem.php b/inc/classes/main/language/class_LanguageSystem.php index df1fe429..3cde5308 100644 --- a/inc/classes/main/language/class_LanguageSystem.php +++ b/inc/classes/main/language/class_LanguageSystem.php @@ -91,7 +91,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage, $langInstance->initLanguageStrings(); // Set language code from default config - $langInstance->setLanguageCode(FrameworkConfiguration::getInstance()->getConfigEntry('default_lang')); + $langInstance->setLanguageCode(FrameworkConfiguration::getSelfInstance()->getConfigEntry('default_lang')); // Remember this instance self::$thisInstance = $langInstance; @@ -105,7 +105,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage, * * @return $thisInstance An instance of this class */ - public static final function getInstance () { + public static final function getSelfInstance () { return self::$thisInstance; } diff --git a/inc/classes/main/output/class_ConsoleOutput.php b/inc/classes/main/output/class_ConsoleOutput.php index af45aaad..3fc2bcc0 100644 --- a/inc/classes/main/output/class_ConsoleOutput.php +++ b/inc/classes/main/output/class_ConsoleOutput.php @@ -72,7 +72,7 @@ class ConsoleOutput extends BaseFrameworkSystem implements OutputStreamer { public static final function getInstance() { // Is the self-instance already set? if (is_null(self::$consoleInstance)) { - $contentType = FrameworkConfiguration::getInstance()->getConfigEntry('web_content_type'); + $contentType = FrameworkConfiguration::getSelfInstance()->getConfigEntry('web_content_type'); self::$consoleInstance = ConsoleOutput::createConsoleOutput($contentType); } // END - if diff --git a/inc/classes/main/registry/class_BaseRegistry.php b/inc/classes/main/registry/class_BaseRegistry.php index 390d2c67..718f0a4f 100644 --- a/inc/classes/main/registry/class_BaseRegistry.php +++ b/inc/classes/main/registry/class_BaseRegistry.php @@ -74,7 +74,7 @@ class BaseRegistry extends BaseFrameworkSystem implements Registerable { } /** - * Getter for whole instanceregistry + * Getter for whole instance registry * * @return $instanceRegistry The whole instance registry array */ diff --git a/inc/classes/middleware/database/class_DatabaseConnection.php b/inc/classes/middleware/database/class_DatabaseConnection.php index 84b8cc24..0a688c39 100644 --- a/inc/classes/middleware/database/class_DatabaseConnection.php +++ b/inc/classes/middleware/database/class_DatabaseConnection.php @@ -67,7 +67,7 @@ class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Re } // Get an instance of this class - public static final function getInstance () { + public static final function getSelfInstance () { return self::$thisInstance; } diff --git a/inc/classes/middleware/debug/class_DebugMiddleware.php b/inc/classes/middleware/debug/class_DebugMiddleware.php index 4d70703b..14901161 100644 --- a/inc/classes/middleware/debug/class_DebugMiddleware.php +++ b/inc/classes/middleware/debug/class_DebugMiddleware.php @@ -84,7 +84,7 @@ class DebugMiddleware extends BaseMiddleware implements Registerable { * * @return $thisInstance An instance of this class */ - public static final function getInstance() { + public static final function getSelfInstance() { return self::$thisInstance; } diff --git a/inc/classes/middleware/io/class_FileIoHandler.php b/inc/classes/middleware/io/class_FileIoHandler.php index 22dff803..70afeefe 100644 --- a/inc/classes/middleware/io/class_FileIoHandler.php +++ b/inc/classes/middleware/io/class_FileIoHandler.php @@ -74,7 +74,7 @@ class FileIoHandler extends BaseMiddleware { * * @return $thisInstance An instance of this class */ - public static final function getInstance () { + public static final function getSelfInstance () { return self::$thisInstance; } diff --git a/inc/config.php b/inc/config.php index 441e0caf..8e9c3d4f 100644 --- a/inc/config.php +++ b/inc/config.php @@ -30,7 +30,7 @@ require(ApplicationEntryPoint::detectCorePath() . '/inc/classes/interfaces/regis require(ApplicationEntryPoint::detectCorePath() . '/inc/config/class_FrameworkConfiguration.php'); // Get a new configuration instance -$cfg = FrameworkConfiguration::getInstance(); +$cfg = FrameworkConfiguration::getSelfInstance(); // CFG: SERVER-PATH $cfg->setConfigEntry('base_path', ApplicationEntryPoint::detectCorePath() . '/'); diff --git a/inc/config/class_FrameworkConfiguration.php b/inc/config/class_FrameworkConfiguration.php index 938b67ba..5006ea46 100644 --- a/inc/config/class_FrameworkConfiguration.php +++ b/inc/config/class_FrameworkConfiguration.php @@ -65,7 +65,7 @@ class FrameworkConfiguration implements Registerable { * * @return $configInstance An instance of this class */ - public static final function getInstance () { + public static final function getSelfInstance () { // is the instance there? if (is_null(self::$configInstance)) { // Create a config instance diff --git a/inc/config/config-hubmaster.php b/inc/config/config-hubmaster.php index 9e06c503..be3267b3 100644 --- a/inc/config/config-hubmaster.php +++ b/inc/config/config-hubmaster.php @@ -22,7 +22,7 @@ */ // Get the configuration instance -$cfg = FrameworkConfiguration::getInstance(); +$cfg = FrameworkConfiguration::getSelfInstance(); // CFG: HUB-BOOTSTRAP-NODES $cfg->setConfigEntry('hub_bootstrap_nodes', '188.138.90.169:9060'); diff --git a/inc/database.php b/inc/database.php index 54329fde..badcd355 100644 --- a/inc/database.php +++ b/inc/database.php @@ -28,7 +28,7 @@ $databaseInstance = NULL; // Generate FQFN for the database layer -$fqfn = FrameworkConfiguration::getInstance()->getConfigEntry('base_path') . 'inc/database/lib-' . FrameworkConfiguration::getInstance()->getConfigEntry('db_type') . '.php'; +$fqfn = FrameworkConfiguration::getSelfInstance()->getConfigEntry('base_path') . 'inc/database/lib-' . FrameworkConfiguration::getSelfInstance()->getConfigEntry('db_type') . '.php'; // Load the database layer include if ((file_exists($fqfn)) && (is_file($fqfn)) && (is_readable($fqfn))) { @@ -37,7 +37,7 @@ if ((file_exists($fqfn)) && (is_file($fqfn)) && (is_readable($fqfn))) { } else { // Layer is missing! ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer is missing! (%s) -> R.I.P.", - FrameworkConfiguration::getInstance()->getConfigEntry('db_type') + FrameworkConfiguration::getSelfInstance()->getConfigEntry('db_type') )); } @@ -45,7 +45,7 @@ if ((file_exists($fqfn)) && (is_file($fqfn)) && (is_readable($fqfn))) { unset($fqfn); // Prepare database instance -$connectionInstance = DatabaseConnection::createDatabaseConnection(DebugMiddleware::getInstance(), $databaseInstance); +$connectionInstance = DatabaseConnection::createDatabaseConnection(DebugMiddleware::getSelfInstance(), $databaseInstance); // Is the app variable there and valid? // @TODO Rewrite this diff --git a/inc/includes.php b/inc/includes.php index 38ec9eec..95d8086f 100644 --- a/inc/includes.php +++ b/inc/includes.php @@ -25,14 +25,14 @@ */ // Include the class loader function -require(FrameworkConfiguration::getInstance()->getConfigEntry('base_path') . 'inc/loader/class_ClassLoader.php'); +require(FrameworkConfiguration::getSelfInstance()->getConfigEntry('base_path') . 'inc/loader/class_ClassLoader.php'); // Shall we include additional configs where you can configure some things? Then // Load matching config -ClassLoader::getInstance()->loadExtraConfigs(); +ClassLoader::getSelfInstance()->loadExtraConfigs(); // Register hooks here -require(FrameworkConfiguration::getInstance()->getConfigEntry('base_path') . 'inc/hooks.php'); +require(FrameworkConfiguration::getSelfInstance()->getConfigEntry('base_path') . 'inc/hooks.php'); // Does the user has an application specified? // @TODO Find a nicer OOP-ed way for this @@ -48,11 +48,11 @@ if (!empty($_GET['app'])) { $application = trim($app[1]); } else { // Invalid entry found, first must be "app"! - $application = FrameworkConfiguration::getInstance()->getConfigEntry('default_application'); + $application = FrameworkConfiguration::getSelfInstance()->getConfigEntry('default_application'); } } else { // Set the "application selector" application - $application = FrameworkConfiguration::getInstance()->getConfigEntry('default_application'); + $application = FrameworkConfiguration::getSelfInstance()->getConfigEntry('default_application'); } // Secure it, by keeping out tags @@ -62,7 +62,7 @@ $application = htmlentities(strip_tags($application), ENT_QUOTES); $application = preg_replace('/([^a-z0-9_-])+/i', '', $application); // Set the application name for later usage -FrameworkConfiguration::getInstance()->setConfigEntry('app_name', $application); +FrameworkConfiguration::getSelfInstance()->setConfigEntry('app_name', $application); // [EOF] ?> diff --git a/inc/loader/class_ClassLoader.php b/inc/loader/class_ClassLoader.php index 18b9244c..ae5eb6fe 100644 --- a/inc/loader/class_ClassLoader.php +++ b/inc/loader/class_ClassLoader.php @@ -25,7 +25,7 @@ * 1.3 * - Constructor is now empty and factory method 'createClassLoader' is created * - renamed loadClasses to scanClassPath - * - Added initLoader(), $configInstance renamed to $configInstance + * - Added initLoader() * 1.2 * - ClassLoader rewritten to PHP SPL's own RecursiveIteratorIterator class * 1.1 @@ -98,12 +98,12 @@ class ClassLoader { /** * The protected constructor. Please use the factory method below, or use - * getInstance() for singleton + * getSelfInstance() for singleton * * @return void */ protected function __construct () { - // Is Currently empty + // Is currently empty } /** @@ -179,7 +179,9 @@ class ClassLoader { self::$selfInstance = $this; // Skip here if no dev-mode - if (defined('DEVELOPER')) return; + if (defined('DEVELOPER')) { + return; + } // END - if // IS the cache there? if (file_exists($this->listCacheFQFN)) { @@ -211,19 +213,19 @@ class ClassLoader { */ public static function autoLoad ($className) { // Try to include this class - self::getInstance()->includeClass($className); + self::getSelfInstance()->includeClass($className); } /** - * Getter for an instance of this class + * Singleton getter for an instance of this class * - * @return $selfInstance An instance of this class + * @return $selfInstance A singleton instance of this class */ - public static final function getInstance () { + public static final function getSelfInstance () { // Is the instance there? if (is_null(self::$selfInstance)) { // Get a new one - self::$selfInstance = ClassLoader::createClassLoader(FrameworkConfiguration::getInstance()); + self::$selfInstance = ClassLoader::createClassLoader(FrameworkConfiguration::getSelfInstance()); } // END - if // Return the instance diff --git a/inc/output.php b/inc/output.php index 1e670565..6dbafafa 100644 --- a/inc/output.php +++ b/inc/output.php @@ -25,10 +25,10 @@ */ // Get a debugger instance -$debug = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getInstance()->getConfigEntry('debug_class')); +$debug = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getSelfInstance()->getConfigEntry('debug_class')); // Empty string should be ignored and used for testing the middleware -DebugMiddleware::getInstance()->output(''); +DebugMiddleware::getSelfInstance()->output(''); // [EOF] ?> diff --git a/inc/selector.php b/inc/selector.php index 00b1dffb..38f76561 100644 --- a/inc/selector.php +++ b/inc/selector.php @@ -26,7 +26,7 @@ // Try to load these includes in the given order $configAppIncludes = array( - 'class_' . FrameworkConfiguration::getInstance()->getConfigEntry('app_helper_class'), // The ApplicationHelper class + 'class_' . FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_helper_class'), // The ApplicationHelper class 'debug', // Some debugging stuff 'exceptions', // The application's own exception handler 'loader', // The application's class loader @@ -38,12 +38,12 @@ $configAppIncludes = array( ); // Cache base path/file here -$basePathFile = FrameworkConfiguration::getInstance()->getConfigEntry('application_path') . FrameworkConfiguration::getInstance()->getConfigEntry('app_name'); +$basePathFile = FrameworkConfiguration::getSelfInstance()->getConfigEntry('application_path') . FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_name'); // Is the directory there? if (!is_dir($basePathFile)) { // Not found. - trigger_error('Application ' . FrameworkConfiguration::getInstance()->getConfigEntry('app_name') . ' not found.'); + trigger_error('Application ' . FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_name') . ' not found.'); } // END - if // Load them all (try only) @@ -63,7 +63,7 @@ foreach ($configAppIncludes as $appInc) { //* DEBUG: */ print basename(__FILE__)."[".__LINE__."]: Loading ".basename($appFqFn)." - START\n"; require($appFqFn); //* DEBUG: */ print basename(__FILE__)."[".__LINE__."]: Loading ".basename($appFqFn)." - END\n"; - } elseif (FrameworkConfiguration::getInstance()->getConfigEntry('verbose_level') > 0) { + } elseif (FrameworkConfiguration::getSelfInstance()->getConfigEntry('verbose_level') > 0) { // File is missing trigger_error(sprintf("Cannot load application script %s.php! File is missing or read-protected.", $appInc