From 98ced4f4bc205820b42b6e09f9255792fdf6fcb5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 6 Dec 2020 08:48:31 +0100 Subject: [PATCH] Continued: - Application instance in generic registry was a little of an overdoze when there is ApplicationHelper::getSelfInstance() around, this means lesser method invocations and a bit smaller footprint (one registry entry lesser) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../application/class_BaseApplication.php | 5 +-- .../classes/class_BaseFrameworkSystem.php | 3 +- .../classes/commands/class_BaseCommand.php | 3 +- .../html/class_HtmlConfirmCommand.php | 3 +- .../commands/html/class_HtmlHomeCommand.php | 3 +- .../html/class_HtmlLoginAreaCommand.php | 8 ++--- .../commands/html/class_HtmlLoginCommand.php | 3 +- .../html/class_HtmlLoginFailedCommand.php | 3 +- .../html/class_HtmlLogoutDoneCommand.php | 3 +- .../html/class_HtmlRegisterCommand.php | 3 +- .../html/class_HtmlResendLinkCommand.php | 3 +- .../commands/html/class_HtmlStatusCommand.php | 3 +- .../image/class_ImageCodeCaptchaCommand.php | 3 +- .../html/form/class_HtmlDoFormController.php | 3 -- .../classes/criteria/class_BaseCriteria.php | 20 ++++------- .../class_FrameworkDirectoryPointer.php | 3 +- .../payment/class_PaymentDiscoveryFilter.php | 4 +-- .../captcha/images/class_ImageHelper.php | 22 ++++++------ .../html/links/class_HtmlLinkHelper.php | 3 +- .../main/classes/images/class_BaseImage.php | 8 ++--- .../classes/language/class_LanguageSystem.php | 16 ++++----- .../mailer/debug/class_DebugMailer.php | 3 +- .../main/classes/menu/class_BaseMenu.php | 3 +- .../output/console/class_ConsoleOutput.php | 3 +- .../action/class_BaseActionResolver.php | 4 +-- .../classes/resolver/class_BaseResolver.php | 29 ++------------- .../class_BaseControllerResolver.php | 9 +++-- .../classes/response/class_BaseResponse.php | 21 +++++------ .../response/html/class_HtmlResponse.php | 8 ++--- .../response/image/class_ImageResponse.php | 12 +++---- .../template/class_BaseTemplateEngine.php | 3 +- .../console/class_ConsoleTemplateEngine.php | 3 +- .../html/class_HtmlTemplateEngine.php | 3 +- .../image/class_ImageTemplateEngine.php | 3 +- .../mail/class_MailTemplateEngine.php | 3 +- .../menu/class_MenuTemplateEngine.php | 7 ++-- .../xml/class_BaseXmlTemplateEngine.php | 3 +- .../main/classes/user/class_BaseUser.php | 10 +++--- .../classes/visitor/class_BaseVisitor.php | 4 +-- .../response/class_Responseable.php | 16 ++++----- .../api/wernisportal/class_WernisApi.php | 35 +++++++++---------- 41 files changed, 141 insertions(+), 166 deletions(-) diff --git a/framework/main/classes/application/class_BaseApplication.php b/framework/main/classes/application/class_BaseApplication.php index bdf05189..1c83f728 100644 --- a/framework/main/classes/application/class_BaseApplication.php +++ b/framework/main/classes/application/class_BaseApplication.php @@ -4,9 +4,9 @@ namespace Org\Mxchange\CoreFramework\Application; // Import framework stuff use Org\Mxchange\CoreFramework\Controller\Controller; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Manager\ManageableApplication; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; -use Org\Mxchange\CoreFramework\Registry\GenericRegistry; /** * A general application class for the ApplicationHelper classes. @@ -65,9 +65,6 @@ abstract class BaseApplication extends BaseFrameworkSystem { protected function __construct (string $className) { // Call parent constructor parent::__construct($className); - - // Set this instance as application instance - GenericRegistry::getRegistry()->addInstance('application', $this); } /** diff --git a/framework/main/classes/class_BaseFrameworkSystem.php b/framework/main/classes/class_BaseFrameworkSystem.php index 2585985a..526346ca 100644 --- a/framework/main/classes/class_BaseFrameworkSystem.php +++ b/framework/main/classes/class_BaseFrameworkSystem.php @@ -11,6 +11,7 @@ use Org\Mxchange\CoreFramework\Filesystem\PathWriteProtectedException; use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; use Org\Mxchange\CoreFramework\Generic\NullPointerException; use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Loader\ClassLoader; use Org\Mxchange\CoreFramework\Manager\ManageableApplication; use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware; @@ -1642,7 +1643,7 @@ Loaded includes: */ protected function initWebOutputInstance () { // Get application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Init web output instance $outputInstance = ObjectFactory::createObjectByConfiguredName('output_class', array($applicationInstance)); diff --git a/framework/main/classes/commands/class_BaseCommand.php b/framework/main/classes/commands/class_BaseCommand.php index b66cb3ff..87cca6cf 100644 --- a/framework/main/classes/commands/class_BaseCommand.php +++ b/framework/main/classes/commands/class_BaseCommand.php @@ -5,6 +5,7 @@ namespace Org\Mxchange\CoreFramework\Command; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Request\Requestable; @@ -77,7 +78,7 @@ abstract class BaseCommand extends BaseFrameworkSystem { assert(!$requestInstance->isPostRequestMethod()); // Get the application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Transfer application data $this->getTemplateInstance()->assignApplicationData(); diff --git a/framework/main/classes/commands/html/class_HtmlConfirmCommand.php b/framework/main/classes/commands/html/class_HtmlConfirmCommand.php index e0ee64cf..40ec5ddd 100644 --- a/framework/main/classes/commands/html/class_HtmlConfirmCommand.php +++ b/framework/main/classes/commands/html/class_HtmlConfirmCommand.php @@ -9,6 +9,7 @@ use Org\Mxchange\CoreFramework\Command\Commandable; use Org\Mxchange\CoreFramework\Controller\Controller; use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Generic\NullPointerException; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Request\Requestable; @@ -74,7 +75,7 @@ class HtmlConfirmCommand extends BaseCommand implements Commandable { */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Get the application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Assign application data with template engine $this->getTemplateInstance()->assignApplicationData(); diff --git a/framework/main/classes/commands/html/class_HtmlHomeCommand.php b/framework/main/classes/commands/html/class_HtmlHomeCommand.php index 5213906d..8127793c 100644 --- a/framework/main/classes/commands/html/class_HtmlHomeCommand.php +++ b/framework/main/classes/commands/html/class_HtmlHomeCommand.php @@ -8,6 +8,7 @@ use Org\Mxchange\CoreFramework\Command\BaseCommand; use Org\Mxchange\CoreFramework\Command\Commandable; use Org\Mxchange\CoreFramework\Controller\Controller; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Request\Requestable; use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver; @@ -72,7 +73,7 @@ class HtmlHomeCommand extends BaseCommand implements Commandable { */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Get the application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Prepare a template instance // Transfer application data diff --git a/framework/main/classes/commands/html/class_HtmlLoginAreaCommand.php b/framework/main/classes/commands/html/class_HtmlLoginAreaCommand.php index 6ec51ebb..95fac58a 100644 --- a/framework/main/classes/commands/html/class_HtmlLoginAreaCommand.php +++ b/framework/main/classes/commands/html/class_HtmlLoginAreaCommand.php @@ -9,6 +9,7 @@ use Org\Mxchange\CoreFramework\Command\BaseCommand; use Org\Mxchange\CoreFramework\Command\Commandable; use Org\Mxchange\CoreFramework\Controller\Controller; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Request\Requestable; use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver; @@ -100,7 +101,7 @@ class HtmlLoginAreaCommand extends BaseCommand implements Commandable { } // Get the application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Assign base URL $this->getTemplateInstance()->assignConfigVariable('base_url'); @@ -174,11 +175,8 @@ class HtmlLoginAreaCommand extends BaseCommand implements Commandable { * @return void */ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { - // Get registry - $registryInstance = GenericRegistry::getRegistry(); - // Get our application instance from the registry - $applicationInstance = $registryInstance->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Default action is the one from configuration $this->actionName = StringUtils::convertDashesToUnderscores($applicationInstance->getAppShortName()) . '_login_' . FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('login_default_action'); diff --git a/framework/main/classes/commands/html/class_HtmlLoginCommand.php b/framework/main/classes/commands/html/class_HtmlLoginCommand.php index 77f9be23..01f05c6b 100644 --- a/framework/main/classes/commands/html/class_HtmlLoginCommand.php +++ b/framework/main/classes/commands/html/class_HtmlLoginCommand.php @@ -8,6 +8,7 @@ use Org\Mxchange\CoreFramework\Command\BaseCommand; use Org\Mxchange\CoreFramework\Command\Commandable; use Org\Mxchange\CoreFramework\Controller\Controller; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Request\Requestable; use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver; @@ -75,7 +76,7 @@ class HtmlLoginCommand extends BaseCommand implements Commandable { GenericRegistry::getRegistry()->addInstance('extra', $this); // Get the application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Assign application data with template engine $this->getTemplateInstance()->assignApplicationData(); diff --git a/framework/main/classes/commands/html/class_HtmlLoginFailedCommand.php b/framework/main/classes/commands/html/class_HtmlLoginFailedCommand.php index 6507520c..0172fdf4 100644 --- a/framework/main/classes/commands/html/class_HtmlLoginFailedCommand.php +++ b/framework/main/classes/commands/html/class_HtmlLoginFailedCommand.php @@ -8,6 +8,7 @@ use Org\Mxchange\CoreFramework\Command\BaseCommand; use Org\Mxchange\CoreFramework\Command\Commandable; use Org\Mxchange\CoreFramework\Controller\Controller; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Request\Requestable; use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver; @@ -72,7 +73,7 @@ class HtmlLoginFailedCommand extends BaseCommand implements Commandable { */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Get the application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Assign application data with template engine $this->getTemplateInstance()->assignApplicationData(); diff --git a/framework/main/classes/commands/html/class_HtmlLogoutDoneCommand.php b/framework/main/classes/commands/html/class_HtmlLogoutDoneCommand.php index 6ef72aca..13f69e8d 100644 --- a/framework/main/classes/commands/html/class_HtmlLogoutDoneCommand.php +++ b/framework/main/classes/commands/html/class_HtmlLogoutDoneCommand.php @@ -8,6 +8,7 @@ use Org\Mxchange\CoreFramework\Command\BaseCommand; use Org\Mxchange\CoreFramework\Command\Commandable; use Org\Mxchange\CoreFramework\Controller\Controller; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Request\Requestable; use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver; @@ -72,7 +73,7 @@ class HtmlLogoutDoneCommand extends BaseCommand implements Commandable { */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Get the application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Assign application data $this->getTemplateInstance()->assignApplicationData(); diff --git a/framework/main/classes/commands/html/class_HtmlRegisterCommand.php b/framework/main/classes/commands/html/class_HtmlRegisterCommand.php index 1c65919a..7ca5a6ed 100644 --- a/framework/main/classes/commands/html/class_HtmlRegisterCommand.php +++ b/framework/main/classes/commands/html/class_HtmlRegisterCommand.php @@ -8,6 +8,7 @@ use Org\Mxchange\CoreFramework\Command\BaseCommand; use Org\Mxchange\CoreFramework\Command\Commandable; use Org\Mxchange\CoreFramework\Controller\Controller; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Request\Requestable; use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver; @@ -75,7 +76,7 @@ class HtmlRegisterCommand extends BaseCommand implements Commandable { GenericRegistry::getRegistry()->addInstance('extra', $this); // Get the application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Assign all the application's data with template variables $this->getTemplateInstance()->assignApplicationData(); diff --git a/framework/main/classes/commands/html/class_HtmlResendLinkCommand.php b/framework/main/classes/commands/html/class_HtmlResendLinkCommand.php index 7ddcc8b4..ab8974db 100644 --- a/framework/main/classes/commands/html/class_HtmlResendLinkCommand.php +++ b/framework/main/classes/commands/html/class_HtmlResendLinkCommand.php @@ -9,6 +9,7 @@ use Org\Mxchange\CoreFramework\Command\Commandable; use Org\Mxchange\CoreFramework\Controller\Controller; use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Request\Requestable; use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver; @@ -76,7 +77,7 @@ class HtmlResendLinkCommand extends BaseCommand implements Commandable { $userInstance = GenericRegistry::getRegistry()->getInstance('user'); // Get an application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Get a RNG instance (Random Number Generator) $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class'); diff --git a/framework/main/classes/commands/html/class_HtmlStatusCommand.php b/framework/main/classes/commands/html/class_HtmlStatusCommand.php index 485ca585..57cf347e 100644 --- a/framework/main/classes/commands/html/class_HtmlStatusCommand.php +++ b/framework/main/classes/commands/html/class_HtmlStatusCommand.php @@ -8,6 +8,7 @@ use Org\Mxchange\CoreFramework\Command\BaseCommand; use Org\Mxchange\CoreFramework\Command\Commandable; use Org\Mxchange\CoreFramework\Controller\Controller; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Request\Requestable; use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver; use Org\Mxchange\CoreFramework\Response\Responseable; @@ -72,7 +73,7 @@ class HtmlStatusCommand extends BaseCommand implements Commandable { */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Get the application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Transfer application data $this->getTemplateInstance()->assignApplicationData(); diff --git a/framework/main/classes/commands/image/class_ImageCodeCaptchaCommand.php b/framework/main/classes/commands/image/class_ImageCodeCaptchaCommand.php index ea5f737d..53709e65 100644 --- a/framework/main/classes/commands/image/class_ImageCodeCaptchaCommand.php +++ b/framework/main/classes/commands/image/class_ImageCodeCaptchaCommand.php @@ -6,6 +6,7 @@ namespace Org\Mxchange\CoreFramework\Command\Captcha; use Org\Mxchange\CoreFramework\Command\BaseCommand; use Org\Mxchange\CoreFramework\Command\Commandable; use Org\Mxchange\CoreFramework\Controller\Controller; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Request\Requestable; use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver; @@ -73,7 +74,7 @@ class ImageCodeCaptchaCommand extends BaseCommand implements Commandable { $decryptedCode = $requestInstance->getRequestElement('decrypted'); // Get the application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Assign variable $this->getTemplateInstance()->assignVariable('decrypted_code', $decryptedCode); diff --git a/framework/main/classes/controller/html/form/class_HtmlDoFormController.php b/framework/main/classes/controller/html/form/class_HtmlDoFormController.php index e5c1537d..177705d5 100644 --- a/framework/main/classes/controller/html/form/class_HtmlDoFormController.php +++ b/framework/main/classes/controller/html/form/class_HtmlDoFormController.php @@ -55,9 +55,6 @@ class HtmlDoFormController extends BaseController implements Controller { // Set resolver instance $controllerInstance->setResolverInstance($resolverInstance); - // We need the controller instance in resolver class so set it here - $resolverInstance->setControllerInstance($controllerInstance); - // Return the prepared instance return $controllerInstance; } diff --git a/framework/main/classes/criteria/class_BaseCriteria.php b/framework/main/classes/criteria/class_BaseCriteria.php index e38926cf..db77c59e 100644 --- a/framework/main/classes/criteria/class_BaseCriteria.php +++ b/framework/main/classes/criteria/class_BaseCriteria.php @@ -236,10 +236,8 @@ abstract class BaseCriteria extends BaseFrameworkSystem implements Criteria { // Make sure no 'my-' or 'my_' passes this point assert((strpos($criteriaKey, 'my-') === false) && (strpos($criteriaKey, 'my_') === false) && (!is_bool($criteriaValue))); - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '(' . $this->__toString() . ')-CRITERIA: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue); - // Add it + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '(' . $this->__toString() . ')-CRITERIA: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue); $this->pushValueToGenericArrayElement('criteria', 'choice', 'entries', StringUtils::convertDashesToUnderscores($criteriaKey), (string) $criteriaValue); } @@ -264,7 +262,7 @@ abstract class BaseCriteria extends BaseFrameworkSystem implements Criteria { * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' * @return void */ - public final function addConfiguredCriteria ($criteriaKey, $configEntry, string $criteriaType = 'default') { + public final function addConfiguredCriteria (string $criteriaKey, string $configEntry, string $criteriaType = 'default') { // Add the configuration entry as a criteria $value = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configEntry); $this->addCriteria($criteriaKey, $value, $criteriaType); @@ -277,20 +275,16 @@ abstract class BaseCriteria extends BaseFrameworkSystem implements Criteria { * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' * @return $value Whether the value of the critera or false */ - public function getCriteriaElemnent ($criteriaKey, string $criteriaType = 'default') { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: criteriaKey=' . $criteriaKey . ',criteriaType=' . $criteriaType . ' - CALLED!'); - + public function getCriteriaElemnent (string $criteriaKey, string $criteriaType = 'default') { // Make sure no 'my-' or 'my_' passes this point + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: criteriaKey=' . $criteriaKey . ',criteriaType=' . $criteriaType . ' - CALLED!'); assert((strpos($criteriaKey, 'my-') === false) && (strpos($criteriaKey, 'my_') === false)); // Convert dashes to underscore $criteriaKey = StringUtils::convertDashesToUnderscores($criteriaKey); - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: criteriaKey=' . $criteriaKey . ',criteria()=' . $this->countGenericArrayGroup('criteria', $criteriaType)); - // Default is not found + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: criteriaKey=' . $criteriaKey . ',criteria()=' . $this->countGenericArrayGroup('criteria', $criteriaType)); $value = false; // Is the criteria there? @@ -299,10 +293,8 @@ abstract class BaseCriteria extends BaseFrameworkSystem implements Criteria { $value = $this->getGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey); } // END - if - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: value=' . $value . ' - EXIT!'); - // Return the value + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: value=' . $value . ' - EXIT!'); return $value; } diff --git a/framework/main/classes/file_directories/directory/class_FrameworkDirectoryPointer.php b/framework/main/classes/file_directories/directory/class_FrameworkDirectoryPointer.php index 52a197b1..6816e4e4 100644 --- a/framework/main/classes/file_directories/directory/class_FrameworkDirectoryPointer.php +++ b/framework/main/classes/file_directories/directory/class_FrameworkDirectoryPointer.php @@ -232,8 +232,7 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem implements Framework * @param $pathName The new path name * @return void */ - protected final function setPathName ($pathName) { - $pathName = (string) $pathName; + protected final function setPathName (string $pathName) { $this->pathName = $pathName; } diff --git a/framework/main/classes/filter/payment/class_PaymentDiscoveryFilter.php b/framework/main/classes/filter/payment/class_PaymentDiscoveryFilter.php index 08737bdf..1588a795 100644 --- a/framework/main/classes/filter/payment/class_PaymentDiscoveryFilter.php +++ b/framework/main/classes/filter/payment/class_PaymentDiscoveryFilter.php @@ -91,8 +91,8 @@ class PaymentDiscoveryFilter extends BaseFilter implements Filterable { * @param $actionName Action name to set * @return void */ - protected final function setActionName ($actionName) { - $this->actionName = (string) $actionName; + protected final function setActionName (string $actionName) { + $this->actionName = $actionName; } /** diff --git a/framework/main/classes/helper/captcha/images/class_ImageHelper.php b/framework/main/classes/helper/captcha/images/class_ImageHelper.php index a1ef9add..739c9777 100644 --- a/framework/main/classes/helper/captcha/images/class_ImageHelper.php +++ b/framework/main/classes/helper/captcha/images/class_ImageHelper.php @@ -53,20 +53,20 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate { /** * Array for background color values */ - private $backgroundColor = array( + private $backgroundColor = [ 'red' => 0, 'green' => 0, 'blue' => 0 - ); + ]; /** * Array for foreground color values */ - private $foregroundColor = array( + private $foregroundColor = [ 'red' => 0, 'green' => 0, 'blue' => 0 - ); + ]; /** * All image strings @@ -100,7 +100,7 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate { * @param $imageType Type of the image * @return $helperInstance A preparedf instance of this helper */ - public static final function createImageHelper (CompileableTemplate $templateInstance, $imageType) { + public static final function createImageHelper (CompileableTemplate $templateInstance, string $imageType) { // Get new instance $helperInstance = new ImageHelper(); @@ -267,7 +267,7 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate { * * @param $stringName String name (identifier) */ - public function addTextLine ($stringName) { + public function addTextLine (string $stringName) { // Create the image string $this->imageStrings[$stringName] = array( 'x' => '', @@ -286,8 +286,8 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate { * @param $imageString A message to display in image * @return void */ - public final function setImageString ($imageString) { - $this->imageStrings[$this->currString]['string'] = (string) $imageString; + public final function setImageString (string $imageString) { + $this->imageStrings[$this->currString]['string'] = $imageString; } /** @@ -306,9 +306,9 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate { * @param $y Y coordinate * @return void */ - public final function setCoord ($x, $y) { - $this->imageStrings[$this->currString]['x'] = (int) $x; - $this->imageStrings[$this->currString]['y'] = (int) $y; + public final function setCoord (int $x, int $y) { + $this->imageStrings[$this->currString]['x'] = $x; + $this->imageStrings[$this->currString]['y'] = $y; } /** diff --git a/framework/main/classes/helper/html/links/class_HtmlLinkHelper.php b/framework/main/classes/helper/html/links/class_HtmlLinkHelper.php index e603d805..6ad10722 100644 --- a/framework/main/classes/helper/html/links/class_HtmlLinkHelper.php +++ b/framework/main/classes/helper/html/links/class_HtmlLinkHelper.php @@ -7,6 +7,7 @@ use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Configuration\FrameworkConfiguration; use Org\Mxchange\CoreFramework\Configuration\NoConfigEntryException; use Org\Mxchange\CoreFramework\Generic\NullPointerException; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Helper\Template\HelpableTemplate; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Utils\String\StringUtils; @@ -85,7 +86,7 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { $helperInstance->setLinkName($linkName); // Get the application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Get the request instance $requestInstance = FrameworkBootstrap::getRequestInstance(); diff --git a/framework/main/classes/images/class_BaseImage.php b/framework/main/classes/images/class_BaseImage.php index 5ba5ce43..949f0c5a 100644 --- a/framework/main/classes/images/class_BaseImage.php +++ b/framework/main/classes/images/class_BaseImage.php @@ -324,8 +324,8 @@ abstract class BaseImage extends BaseFrameworkSystem implements Registerable { * @param $string String to set in image * @return void */ - public final function setString ($string) { - $this->imageString = (string) $string; + public final function setString (string $string) { + $this->imageString = $string; } /** @@ -362,8 +362,8 @@ abstract class BaseImage extends BaseFrameworkSystem implements Registerable { * @param $name Name of the image * @return void */ - public final function setImageName ($name) { - $this->imageName = (string) $name; + public final function setImageName (string $name) { + $this->imageName = $name; } /** diff --git a/framework/main/classes/language/class_LanguageSystem.php b/framework/main/classes/language/class_LanguageSystem.php index c8cc07a0..d3791d37 100644 --- a/framework/main/classes/language/class_LanguageSystem.php +++ b/framework/main/classes/language/class_LanguageSystem.php @@ -4,6 +4,7 @@ namespace Org\Mxchange\CoreFramework\Localization; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Localization\ManageableLanguage; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; use Org\Mxchange\CoreFramework\ObjectArray\FrameworkArrayObject; @@ -87,7 +88,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage, if (empty($languageBasePath)) { // No, then attempt "auto-dection": // 1) Get application - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // 2) Try to build it $languageBasePath = sprintf('%s%s/language/', @@ -141,7 +142,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage, */ protected final function setLanguageBasePath (string $languageBasePath) { // And set it - $this->languageBasePath = (string) $languageBasePath; + $this->languageBasePath = $languageBasePath; } /** @@ -167,7 +168,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage, * * Origin: StatusNet's lib/language.php */ - $localeCategories = array( + foreach ([ 'LC_CTYPE', 'LC_NUMERIC', 'LC_TIME', @@ -175,16 +176,13 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage, 'LC_MONETARY', 'LC_MESSAGES', 'LC_ALL' - ); - - // Set all, if not defined - foreach ($localeCategories as $key => $name) { + ] as $key => $name) { // Is it set? if (!defined($name)) { // No, then set it define($name, $key); - } // END - if - } // END - foreach + } + } // Init language strings array $this->langStrings = new FrameworkArrayObject('FakedLanguageStrings'); diff --git a/framework/main/classes/mailer/debug/class_DebugMailer.php b/framework/main/classes/mailer/debug/class_DebugMailer.php index 810163f8..4f1c8ec6 100644 --- a/framework/main/classes/mailer/debug/class_DebugMailer.php +++ b/framework/main/classes/mailer/debug/class_DebugMailer.php @@ -5,6 +5,7 @@ namespace Org\Mxchange\CoreFramework\Mailer\Debug; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Generic\NullPointerException; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Mailer\BaseMailer; use Org\Mxchange\CoreFramework\Mailer\DeliverableMail; use Org\Mxchange\CoreFramework\Manager\Login\ManageableMember; @@ -173,7 +174,7 @@ class DebugMailer extends BaseMailer implements DeliverableMail { $templateInstance->assignTemplateWithVariable('footer', 'footer'); // Get master template name - $masterTemplateName = GenericRegistry::getRegistry()->getInstance('application')->buildMasterTemplateName(); + $masterTemplateName = ApplicationHelper::getSelfInstance()->buildMasterTemplateName(); // Load the master template $templateInstance->loadCodeTemplate($masterTemplateName); diff --git a/framework/main/classes/menu/class_BaseMenu.php b/framework/main/classes/menu/class_BaseMenu.php index 2defb635..f73d34e0 100644 --- a/framework/main/classes/menu/class_BaseMenu.php +++ b/framework/main/classes/menu/class_BaseMenu.php @@ -6,6 +6,7 @@ namespace Org\Mxchange\CoreFramework\Menu; use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Traits\Template\CompileableTemplateTrait; @@ -69,7 +70,7 @@ abstract class BaseMenu extends BaseFrameworkSystem { // If page is empty, choose default if (empty($command)) { // Use default page as none has been specified - $command = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('default_' . GenericRegistry::getRegistry()->getInstance('application')->getAppShortName() . '_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_command'); + $command = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('default_' . ApplicationHelper::getSelfInstance()->getAppShortName() . '_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_command'); } // END - if // Load the menu template for this page diff --git a/framework/main/classes/output/console/class_ConsoleOutput.php b/framework/main/classes/output/console/class_ConsoleOutput.php index 9dcae976..3ffff09f 100644 --- a/framework/main/classes/output/console/class_ConsoleOutput.php +++ b/framework/main/classes/output/console/class_ConsoleOutput.php @@ -53,9 +53,8 @@ class ConsoleOutput extends BaseOutput implements OutputStreamer { * @param $contentType A valid content-type * @return $debugInstance An instance of this middleware class */ - public static final function createConsoleOutput ($contentType) { + public static final function createConsoleOutput (string $contentType) { // Cast the content-type to string - $contentType = (string) $contentType; $contentType = trim($contentType); // Get instance diff --git a/framework/main/classes/resolver/action/class_BaseActionResolver.php b/framework/main/classes/resolver/action/class_BaseActionResolver.php index 6a30c35c..3578fb3d 100644 --- a/framework/main/classes/resolver/action/class_BaseActionResolver.php +++ b/framework/main/classes/resolver/action/class_BaseActionResolver.php @@ -55,8 +55,8 @@ abstract class BaseActionResolver extends BaseResolver { * @param $actionName Last validated action name * @return void */ - protected final function setActionName ($actionName) { - $this->actionName = (string) $actionName; + protected final function setActionName (string $actionName) { + $this->actionName = $actionName; } /** diff --git a/framework/main/classes/resolver/class_BaseResolver.php b/framework/main/classes/resolver/class_BaseResolver.php index c92a0ab2..58816825 100644 --- a/framework/main/classes/resolver/class_BaseResolver.php +++ b/framework/main/classes/resolver/class_BaseResolver.php @@ -3,7 +3,6 @@ namespace Org\Mxchange\CoreFramework\Resolver; // Import framework stuff -use Org\Mxchange\CoreFramework\Controller\Controller; use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; use Org\Mxchange\CoreFramework\Utils\String\StringUtils; @@ -57,11 +56,6 @@ abstract class BaseResolver extends BaseFrameworkSystem { */ private $resolvedInstance = NULL; - /** - * A controller instance - */ - private $controllerInstance = NULL; - /** * Protected constructor * @@ -142,8 +136,8 @@ abstract class BaseResolver extends BaseFrameworkSystem { * @param $classPrefix Last validated classPrefix * @return void */ - protected final function setClassPrefix ($classPrefix) { - $this->classPrefix = (string) $classPrefix; + protected final function setClassPrefix (string $classPrefix) { + $this->classPrefix = $classPrefix; } /** @@ -165,23 +159,4 @@ abstract class BaseResolver extends BaseFrameworkSystem { $this->resolvedInstance = $resolvedInstance; } - /** - * Setter for controller instance (this surely breaks a bit the MVC patterm) - * - * @param $controllerInstance An instance of the controller - * @return void - */ - public final function setControllerInstance (Controller $controllerInstance) { - $this->controllerInstance = $controllerInstance; - } - - /** - * Getter for controller instance (this surely breaks a bit the MVC patterm) - * - * @return $controllerInstance An instance of the controller - */ - public final function getControllerInstance () { - return $this->controllerInstance; - } - } diff --git a/framework/main/classes/resolver/controller/class_BaseControllerResolver.php b/framework/main/classes/resolver/controller/class_BaseControllerResolver.php index c67f501f..cf828e61 100644 --- a/framework/main/classes/resolver/controller/class_BaseControllerResolver.php +++ b/framework/main/classes/resolver/controller/class_BaseControllerResolver.php @@ -8,6 +8,7 @@ use Org\Mxchange\CoreFramework\Controller\Controller; use Org\Mxchange\CoreFramework\Controller\DefaultControllerException; use Org\Mxchange\CoreFramework\Controller\InvalidControllerException; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Resolver\BaseResolver; use Org\Mxchange\CoreFramework\Resolver\Controller\ControllerResolver; @@ -88,9 +89,6 @@ abstract class BaseControllerResolver extends BaseResolver { // Cache default controller $defaultController = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('default_' . strtolower($this->getClassPrefix()) . '_controller'); - // Init controller instance - $controllerInstance = NULL; - // Create full class name $className = sprintf( '%s\%sDefaultNewsController', @@ -138,9 +136,11 @@ abstract class BaseControllerResolver extends BaseResolver { $resolverConfigEntry, array( $controllerName, - GenericRegistry::getRegistry()->getInstance('application') + ApplicationHelper::getSelfInstance() ) ); + + // Get controller instance $controllerInstance = ObjectFactory::createObjectByName( $this->getClassName(), array($resolverInstance) @@ -227,7 +227,6 @@ abstract class BaseControllerResolver extends BaseResolver { public function resolveController () { // Init variables $controllerName = $this->getControllerName(); - $controllerInstance = NULL; // Get the controller $controllerInstance = $this->loadController($controllerName); diff --git a/framework/main/classes/response/class_BaseResponse.php b/framework/main/classes/response/class_BaseResponse.php index 7d223365..9f364bb1 100644 --- a/framework/main/classes/response/class_BaseResponse.php +++ b/framework/main/classes/response/class_BaseResponse.php @@ -4,6 +4,7 @@ namespace Org\Mxchange\CoreFramework\Response; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; @@ -75,8 +76,8 @@ abstract class BaseResponse extends BaseFrameworkSystem { * @param $status New response status * @return void */ - public final function setResponseStatus ($status) { - $this->responseStatus = (string) $status; + public final function setResponseStatus (string $status) { + $this->responseStatus = $status; } /** @@ -86,7 +87,7 @@ abstract class BaseResponse extends BaseFrameworkSystem { * @param $value Value of header element * @return void */ - public final function addHeader ($name, $value) { + public final function addHeader (string $name, $value) { $this->responseHeaders[$name] = $value; } @@ -105,7 +106,7 @@ abstract class BaseResponse extends BaseFrameworkSystem { * @param $output Output we shall sent in the HTTP response * @return void */ - public final function writeToBody ($output) { + public final function writeToBody (string $output) { $this->responseBody .= $output; } @@ -125,7 +126,7 @@ abstract class BaseResponse extends BaseFrameworkSystem { * @param $responseType Response type * @return void */ - protected final function setResponseType ($responseType) { + protected final function setResponseType (string $responseType) { $this->responseType = $responseType; } @@ -146,7 +147,7 @@ abstract class BaseResponse extends BaseFrameworkSystem { * @param $messageId The message id we shall add * @return void */ - public final function addFatalMessage ($messageId) { + public final function addFatalMessage (string $messageId) { // Adds the resolved message id to the fatal message list $this->addFatalMessagePlain(FrameworkBootstrap::getLanguageInstance()->getMessage($messageId)); } @@ -157,7 +158,7 @@ abstract class BaseResponse extends BaseFrameworkSystem { * @param $message The plain message we shall add * @return void */ - public final function addFatalMessagePlain ($message) { + public final function addFatalMessagePlain (string $message) { // Adds the resolved message id to the fatal message list $this->pushValueToGenericArrayKey('fatal_messages', 'generic', 'message', $message); } @@ -171,9 +172,9 @@ abstract class BaseResponse extends BaseFrameworkSystem { * @throws ResponseHeadersAlreadySentException Thrown if headers are * already sent */ - public function flushBuffer ($force = false) { + public function flushBuffer (bool $force = false) { // Get application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Headers already sent? if ((headers_sent()) && ($force === false)) { @@ -236,7 +237,7 @@ abstract class BaseResponse extends BaseFrameworkSystem { */ public function determineDefaultCommand () { // Get application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Generate config key $configKey = sprintf('default_%s_%s_command', diff --git a/framework/main/classes/response/html/class_HtmlResponse.php b/framework/main/classes/response/html/class_HtmlResponse.php index 2cba458d..9ef39d64 100644 --- a/framework/main/classes/response/html/class_HtmlResponse.php +++ b/framework/main/classes/response/html/class_HtmlResponse.php @@ -4,6 +4,7 @@ namespace Org\Mxchange\CoreFramework\Response; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Manager\ManageableApplication; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Response\Responseable; @@ -70,7 +71,6 @@ class HtmlResponse extends BaseResponse implements Responseable { * @return void * @throws ResponseHeadersAlreadySentException If headers are already sent * @todo Encryption of cookie data not yet supported. - * @todo Why are these parameters conflicting? * @todo If the return statement is removed and setcookie() commented out, * @todo this will send only one cookie out, the first one. */ @@ -123,7 +123,7 @@ class HtmlResponse extends BaseResponse implements Responseable { */ public function redirectToConfiguredUrl ($configEntry) { // Get application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Is the header not yet sent? if (headers_sent()) { @@ -173,7 +173,7 @@ class HtmlResponse extends BaseResponse implements Responseable { * @param $cookieName Cookie to expire * @return void */ - public function expireCookie ($cookieName) { + public function expireCookie (string $cookieName) { // Is the cookie there? if (isset($_COOKIE[$cookieName])) { // Then expire it with 20 minutes past @@ -190,7 +190,7 @@ class HtmlResponse extends BaseResponse implements Responseable { * @param $cookieName Cookie to refresh * @return void */ - public function refreshCookie ($cookieName) { + public function refreshCookie (string $cookieName) { // Only update existing cookies if (isset($_COOKIE[$cookieName])) { // Update the cookie diff --git a/framework/main/classes/response/image/class_ImageResponse.php b/framework/main/classes/response/image/class_ImageResponse.php index 5354c0ec..8bb696da 100644 --- a/framework/main/classes/response/image/class_ImageResponse.php +++ b/framework/main/classes/response/image/class_ImageResponse.php @@ -4,6 +4,7 @@ namespace Org\Mxchange\CoreFramework\Response; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Image\BaseImage; use Org\Mxchange\CoreFramework\Manager\ManageableApplication; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; @@ -95,7 +96,6 @@ class ImageResponse extends BaseResponse implements Responseable { * @return void * @throws ResponseHeadersAlreadySentException If headers are already sent * @todo Encryption of cookie data not yet supported. - * @todo Why are these parameters conflicting? * @todo If the return statement is removed and setcookie() commented out, * @todo this will send only one cookie out, the first one. */ @@ -144,9 +144,9 @@ class ImageResponse extends BaseResponse implements Responseable { * @return void * @throws ResponseHeadersAlreadySentException If headers are already sent */ - public function redirectToConfiguredUrl ($configEntry) { + public function redirectToConfiguredUrl (string $configEntry) { // Get application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Is the header not yet sent? if (headers_sent()) { @@ -195,7 +195,7 @@ class ImageResponse extends BaseResponse implements Responseable { * already sent with an exception * @return void */ - public function flushBuffer ($force = false) { + public function flushBuffer (bool $force = false) { // Finish the image $this->getImageInstance()->finishImage(); @@ -218,7 +218,7 @@ class ImageResponse extends BaseResponse implements Responseable { * @param $cookieName Cookie to expire * @return void */ - public function expireCookie ($cookieName) { + public function expireCookie (string $cookieName) { // Is the cookie there? if (isset($_COOKIE[$cookieName])) { // Then expire it with 20 minutes past @@ -235,7 +235,7 @@ class ImageResponse extends BaseResponse implements Responseable { * @param $cookieName Cookie to refresh * @return void */ - public function refreshCookie ($cookieName) { + public function refreshCookie (string $cookieName) { // Only update existing cookies if (isset($_COOKIE[$cookieName])) { // Update the cookie diff --git a/framework/main/classes/template/class_BaseTemplateEngine.php b/framework/main/classes/template/class_BaseTemplateEngine.php index 8c09dfbf..523c273d 100644 --- a/framework/main/classes/template/class_BaseTemplateEngine.php +++ b/framework/main/classes/template/class_BaseTemplateEngine.php @@ -8,6 +8,7 @@ use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException; use Org\Mxchange\CoreFramework\Generic\NullPointerException; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Manager\ManageableApplication; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; @@ -1209,7 +1210,7 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem { */ public function assignApplicationData () { // Get application instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Get long name and assign it $this->assignVariable('app_full_name' , $applicationInstance->getAppName()); diff --git a/framework/main/classes/template/console/class_ConsoleTemplateEngine.php b/framework/main/classes/template/console/class_ConsoleTemplateEngine.php index a718d80d..85d61d6d 100644 --- a/framework/main/classes/template/console/class_ConsoleTemplateEngine.php +++ b/framework/main/classes/template/console/class_ConsoleTemplateEngine.php @@ -5,6 +5,7 @@ namespace Org\Mxchange\CoreFramework\Template\Engine; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Filesystem\InvalidDirectoryException; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Template\CompileableTemplate; use Org\Mxchange\CoreFramework\Template\Engine\BaseTemplateEngine; @@ -61,7 +62,7 @@ class ConsoleTemplateEngine extends BaseTemplateEngine implements CompileableTem $templateInstance = new ConsoleTemplateEngine(); // Get the application instance from registry - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Determine base path $templateBasePath = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('application_base_path') . $applicationInstance->getAppShortName(). '/'; diff --git a/framework/main/classes/template/html/class_HtmlTemplateEngine.php b/framework/main/classes/template/html/class_HtmlTemplateEngine.php index 32513179..76dac48c 100644 --- a/framework/main/classes/template/html/class_HtmlTemplateEngine.php +++ b/framework/main/classes/template/html/class_HtmlTemplateEngine.php @@ -5,6 +5,7 @@ namespace Org\Mxchange\CoreFramework\Template\Engine; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Filesystem\InvalidDirectoryException; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Template\CompileableTemplate; use Org\Mxchange\CoreFramework\Template\Engine\BaseTemplateEngine; @@ -61,7 +62,7 @@ class HtmlTemplateEngine extends BaseTemplateEngine implements CompileableTempla $templateInstance = new HtmlTemplateEngine(); // Get the application instance from registry - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Determine base path $templateBasePath = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('application_base_path') . $applicationInstance->getAppShortName(). '/'; diff --git a/framework/main/classes/template/image/class_ImageTemplateEngine.php b/framework/main/classes/template/image/class_ImageTemplateEngine.php index d5efe92a..925c96bf 100644 --- a/framework/main/classes/template/image/class_ImageTemplateEngine.php +++ b/framework/main/classes/template/image/class_ImageTemplateEngine.php @@ -6,6 +6,7 @@ namespace Org\Mxchange\CoreFramework\Template\Engine; use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Filesystem\InvalidDirectoryException; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Image\BaseImage; use Org\Mxchange\CoreFramework\Parser\Parseable; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; @@ -105,7 +106,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl $templateInstance = new ImageTemplateEngine(); // Get the application instance from registry - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Determine base path $templateBasePath = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('application_base_path') . $applicationInstance->getAppShortName(). '/'; diff --git a/framework/main/classes/template/mail/class_MailTemplateEngine.php b/framework/main/classes/template/mail/class_MailTemplateEngine.php index 951093a0..338fd743 100644 --- a/framework/main/classes/template/mail/class_MailTemplateEngine.php +++ b/framework/main/classes/template/mail/class_MailTemplateEngine.php @@ -5,6 +5,7 @@ namespace Org\Mxchange\CoreFramework\Template\Engine; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Filesystem\InvalidDirectoryException; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Mailer\DeliverableMail; use Org\Mxchange\CoreFramework\Parser\Parseable; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; @@ -95,7 +96,7 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla $templateInstance = new MailTemplateEngine(); // Get the application instance from registry - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Determine base path $templateBasePath = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('application_base_path') . $applicationInstance->getAppShortName(). '/'; diff --git a/framework/main/classes/template/menu/class_MenuTemplateEngine.php b/framework/main/classes/template/menu/class_MenuTemplateEngine.php index 8d653dbd..ed9468ef 100644 --- a/framework/main/classes/template/menu/class_MenuTemplateEngine.php +++ b/framework/main/classes/template/menu/class_MenuTemplateEngine.php @@ -6,6 +6,7 @@ namespace Org\Mxchange\CoreFramework\Template\Engine; use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Filesystem\InvalidDirectoryException; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Menu\RenderableMenu; use Org\Mxchange\CoreFramework\Parser\Parseable; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; @@ -157,7 +158,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla $templateInstance = new MenuTemplateEngine(); // Get the application instance from registry - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Determine base path $templateBasePath = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('application_base_path') . $applicationInstance->getAppShortName(). '/'; @@ -391,7 +392,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla */ private function initMenu (string $templateDependency = '') { // Get web template engine - $this->setTemplateInstance(ObjectFactory::createObjectByConfiguredName('html_template_class', array(GenericRegistry::getRegistry()->getInstance('application')))); + $this->setTemplateInstance(ObjectFactory::createObjectByConfiguredName('html_template_class', array(ApplicationHelper::getSelfInstance()))); // Handle the dependency template $this->handleTemplateDependency('menu', $templateDependency); @@ -889,7 +890,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla */ public function getMenuCacheFile () { // Get the application instance from registry - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Get the file instance ready $fileInstance = new SplFileInfo(sprintf('%s%smenus/_cache/%s.%s', diff --git a/framework/main/classes/template/xml/class_BaseXmlTemplateEngine.php b/framework/main/classes/template/xml/class_BaseXmlTemplateEngine.php index 6789a562..253e0a8a 100644 --- a/framework/main/classes/template/xml/class_BaseXmlTemplateEngine.php +++ b/framework/main/classes/template/xml/class_BaseXmlTemplateEngine.php @@ -6,6 +6,7 @@ namespace Org\Mxchange\CoreFramework\Template\Engine\Xml; use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Factory\Template\XmlTemplateEngineFactory; +use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Template\CompileableTemplate; use Org\Mxchange\CoreFramework\Template\Engine\BaseTemplateEngine; @@ -115,7 +116,7 @@ abstract class BaseXmlTemplateEngine extends BaseTemplateEngine implements Compi $this->typePrefix = $typePrefix; // Get template instance - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Determine base path $templateBasePath = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('application_base_path') . FrameworkBootstrap::getRequestInstance()->getRequestElement('app') . '/'; diff --git a/framework/main/classes/user/class_BaseUser.php b/framework/main/classes/user/class_BaseUser.php index f5fb074e..c8e692f8 100644 --- a/framework/main/classes/user/class_BaseUser.php +++ b/framework/main/classes/user/class_BaseUser.php @@ -76,8 +76,8 @@ abstract class BaseUser extends BaseFrameworkSystem implements Updateable { * @param $userName The username to set * @return void */ - public final function setUserName ($userName) { - $this->userName = (string) $userName; + public final function setUserName (string $userName) { + $this->userName = $userName; } /** @@ -96,7 +96,7 @@ abstract class BaseUser extends BaseFrameworkSystem implements Updateable { * @return void * @todo Find a way of casting here. "(int)" might destroy the user id > 32766 */ - public final function setUserId ($userId) { + public final function setUserId (int $userId) { $this->userId = $userId; } @@ -115,8 +115,8 @@ abstract class BaseUser extends BaseFrameworkSystem implements Updateable { * @param $email The email to set * @return void */ - protected final function setEmail ($email) { - $this->email = (string) $email; + protected final function setEmail (string $email) { + $this->email = $email; } /** diff --git a/framework/main/classes/visitor/class_BaseVisitor.php b/framework/main/classes/visitor/class_BaseVisitor.php index 162fd537..f53ab802 100644 --- a/framework/main/classes/visitor/class_BaseVisitor.php +++ b/framework/main/classes/visitor/class_BaseVisitor.php @@ -50,8 +50,8 @@ abstract class BaseVisitor extends BaseFrameworkSystem { * @param $visitorMode New visitor mode to set * @return void */ - protected final function setVisitorMode ($visitorMode) { - $this->visitorMode = (string) $visitorMode; + protected final function setVisitorMode (string $visitorMode) { + $this->visitorMode = $visitorMode; } /** diff --git a/framework/main/interfaces/response/class_Responseable.php b/framework/main/interfaces/response/class_Responseable.php index 0a302497..f92b1401 100644 --- a/framework/main/interfaces/response/class_Responseable.php +++ b/framework/main/interfaces/response/class_Responseable.php @@ -34,7 +34,7 @@ interface Responseable extends FrameworkInterface { * @param $status New response status * @return void */ - function setResponseStatus ($status); + function setResponseStatus (string $status); /** * Adds a header to the response. This method "wraps" the direct header() @@ -47,7 +47,7 @@ interface Responseable extends FrameworkInterface { * @param $value Value of header element * @return void */ - function addHeader ($name, $value); + function addHeader (string $name, $value); /** * "Writes" data to the response body @@ -55,7 +55,7 @@ interface Responseable extends FrameworkInterface { * @param $output Output we shall sent in the HTTP response * @return void */ - function writeToBody ($output); + function writeToBody (string $output); /** * Flushs the cached HTTP response to the outer world @@ -66,7 +66,7 @@ interface Responseable extends FrameworkInterface { * @throws ResponseHeadersAlreadySentException Thrown if headers are * already sent */ - function flushBuffer ($force = false); + function flushBuffer (bool $force = false); /** * Adds a fatal message id to the response. The added messages can then be @@ -75,7 +75,7 @@ interface Responseable extends FrameworkInterface { * @param $messageId The message id we shall add * @return void */ - function addFatalMessage ($messageId); + function addFatalMessage (string $messageId); /** * Adds a cookie to the response @@ -98,7 +98,7 @@ interface Responseable extends FrameworkInterface { * @return void * @throws ResponseHeadersAlreadySentException If headers are already sent */ - function redirectToConfiguredUrl ($configEntry); + function redirectToConfiguredUrl (string $configEntry); /** * Expires the given cookie if it is set @@ -106,7 +106,7 @@ interface Responseable extends FrameworkInterface { * @param $cookieName Cookie to expire * @return void */ - function expireCookie ($cookieName); + function expireCookie (string $cookieName); /** * Refreshs a given cookie. This will make the cookie live longer @@ -114,6 +114,6 @@ interface Responseable extends FrameworkInterface { * @param $cookieName Cookie to refresh * @return void */ - function refreshCookie ($cookieName); + function refreshCookie (string $cookieName); } diff --git a/framework/main/third_party/api/wernisportal/class_WernisApi.php b/framework/main/third_party/api/wernisportal/class_WernisApi.php index aa251029..e8dd99d7 100644 --- a/framework/main/third_party/api/wernisportal/class_WernisApi.php +++ b/framework/main/third_party/api/wernisportal/class_WernisApi.php @@ -1,6 +1,6 @@ setCoonfigArray($cfg); + $apiInstance->setCoonfigArray($configArray); // Return the instance return $apiInstance; @@ -106,7 +109,7 @@ class WernisApi extends BaseFrameworkSystem { * @param $w_pwd Clear password of the gamer * @return void */ - public function setUser ($w_id, $w_pwd) { + public function setUser (int $w_id, string $w_pwd) { // Set username (id) $this->w_id = $w_id; @@ -118,10 +121,8 @@ class WernisApi extends BaseFrameworkSystem { * The following methods are not yet rewritten! * ************************************************/ - public function einziehen ($amount) { + public function einziehen (int $amount) { // amount auf Gueltigkeit pruefen - $amount = isset($amount) ? $amount+0 : 0; - if ($amount < $this->config['mineinsatz']) { $this->setStatusMessage('low_stakes', sprintf('Dein Einsatz muss mindestens %d Wernis betragen.', $this->config['mineinsatz'])); return false; @@ -131,10 +132,8 @@ class WernisApi extends BaseFrameworkSystem { return $this->executeWithdraw($amount); } - public function verschicken ($amount) { + public function verschicken (int $amount) { // amount auf Gueltigkeit pruefen - $amount = isset($amount) ? $amount+0 : 0; - if ($amount < $this->config['mineinsatz']) { $this->setStatusMessage('low_stakes', sprintf('Dein Einsatz muss mindestens %d Wernis betragen.', $this->config['mineinsatz'])); return false; @@ -159,7 +158,7 @@ class WernisApi extends BaseFrameworkSystem { } // Sets a status message and code - public function setStatusMessage ($msg, $status) { + public function setStatusMessage (string $msg, string $status) { $this->statusArray['message'] = $msg; $this->statusArray['status'] = $status; } @@ -187,7 +186,7 @@ class WernisApi extends BaseFrameworkSystem { } // Sends out a request to the API and returns it's result - private function sendRequest ($scriptName, array $requestData = array()) { + private function sendRequest (string $scriptName, array $requestData = []) { // Is the requestData an array? if (!is_array($requestData)) { // Then abort here! @@ -307,7 +306,7 @@ class WernisApi extends BaseFrameworkSystem { } // Widthdraw this amount - private function executeWithdraw ($amount) { + private function executeWithdraw (int $amount) { // First all fails... $result = false; @@ -340,7 +339,7 @@ class WernisApi extends BaseFrameworkSystem { } // Payout this amount - private function executePayout ($amount) { + private function executePayout (int $amount) { // First all fails... $result = false; @@ -373,7 +372,7 @@ class WernisApi extends BaseFrameworkSystem { } // Send raw GET request - private function sendRawRequest ($script) { + private function sendRawRequest (string $script) { // Use the hostname from script URL as new hostname $url = substr($script, 7); $extract = explode('/', $url); -- 2.39.2