// 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) {
// Throw an exception here
throw new AssertionException($message, BaseFrameworkSystem::EXCEPTION_ASSERTION_FAILED);
-} // END - function
+}
// Set error handler
//set_error_handler('tests_error_handler');
* 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)
'init' => 'deprecated',
// Application starter (deprecated)
'starter' => 'deprecated',
- );
+ ];
/**
* Private constructor, no instance is needed from this class as only
if (is_null(self::$configurationInstance)) {
// Init new instance
self::$configurationInstance = new FrameworkConfiguration();
- } // END - if
+ }
// Return it
return self::$configurationInstance;
if (isset($_SERVER['HTTP_HOST'])) {
// Then it is a HTML response/request.
$requestType = 'html';
- } // END - if
+ }
// Return it
return $requestType;
// 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;
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();
* @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
// Skip loading deprecated file
continue;
- } // END - if
+ }
// Load it
self::loadInclude($fileInstance);
- } // END - foreach
+ }
// Scan for application's classes, exceptions and interfaces
ClassLoader::scanApplicationClasses();
* @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(
// Call method
call_user_func(array($applicationInstance, $methodName));
- } // END - foreach
+ }
}
/**
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');
* 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;
// Run auto-detecting through console tools lib
self::$serverAddress = ConsoleTools::acquireSelfIpAddress();
}
- } // END - if
+ }
// Return it
return self::$serverAddress;
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());
if (isset($_SERVER['SERVER_NAME'])) {
// Detect the full domain
$fullDomain = htmlentities(strip_tags($_SERVER['SERVER_NAME']), ENT_QUOTES);
- } // END - if
+ }
// Return it
return $fullDomain;
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;
// 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));
* 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');
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);
}
/**
'%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
));
// 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
* @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;
if (empty($message)) {
// No message provided
$message = 'No message provided.';
- } // END - if
+ }
// Get config instance
$configInstance = FrameworkBootstrap::getConfigurationInstance();
// 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');
}
// 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,
$trace['function'],
count($trace['args'])
);
- } // END - foreach
+ }
// Init application instance
$applicationInstance = NULL;
// Assign application data
$templateInstance->assignApplicationData();
- } // END - if
+ }
// We only try this
try {
}
// 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
));
}
// 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);
// 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;
<?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;
// 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();
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
// 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__);
}