From: Roland Häder Date: Sat, 1 Feb 2025 22:40:59 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f553503c6f872be408b6e392112301b69d587336;p=hub.git Continued: - added more returned scalar types - updated 'core' framework --- diff --git a/application/hub/classes/dht/class_ b/application/hub/classes/dht/class_ index cbb5a5f19..bf011e816 100644 --- a/application/hub/classes/dht/class_ +++ b/application/hub/classes/dht/class_ @@ -47,7 +47,7 @@ class ???DhtFacade extends BaseDht implements Distributable { * * @return $dhtInstance An instance of a Distributable class */ - public final static function create??? () { + public final static function create??? (): Distributable { // Get new instance $dhtInstance = new ???DhtFacade(); @@ -64,7 +64,8 @@ class ???DhtFacade extends BaseDht implements Distributable { * @return void * @todo 0% done */ - protected function insertDataIntoDht (array $dhtData) { + protected function insertDataIntoDht (array $dhtData): void { DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.'); } + } diff --git a/application/hub/classes/dht/class_BaseDht.php b/application/hub/classes/dht/class_BaseDht.php index 2ea555305..16bd47190 100644 --- a/application/hub/classes/dht/class_BaseDht.php +++ b/application/hub/classes/dht/class_BaseDht.php @@ -87,7 +87,7 @@ abstract class BaseDht extends BaseHubSystem implements Distributable { * * @return void */ - private function initStacks () { + private function initStacks (): void { // Initialize all stacker $this->getStackInstance()->initStacks([ self::STACKER_NAME_INSERT_NODE, @@ -103,7 +103,7 @@ abstract class BaseDht extends BaseHubSystem implements Distributable { * @param $dhtData A valid array with DHT-related data (e.g. node/peer data) * @return void */ - protected abstract function insertDataIntoDht (array $dhtData); + protected abstract function insertDataIntoDht (array $dhtData): void; /** * Updates/refreshes DHT data (e.g. status). @@ -111,7 +111,7 @@ abstract class BaseDht extends BaseHubSystem implements Distributable { * @return void * @todo Find more to do here */ - public function updateDhtData () { + public function updateDhtData (): void { // Set some dummy configuration entries, e.g. dht_status FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('dht_status', $this->getStateInstance()->getStateName()); } @@ -121,7 +121,7 @@ abstract class BaseDht extends BaseHubSystem implements Distributable { * * @return $isPending Whether there are pending entries */ - public function ifInsertNodeDataPending () { + public function ifInsertNodeDataPending (): bool { // Determine it if it is not empty $isPending = ($this->getStackInstance()->isStackEmpty(self::STACKER_NAME_INSERT_NODE) === FALSE); @@ -134,7 +134,7 @@ abstract class BaseDht extends BaseHubSystem implements Distributable { * * @return void */ - public function insertSingleNodeData () { + public function insertSingleNodeData (): void { // Get next node data from stack $nodeData = $this->getStackInstance()->popNamed(self::STACKER_NAME_INSERT_NODE); @@ -151,7 +151,7 @@ abstract class BaseDht extends BaseHubSystem implements Distributable { * @return $hasUnpublished Whether there are unpublished entries * @todo Add minimum/maximum age limitations */ - public function hasUnpublishedEntries () { + public function hasUnpublishedEntries (): bool { // Call method on database frontend $hasUnpublished = $this->getFrontendInstance()->hasUnpublishedEntries(); @@ -167,7 +167,7 @@ abstract class BaseDht extends BaseHubSystem implements Distributable { * @return void * @throws UnexpectedValueException If $resultInstance is not valid */ - public function initEntryPublication () { + public function initEntryPublication (): void { // Call method on database frontend /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-DHT: CALLED!'); $this->getFrontendInstance()->initEntryPublication(); @@ -210,7 +210,7 @@ abstract class BaseDht extends BaseHubSystem implements Distributable { * * @return $isPending Whether there are entries pending publication */ - public function hasEntriesPendingPublication () { + public function hasEntriesPendingPublication (): bool { // Determine it if it is not empty /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-DHT: CALLED!'); $isPending = ($this->getStackInstance()->isStackEmpty(self::STACKER_NAME_PENDING_PUBLISHING) === FALSE); @@ -225,7 +225,7 @@ abstract class BaseDht extends BaseHubSystem implements Distributable { * * @return $isBooting Whether this DHT is currently booting */ - public function ifDhtIsBooting () { + public function ifDhtIsBooting (): boot { // Call state instance /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-DHT: CALLED!'); $isBooting = $this->getStateInstance()->ifDhtIsBooting(); @@ -243,7 +243,7 @@ abstract class BaseDht extends BaseHubSystem implements Distributable { * @todo Find out if loadDescriptorXml() can be called only once to avoid a lot methods working. * @throws BadMethodCallException If this method was called but no pending entries publication */ - public function publishEntry () { + public function publishEntry (): void { // This test must not fail /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-DHT: CALLED!'); if (!$this->hasEntriesPendingPublication()) { @@ -288,7 +288,7 @@ abstract class BaseDht extends BaseHubSystem implements Distributable { * @return $isFullyBooted Whether the DHT is fully booted * @todo 0% done */ - public function hasFullyBootstrapped () { + public function hasFullyBootstrapped (): bool { // Get state and check it /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-DHT: CALLED!'); DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.'); @@ -300,7 +300,7 @@ abstract class BaseDht extends BaseHubSystem implements Distributable { * @return void * @todo Switch flag 'accept_bootstrap' */ - public function enableAcceptDhtBootstrap () { + public function enableAcceptDhtBootstrap (): void { // Call method on database frontend $this->getFrontendInstance()->enableAcceptDhtBootstrap(); } diff --git a/application/hub/classes/dht/node/class_NodeDhtFacade.php b/application/hub/classes/dht/node/class_NodeDhtFacade.php index 54296add0..96067f75a 100644 --- a/application/hub/classes/dht/node/class_NodeDhtFacade.php +++ b/application/hub/classes/dht/node/class_NodeDhtFacade.php @@ -66,7 +66,7 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable { * * @return $dhtInstance An instance of a Distributable class */ - public final static function createNodeDhtFacade () { + public final static function createNodeDhtFacade (): DistributableNode { // Get new instance $dhtInstance = new NodeDhtFacade(); @@ -89,7 +89,7 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable { * @return void * @todo Does this data need to be enriched with more meta data? */ - protected function insertDataIntoDht (array $dhtData) { + protected function insertDataIntoDht (array $dhtData): void { // Check if there is already an entry for given node_id /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: dhtData()=%d - CALLED!', count($dhtData))); if ($this->getFrontendInstance()->isNodeRegistered($dhtData)) { @@ -118,7 +118,7 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable { * * @return void */ - public function initDht () { + public function initDht (): void { // Is the local node registered? /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE-DHT-FACADE: CALLED!'); if ($this->getFrontendInstance()->isLocalNodeRegistered()) { @@ -145,7 +145,7 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable { * * @return void */ - public function bootstrapDht () { + public function bootstrapDht (): void { // Get a helper instance $helperInstance = ObjectFactory::createObjectByConfiguredName('dht_bootstrap_helper_class'); @@ -172,7 +172,7 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable { * @param $sessionId Session id to lookup * @return $nodeData Node-data array */ - public function findNodeLocalBySessionId (string $sessionId) { + public function findNodeLocalBySessionId (string $sessionId): array { // Validate parameter /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: sessionId=%s - CALLED!', $sessionId)); if (empty($sessionId)) { @@ -213,7 +213,7 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable { * @param $locatorInstance An instance of a LocateableNode class * @return $nodeData Node-data array */ - public function findNodeByUniversalNodeLocator (LocateableNode $locatorInstance) { + public function findNodeByUniversalNodeLocator (LocateableNode $locatorInstance): array { // Default is empty data array /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: locatorInstance=%s - CALLED!', $locatorInstance->__toString())); //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: locatorInstance=%s', __METHOD__, __LINE__, print_r($locatorInstance, TRUE))); @@ -256,7 +256,7 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable { * @throws NodeSessionIdVerficationException If the node was not found and update is forced * @throws UnexpectedValueException If $resultInstance does not implement wanted interface */ - public function registerNodeByMessageInstance (DeliverableMessage $messageInstance, HandleableDataSet $handlerInstance, bool $forceUpdate = FALSE) { + public function registerNodeByMessageInstance (DeliverableMessage $messageInstance, HandleableDataSet $handlerInstance, bool $forceUpdate = FALSE): void { // Get a search criteria class /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: state=%s,messageInstance=%s,handlerInstance=%s,forceUpdate=%d - CALLED', $this->getPrintableState(), $messageInstance->__toString(), $handlerInstance->__toString(), intval($forceUpdate))); $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); @@ -317,7 +317,7 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable { * @return $nodeList An array with all found nodes * @throws UnexpectedValueException If $resultInstance does not implement wanted interface */ - public function queryLocalNodeListExceptByMessageInstance (DeliverableMessage $messageInstance, HandleableDataSet $handlerInstance, string $excludeKey, string $andKey, string $separator) { + public function queryLocalNodeListExceptByMessageInstance (DeliverableMessage $messageInstance, HandleableDataSet $handlerInstance, string $excludeKey, string $andKey, string $separator): array { // Get a search criteria class /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: messageInstance=%s,handlerInstance=%s,excludeKey=%s,andKey=%s,separator=%s - CALLED!', $messageInstance->__toString(), $handlerInstance->__toString(), $excludeKey, $andKey, $separator)); //* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: state=%s,messageInstance=%s', $this->getPrintableState(), print_r($messageInstance, TRUE))); @@ -389,7 +389,7 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable { * @param $nodeList An array from an earlier database result instance * @return void */ - public function insertNodeList (array $nodeList) { + public function insertNodeList (array $nodeList): void { // If no node is in the list (array), skip the rest of this method /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: nodeList()=%d - CALLED!', count($nodeList))); if (count($nodeList) == 0) { @@ -415,7 +415,7 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable { * @return $recipients An indexed array with DHT recipients * @throws UnexpectedValueException If $resultInstance does not implement wanted interface */ - public function findRecipientsByPackageInstance (DeliverablePackage $packageInstance) { + public function findRecipientsByPackageInstance (DeliverablePackage $packageInstance): array { // Query get a result instance back from DHT database frontend /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: packageInstance=%s - CALLED!', $packageInstance->__toString())); $resultInstance = $this->getFrontendInstance()->getResultFromExcludedSender($packageInstance); @@ -457,11 +457,11 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable { * * @param $key Key to search for * @param $value Value to check on found key - * @return $recipiens Array with DHT recipients from given key/value pair + * @return $recipients Array with DHT recipients from given key/value pair * @throws InvalidArgumentException If $key is empty * @throws UnexpectedValueException If $resultInstance does not implement wanted interface */ - public function findRecipientsByKey (string $key, $value) { + public function findRecipientsByKey (string $key, mixed $value): array { // Is key parameter valid? /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: key=%s,value[%s]=%s - CALLED!', $key, gettype($value), $value)); if (empty($key)) { diff --git a/application/hub/classes/feature/hubcoin_reward/class_HubcoinRewardFeature.php b/application/hub/classes/feature/hubcoin_reward/class_HubcoinRewardFeature.php index a8e639bd8..ee2092bbf 100644 --- a/application/hub/classes/feature/hubcoin_reward/class_HubcoinRewardFeature.php +++ b/application/hub/classes/feature/hubcoin_reward/class_HubcoinRewardFeature.php @@ -51,9 +51,11 @@ class HubcoinRewardFeature extends BaseFeature implements Feature { */ public final static function createHubcoinRewardFeature () { // Get a new instance + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('[%s:%d]: CALLED!', __METHOD__, __LINE__)); $featureInstance = new HubcoinRewardFeature(); // Return the prepared instance + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('[%s:%d]: featureInstance=%s - EXIT!', __METHOD__, __LINE__, $featureInstance->__toString())); return $featureInstance; } @@ -64,11 +66,11 @@ class HubcoinRewardFeature extends BaseFeature implements Feature { */ public function isFeatureAvailable () { // Testing this feature is pretty simple: - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: CALLED!', __METHOD__, __LINE__)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('[%s:%d]: CALLED!', __METHOD__, __LINE__)); $isAvailable = ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('extension_scrypt_loaded') === TRUE) && (extension_loaded('scrypt')) && (is_callable('scrypt'))); // Return status - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: isAvailable=%d - EXIT!', __METHOD__, __LINE__, intval($isAvailable))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('[%s:%d]: isAvailable=%d - EXIT!', __METHOD__, __LINE__, intval($isAvailable))); return $isAvailable; } @@ -84,14 +86,14 @@ class HubcoinRewardFeature extends BaseFeature implements Feature { */ public function featureMethodGenerateHash ($data) { // Make sure the feature is available - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: data()=%d - CALLED!', __METHOD__, __LINE__, strlen($data))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('[%s:%d]: data()=%d - CALLED!', __METHOD__, __LINE__, strlen($data))); assert(FrameworkFeature::isFeatureAvailable('hubcoin_reward')); // Call inner class $hash = Scrypt::hashScrypt($data); // Return generated hash - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: hash=%s - EXIT!', __METHOD__, __LINE__, $hash)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('[%s:%d]: hash=%s - EXIT!', __METHOD__, __LINE__, $hash)); return $hash; } @@ -104,14 +106,14 @@ class HubcoinRewardFeature extends BaseFeature implements Feature { */ public function featureMethodCheckHash ($data, string $hash) { // Make sure the feature is available - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: data()=%d,hash=%s - CALLED!', __METHOD__, __LINE__, strlen($data), $hash)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('[%s:%d]: data()=%d,hash=%s - CALLED!', __METHOD__, __LINE__, strlen($data), $hash)); assert(FrameworkFeature::isFeatureAvailable('hubcoin_reward')); // Determine it $isValid = Scrypt::checkScrypt($data, $hash); // Return status - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: isValid=%d - EXIT!', __METHOD__, __LINE__, intval($isValid))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('[%s:%d]: isValid=%d - EXIT!', __METHOD__, __LINE__, intval($isValid))); return $isValid; } diff --git a/application/hub/classes/pools/peer/class_DefaultPeerPool.php b/application/hub/classes/pools/peer/class_DefaultPeerPool.php index af5d18ac7..be0128585 100644 --- a/application/hub/classes/pools/peer/class_DefaultPeerPool.php +++ b/application/hub/classes/pools/peer/class_DefaultPeerPool.php @@ -80,7 +80,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { */ private function validateSocket (StorableSocket $socketInstance) { // Is it a valid resource? - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-SYSTEM: socketInstance->socketResource=%s - CALLED!', $socketInstance->getPrintableName())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('HUB-SYSTEM: socketInstance->socketResource=%s - CALLED!', $socketInstance->getPrintableName())); if (!$socketInstance->isValidSocket()) { // Throw an exception throw new InvalidSocketException([$this, $socketInstance->getSocketResource()], self::EXCEPTION_INVALID_SOCKET); @@ -105,9 +105,9 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { * @throws InvalidArgumentException If $connectionType is empty * @throws InvalidConnectionTypeException If the provided connection type is not valid */ - public function addPeer (StorableSocket $socketInstance, string $connectionType) { + public function addPeer (StorableSocket $socketInstance, string $connectionType): void { // Validate parameter - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: socketResource[%s]=%s,connectionType=%s - CALLED!', gettype($socketInstance->getSocketResource()), $socketInstance->getPrintableName(), $connectionType)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DEFAULT-PEER-POOL: socketResource[%s]=%s,connectionType=%s - CALLED!', gettype($socketInstance->getSocketResource()), $socketInstance->getPrintableName(), $connectionType)); if (empty($connectionType)) { // Throw exception throw new InvalidArgumentException('Parameter "connectionType" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); @@ -157,12 +157,12 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { * * @return $sockets An array with all sockets */ - public final function getAllSockets () { + public final function getAllSockets (): array { // Get the list $sockets = $this->getArrayFromList('pool'); // Return it - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: sockets()=%d - EXIT!', count($sockets))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DEFAULT-PEER-POOL: sockets()=%d - EXIT!', count($sockets))); return $sockets; } @@ -171,7 +171,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { * * @return $sockets An array with all socket arrays */ - public final function getAllSingleSockets () { + public final function getAllSingleSockets (): array { // Get the array list $socketArrays = $this->getArrayFromList('pool'); @@ -196,9 +196,9 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { * @throws InvalidConnectionTypeException If the found connection type is not valid * @throws InvalidArgumentException If $connectionType is empty */ - public function getSocketsByConnectionType (string $connectionType) { + public function getSocketsByConnectionType (string $connectionType): array { // Validate parameter - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: connectionType=%s - CALLED!', $connectionType)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DEFAULT-PEER-POOL: connectionType=%s - CALLED!', $connectionType)); if (empty($connectionType)) { // Throw exception throw new InvalidArgumentException('Parameter "connectionType" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); @@ -241,7 +241,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { */ public function getSocketFromPackageInstance (DeliverablePackage $packageInstance, string $connectionType = NULL) { // Validate parameter - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: packageInstance=%s,connectionType[%s]=%s - CALLED!', $packageInstance->__toString(), gettype($connectionType), $connectionType)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DEFAULT-PEER-POOL: packageInstance=%s,connectionType[%s]=%s - CALLED!', $packageInstance->__toString(), gettype($connectionType), $connectionType)); if (empty($connectionType)) { // Throw exception throw new InvalidArgumentException('Parameter "connectionType" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); @@ -301,7 +301,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { } // Return the determined socket instance - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: socketInstance[]=%s - EXIT!', gettype($socketInstance))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('DEFAULT-PEER-POOL: socketInstance[]=%s - EXIT!', gettype($socketInstance))); return $socketInstance; } diff --git a/application/hub/classes/tools/hub/class_HubTools.php b/application/hub/classes/tools/hub/class_HubTools.php index 056fb72ea..216407326 100644 --- a/application/hub/classes/tools/hub/class_HubTools.php +++ b/application/hub/classes/tools/hub/class_HubTools.php @@ -97,7 +97,7 @@ class HubTools extends BaseHubSystem { * * @return $sessionIdLength Length of session ids */ - protected final function getSessionIdLength () { + protected final function getSessionIdLength (): int { return $this->sessionIdLength; } @@ -106,10 +106,10 @@ class HubTools extends BaseHubSystem { * is resolveSessionIdByUniversalNodeLocator() * * @param $sessionId A valid session id - * @return $recipientUniversalNodeLocator Recipient as Universal Node Locator + * @return $recipientUnl Recipient as Universal Node Locator * @throws InvalidArgumentException If $sessionId is not valid */ - protected function resolveUniversalNodeLocatorBySessionId (string $sessionId) { + protected function resolveUniversalNodeLocatorBySessionId (string $sessionId): string { // Validate parameter /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TOOLS: sessionId=%s - CALLED!', $sessionId)); if (empty($sessionId)) { @@ -152,7 +152,7 @@ class HubTools extends BaseHubSystem { * @return $nodeId Node id * @throws InvalidArgumentException If $sessionId is not valid */ - public static function resolveNodeIdBySessionId (string $sessionId) { + public static function resolveNodeIdBySessionId (string $sessionId): string { // Validate parameter /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TOOLS: sessionId=%s - CALLED!', $sessionId)); if (empty($sessionId)) { @@ -182,7 +182,7 @@ class HubTools extends BaseHubSystem { * @param $locatorInstance An instance of a LocateableNode class * @return $sessionId Valid session id */ - public static function resolveSessionIdByUniversalNodeLocator (LocateableNode $locatorInstance) { + public static function resolveSessionIdByUniversalNodeLocator (LocateableNode $locatorInstance): string { // Get an own instance /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TOOLS: locatorInstance=%s - CALLED!', $locatorInstance->__toString())); $selfInstance = self::getSelfInstance(); @@ -215,7 +215,7 @@ class HubTools extends BaseHubSystem { * @throws InvalidSessionIdException If the provided session id is invalid (and no Universal Node Locator) * @throws NoValidHostnameException If the provided hostname cannot be resolved into an IP address */ - public static function resolveSessionIdToUnl (string $address) { + public static function resolveSessionIdToUnl (string $address): string { // Is the parameter valid? /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TOOLS: address=%s - CALLED!', $address)); if (empty($address)) { @@ -256,7 +256,7 @@ class HubTools extends BaseHubSystem { * * @return $unl The determined external UNL of this node */ - public static function determineOwnExternalAddress () { + public static function determineOwnExternalAddress (): string { // Is the external_address config entry set? //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: CALLED!'); if (isset(self::$cachedAddresses[DiscoverableUniversalNodeLocator::UNL_TYPE_EXTERNAL])) { @@ -285,7 +285,7 @@ class HubTools extends BaseHubSystem { * * @return $unl The determined internal UNL of this node */ - public static function determineOwnInternalAddress () { + public static function determineOwnInternalAddress (): string { // Is the internal_address config entry set? //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: CALLED!'); if (isset(self::$cachedAddresses[DiscoverableUniversalNodeLocator::UNL_TYPE_INTERNAL])) { @@ -338,7 +338,7 @@ class HubTools extends BaseHubSystem { * * @return $externalUnl External UNL */ - public static function determineExternalUniversalNodeLocator () { + public static function determineExternalUniversalNodeLocator (): string { // Determine UNL based on this node: //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: CALLED!'); // 1) Get discovery class diff --git a/application/hub/classes/tools/node/class_NodeLocatorUtils.php b/application/hub/classes/tools/node/class_NodeLocatorUtils.php index f774c961c..568b5b2d1 100644 --- a/application/hub/classes/tools/node/class_NodeLocatorUtils.php +++ b/application/hub/classes/tools/node/class_NodeLocatorUtils.php @@ -52,7 +52,7 @@ class NodeLocatorUtils extends BaseHubSystem { * @param $unl Universal Node Locator to validate * @return $isValid Whether the UNL is valid */ - public static function isValidUniversalNodeLocator (string $unl) { + public static function isValidUniversalNodeLocator (string $unl): bool { // Debug message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UNIVERSAL-NODE-LOCATOR: unl=' . $unl . ' - CALLED!'); diff --git a/application/hub/interfaces/distributable/node/class_DistributableNode.php b/application/hub/interfaces/distributable/node/class_DistributableNode.php index a917c75ec..6dff88b3b 100644 --- a/application/hub/interfaces/distributable/node/class_DistributableNode.php +++ b/application/hub/interfaces/distributable/node/class_DistributableNode.php @@ -43,7 +43,7 @@ interface DistributableNode extends Distributable { * @return $nodeData Node-data array * @throws InvalidArgumentException If parameter $sessionId is not valid */ - function findNodeLocalBySessionId (string $sessionId); + function findNodeLocalBySessionId (string $sessionId): array; /** * Finds a node locally by given UNL instance @@ -51,7 +51,7 @@ interface DistributableNode extends Distributable { * @param $locatorInstance An instance of a LocateableNode class * @return $nodeData Node-data array */ - function findNodeByUniversalNodeLocator (LocateableNode $locatorInstance); + function findNodeByUniversalNodeLocator (LocateableNode $locatorInstance): array; /** * Registers an other node with this node by given message data. The @@ -66,7 +66,7 @@ interface DistributableNode extends Distributable { * @param $forceUpdate Optionally force update, don't register (default: register if not found) * @return void */ - function registerNodeByMessageInstance (DeliverableMessage $messageInstance, HandleableDataSet $handlerInstance, bool $forceUpdate = FALSE); + function registerNodeByMessageInstance (DeliverableMessage $messageInstance, HandleableDataSet $handlerInstance, bool $forceUpdate = FALSE): void; /** * Queries the local DHT data(base) for a node list with all supported @@ -79,7 +79,7 @@ interface DistributableNode extends Distributable { * @param $separator Sepator char (1st parameter for explode() call) * @return $nodeList An array with all found nodes */ - function queryLocalNodeListExceptByMessageInstance (DeliverableMessage $messageInstance, HandleableDataSet $handlerInstance, string $excludeKey, string $andKey, string $separator); + function queryLocalNodeListExceptByMessageInstance (DeliverableMessage $messageInstance, HandleableDataSet $handlerInstance, string $excludeKey, string $andKey, string $separator): array; /** * Inserts given node list array (from earlier database result produced by @@ -89,21 +89,21 @@ interface DistributableNode extends Distributable { * @param $nodeList An array from an earlier database result instance * @return void */ - function insertNodeList (array $nodeList); + function insertNodeList (array $nodeList): void; /** * Checks whether there are entries in "INSERT" node data stack * * @return $isPending Whether there are pending entries */ - function ifInsertNodeDataPending (); + function ifInsertNodeDataPending (): bool; /** * Checks whether there are unpublished entries * * @return $hasUnpublished Whether there are unpublished entries */ - function hasUnpublishedEntries (); + function hasUnpublishedEntries (): bool; /** * Initializes publication of DHT entries. This does only prepare @@ -112,14 +112,14 @@ interface DistributableNode extends Distributable { * * @return void */ - function initEntryPublication (); + function initEntryPublication (): void; /** * Checks whether there are entries pending publication * * @return $isPending Whether there are entries pending publication */ - function hasEntriesPendingPublication (); + function hasEntriesPendingPublication (): bool; /** * Publishes next entry found in stack. This method shall also update the @@ -127,6 +127,6 @@ interface DistributableNode extends Distributable { * * @return void */ - function publishEntry (); + function publishEntry (): void; } diff --git a/application/hub/interfaces/pool/peer/class_PoolablePeer.php b/application/hub/interfaces/pool/peer/class_PoolablePeer.php index ddee9884b..5488d3e5f 100644 --- a/application/hub/interfaces/pool/peer/class_PoolablePeer.php +++ b/application/hub/interfaces/pool/peer/class_PoolablePeer.php @@ -38,21 +38,21 @@ interface PoolablePeer extends Poolable, SocketTag { * @return void * @throws InvalidConnectionTypeException If the provided connection type is not valid */ - function addPeer (StorableSocket $socketInstance, string $connectionType); + function addPeer (StorableSocket $socketInstance, string $connectionType): void; /** * Getter for array of all socket resources * * @return $sockets An array with all sockets */ - function getAllSockets (); + function getAllSockets (): array; /** * Getter for array of all socket arrays * * @return $sockets An array with all socket arrays */ - function getAllSingleSockets (); + function getAllSingleSockets (): array; /** * "Getter" for all sockets of specified type diff --git a/core b/core index cc9a1193f..ba75c20fc 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit cc9a1193fe856148b71982e055dd05051751cef2 +Subproject commit ba75c20fcc3cc172de195703b3220168d97912fd