]> git.mxchange.org Git - core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 6 Dec 2020 09:32:52 +0000 (10:32 +0100)
committerRoland Häder <roland@mxchange.org>
Sun, 6 Dec 2020 09:36:30 +0000 (10:36 +0100)
- updated index.php
- PHP_Invoker is now with a namespace, so no need for disabling strict
  naming-convention check
- removed some old END - *
- renamed configuration entries 'detect_*' to '__detect_*' as they are dummies
- maybe later get rid of them as the configuration class seem to be "abused"
  here a bit
- converted old array() to "new" []

Signed-off-by: Roland Häder <roland@mxchange.org>
application/tests/exceptions.php
framework/bootstrap/class_FrameworkBootstrap.php
framework/loader/class_ClassLoader.php
index.php
tests/framework/bootstrap/class_FrameworkBootstrapTest.php
tests/framework/config/FrameworkConfigurationTest.php

index 66121d2bd0c0004273103f8d8dcdc3a3d9674987..6e1852ebcb4e7d37b8be2aa80e1a2905455922d9 100644 (file)
@@ -114,7 +114,7 @@ function tests_error_handler ($errno, $errstr, $errfile, $errline, array $errcon
 
        // Throw an exception here
        throw new FatalErrorException($message, BaseFrameworkSystem::EXCEPTION_FATAL_ERROR);
-} // END - function
+}
 
 // Assertion handler
 function tests_assert_handler (string $file, int $line, $code) {
@@ -135,7 +135,7 @@ function tests_assert_handler (string $file, int $line, $code) {
 
        // Throw an exception here
        throw new AssertionException($message, BaseFrameworkSystem::EXCEPTION_ASSERTION_FAILED);
-} // END - function
+}
 
 // Set error handler
 //set_error_handler('tests_error_handler');
index 9f376df51ba254807866e0160364ccd306620950..5d9aa02757ef55375523b11c3d96fae8d16c9ff9 100644 (file)
@@ -84,7 +84,7 @@ final class FrameworkBootstrap {
         * Includes applications may have. They will be tried in the given order,
         * some will become soon deprecated.
         */
-       private static $configAppIncludes = array(
+       private static $configAppIncludes = [
                // The ApplicationHelper class (required)
                'class_ApplicationHelper' => 'required',
                // Some debugging stuff (optional but can be committed)
@@ -103,7 +103,7 @@ final class FrameworkBootstrap {
                'init'                    => 'deprecated',
                // Application starter (deprecated)
                'starter'                 => 'deprecated',
-       );
+       ];
 
        /**
         * Private constructor, no instance is needed from this class as only
@@ -123,7 +123,7 @@ final class FrameworkBootstrap {
                if (is_null(self::$configurationInstance)) {
                        // Init new instance
                        self::$configurationInstance = new FrameworkConfiguration();
-               } // END - if
+               }
 
                // Return it
                return self::$configurationInstance;
@@ -142,7 +142,7 @@ final class FrameworkBootstrap {
                if (isset($_SERVER['HTTP_HOST'])) {
                        // Then it is a HTML response/request.
                        $requestType = 'html';
-               } // END - if
+               }
 
                // Return it
                return $requestType;
@@ -174,8 +174,8 @@ final class FrameworkBootstrap {
 
                                        // Abort lookup as it has been found in open_basedir
                                        break;
-                               } // END - if
-                       } // END - foreach
+                               }
+                       }
                } else {
                        // If open_basedir is not set, all is allowed
                        $isReachable = true;
@@ -226,7 +226,7 @@ final class FrameworkBootstrap {
                if (!self::isReadableFile($fileInstance)) {
                        // Abort here
                        throw new InvalidArgumentException(sprintf('Cannot find fileInstance.pathname=%s.', $fileInstance->getPathname()));
-               } // END - if
+               }
 
                // Load it
                require_once $fileInstance->getPathname();
@@ -292,9 +292,9 @@ final class FrameworkBootstrap {
         * @return      void
         */
        public static function prepareApplication () {
-               // Configuration entry 'detected_app_name' must be set, get it here, including full path
-               $application = self::getConfigurationInstance()->getConfigEntry('detected_app_name');
-               $fullPath    = self::getConfigurationInstance()->getConfigEntry('detected_full_app_path');
+               // Configuration entry '__detected_app_name' must be set, get it here, including full path
+               $application = self::getConfigurationInstance()->getConfigEntry('__detected_app_name');
+               $fullPath    = self::getConfigurationInstance()->getConfigEntry('__detected_full_app_path');
 
                /*
                 * Now check and load all files, found deprecated files will throw a
@@ -323,11 +323,11 @@ final class FrameworkBootstrap {
 
                                // Skip loading deprecated file
                                continue;
-                       } // END - if
+                       }
 
                        // Load it
                        self::loadInclude($fileInstance);
-               } // END - foreach
+               }
 
                // Scan for application's classes, exceptions and interfaces
                ClassLoader::scanApplicationClasses();
@@ -340,8 +340,8 @@ final class FrameworkBootstrap {
         * @return      void
         */
        public static function startApplication () {
-               // Configuration entry 'detected_app_name' must be set, get it here
-               $application = self::getConfigurationInstance()->getConfigEntry('detected_app_name');
+               // Configuration entry '__detected_app_name' must be set, get it here
+               $application = self::getConfigurationInstance()->getConfigEntry('__detected_app_name');
 
                // Is there an application helper instance?
                $applicationInstance = call_user_func_array(
@@ -377,7 +377,7 @@ final class FrameworkBootstrap {
 
                        // Call method
                        call_user_func(array($applicationInstance, $methodName));
-               } // END - foreach
+               }
        }
 
        /**
@@ -393,7 +393,7 @@ final class FrameworkBootstrap {
                if (self::getDatabaseInstance() instanceof DatabaseConnector) {
                        // Yes, then abort here
                        throw new BadMethodCallException('Method called twice.');
-               } // END - if
+               }
 
                // Initialize database layer
                $databaseInstance = ObjectFactory::createObjectByConfiguredName(self::getConfigurationInstance()->getConfigEntry('database_type') . '_class');
@@ -430,7 +430,7 @@ final class FrameworkBootstrap {
                                         * false as many other PHP functions are doing? ;-(
                                         */
                                        throw new UnknownHostnameException(sprintf('Cannot resolve "%s" to an IP address. Please fix your setup.', $_SERVER['SERVER_NAME']));
-                               } // END - if
+                               }
 
                                // Al fine, set it
                                self::$serverAddress = $serverIp;
@@ -438,7 +438,7 @@ final class FrameworkBootstrap {
                                // Run auto-detecting through console tools lib
                                self::$serverAddress = ConsoleTools::acquireSelfIpAddress();
                        }
-               } // END - if
+               }
 
                // Return it
                return self::$serverAddress;
