From: Roland Häder Date: Thu, 21 Aug 2025 18:32:13 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=72941c5377c1989e109e775a053c0c19403a6181;p=core.git Continued: - introduced trait `RandomNumberGeneratorTrait` - added more type-hints --- diff --git a/framework/bootstrap/class_FrameworkBootstrap.php b/framework/bootstrap/class_FrameworkBootstrap.php index 35169d4e..dfb76d58 100644 --- a/framework/bootstrap/class_FrameworkBootstrap.php +++ b/framework/bootstrap/class_FrameworkBootstrap.php @@ -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; } diff --git a/framework/config/class_FrameworkConfiguration.php b/framework/config/class_FrameworkConfiguration.php index 98dd71b9..4c1aec09 100644 --- a/framework/config/class_FrameworkConfiguration.php +++ b/framework/config/class_FrameworkConfiguration.php @@ -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()); } diff --git a/framework/main/classes/application/class_BaseApplication.php b/framework/main/classes/application/class_BaseApplication.php index bd3fbf12..21799d5a 100644 --- a/framework/main/classes/application/class_BaseApplication.php +++ b/framework/main/classes/application/class_BaseApplication.php @@ -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; } diff --git a/framework/main/classes/crypto/class_CryptoHelper.php b/framework/main/classes/crypto/class_CryptoHelper.php index e913a91b..f340b540 100644 --- a/framework/main/classes/crypto/class_CryptoHelper.php +++ b/framework/main/classes/crypto/class_CryptoHelper.php @@ -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 . */ 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; diff --git a/framework/main/classes/database/frontend/payments/class_PaymentsDatabaseFrontend.php b/framework/main/classes/database/frontend/payments/class_PaymentsDatabaseFrontend.php index cad152f6..3b644c16 100644 --- a/framework/main/classes/database/frontend/payments/class_PaymentsDatabaseFrontend.php +++ b/framework/main/classes/database/frontend/payments/class_PaymentsDatabaseFrontend.php @@ -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(); diff --git a/framework/main/classes/database/migration/format_upgrade/lfdb/class_LocalFileDatabaseFormatVersion01To02Upgrade.php b/framework/main/classes/database/migration/format_upgrade/lfdb/class_LocalFileDatabaseFormatVersion01To02Upgrade.php index 47680890..e0de036c 100644 --- a/framework/main/classes/database/migration/format_upgrade/lfdb/class_LocalFileDatabaseFormatVersion01To02Upgrade.php +++ b/framework/main/classes/database/migration/format_upgrade/lfdb/class_LocalFileDatabaseFormatVersion01To02Upgrade.php @@ -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(); diff --git a/framework/main/classes/helper/captcha/class_BaseCaptcha.php b/framework/main/classes/helper/captcha/class_BaseCaptcha.php index 56553c59..93b5c137 100644 --- a/framework/main/classes/helper/captcha/class_BaseCaptcha.php +++ b/framework/main/classes/helper/captcha/class_BaseCaptcha.php @@ -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) * diff --git a/framework/main/classes/lists/groups/class_ListGroupList.php b/framework/main/classes/lists/groups/class_ListGroupList.php index 8f3f6ac5..8587b889 100644 --- a/framework/main/classes/lists/groups/class_ListGroupList.php +++ b/framework/main/classes/lists/groups/class_ListGroupList.php @@ -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.'); } diff --git a/framework/main/classes/lists/tasks/class_TaskList.php b/framework/main/classes/lists/tasks/class_TaskList.php index 200cc39a..be75722e 100644 --- a/framework/main/classes/lists/tasks/class_TaskList.php +++ b/framework/main/classes/lists/tasks/class_TaskList.php @@ -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'); } diff --git a/framework/main/classes/streams/crypto/class_BaseCryptoStream.php b/framework/main/classes/streams/crypto/class_BaseCryptoStream.php index f1ffed0c..6d08b2fc 100644 --- a/framework/main/classes/streams/crypto/class_BaseCryptoStream.php +++ b/framework/main/classes/streams/crypto/class_BaseCryptoStream.php @@ -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 . */ 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; - } - } diff --git a/framework/main/classes/user/class_BaseUser.php b/framework/main/classes/user/class_BaseUser.php index 920127ed..506a3962 100644 --- a/framework/main/classes/user/class_BaseUser.php +++ b/framework/main/classes/user/class_BaseUser.php @@ -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')); diff --git a/framework/main/exceptions/class_FrameworkException.php b/framework/main/exceptions/class_FrameworkException.php index 7852a066..56eb3a8a 100644 --- a/framework/main/exceptions/class_FrameworkException.php +++ b/framework/main/exceptions/class_FrameworkException.php @@ -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; } diff --git a/framework/main/middleware/compressor/class_CompressorChannel.php b/framework/main/middleware/compressor/class_CompressorChannel.php index a78bb6e8..34b2ef9b 100644 --- a/framework/main/middleware/compressor/class_CompressorChannel.php +++ b/framework/main/middleware/compressor/class_CompressorChannel.php @@ -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(); } diff --git a/framework/main/middleware/io/class_FileIoHandler.php b/framework/main/middleware/io/class_FileIoHandler.php index f6c649d0..e5f3c90f 100644 --- a/framework/main/middleware/io/class_FileIoHandler.php +++ b/framework/main/middleware/io/class_FileIoHandler.php @@ -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; diff --git a/framework/main/traits/cache/class_CacheableTrait.php b/framework/main/traits/cache/class_CacheableTrait.php index deaa10f4..002e70a8 100644 --- a/framework/main/traits/cache/class_CacheableTrait.php +++ b/framework/main/traits/cache/class_CacheableTrait.php @@ -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; } diff --git a/framework/main/traits/compressor/class_CompressorChannelTrait.php b/framework/main/traits/compressor/class_CompressorChannelTrait.php index 1c336065..7743bedd 100644 --- a/framework/main/traits/compressor/class_CompressorChannelTrait.php +++ b/framework/main/traits/compressor/class_CompressorChannelTrait.php @@ -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; } diff --git a/framework/main/traits/criteria/class_LocalSearchCriteriaTrait.php b/framework/main/traits/criteria/class_LocalSearchCriteriaTrait.php index e50fe582..a5e63eb7 100644 --- a/framework/main/traits/criteria/class_LocalSearchCriteriaTrait.php +++ b/framework/main/traits/criteria/class_LocalSearchCriteriaTrait.php @@ -48,7 +48,7 @@ trait LocalSearchCriteriaTrait { * * @return $searchInstance Searchable criteria instance */ - public final function getSearchInstance () { + public final function getSearchInstance (): LocalSearchCriteria { return $this->searchInstance; } diff --git a/framework/main/traits/crypto/class_CryptoTrait.php b/framework/main/traits/crypto/class_CryptoTrait.php index 1fe82416..b78d361a 100644 --- a/framework/main/traits/crypto/class_CryptoTrait.php +++ b/framework/main/traits/crypto/class_CryptoTrait.php @@ -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 index 00000000..b411484a --- /dev/null +++ b/framework/main/traits/crypto/rng/class_RandomNumberGeneratorTrait.php @@ -0,0 +1,56 @@ + + * @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 . + */ +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; + } + +} diff --git a/framework/main/traits/database/frontend/class_DatabaseFrontendTrait.php b/framework/main/traits/database/frontend/class_DatabaseFrontendTrait.php index ad876fda..13bed6f7 100644 --- a/framework/main/traits/database/frontend/class_DatabaseFrontendTrait.php +++ b/framework/main/traits/database/frontend/class_DatabaseFrontendTrait.php @@ -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; } diff --git a/framework/main/traits/file/class_BinaryFileTrait.php b/framework/main/traits/file/class_BinaryFileTrait.php index b8087ae4..24a0c6db 100644 --- a/framework/main/traits/file/class_BinaryFileTrait.php +++ b/framework/main/traits/file/class_BinaryFileTrait.php @@ -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; } diff --git a/framework/main/traits/handler/class_HandleableTrait.php b/framework/main/traits/handler/class_HandleableTrait.php index 1d17043e..b4f80295 100644 --- a/framework/main/traits/handler/class_HandleableTrait.php +++ b/framework/main/traits/handler/class_HandleableTrait.php @@ -48,7 +48,7 @@ trait HandleableTrait { * * @return $handlerInstance A Handleable instance */ - public final function getHandlerInstance () { + public final function getHandlerInstance (): Handleable { return $this->handlerInstance; } diff --git a/framework/main/traits/handler/io/class_IoHandlerTrait.php b/framework/main/traits/handler/io/class_IoHandlerTrait.php index feda6340..1e53e5fa 100644 --- a/framework/main/traits/handler/io/class_IoHandlerTrait.php +++ b/framework/main/traits/handler/io/class_IoHandlerTrait.php @@ -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; } diff --git a/framework/main/traits/helper/class_HelperTrait.php b/framework/main/traits/helper/class_HelperTrait.php index f49ae223..b95179b7 100644 --- a/framework/main/traits/helper/class_HelperTrait.php +++ b/framework/main/traits/helper/class_HelperTrait.php @@ -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; } diff --git a/framework/main/traits/index/class_IndexableTrait.php b/framework/main/traits/index/class_IndexableTrait.php index 55f3fb29..41cc9d16 100644 --- a/framework/main/traits/index/class_IndexableTrait.php +++ b/framework/main/traits/index/class_IndexableTrait.php @@ -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; } diff --git a/framework/main/traits/iterator/class_IteratorTrait.php b/framework/main/traits/iterator/class_IteratorTrait.php index dadd9846..84295a9b 100644 --- a/framework/main/traits/iterator/class_IteratorTrait.php +++ b/framework/main/traits/iterator/class_IteratorTrait.php @@ -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; } diff --git a/framework/main/traits/list/class_ListableTrait.php b/framework/main/traits/list/class_ListableTrait.php index 1b74cb6d..6d008024 100644 --- a/framework/main/traits/list/class_ListableTrait.php +++ b/framework/main/traits/list/class_ListableTrait.php @@ -48,7 +48,7 @@ trait ListableTrait { * * @return $listInstance A list of Listable */ - protected final function getListInstance () { + protected final function getListInstance (): Listable { return $this->listInstance; } diff --git a/framework/main/traits/manager/account/class_ManageableAccountTrait.php b/framework/main/traits/manager/account/class_ManageableAccountTrait.php index 3348ef44..f175a248 100644 --- a/framework/main/traits/manager/account/class_ManageableAccountTrait.php +++ b/framework/main/traits/manager/account/class_ManageableAccountTrait.php @@ -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; } diff --git a/framework/main/traits/registry/class_RegisterTrait.php b/framework/main/traits/registry/class_RegisterTrait.php index 0471319d..b4ce82e9 100644 --- a/framework/main/traits/registry/class_RegisterTrait.php +++ b/framework/main/traits/registry/class_RegisterTrait.php @@ -48,7 +48,7 @@ trait RegisterTrait { * * @return $registryInstance The debug registry instance */ - protected final function getRegistryInstance () { + protected final function getRegistryInstance (): Register { return $this->registryInstance; } diff --git a/framework/main/traits/resolver/class_ResolverTrait.php b/framework/main/traits/resolver/class_ResolverTrait.php index b579f91f..09431627 100644 --- a/framework/main/traits/resolver/class_ResolverTrait.php +++ b/framework/main/traits/resolver/class_ResolverTrait.php @@ -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; } diff --git a/framework/main/traits/result/search/class_SearchableResultTrait.php b/framework/main/traits/result/search/class_SearchableResultTrait.php index 31cb13d6..0ad71b9e 100644 --- a/framework/main/traits/result/search/class_SearchableResultTrait.php +++ b/framework/main/traits/result/search/class_SearchableResultTrait.php @@ -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; } diff --git a/framework/main/traits/stacker/class_StackableTrait.php b/framework/main/traits/stacker/class_StackableTrait.php index 3d962e67..d17297f7 100644 --- a/framework/main/traits/stacker/class_StackableTrait.php +++ b/framework/main/traits/stacker/class_StackableTrait.php @@ -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; } diff --git a/framework/main/traits/state/class_StateableTrait.php b/framework/main/traits/state/class_StateableTrait.php index 79b67fdd..4f8bf4c8 100644 --- a/framework/main/traits/state/class_StateableTrait.php +++ b/framework/main/traits/state/class_StateableTrait.php @@ -48,7 +48,7 @@ trait StateableTrait { * * @return $stateInstance A Stateable instance */ - public final function getStateInstance () { + public final function getStateInstance (): Stateable { return $this->stateInstance; } diff --git a/framework/main/traits/stream/input/class_InputStreamTrait.php b/framework/main/traits/stream/input/class_InputStreamTrait.php index 27295149..715b81f8 100644 --- a/framework/main/traits/stream/input/class_InputStreamTrait.php +++ b/framework/main/traits/stream/input/class_InputStreamTrait.php @@ -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; } diff --git a/framework/main/traits/stream/output/class_OutputStreamTrait.php b/framework/main/traits/stream/output/class_OutputStreamTrait.php index bdabafac..fba2dea5 100644 --- a/framework/main/traits/stream/output/class_OutputStreamTrait.php +++ b/framework/main/traits/stream/output/class_OutputStreamTrait.php @@ -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; } diff --git a/framework/main/traits/streamer/file/input/class_FileInputStreamerTrait.php b/framework/main/traits/streamer/file/input/class_FileInputStreamerTrait.php index d08e884a..a90c863e 100644 --- a/framework/main/traits/streamer/file/input/class_FileInputStreamerTrait.php +++ b/framework/main/traits/streamer/file/input/class_FileInputStreamerTrait.php @@ -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; } diff --git a/framework/main/traits/streamer/file/output/class_FileOutputStreamerTrait.php b/framework/main/traits/streamer/file/output/class_FileOutputStreamerTrait.php index 8f8dd67f..ac58b7a9 100644 --- a/framework/main/traits/streamer/file/output/class_FileOutputStreamerTrait.php +++ b/framework/main/traits/streamer/file/output/class_FileOutputStreamerTrait.php @@ -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; } diff --git a/framework/main/traits/streamer/output/class_OutputStreamerTrait.php b/framework/main/traits/streamer/output/class_OutputStreamerTrait.php index 916dce52..f875e4fd 100644 --- a/framework/main/traits/streamer/output/class_OutputStreamerTrait.php +++ b/framework/main/traits/streamer/output/class_OutputStreamerTrait.php @@ -48,7 +48,7 @@ trait OutputStreamerTrait { * * @return $outputInstance The debug output instance */ - protected final function getOutputInstance () { + protected final function getOutputInstance (): OutputStreamer { return $this->outputInstance; } diff --git a/framework/main/traits/template/class_CompileableTemplateTrait.php b/framework/main/traits/template/class_CompileableTemplateTrait.php index ad1f2d52..7afeec83 100644 --- a/framework/main/traits/template/class_CompileableTemplateTrait.php +++ b/framework/main/traits/template/class_CompileableTemplateTrait.php @@ -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; } diff --git a/framework/main/traits/visitor/class_VisitorTrait.php b/framework/main/traits/visitor/class_VisitorTrait.php index ab5798b1..f38d5850 100644 --- a/framework/main/traits/visitor/class_VisitorTrait.php +++ b/framework/main/traits/visitor/class_VisitorTrait.php @@ -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; }