]> git.mxchange.org Git - core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Thu, 21 Aug 2025 18:32:13 +0000 (20:32 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 21 Aug 2025 18:36:55 +0000 (20:36 +0200)
- introduced trait `RandomNumberGeneratorTrait`
- added more type-hints

40 files changed:
framework/bootstrap/class_FrameworkBootstrap.php
framework/config/class_FrameworkConfiguration.php
framework/main/classes/application/class_BaseApplication.php
framework/main/classes/crypto/class_CryptoHelper.php
framework/main/classes/database/frontend/payments/class_PaymentsDatabaseFrontend.php
framework/main/classes/database/migration/format_upgrade/lfdb/class_LocalFileDatabaseFormatVersion01To02Upgrade.php
framework/main/classes/helper/captcha/class_BaseCaptcha.php
framework/main/classes/lists/groups/class_ListGroupList.php
framework/main/classes/lists/tasks/class_TaskList.php
framework/main/classes/streams/crypto/class_BaseCryptoStream.php
framework/main/classes/user/class_BaseUser.php
framework/main/exceptions/class_FrameworkException.php
framework/main/middleware/compressor/class_CompressorChannel.php
framework/main/middleware/io/class_FileIoHandler.php
framework/main/traits/cache/class_CacheableTrait.php
framework/main/traits/compressor/class_CompressorChannelTrait.php
framework/main/traits/criteria/class_LocalSearchCriteriaTrait.php
framework/main/traits/crypto/class_CryptoTrait.php
framework/main/traits/crypto/rng/class_RandomNumberGeneratorTrait.php [new file with mode: 0644]
framework/main/traits/database/frontend/class_DatabaseFrontendTrait.php
framework/main/traits/file/class_BinaryFileTrait.php
framework/main/traits/handler/class_HandleableTrait.php
framework/main/traits/handler/io/class_IoHandlerTrait.php
framework/main/traits/helper/class_HelperTrait.php
framework/main/traits/index/class_IndexableTrait.php
framework/main/traits/iterator/class_IteratorTrait.php
framework/main/traits/list/class_ListableTrait.php
framework/main/traits/manager/account/class_ManageableAccountTrait.php
framework/main/traits/registry/class_RegisterTrait.php
framework/main/traits/resolver/class_ResolverTrait.php
framework/main/traits/result/search/class_SearchableResultTrait.php
framework/main/traits/stacker/class_StackableTrait.php
framework/main/traits/state/class_StateableTrait.php
framework/main/traits/stream/input/class_InputStreamTrait.php
framework/main/traits/stream/output/class_OutputStreamTrait.php
framework/main/traits/streamer/file/input/class_FileInputStreamerTrait.php
framework/main/traits/streamer/file/output/class_FileOutputStreamerTrait.php
framework/main/traits/streamer/output/class_OutputStreamerTrait.php
framework/main/traits/template/class_CompileableTemplateTrait.php
framework/main/traits/visitor/class_VisitorTrait.php

index 35169d4edb78190cd835328eaf863eb2f5002a87..dfb76d583e4068a5ad87f6992f70c1fc2090eac9 100644 (file)
@@ -808,7 +808,7 @@ final class FrameworkBootstrap {
         *
         * @return      $databaseInstance       An instance of a DatabaseConnection class
         */
-       public static function getDatabaseInstance (): ?DatabaseConnection {
+       public static function getDatabaseInstance (): DatabaseConnection {
                // Return instance
                return self::$databaseInstance;
        }
index 98dd71b987dd6f63aa6d3cbed369b80da4332fb8..4c1aec09b7a9187db84e7f10a7f1d00baf21fe72 100644 (file)
@@ -73,7 +73,7 @@ class FrameworkConfiguration implements Registerable {
         *
         * @return      __CLASS__       This class' name
         */
-       public function __toString () {
+       public function __toString (): string {
                return get_class($this);
        }
 
@@ -164,7 +164,7 @@ class FrameworkConfiguration implements Registerable {
         *
         * @return      $config         Configuration array
         */
-       public final function getConfigurationArray () {
+       public final function getConfigurationArray (): array {
                // Return it
                //* NOISY-DEBUG: */ printf('[%s:%d]: self::configData()=%d - EXIT!' . PHP_EOL, __METHOD__, __LINE__, count(self::$configData));
                return self::$configData;
@@ -177,7 +177,7 @@ class FrameworkConfiguration implements Registerable {
         *
         * @return      void
         */
-       public final function sortConfigurationArray () {
+       public final function sortConfigurationArray (): void {
                // Resort the array
                //* NOISY-DEBUG: */ printf('[%s:%d]: Sorting %d records - CALLED!' . PHP_EOL, __METHOD__, __LINE__, count(self::$configData));
                ksort(self::$configData);
@@ -261,7 +261,7 @@ class FrameworkConfiguration implements Registerable {
         *
         * @return      $hashCode       The hash code respresenting this class
         */
-       public function hashCode () {
+       public function hashCode (): int {
                return crc32($this->__toString());
        }
 
index bd3fbf12f4286d083345ece389abaa5805cdfe8e..21799d5adf108570a2ae81f86169f380796ed100 100644 (file)
@@ -72,7 +72,7 @@ abstract class BaseApplication extends BaseFrameworkSystem {
         *
         * @return      $applicationInstance    An instance of a ManageableApplication class
         */
-       public static final function getApplicationInstance (): ?ManageableApplication {
+       public static final function getApplicationInstance (): ManageableApplication {
                return self::$applicationInstance;
        }
 
index e913a91bc05d2f89ee79418d449043a52d6f6a70..f340b540dc53829a571ba389a42f5f88fd4dcf28 100644 (file)
@@ -5,9 +5,9 @@ namespace Org\Mxchange\CoreFramework\Helper\Crypto;
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\Crypto\Cryptable;
-use Org\Mxchange\CoreFramework\Crypto\RandomNumber\RandomNumberGenerator;
 use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
+use Org\Mxchange\CoreFramework\Traits\Crypto\Rng\RandomNumberGeneratorTrait;
 
 /**
  * A helper class for cryptographical things like hashing passwords and so on
@@ -32,6 +32,9 @@ use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
+       // Load traits
+       use RandomNumberGeneratorTrait;
+
        // Exception constants
        const EXCEPTION_ENCRYPT_MISSING = 0x1f0;
        const EXCEPTION_ENCRYPT_INVALID = 0x1f1;
@@ -51,11 +54,6 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
         */
        private $salt = '';
 
-       /**
-        * Instance of a RNG
-        */
-       private $rngInstance = NULL;
-
        /**
         * Protected constructor
         *
@@ -71,7 +69,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
         *
         * @return      $cryptoInstance         An instance of this crypto helper class
         */
-       public static final function createCryptoHelper () {
+       public static final function createCryptoHelper (): Cryptable {
                // Get a new instance
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CRYPTO-HELPER: CALLED!');
                $cryptoInstance = new CryptoHelper();
@@ -94,7 +92,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
         *
         * @return      $selfInstance   An instance of this crypto helper class
         */
-       public static final function getSelfInstance () {
+       public static final function getSelfInstance (): Cryptable {
                // Is no instance there?
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CRYPTO-HELPER: self::selfInstance[]=%s - CALLED!', gettype(self::$selfInstance)));
                if (is_null(self::$selfInstance)) {
@@ -107,32 +105,13 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
                return self::$selfInstance;
        }
 
-       /**
-        * Setter for RNG instance
-        *
-        * @param       $rngInstance    An instance of a random number generator (RNG)
-        * @return      void
-        */
-       protected final function setRngInstance (RandomNumberGenerator $rngInstance) {
-               $this->rngInstance = $rngInstance;
-       }
-
-       /**
-        * Getter for RNG instance
-        *
-        * @return      $rngInstance    An instance of a random number generator (RNG)
-        */
-       public final function getRngInstance () {
-               return $this->rngInstance;
-       }
-
        /**
         * Attaches a crypto stream to this crypto helper by detecting loaded
         * modules.
         *
         * @return      void
         */
-       protected function attachCryptoStream () {
+       protected function attachCryptoStream (): void {
                // @TODO Maybe rewrite this with DirectoryIterator, similar to Compressor thing?
                // Do we have openssl loaded?
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CRYPTO-HELPER: CALLED!');
@@ -155,7 +134,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
         *
         * @return      void
         */
-       protected function initHasher () {
+       protected function initHasher (): void {
                // Initialize the random number generator which is required by some crypto methods
                $this->setRngInstance(ObjectFactory::createObjectByConfiguredName('rng_class'));
 
@@ -168,7 +147,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
         *
         * @return      void
         */
-       private function generateSalt () {
+       private function generateSalt (): void {
                // Get a random string from the RNG
                $randomString = $this->getRngInstance()->randomString() . $this->createUuid();
 
@@ -185,7 +164,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
         *
         * @return      $uuid   UUID with leading dash or empty string
         */
-       public function createUuid () {
+       public function createUuid (): string {
                // Init empty UUID
                $uuid = '';
 
@@ -210,7 +189,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
         * @param       $withFixed      Whether to include a fixed salt (not recommended in p2p applications)
         * @return      $hashed         The hashed and salted string
         */
-       public function hashString (string $str, string $oldHash = '', bool $withFixed = true) {
+       public function hashString (string $str, string $oldHash = '', bool $withFixed = true): string {
                // Default is the default salt ;-)
                $salt = $this->salt;
 
index cad152f658d88f6cae5c5977c75a50333bd8ac33..3b644c16d4da3e47cc4075ae33feef39c1ad6dca 100644 (file)
@@ -51,7 +51,7 @@ class PaymentsDatabaseFrontend extends BaseDatabaseFrontend implements Registera
         *
         * @return      $frontendInstance       An instance of the created frontend class
         */
-       public static final function createPaymentsDatabaseFrontend () {
+       public static final function createPaymentsDatabaseFrontend (): BaseDatabaseFrontend {
                // Get a new instance
                $frontendInstance = new PaymentsDatabaseFrontend();
 
index 476808907d369b171e7d63250052ca7311e36ad4..e0de036cf52647f1a911c9c48e547ef0957742f4 100644 (file)
@@ -44,7 +44,7 @@ class LocalFileDatabaseFormatVersion01To02Upgrade extends BaseFormatUpgrade impl
         *
         * @return      $upgradeInstance        An instance of this UpgradeableDatabaseFormat class
         */
-       public final static function createLocalFileDatabaseFormatVersion01To02Upgrade () {
+       public final static function createLocalFileDatabaseFormatVersion01To02Upgrade (): UpgradeableDatabaseFormat {
                // Get a new instance
                $upgradeInstance = new LocalFileDatabaseFormatVersion01To02Upgrade();
 
index 56553c59f1f17a08d3be896b4354082a24886b53..93b5c13719c6b19e88d6e7aceaacf5e36fc0de62 100644 (file)
@@ -8,6 +8,7 @@ use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
 use Org\Mxchange\CoreFramework\Helper\BaseHelper;
 use Org\Mxchange\CoreFramework\Helper\Helper;
+use Org\Mxchange\CoreFramework\Traits\Crypto\Rng\RandomNumberGeneratorTrait;
 use Org\Mxchange\CoreFramework\Traits\Helper\HelperTrait;
 
 /**
@@ -35,11 +36,7 @@ use Org\Mxchange\CoreFramework\Traits\Helper\HelperTrait;
 abstract class BaseCaptcha extends BaseHelper implements Helper {
        // Load traits
        use HelperTrait;
-
-       /**
-        * Instance of a RNG
-        */
-       private $rngInstance = NULL;
+       use RandomNumberGeneratorTrait;
 
        /**
         * Protected constructor
@@ -52,25 +49,6 @@ abstract class BaseCaptcha extends BaseHelper implements Helper {
                parent::__construct($className);
        }
 
-       /**
-        * Setter for RNG instance
-        *
-        * @param       $rngInstance    An instance of a random number generator (RNG)
-        * @return      void
-        */
-       protected final function setRngInstance (RandomNumberGenerator $rngInstance) {
-               $this->rngInstance = $rngInstance;
-       }
-
-       /**
-        * Getter for RNG instance
-        *
-        * @return      $rngInstance    An instance of a random number generator (RNG)
-        */
-       public final function getRngInstance () {
-               return $this->rngInstance;
-       }
-
        /**
         * Initializes the random number generator (RNG)
         *
index 8f3f6ac5a765faa53d4fa4d8ac55c62e75366ce7..8587b88962a677b068826882566de8d5f7e37698 100644 (file)
@@ -45,7 +45,7 @@ class ListGroupList extends BaseList implements Listable {
         *
         * @return      $listInstance   An instance a Listable class
         */
-       public static final function createListGroupList () {
+       public static final function createListGroupList (): Listable {
                // Get new instance
                $listInstance = new ListGroupList();
 
@@ -68,7 +68,7 @@ class ListGroupList extends BaseList implements Listable {
         * @return      void
         * @todo        0% done
         */
-       public function clearList () {
+       public function clearList (): void {
                DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.');
        }
 
index 200cc39ac5398a9110a2637ed6d2c1491c0a14b2..be75722e73dc09d0ceb27650e7b07399a3b12738 100644 (file)
@@ -44,7 +44,7 @@ class TaskList extends BaseList implements Listable {
         *
         * @return      $listInstance           An instance a Listable class
         */
-       public static final function createTaskList () {
+       public static final function createTaskList (): Listable {
                // Get new instance
                $listInstance = new TaskList();
 
@@ -69,7 +69,7 @@ class TaskList extends BaseList implements Listable {
         *
         * @return      void
         */
-       public function clearList () {
+       public function clearList (): void {
                // Clear the only one group
                $this->clearGroup('tasks');
        }
index f1ffed0c642d632aa81df15a9263b115a60220fe..6d08b2fc4797bac213d4228fec7ef8c487670d51 100644 (file)
@@ -3,8 +3,8 @@
 namespace Org\Mxchange\CoreFramework\Stream\Crypto;
 
 // Import framework stuff
-use Org\Mxchange\CoreFramework\Crypto\RandomNumber\RandomNumberGenerator;
 use Org\Mxchange\CoreFramework\Stream\BaseStream;
+use Org\Mxchange\CoreFramework\Traits\Crypto\Rng\RandomNumberGeneratorTrait;
 
 /**
  * A general crypto stream class
@@ -29,10 +29,8 @@ use Org\Mxchange\CoreFramework\Stream\BaseStream;
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 abstract class BaseCryptoStream extends BaseStream {
-       /**
-        * Instance of a RNG
-        */
-       private $rngInstance = NULL;
+       // Load traits
+       use RandomNumberGeneratorTrait;
 
        /**
         * Protected constructor
@@ -45,23 +43,4 @@ abstract class BaseCryptoStream extends BaseStream {
                parent::__construct($className);
        }
 
-       /**
-        * Setter for RNG instance
-        *
-        * @param       $rngInstance    An instance of a random number generator (RNG)
-        * @return      void
-        */
-       protected final function setRngInstance (RandomNumberGenerator $rngInstance) {
-               $this->rngInstance = $rngInstance;
-       }
-
-       /**
-        * Getter for RNG instance
-        *
-        * @return      $rngInstance    An instance of a random number generator (RNG)
-        */
-       protected final function getRngInstance () {
-               return $this->rngInstance;
-       }
-
 }
index 920127ed6cacf5c6767ede07182e12e0bf1fc48c..506a396209a9870c1c8abace72ac723b70cf13f8 100644 (file)
@@ -76,7 +76,7 @@ abstract class BaseUser extends BaseFrameworkSystem implements Updateable {
         * @param       $userName       The username to set
         * @return      void
         */
-       public final function setUserName (string $userName) {
+       public final function setUserName (string $userName): void {
                $this->userName = $userName;
        }
 
@@ -85,7 +85,7 @@ abstract class BaseUser extends BaseFrameworkSystem implements Updateable {
         *
         * @return      $userName       The username to get
         */
-       public final function getUserName () {
+       public final function getUserName (): string {
                return $this->userName;
        }
 
@@ -105,7 +105,7 @@ abstract class BaseUser extends BaseFrameworkSystem implements Updateable {
         *
         * @return      $userId The user id to get
         */
-       public final function getUserId () {
+       public final function getUserId (): int {
                return $this->userId;
        }
 
@@ -124,7 +124,7 @@ abstract class BaseUser extends BaseFrameworkSystem implements Updateable {
         *
         * @return      $email  The email to get
         */
-       public final function getEmail () {
+       public final function getEmail (): string {
                return $this->email;
        }
 
@@ -133,7 +133,7 @@ abstract class BaseUser extends BaseFrameworkSystem implements Updateable {
         *
         * @return      $exists         Whether the username exists
         */
-       public function ifUsernameExists () {
+       public function ifUsernameExists (): bool {
                // By default the username does not exist
                $exists = false;
 
@@ -177,7 +177,7 @@ abstract class BaseUser extends BaseFrameworkSystem implements Updateable {
         *
         * @return      $exists         Whether the email exists
         */
-       public function ifEmailAddressExists () {
+       public function ifEmailAddressExists (): bool {
                // By default the email does not exist
                $exists = false;
 
@@ -232,7 +232,7 @@ abstract class BaseUser extends BaseFrameworkSystem implements Updateable {
         * @param       $requestInstance        A Requestable class instance
         * @return      $matches                        Whether the supplied password hash matches
         */
-       public function ifPasswordHashMatches (Requestable $requestInstance) {
+       public function ifPasswordHashMatches (Requestable $requestInstance): bool {
                // By default nothing matches... ;)
                $matches = false;
 
@@ -280,7 +280,7 @@ abstract class BaseUser extends BaseFrameworkSystem implements Updateable {
         *
         * @return      $passHash       User's password hash from database result
         */
-       public final function getPasswordHash () {
+       public final function getPasswordHash (): string {
                // Default is missing password hash
                $passHash = NULL;
 
@@ -302,7 +302,7 @@ abstract class BaseUser extends BaseFrameworkSystem implements Updateable {
         *
         * @return      $primaryValue   Value of the primary key based on database type
         */
-       public final function getPrimaryKey () {
+       public final function getPrimaryKey (): mixed {
                // Get a user database frontend
                $frontendInstance = ObjectFactory::createObjectByConfiguredName('user_db_frontend_class');
 
@@ -324,7 +324,7 @@ abstract class BaseUser extends BaseFrameworkSystem implements Updateable {
         * @return      void
         * @todo        Try to make this method more generic so we can move it in BaseFrameworkSystem
         */
-       public function updateDatabaseField (string $fieldName, $fieldValue) {
+       public function updateDatabaseField (string $fieldName, mixed $fieldValue): void {
                // Get a critieria instance
                $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
 
@@ -353,7 +353,7 @@ abstract class BaseUser extends BaseFrameworkSystem implements Updateable {
         *
         * @return      $isConfirmed    Whether the user status is 'confirmed'
         */
-       public function isConfirmed () {
+       public function isConfirmed (): bool {
                // Determine it
                $isConfirmed = ($this->getField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS) == FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_confirmed'));
 
@@ -366,7 +366,7 @@ abstract class BaseUser extends BaseFrameworkSystem implements Updateable {
         *
         * @return      $isGuest        Whether the user status is 'guest'
         */
-       public function isGuest () {
+       public function isGuest (): bool {
                // Determine it
                $isGuest = ($this->getField(UserDatabaseFrontend::DB_COLUMN_USER_STATUS) == FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_status_guest'));
 
index 7852a066079ed3a33771f38d8a6a8fac7535b8c7..56eb3a8aa5db5555e0fb8ecd0a85b5871c6908d3 100644 (file)
@@ -85,7 +85,7 @@ abstract class FrameworkException extends ReflectionException {
         *
         * @return      void
         */
-       private function saveBackTrace () {
+       private function saveBackTrace (): void {
                // Get full backtrace
                $this->backTrace = debug_backtrace();
 
@@ -101,7 +101,7 @@ abstract class FrameworkException extends ReflectionException {
         *
         * @return      $backTrace      The full backtrace in an array
         */
-       public final function getBackTrace () {
+       public final function getBackTrace (): array {
                return $this->backTrace;
        }
 
@@ -110,7 +110,7 @@ abstract class FrameworkException extends ReflectionException {
         *
         * @return      $backTrace      Backtrace for web pages
         */
-       public final function getPrintableBackTrace () {
+       public final function getPrintableBackTrace (): string {
                // Get the backtrace
                $dbgTrace = $this->getBackTrace();
 
@@ -166,7 +166,7 @@ abstract class FrameworkException extends ReflectionException {
         *
         * @return      $toString               The name of the thrown exception
         */
-       public function __toString() {
+       public function __toString(): string {
                return get_class($this);
        }
 
@@ -205,7 +205,7 @@ abstract class FrameworkException extends ReflectionException {
         *
         * @return      $extraData      Extra data to store
         */
-       public final function getExtraData () {
+       public final function getExtraData (): string {
                return $this->extraData;
        }
 
index a78bb6e82786d2d662e4e4db8d78da9cf14b6823..34b2ef9bcfb158c84237a5e14ac223be95f31d6f 100644 (file)
@@ -52,7 +52,7 @@ class CompressorChannel extends BaseMiddleware implements Registerable {
         *
         * @return      $compressorInstance             A prepared instance of this class
         */
-       public static final function createCompressorChannel () {
+       public static final function createCompressorChannel (): CompressorChannel {
                // Get new instance
                $compressorInstance = new CompressorChannel();
 
@@ -130,7 +130,7 @@ class CompressorChannel extends BaseMiddleware implements Registerable {
         *
         * @return      $compressor     The compressor instance
         */
-       public final function getCompressor () {
+       public final function getCompressor (): Compressor {
                return $this->compressor;
        }
 
@@ -140,14 +140,14 @@ class CompressorChannel extends BaseMiddleware implements Registerable {
         * @param               $compressorInstance     The compressor instance we shall use
         * @return      void
         */
-       public final function setCompressor (Compressor $compressorInstance = NULL) {
+       public final function setCompressor (Compressor $compressorInstance = NULL): void {
                $this->compressor = $compressorInstance;
        }
 
        /**
         * Getter for the file extension of the current compressor
         */
-       public final function getCompressorExtension () {
+       public final function getCompressorExtension (): string {
                // Get compressor extension from current compressor
                return $this->getCompressor()->getCompressorExtension();
        }
index f6c649d0da9eda2a470d3ca4443fe14812739094..e5f3c90f7bdcce33a62248f49a79f954a6ae1734 100644 (file)
@@ -72,7 +72,7 @@ class FileIoHandler extends BaseMiddleware implements IoHandler {
         *
         * @return      $ioHandlerInstance      A prepared instance of FilIoHandler
         */
-       public static final function createFileIoHandler () {
+       public static final function createFileIoHandler (): IoHandler {
                // Get instance
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('FILE-IO-HANDLER: CALLED!');
                $ioHandlerInstance = new FileIoHandler();
@@ -91,7 +91,7 @@ class FileIoHandler extends BaseMiddleware implements IoHandler {
         *
         * @return      $selfInstance   An instance of this class
         */
-       public static final function getSelfInstance () {
+       public static final function getSelfInstance (): IoHandler {
                // Trace message
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('FILE-IO-HANDLER: Returning self::selfInstance[]=%s - EXIT!', gettype(self::$selfInstance)));
                return self::$selfInstance;
index deaa10f4e932e156224399001dd1f2b39a09ffa7..002e70a86ece426954f58cc4ff09677db7cad1e4 100644 (file)
@@ -48,7 +48,7 @@ trait CacheableTrait {
         *
         * @return      $cacheInstance  Name of table name to set
         */
-       protected final function getCacheInstance () {
+       protected final function getCacheInstance (): Cacheable {
                return $this->cacheInstance;
        }
 
index 1c33606564e59741432f19b3c576e382f647ddc1..7743bedddbe854f8fa64195b0815948957c43fd0 100644 (file)
@@ -48,7 +48,7 @@ trait CompressorChannelTrait {
         *
         * @return      $compressorChannelInstance      An instance of a CompressorChannel class
         */
-       protected final function getCompressorChannelInstance () {
+       protected final function getCompressorChannelInstance (): CompressorChannel {
                return $this->compressorChannelInstance;
        }
 
index e50fe582ccbeaa0a77bff24442a346ec6e1d7f04..a5e63eb7eb5f883696827427182f989eb36f1862 100644 (file)
@@ -48,7 +48,7 @@ trait LocalSearchCriteriaTrait {
         *
         * @return      $searchInstance         Searchable criteria instance
         */
-       public final function getSearchInstance () {
+       public final function getSearchInstance (): LocalSearchCriteria {
                return $this->searchInstance;
        }
 
index 1fe82416bda87ef2bb0657dfa36bfc1eeac63e10..b78d361a6ded621c9e3117ac9821ec44e745fd46 100644 (file)
@@ -48,7 +48,7 @@ trait CryptoTrait {
         *
         * @return      $cryptoInstance An instance of a Cryptable class
         */
-       public final function getCryptoInstance () {
+       public final function getCryptoInstance (): Cryptable {
                return $this->cryptoInstance;
        }
 
diff --git a/framework/main/traits/crypto/rng/class_RandomNumberGeneratorTrait.php b/framework/main/traits/crypto/rng/class_RandomNumberGeneratorTrait.php
new file mode 100644 (file)
index 0000000..b411484
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Traits\Crypto\Rng;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Crypto\RandomNumber\RandomNumberGenerator;
+
+/**
+ * A general captcha
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+trait RandomNumberGeneratorTrait {
+
+       /**
+        * Instance of a RNG
+        */
+       private $rngInstance = NULL;
+
+       /**
+        * Setter for RNG instance
+        *
+        * @param       $rngInstance    An instance of a random number generator (RNG)
+        * @return      void
+        */
+       protected final function setRngInstance (RandomNumberGenerator $rngInstance) {
+               $this->rngInstance = $rngInstance;
+       }
+
+       /**
+        * Getter for RNG instance
+        *
+        * @return      $rngInstance    An instance of a random number generator (RNG)
+        */
+       public final function getRngInstance () {
+               return $this->rngInstance;
+       }
+
+}
index ad876fdaee686ae2d57a070aa4df8a49ede08ec0..13bed6f75af01f663c6fa1dd659ddf9ad98c21a3 100644 (file)
@@ -48,7 +48,7 @@ trait DatabaseFrontendTrait {
         *
         * @return      $frontendInstance       An instance of a DatabaseFrontend class
         */
-       public final function getFrontendInstance () {
+       public final function getFrontendInstance (): DatabaseFrontend {
                return $this->frontendInstance;
        }
 
index b8087ae47c6a976656132e0fb3fb473a1b5229c0..24a0c6db773437902281234aa4089a27b80d89b3 100644 (file)
@@ -48,7 +48,7 @@ trait BinaryFileTrait {
         *
         * @return      $binaryFileInstance     An instance of an BinaryFile class
         */
-       public final function getBinaryFileInstance () {
+       public final function getBinaryFileInstance (): BinaryFile {
                return $this->binaryFileInstance;
        }
 
index 1d17043ee176c35000f148c6946d44c346a7ffa6..b4f8029543559494ecc3f6e8c3b12a4f250ef4ea 100644 (file)
@@ -48,7 +48,7 @@ trait HandleableTrait {
         *
         * @return      $handlerInstance        A Handleable instance
         */
-       public final function getHandlerInstance () {
+       public final function getHandlerInstance (): Handleable {
                return $this->handlerInstance;
        }
 
index feda63405f4b130353828ae9ae3797c9324b952f..1e53e5fa928b713bbf560d83fa71528670bb4ef4 100644 (file)
@@ -38,7 +38,7 @@ trait IoHandlerTrait {
         *
         * @return      $fileIoInstance         An instance to the file I/O sub-system
         */
-       protected final function getFileIoInstance () {
+       protected final function getFileIoInstance (): IoHandler {
                return $this->fileIoInstance;
        }
 
index f49ae2231dc8c338778a8dde6418dd5b75fa2b8f..b95179b7f21614daad2126e22dbc6e901d9a5706 100644 (file)
@@ -48,7 +48,7 @@ trait HelperTrait {
         *
         * @return      $helperInstance         An instance of a helper class
         */
-       public final function getHelperInstance () {
+       public final function getHelperInstance (): Helper {
                return $this->helperInstance;
        }
 
index 55f3fb29f1a7a53f5785d7030ed82c7f84245f3a..41cc9d16e6789fd39fa7563507b9889fb9c6dfde 100644 (file)
@@ -48,7 +48,7 @@ trait IndexableTrait {
         *
         * @return      $indexInstance  An instance of an Indexable class
         */
-       public final function getIndexInstance () {
+       public final function getIndexInstance (): Indexable {
                return $this->indexInstance;
        }
 
index dadd98464310e074682bedd6e8e05a8da96d80a8..84295a9bb28ab0ba9536531674488302452f8588 100644 (file)
@@ -48,7 +48,7 @@ trait IteratorTrait {
         *
         * @return      $iteratorInstance       An instance of an Iterator
         */
-       public final function getIteratorInstance () {
+       public final function getIteratorInstance (): Iterator {
                return $this->iteratorInstance;
        }
 
index 1b74cb6de1672bf6e3afb97782116e5b17eacdc6..6d00802402cec064f0d5c98589b0bd63d32bb939 100644 (file)
@@ -48,7 +48,7 @@ trait ListableTrait {
         *
         * @return      $listInstance   A list of Listable
         */
-       protected final function getListInstance () {
+       protected final function getListInstance (): Listable {
                return $this->listInstance;
        }
 
index 3348ef44646ad95a4590554d62241c49c74dd05e..f175a248f2dafd1d4198b4249cbeaaa1077ad511 100644 (file)
@@ -49,7 +49,7 @@ trait ManageableAccountTrait {
         *
         * @return      $userInstance   An instance of a user class
         */
-       public final function getUserInstance () {
+       public final function getUserInstance (): ManageableAccount {
                return $this->userInstance;
        }
 
index 0471319da9214ec2261a11aada640abc9315b24a..b4ce82e9aee83838f0ce04da7896452fe2afbb1a 100644 (file)
@@ -48,7 +48,7 @@ trait RegisterTrait {
         *
         * @return      $registryInstance       The debug registry instance
         */
-       protected final function getRegistryInstance () {
+       protected final function getRegistryInstance (): Register {
                return $this->registryInstance;
        }
 
index b579f91fac1abe9afc0d64576492ab036c43d77c..094316271fd4ba1a4167559d13d12d16a084f46e 100644 (file)
@@ -48,7 +48,7 @@ trait ResolverTrait {
         *
         * @return      $resolverInstance       Instance of a command resolver class
         */
-       protected final function getResolverInstance () {
+       protected final function getResolverInstance (): Resolver {
                return $this->resolverInstance;
        }
 
index 31cb13d69ce13e4faba3f34d9d16745d9c54d513..0ad71b9ec8d88b9b34ac37268fdb5e0bb7f1a50b 100644 (file)
@@ -49,7 +49,7 @@ trait SearchableResultTrait {
         *
         * @return      $resultInstance         An instance of a database result class
         */
-       public final function getResultInstance () {
+       public final function getResultInstance (): SearchableResult {
                return $this->resultInstance;
        }
 
index 3d962e670d957dda582def9eb2a341b471f82b57..d17297f7a16d31d048e14a2c852ea31b00125f01 100644 (file)
@@ -48,7 +48,7 @@ trait StackableTrait {
         *
         * @return      $stackInstance  An instance of an stacker
         */
-       public final function getStackInstance () {
+       public final function getStackInstance (): Stackable {
                return $this->stackInstance;
        }
 
index 79b67fddcfa5fafbc2fa21d547ad131643d85c51..4f8bf4c8846548448dcbf857043488bcaa145eb1 100644 (file)
@@ -48,7 +48,7 @@ trait StateableTrait {
         *
         * @return      $stateInstance  A Stateable instance
         */
-       public final function getStateInstance () {
+       public final function getStateInstance (): Stateable {
                return $this->stateInstance;
        }
 
index 27295149b7fe598d5fe5967666dc085f61e331c5..715b81f88d14b37e14c72b675c70f010c4447f5f 100644 (file)
@@ -38,7 +38,7 @@ trait InputStreamTrait {
         *
         * @param       $inputStreamInstance    An instance of an InputStream class
         */
-       protected final function getInputStreamInstance () {
+       protected final function getInputStreamInstance (): InputStream {
                return $this->inputStreamInstance;
        }
 
index bdabafacd7cfdb82b521d2d660c5ee28a1d1b242..fba2dea5a74d66672b558f5d184820f3f369de45 100644 (file)
@@ -38,7 +38,7 @@ trait OutputStreamTrait {
         *
         * @param       $outputStreamInstance   An instance of an OutputStream class
         */
-       protected final function getOutputStreamInstance () {
+       protected final function getOutputStreamInstance (): OutputStream {
                return $this->outputStreamInstance;
        }
 
index d08e884af78a82580ad82273df0167afc9894f23..a90c863e1c6802f99bf96a329660ab37ac837f72 100644 (file)
@@ -48,7 +48,7 @@ trait FileInputStreamerTrait {
         *
         * @return      $inputStreamerInstance  The *real* file-input class
         */
-       public final function getInputStreamerInstance () {
+       public final function getInputStreamerInstance (): FileInputStreamer {
                return $this->inputStreamerInstance;
        }
 
index 8f8dd67fcc0646198ccb62bd1d6d543be3cdd098..ac58b7a9d190ca30abeb2903db5ba3e6257277fb 100644 (file)
@@ -48,7 +48,7 @@ trait FileOutputStreamerTrait {
         *
         * @return      $outputStreamerInstance The *real* file-output class
         */
-       public final function getOutputStreamerInstance () {
+       public final function getOutputStreamerInstance (): FileOutputStreamer {
                return $this->outputStreamerInstance;
        }
 
index 916dce52d0e3aa79d2abc70319fcc067594dca05..f875e4fd7215456200fdc8f019d3452cc0ba3bf8 100644 (file)
@@ -48,7 +48,7 @@ trait OutputStreamerTrait {
         *
         * @return      $outputInstance The debug output instance
         */
-       protected final function getOutputInstance () {
+       protected final function getOutputInstance (): OutputStreamer {
                return $this->outputInstance;
        }
 
index ad1f2d521d2a2c19088719e61864544d1164634d..7afeec83de0e8bf117d26d4a451e52fb40dcce89 100644 (file)
@@ -48,7 +48,7 @@ trait CompileableTemplateTrait {
         *
         * @return      $templateInstance       An instance of a CompileableTemplate class
         */
-       public final function getTemplateInstance () {
+       public final function getTemplateInstance (): CompileableTemplate {
                return $this->templateInstance;
        }
 
index ab5798b11a1339d904b19caa0d26544eff9f8d40..f38d58503f9ca79230eebfbedd791e2ea858fa2e 100644 (file)
@@ -48,7 +48,7 @@ trait VisitorTrait {
         *
         * @return      $visitorInstance        An instance of a Visitor class
         */
-       protected final function getVisitorInstance () {
+       protected final function getVisitorInstance (): Visitor {
                return $this->visitorInstance;
        }