@@ -508,7 +508,7 @@ final class FrameworkBootstrap {
                if (self::isHttpSecured()) {
                        // Add the >s< for HTTPS
                        $protocol = 'https';
-               } // END - if
+               }
 
                // Construct the full URL and secure it against CSRF attacks
                $baseUrl = sprintf('%s://%s%s', $protocol, self::detectDomain(), self::detectScriptPath());
@@ -530,7 +530,7 @@ final class FrameworkBootstrap {
                if (isset($_SERVER['SERVER_NAME'])) {
                        // Detect the full domain
                        $fullDomain = htmlentities(strip_tags($_SERVER['SERVER_NAME']), ENT_QUOTES);
-               } // END - if
+               }
 
                // Return it
                return $fullDomain;
@@ -550,7 +550,7 @@ final class FrameworkBootstrap {
                if (isset($_SERVER['SCRIPT_NAME'])) {
                        // Get dirname from it and replace back-slashes with slashes for lame OSes...
                        $scriptPath = str_replace("\\", '/', dirname($_SERVER['SCRIPT_NAME']));
-               } // END - if
+               }
 
                // Return it
                return $scriptPath;
@@ -601,7 +601,7 @@ final class FrameworkBootstrap {
                        // Then use it
                        $request = strtolower($requestInstance->getRequestElement('request'));
                        $requestType = $request;
-               } // END - if
+               }
 
                // ... and a new response object
                $responseClass = sprintf('Org\Mxchange\CoreFramework\Response\%sResponse', StringUtils::convertToClassName($request));
@@ -625,7 +625,7 @@ final class FrameworkBootstrap {
                         * application (by user).
                         */
                        ApplicationEntryPoint::exitApplication('No application specified. Please provide a parameter "app" and retry.');
-               } // END - if
+               }
 
                // Get it for local usage
                $application = self::getRequestInstance()->getRequestElement('app');
@@ -649,11 +649,11 @@ final class FrameworkBootstrap {
                if ((!is_dir($applicationPath)) || (!is_readable($applicationPath))) {
                        // Not found or not readable
                        ApplicationEntryPoint::exitApplication(sprintf('Application "%s" not found.', $application));
-               } // END - if
+               }
 
                // Set the detected application's name and full path for later usage
