]> git.mxchange.org Git - core.git/commitdiff
Continued: master
authorRoland Häder <roland@mxchange.org>
Fri, 22 Aug 2025 21:37:14 +0000 (23:37 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 22 Aug 2025 21:37:14 +0000 (23:37 +0200)
- more type-hints added
- sometimes set $this as an extra (RNG initializer) instance

framework/main/classes/commands/html/class_HtmlResendLinkCommand.php
framework/main/classes/crypto/class_CryptoHelper.php
framework/main/classes/helper/captcha/class_BaseCaptcha.php
framework/main/classes/rng/class_RandomNumberGenerator.php

index 4cf80330ecf78cf9a852393f25b5ad5ad0e2de34..2e75786aefb846f7f0acdf3d975bbe06668734e9 100644 (file)
@@ -81,7 +81,7 @@ class HtmlResendLinkCommand extends BaseCommand implements Commandable {
                $applicationInstance = ApplicationHelper::getSelfInstance();
 
                // Get a RNG instance (Random Number Generator)
-               $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
+               $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class', [$this]);
 
                // Generate a pseudo-random string
                $randomString = $rngInstance->randomString(255);
@@ -102,7 +102,7 @@ class HtmlResendLinkCommand extends BaseCommand implements Commandable {
                $this->getTemplateInstance()->assignApplicationData();
 
                // Get a mailer class
-               $mailerInstance = ObjectFactory::createObjectByConfiguredName('mailer_class', array($this->getTemplateInstance(), 'resend_link'));
+               $mailerInstance = ObjectFactory::createObjectByConfiguredName('mailer_class', [$this->getTemplateInstance(), 'resend_link']);
 
                // Set this mailer in our template engine
                $this->getTemplateInstance()->setMailerInstance($mailerInstance);
index 8d5b4a00c31e644fc04dd7b129f56a30fc2024cb..2f6f437f2b9b34662481447b43bc84c4a471eab1 100644 (file)
@@ -136,7 +136,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
         */
        protected function initHasher (): void {
                // Initialize the random number generator which is required by some crypto methods
-               $this->setRngInstance(ObjectFactory::createObjectByConfiguredName('rng_class'));
+               $this->setRngInstance(ObjectFactory::createObjectByConfiguredName('rng_class', [$this]));
 
                // Generate a salt for the hasher
                $this->generateSalt();
index 8fc62058ee4a6447d77f1340431434cdff7d7f79..6cac40b4645f332a456826b9bb05858130aad623 100644 (file)
@@ -57,7 +57,7 @@ abstract class BaseCaptcha extends BaseHelper implements Helper {
         */
        protected final function initializeRandomNumberGenerator (FrameworkInterface $extraInstance = NULL): void {
                // Get an RNG from factory
-               $this->setRngInstance(ObjectFactory::createObjectByConfiguredName('rng_class', array($extraInstance)));
+               $this->setRngInstance(ObjectFactory::createObjectByConfiguredName('rng_class', [$extraInstance]));
        }
 
 }
index 5031f705073a90509c66ea09045ca544155d0eda..f95c9abd6d98821f86de1b3a5cfa1e5d7f5fd195 100644 (file)
@@ -104,7 +104,7 @@ class RandomNumberGenerator extends BaseFrameworkSystem {
         * @return      void
         * @todo        Add site key for stronger salt!
         */
-       protected function initRng ($extraInstance) {
+       protected function initRng (FrameworkInterface $extraInstance = NULL): void {
                // Get the prime number from config
                $this->prime = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('math_prime');
 
@@ -155,7 +155,7 @@ class RandomNumberGenerator extends BaseFrameworkSystem {
         * @param       $length                 Length of the string, default: 128
         * @return      $randomString   The pseudo-random string
         */
-       public function randomString ($length = -1) {
+       public function randomString (int $length = 0): string {
                // Is the number <1, then fix it to default length
                if ($length < 1) {
                        $length = $this->rndStrLen;
@@ -182,7 +182,7 @@ class RandomNumberGenerator extends BaseFrameworkSystem {
         * @return      $num    Pseudo-random number
         * @todo        I had a better random number generator here but now it is somewhere lost :(
         */
-       public function randomNumber ($min, $max) {
+       public function randomNumber (int $min, int $max): int {
                return mt_rand($min, $max);
        }
 
@@ -191,7 +191,7 @@ class RandomNumberGenerator extends BaseFrameworkSystem {
         *
         * @return      $extraSalt
         */
-       public final function getExtraSalt () {
+       public final function getExtraSalt (): string {
                return $this->extraSalt;
        }
 
@@ -200,7 +200,7 @@ class RandomNumberGenerator extends BaseFrameworkSystem {
         *
         * @return      $fixedSalt
         */
-       public final function getFixedSalt () {
+       public final function getFixedSalt (): string {
                return $this->fixedSalt;
        }
 
@@ -209,7 +209,7 @@ class RandomNumberGenerator extends BaseFrameworkSystem {
         *
         * @return      $key    The generated key for encryption
         */
-       public function generateKey () {
+       public function generateKey (): string {
                // Default is extra salt
                $key = md5($this->getExtraSalt());