-               self::getConfigurationInstance()->setConfigEntry('detected_full_app_path', $applicationPath);
-               self::getConfigurationInstance()->setConfigEntry('detected_app_name'     , $application);
+               self::getConfigurationInstance()->setConfigEntry('__detected_full_app_path', $applicationPath);
+               self::getConfigurationInstance()->setConfigEntry('__detected_app_name'     , $application);
        }
 
        /**
index 72d25add1524733dbdfdcf9f5903d4427ac1235e..4c1ce5817fb3c2dcc30e1c588ade86733d89f6a9 100644 (file)
@@ -272,7 +272,7 @@ class ClassLoader {
                                '%s%s%s%s%s',
                                $configInstance->getConfigEntry('application_base_path'),
                                DIRECTORY_SEPARATOR,
-                               $configInstance->getConfigEntry('detected_app_name'),
+                               $configInstance->getConfigEntry('__detected_app_name'),
                                DIRECTORY_SEPARATOR,
                                $shortPath
                        ));
@@ -505,8 +505,8 @@ class ClassLoader {
                // Construct the FQFN for the cache
                if (!FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('developer_mode_enabled')) {
                        // Init cache instances
-                       $this->listCacheFile  = new SplFileInfo($this->configInstance->getConfigEntry('local_database_path') . 'list-' . $this->configInstance->getConfigEntry('detected_app_name') . '.cache');
-                       $this->classCacheFile = new SplFileInfo($this->configInstance->getConfigEntry('local_database_path') . 'class-' . $this->configInstance->getConfigEntry('detected_app_name') . '.cache');
+                       $this->listCacheFile  = new SplFileInfo($this->configInstance->getConfigEntry('local_database_path') . 'list-' . $this->configInstance->getConfigEntry('__detected_app_name') . '.cache');
+                       $this->classCacheFile = new SplFileInfo($this->configInstance->getConfigEntry('local_database_path') . 'class-' . $this->configInstance->getConfigEntry('__detected_app_name') . '.cache');
                }
 
                // Set suffix and prefix from configuration
index 818fb7386a86c0b9dec9db7fc259b495d9955c13..bc2faf43ddb258a277fbd85e2ab58b31c7660a05 100644 (file)
--- a/index.php
+++ b/index.php
@@ -57,12 +57,12 @@ final class ApplicationEntryPoint {
         * @return      void
         * @todo        This method is old code and needs heavy rewrite and should be moved to ApplicationHelper
         */
-       public static final function exitApplication ($message = '', $code = false, $extraData = '', $silentMode = false) {
+       public static final function exitApplication (string $message = '', int $code = -1, string $extraData = '', bool $silentMode = false) {
                // Is this method already called?
                if (isset($GLOBALS['app_die_called'])) {
                        // Then output the text directly
                        exit($message);
-               } // END - if
+               }
 
                // This method shall not be called twice
                $GLOBALS['app_die_called'] = true;
@@ -71,7 +71,7 @@ final class ApplicationEntryPoint {
                if (empty($message)) {
                        // No message provided
                        $message = 'No message provided.';
-               } // END - if
+               }
 
                // Get config instance
                $configInstance = FrameworkBootstrap::getConfigurationInstance();
@@ -79,8 +79,8 @@ final class ApplicationEntryPoint {
                // Do we have debug installation?
                if (($configInstance->getConfigEntry('product_install_mode') == 'productive') || ($silentMode === true)) {
                        // Abort here
-                       exit();
-               } // END - if
+                       exit;
+               }
 
                // Get some instances
                $tpl = $configInstance->getConfigEntry('html_template_class');
@@ -105,19 +105,18 @@ final class ApplicationEntryPoint {
                        }
 
                        // Get and prepare backtrace for output
-                       $backtraceArray = debug_backtrace();
                        $backtrace = '';
-                       foreach ($backtraceArray as $key => $trace) {
+                       foreach (debug_backtrace() as $key => $trace) {
                                // Set missing array elements
                                if (!isset($trace['file'])) {
                                        $trace['file'] = __FILE__;
-                               } // END - if
+                               }
                                if (!isset($trace['line'])) {
                                        $trace['line'] = __LINE__;
-                               } // END - if
+                               }
                                if (!isset($trace['args'])) {
                                        $trace['args'] = array();
-                               } // END - if
+                               }
 
                                // Add the traceback path to the final output
                                $backtrace .= sprintf('<span class="backtrace_file">%s</span>:%d, <span class="backtrace_function">%s(%d)</span><br />' . PHP_EOL,
@@ -126,7 +125,7 @@ final class ApplicationEntryPoint {
                                        $trace['function'],
                                        count($trace['args'])
                                );
-                       } // END - foreach
+                       }
 
                        // Init application instance
                        $applicationInstance = NULL;
@@ -138,7 +137,7 @@ final class ApplicationEntryPoint {
 
                                // Assign application data
                                $templateInstance->assignApplicationData();
-                       } // END - if
+                       }
 
                        // We only try this
                        try {
@@ -171,10 +170,10 @@ final class ApplicationEntryPoint {
                        }
 
                        // Good bye...
-                       exit();
+                       exit;
                } else {
                        // Output message and die
-                       exit(sprintf('[Main:] Emergency exit reached: <span class="emergency_span">%s</span>',
+                       die(sprintf('[Main:] Emergency exit reached: <span class="emergency_span">%s</span>',
                                $message
                        ));
                }
@@ -196,14 +195,12 @@ final class ApplicationEntryPoint {
                                // Create full path for testing
                                $realPath = realpath($possiblePath);
 
-                               // Debug message
-                               //* NOISY-DEBUG: */ printf('[%s:%d]: realPath[%s]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($realPath), $realPath);
-
                                // Is it false?
+                               //* NOISY-DEBUG: */ printf('[%s:%d]: realPath[%s]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($realPath), $realPath);
                                if ($realPath === false) {
                                        // Then, not found.
                                        continue;
-                               } // END - if
+                               }
 
                                // Append framework path
                                $frameworkPath = sprintf('%s%sframework%s', $realPath, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR);
@@ -211,25 +208,23 @@ final class ApplicationEntryPoint {
                                // First create full-qualified file name (FQFN) to framework/config-global.php
                                $configFile = $frameworkPath . 'config-global.php';
 
-                               // Debug message
-                               //* NOISY-DEBUG: */ printf('[%s:%d]: configFile=%s' . PHP_EOL, __METHOD__, __LINE__, $configFile);
-
                                // Is it readable?
+                               //* NOISY-DEBUG: */ printf('[%s:%d]: configFile=%s' . PHP_EOL, __METHOD__, __LINE__, $configFile);
                                if (is_readable($configFile)) {
                                        // Found one
                                        self::$frameworkPath = $frameworkPath;
 
                                        // Abort here
                                        break;
-                               } // END - if
-                       } // END - foreach
+                               }
+                       }
 
                        // Able to find?
                        if (!is_dir(self::$frameworkPath)) {
                                // Is no directory
                                throw new Exception('Cannot find framework.');
-                       } // END - if
-               } // END - if
+                       }
+               }
 
                // Return it
                return self::$frameworkPath;
index 7b900fd296ba12733146f4437dc15a1e9b7d4e7a..ff22b9a9082615be2c4ab40abd2690ca3437fba2 100644 (file)
@@ -1,11 +1,9 @@
 <?php
-
 // Same namespace as target class
 namespace Org\Mxchange\CoreFramework\Bootstrap;
 
 // Inport framework stuff
 use Org\Mxchange\CoreFramework\Console\Tools\ConsoleTools;
-use Org\Mxchange\CoreFramework\Loader\ClassLoader;
 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
 
@@ -64,12 +62,6 @@ class FrameworkBootstrapTest extends TestCase {
                // Call parent method
                parent::setUpBeforeClass();
 
-               /*
-                * Disable strict naming-convention check in own class loader, because
-                * PHP_Invoker doesn't have namespaces.
-                */
-               ClassLoader::enableStrictNamingConventionCheck(FALSE);
-
                // Lookup own IP address
                self::$ipAddress = ConsoleTools::acquireSelfIpAddress();
 
index 12d8e551e7d8ef3d1d07d232b0ac4e7dbbfa6e46..fb65b3f8dee3cb4f06580fab74dc33c7286dd3ad 100644 (file)
@@ -6,12 +6,10 @@ namespace Org\Mxchange\CoreFramework\Configuration;
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\Configuration\FrameworkConfiguration;
 use Org\Mxchange\CoreFramework\Configuration\NoConfigEntryException;
-use Org\Mxchange\CoreFramework\Loader\ClassLoader;
 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
 
 // Import PHPUnit stuff
-use PHPUnit\Framework\Error\Notice;
 use PHPUnit\Framework\TestCase;
 
 // Import SPL stuff
@@ -68,12 +66,6 @@ class FrameworkConfigurationTest extends TestCase {
                // Init instance
                self::$configInstance = FrameworkBootstrap::getConfigurationInstance();
 
-               /*
-                * Disable strict naming-convention check in own class loader, because
-                * PHP_Invoker doesn't have namespaces.
-                */
-               ClassLoader::enableStrictNamingConventionCheck(FALSE);
-
                // Trace message
                //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
        }