From: Roland Häder Date: Fri, 4 Dec 2020 06:40:30 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9612dfdb7965f71dd1238f881fdb95760ed978c4;p=hub.git Continued: - lesser old-lost " // END - * - also converted assert() into proper thrown exceptions (more OOP) - updated core framework Signed-off-by: Roland Häder --- diff --git a/application/hub/class_ApplicationHelper.php b/application/hub/class_ApplicationHelper.php index 8545f70a7..65cb781ce 100644 --- a/application/hub/class_ApplicationHelper.php +++ b/application/hub/class_ApplicationHelper.php @@ -73,7 +73,7 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication // Is the instance there? if (is_null(self::getApplicationInstance())) { self::setApplicationInstance(new ApplicationHelper()); - } // END - if + } // Return the instance return self::getApplicationInstance(); @@ -136,7 +136,7 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication // Set it in request $requestInstance->setRequestElement('command', $commandName); - } // END - if + } // Is the request type 'html' ? if (FrameworkBootstrap::getRequestTypeFromSystem() == 'html') { @@ -145,7 +145,7 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication // And set it here $this->setLanguageInstance($languageInstance); - } // END - if + } // Configuration entry key $configEntry = sprintf( @@ -173,7 +173,7 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: Shutdown in progress, main loop exited.'); $this->getControllerInstance()->executeShutdownFilters($requestInstance, $responseInstance); self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: Shutdown completed. (This is the last line.)'); - } // END - if + } } /** @@ -197,7 +197,7 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication // Walk through all messages foreach ($messageList as $message) { exit(__METHOD__ . ':MSG:' . $message); - } // END - foreach + } } /** diff --git a/application/hub/classes/chains/class_PackageFilterChain.php b/application/hub/classes/chains/class_PackageFilterChain.php index 29e2c3429..473b88780 100644 --- a/application/hub/classes/chains/class_PackageFilterChain.php +++ b/application/hub/classes/chains/class_PackageFilterChain.php @@ -74,7 +74,7 @@ class PackageFilterChain extends FilterChain { self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Failed to execute lase filter ' . $filterInstance->__toString() . ': ' . $e->getMessage()); break; } - } // END - foreach + } } /** @@ -95,7 +95,7 @@ class PackageFilterChain extends FilterChain { self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Failed to execute lase filter ' . $filterInstance->__toString() . ': ' . $e->getMessage()); break; } - } // END - foreach + } } } diff --git a/application/hub/classes/client/http/class_HttpClient.php b/application/hub/classes/client/http/class_HttpClient.php index f48334e3a..cd943ad76 100644 --- a/application/hub/classes/client/http/class_HttpClient.php +++ b/application/hub/classes/client/http/class_HttpClient.php @@ -74,7 +74,7 @@ class HttpClient extends BaseClient implements Client { FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_port') > 0 ) ); - } // END - if + } // Return cache return $GLOBALS[__METHOD__]; @@ -98,7 +98,7 @@ class HttpClient extends BaseClient implements Client { if (((strtolower($respArray[0]) !== 'http/1.0') && (strtolower($respArray[0]) !== 'http/1.1')) || ($respArray[1] != '200')) { // Response code is not 200 return $response; - } // END - if + } // All fine! return $respArray; @@ -122,7 +122,7 @@ class HttpClient extends BaseClient implements Client { // Add it as well $encodedAuth = base64_encode(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_username') . ':' . FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_password')); $rawRequest .= 'Proxy-Authorization: Basic ' . $encodedAuth . self::HTTP_EOL; - } // END - if + } // Add last new-line $rawRequest .= self::HTTP_EOL; @@ -135,7 +135,7 @@ class HttpClient extends BaseClient implements Client { if (feof($this->getSocketInstance())) { // No response received return $response; - } // END - if + } // Read the first line $resp = trim(fgets($this->getSocketInstance(), 10240)); diff --git a/application/hub/classes/commands/console/class_HubConsoleAptProxyCommand.php b/application/hub/classes/commands/console/class_HubConsoleAptProxyCommand.php index bc40a9273..81883d6af 100644 --- a/application/hub/classes/commands/console/class_HubConsoleAptProxyCommand.php +++ b/application/hub/classes/commands/console/class_HubConsoleAptProxyCommand.php @@ -105,7 +105,7 @@ class HubConsoleAptProxyCommand extends BaseCommand implements Commandable { while (($proxyInstance->isActive()) && ($handlerInstance->hasTasksLeft())) { // Handle all tasks here $handlerInstance->handleTasks(); - } // END - while + } // Debug message self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Leaving main loop. ---'); diff --git a/application/hub/classes/commands/console/class_HubConsoleChatCommand.php b/application/hub/classes/commands/console/class_HubConsoleChatCommand.php index 044b3abca..a4b37312e 100644 --- a/application/hub/classes/commands/console/class_HubConsoleChatCommand.php +++ b/application/hub/classes/commands/console/class_HubConsoleChatCommand.php @@ -105,7 +105,7 @@ class HubConsoleChatCommand extends BaseCommand implements Commandable { while (($chatInstance->isActive()) && ($handlerInstance->hasTasksLeft())) { // Handle all tasks here $handlerInstance->handleTasks(); - } // END - while + } // Debug message self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Leaving main loop. ---'); diff --git a/application/hub/classes/commands/console/class_HubConsoleCrawlerCommand.php b/application/hub/classes/commands/console/class_HubConsoleCrawlerCommand.php index 2eb9830b6..fe4204ca7 100644 --- a/application/hub/classes/commands/console/class_HubConsoleCrawlerCommand.php +++ b/application/hub/classes/commands/console/class_HubConsoleCrawlerCommand.php @@ -105,7 +105,7 @@ class HubConsoleCrawlerCommand extends BaseCommand implements Commandable { while (($crawlerInstance->isActive()) && ($handlerInstance->hasTasksLeft())) { // Handle all tasks here $handlerInstance->handleTasks(); - } // END - while + } // Debug message self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Leaving main loop. ---'); diff --git a/application/hub/classes/commands/console/class_HubConsoleCruncherCommand.php b/application/hub/classes/commands/console/class_HubConsoleCruncherCommand.php index 0f1623909..109f49a17 100644 --- a/application/hub/classes/commands/console/class_HubConsoleCruncherCommand.php +++ b/application/hub/classes/commands/console/class_HubConsoleCruncherCommand.php @@ -105,7 +105,7 @@ class HubConsoleCruncherCommand extends BaseCommand implements Commandable { while (($cruncherInstance->isActive()) && ($handlerInstance->hasTasksLeft())) { // Handle all tasks here $handlerInstance->handleTasks(); - } // END - while + } // Debug message self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Leaving main loop. ---'); diff --git a/application/hub/classes/commands/console/class_HubConsoleMainCommand.php b/application/hub/classes/commands/console/class_HubConsoleMainCommand.php index 092eeaba7..14e6a2276 100644 --- a/application/hub/classes/commands/console/class_HubConsoleMainCommand.php +++ b/application/hub/classes/commands/console/class_HubConsoleMainCommand.php @@ -116,7 +116,7 @@ class HubConsoleMainCommand extends BaseCommand implements Commandable { while (($nodeInstance->isNodeActive()) && ($handlerInstance->hasTasksLeft())) { // Handle all tasks here $handlerInstance->handleTasks(); - } // END - while + } // Debug message self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Leaving main loop. ---'); diff --git a/application/hub/classes/commands/console/class_HubConsoleMinerCommand.php b/application/hub/classes/commands/console/class_HubConsoleMinerCommand.php index ba86d25d2..4840fa61f 100644 --- a/application/hub/classes/commands/console/class_HubConsoleMinerCommand.php +++ b/application/hub/classes/commands/console/class_HubConsoleMinerCommand.php @@ -105,7 +105,7 @@ class HubConsoleMinerCommand extends BaseCommand implements Commandable { while (($minerInstance->isActive()) && ($handlerInstance->hasTasksLeft())) { // Handle all tasks here $handlerInstance->handleTasks(); - } // END - while + } // Debug message self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Leaving main loop. ---'); diff --git a/application/hub/classes/commands/html/class_HubHtmlIndexCommand.php b/application/hub/classes/commands/html/class_HubHtmlIndexCommand.php index df027ec08..d9ac5a7ee 100644 --- a/application/hub/classes/commands/html/class_HubHtmlIndexCommand.php +++ b/application/hub/classes/commands/html/class_HubHtmlIndexCommand.php @@ -76,7 +76,7 @@ class HubHtmlIndexCommand extends BaseCommand implements Commandable { // Bail out exit(); - } // END - if + } /* * This is a generic HTML request, this means that a regular page with diff --git a/application/hub/classes/controller/console/class_HubConsoleAptProxyController.php b/application/hub/classes/controller/console/class_HubConsoleAptProxyController.php index 876b687fb..8949bbc29 100644 --- a/application/hub/classes/controller/console/class_HubConsoleAptProxyController.php +++ b/application/hub/classes/controller/console/class_HubConsoleAptProxyController.php @@ -43,9 +43,9 @@ class HubConsoleAptProxyController extends BaseController implements Controller parent::__construct(__CLASS__); // Init additional filter chains - foreach (array('bootstrap','shutdown') as $filterChain) { + foreach (['bootstrap', 'shutdown'] as $filterChain) { $this->initFilterChain($filterChain); - } // END - foreach + } } /** diff --git a/application/hub/classes/controller/console/class_HubConsoleChatController.php b/application/hub/classes/controller/console/class_HubConsoleChatController.php index e28cbb6ae..f9e445bb3 100644 --- a/application/hub/classes/controller/console/class_HubConsoleChatController.php +++ b/application/hub/classes/controller/console/class_HubConsoleChatController.php @@ -43,9 +43,9 @@ class HubConsoleChatController extends BaseController implements Controller { parent::__construct(__CLASS__); // Init additional filter chains - foreach (array('bootstrap','shutdown') as $filterChain) { + foreach (['bootstrap', 'shutdown'] as $filterChain) { $this->initFilterChain($filterChain); - } // END - foreach + } } /** diff --git a/application/hub/classes/controller/console/class_HubConsoleCrawlerController.php b/application/hub/classes/controller/console/class_HubConsoleCrawlerController.php index c83702530..aabaff533 100644 --- a/application/hub/classes/controller/console/class_HubConsoleCrawlerController.php +++ b/application/hub/classes/controller/console/class_HubConsoleCrawlerController.php @@ -43,9 +43,9 @@ class HubConsoleCrawlerController extends BaseController implements Controller { parent::__construct(__CLASS__); // Init additional filter chains - foreach (array('bootstrap','shutdown') as $filterChain) { + foreach (['bootstrap', 'shutdown'] as $filterChain) { $this->initFilterChain($filterChain); - } // END - foreach + } } /** diff --git a/application/hub/classes/controller/console/class_HubConsoleCruncherController.php b/application/hub/classes/controller/console/class_HubConsoleCruncherController.php index 8be958b38..48f1293a3 100644 --- a/application/hub/classes/controller/console/class_HubConsoleCruncherController.php +++ b/application/hub/classes/controller/console/class_HubConsoleCruncherController.php @@ -44,9 +44,9 @@ class HubConsoleCruncherController extends BaseController implements Controller parent::__construct(__CLASS__); // Init additional filter chains - foreach (array('bootstrap','shutdown') as $filterChain) { + foreach (['bootstrap', 'shutdown'] as $filterChain) { $this->initFilterChain($filterChain); - } // END - foreach + } } /** diff --git a/application/hub/classes/controller/console/class_HubConsoleDefaultNewsController.php b/application/hub/classes/controller/console/class_HubConsoleDefaultNewsController.php index f0108d5b3..b40b69f53 100644 --- a/application/hub/classes/controller/console/class_HubConsoleDefaultNewsController.php +++ b/application/hub/classes/controller/console/class_HubConsoleDefaultNewsController.php @@ -44,9 +44,9 @@ class HubConsoleDefaultNewsController extends BaseController implements Controll parent::__construct(__CLASS__); // Init additional filter chains - foreach (array('bootstrap', 'activation','shutdown') as $filterChain) { + foreach (['bootstrap', 'activation', 'shutdown'] as $filterChain) { $this->initFilterChain($filterChain); - } // END - foreach + } } /** diff --git a/application/hub/classes/controller/console/class_HubConsoleFuseController.php b/application/hub/classes/controller/console/class_HubConsoleFuseController.php index 4d1b7838d..8ed7d00d1 100644 --- a/application/hub/classes/controller/console/class_HubConsoleFuseController.php +++ b/application/hub/classes/controller/console/class_HubConsoleFuseController.php @@ -43,9 +43,9 @@ class HubConsoleFuseController extends BaseController implements Controller { parent::__construct(__CLASS__); // Init additional filter chains - foreach (array('bootstrap','shutdown') as $filterChain) { + foreach (['bootstrap', 'shutdown'] as $filterChain) { $this->initFilterChain($filterChain); - } // END - foreach + } } /** diff --git a/application/hub/classes/controller/console/class_HubConsoleMinerController.php b/application/hub/classes/controller/console/class_HubConsoleMinerController.php index bc9ca93fb..e9a4c0394 100644 --- a/application/hub/classes/controller/console/class_HubConsoleMinerController.php +++ b/application/hub/classes/controller/console/class_HubConsoleMinerController.php @@ -43,9 +43,9 @@ class HubConsoleMinerController extends BaseController implements Controller { parent::__construct(__CLASS__); // Init additional filter chains - foreach (array('bootstrap','shutdown') as $filterChain) { + foreach (['bootstrap', 'shutdown'] as $filterChain) { $this->initFilterChain($filterChain); - } // END - foreach + } } /** diff --git a/application/hub/classes/cruncher/class_BaseHubCruncher.php b/application/hub/classes/cruncher/class_BaseHubCruncher.php index 949c24b0a..ef11ced9b 100644 --- a/application/hub/classes/cruncher/class_BaseHubCruncher.php +++ b/application/hub/classes/cruncher/class_BaseHubCruncher.php @@ -202,8 +202,8 @@ abstract class BaseHubCruncher extends BaseHubSystem implements Updateable { if ((!$this->isInBufferQueueFilled()) && (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('cruncher_test_units_enabled') == 'Y')) { // Then fill the in-buffer with (one) test-unit(s) $this->fillInBufferQueueWithTestUnits(); - } // END - if - } // END - if + } + } } /** diff --git a/application/hub/classes/cruncher/openssl/class_HubOpenSslCruncher.php b/application/hub/classes/cruncher/openssl/class_HubOpenSslCruncher.php index 43327051a..7050734c2 100644 --- a/application/hub/classes/cruncher/openssl/class_HubOpenSslCruncher.php +++ b/application/hub/classes/cruncher/openssl/class_HubOpenSslCruncher.php @@ -93,7 +93,7 @@ class HubOpenSslCruncher extends BaseHubCruncher implements CruncherHelper, Regi // ... and finally queue it to the in-buffer queue $this->queueUnitInstanceToInBuffer($unitInstance); - } // END - for + } } /** @@ -107,7 +107,7 @@ class HubOpenSslCruncher extends BaseHubCruncher implements CruncherHelper, Regi if ($this->getStateInstance()->isCruncherStateVirgin()) { // We can silently skip here, until the generation is finished return; - } // END - if + } // @TODO Implement this method $this->partialStub('Please implement this method.'); diff --git a/application/hub/classes/database/frontend/node_dht/class_NodeDistributedHashTableDatabaseFrontend.php b/application/hub/classes/database/frontend/node_dht/class_NodeDistributedHashTableDatabaseFrontend.php index b3ddc7baf..62d1f379d 100644 --- a/application/hub/classes/database/frontend/node_dht/class_NodeDistributedHashTableDatabaseFrontend.php +++ b/application/hub/classes/database/frontend/node_dht/class_NodeDistributedHashTableDatabaseFrontend.php @@ -20,6 +20,7 @@ use Org\Mxchange\CoreFramework\Registry\Registerable; use Org\Mxchange\CoreFramework\Result\Search\SearchableResult; // Import SPL stuff +use \BadMethodCallException; use \InvalidArgumentException; /** @@ -277,13 +278,15 @@ class NodeDistributedHashTableDatabaseFrontend extends BaseHubDatabaseFrontend i * session id, ip number (and/or hostname) and port number. * * @return void + * @throws BadMethodCallException If node is not locally registered */ public function updateLocalNode () { - // Debug message + // Check condition //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-FRONTEND: CALLED!'); - - // Assert to make sure this method is called with one record in DB (the actual backend of the DHT) - assert($this->isLocalNodeRegistered()); + if (!$this->isLocalNodeRegistered()) { + // Not registered but methoded invoked + throw new BadMethodCallException('Node is not locally registered but method called'); + } // Get search criteria $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); @@ -480,7 +483,7 @@ class NodeDistributedHashTableDatabaseFrontend extends BaseHubDatabaseFrontend i if ($this->isNodeRegistered($nodeData)) { // Throw an exception throw new NodeAlreadyRegisteredException(array($this, $nodeData), self::EXCEPTION_NODE_ALREADY_REGISTERED); - } // END - if + } // @TODO Unimplemented part $this->partialStub('nodeData=' . print_r($nodeData, TRUE)); @@ -513,7 +516,7 @@ class NodeDistributedHashTableDatabaseFrontend extends BaseHubDatabaseFrontend i if (!$this->isNodeRegistered($nodeData)) { // No, then throw an exception throw new NodeDataMissingException(array($this, $nodeData), self::EXCEPTION_NODE_NOT_REGISTERED); - } // END - if + } // Get a search instance $searchInstance = $this->prepareSearchInstance($nodeData); diff --git a/application/hub/classes/decoder/package/class_PackageDecoder.php b/application/hub/classes/decoder/package/class_PackageDecoder.php index cfdcab6b7..b8007a8fb 100644 --- a/application/hub/classes/decoder/package/class_PackageDecoder.php +++ b/application/hub/classes/decoder/package/class_PackageDecoder.php @@ -15,6 +15,9 @@ use Org\Shipsimu\Hub\Handler\Package\NetworkPackageHandler; // Import framework stuff use Org\Mxchange\CoreFramework\Registry\Registerable; +// Import SPL stuff +use \BadMethodCallException; + /** * A Package decoder class * @@ -97,11 +100,15 @@ class PackageDecoder extends BaseDecoder implements Decodeable, Registerable { * Handles raw package data by decoding it * * @return void + * @throws BadMethodCallException If no unhandled package data is pending */ public function handleRawPackageData () { // Assert on it to make sure the next popNamed() call won't throw an exception /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-DECODER: CALLED!'); - assert($this->ifUnhandledRawPackageDataLeft()); + if (!$this->ifUnhandledRawPackageDataLeft()) { + // No unhandled package data pending + throw new BadMethodCallException('No unhandled package data is pending but method called'); + } // "Pop" the next raw package content $rawPackageContent = $this->getHandlerInstance()->getStackInstance()->popNamed(ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA); @@ -146,10 +153,14 @@ class PackageDecoder extends BaseDecoder implements Decodeable, Registerable { * Handles received decoded packages internally (recipient is this node) * * @return void + * @throws BadMethodCallException If no decoded packages are left */ public function handleDecodedPackage () { - // Assert on amount - assert($this->ifDeocedPackagesLeft()); + // Check condition + if (!$this->ifDeocedPackagesLeft()) { + // No decoded packages left + throw new BadMethodCallException('No decoded packages pending but method called'); + } // Get the next entry (assoziative array) $packageInstance = $this->getHandlerInstance()->getStackInstance()->popNamed(self::STACKER_NAME_DECODED_PACKAGE); diff --git a/application/hub/classes/dht/class_BaseDht.php b/application/hub/classes/dht/class_BaseDht.php index e3a6f01e5..9ba58d1a3 100644 --- a/application/hub/classes/dht/class_BaseDht.php +++ b/application/hub/classes/dht/class_BaseDht.php @@ -253,7 +253,7 @@ abstract class BaseDht extends BaseHubSystem implements Distributable { if (!$this->publishHelperInstance instanceof HelpableDht) { // Get a helper instance $this->publishHelperInstance = ObjectFactory::createObjectByConfiguredName('dht_publish_entry_helper_class'); - } // END - if + } // Load the announcement descriptor $this->publishHelperInstance->loadDescriptorXml($this); diff --git a/application/hub/classes/discovery/node/class_UniversalNodeLocatorDiscovery.php b/application/hub/classes/discovery/node/class_UniversalNodeLocatorDiscovery.php index 97c7f07ba..b27d3226b 100644 --- a/application/hub/classes/discovery/node/class_UniversalNodeLocatorDiscovery.php +++ b/application/hub/classes/discovery/node/class_UniversalNodeLocatorDiscovery.php @@ -78,7 +78,7 @@ class UniversalNodeLocatorDiscovery extends BaseNodeDiscovery implements Discove if (is_null($locatorInstance)) { // Throw NPE here throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } // END - if + } // ... and return it return $locatorInstance; @@ -112,7 +112,7 @@ class UniversalNodeLocatorDiscovery extends BaseNodeDiscovery implements Discove // Get back the full UNL $GLOBALS[__METHOD__][$configKey] = $resolverInstance->resolveUniversalNodeLocatorFromConfigKey($configKey); - } // END - if + } // Return cached value /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UNL-DISCOVERY:configKey=' . $configKey . ',unl=' . $GLOBALS[__METHOD__][$configKey] . ' - EXIT!'); diff --git a/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php b/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php index a631ca43d..07fb9e4b3 100644 --- a/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php +++ b/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php @@ -124,11 +124,11 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera // This listener likes our package data, so abort here /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('PACKAGE-SOCKET-DISCOVERY: Listener "%s" is accepting package data.', $listenerInstance->__toString())); break; - } // END - if + } // Debug message /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: Listener is NOT accepting package data.'); - } // END - foreach + } // Return it /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: listenerInstance=' . $listenerInstance->__toString() . ' - EXIT!'); diff --git a/application/hub/classes/factories/chain/class_PackageFilterChainFactory.php b/application/hub/classes/factories/chain/class_PackageFilterChainFactory.php index 72d027f51..0e34a98e9 100644 --- a/application/hub/classes/factories/chain/class_PackageFilterChainFactory.php +++ b/application/hub/classes/factories/chain/class_PackageFilterChainFactory.php @@ -69,7 +69,7 @@ class PackageFilterChainFactory extends ObjectFactory { // Add this filter to the chain $chainInstance->addFilter($filterInstance); - } // END - foreach + } // Add the finished chain to the registry GenericRegistry::getRegistry()->addInstance($registryKey, $chainInstance); diff --git a/application/hub/classes/factories/client/class_ClientFactory.php b/application/hub/classes/factories/client/class_ClientFactory.php index c5349db5b..ac8f1d957 100644 --- a/application/hub/classes/factories/client/class_ClientFactory.php +++ b/application/hub/classes/factories/client/class_ClientFactory.php @@ -69,7 +69,7 @@ class ClientFactory extends ObjectFactory { if ($socketInstance instanceof StorableSocket) { // Set socket instance $clientInstance->setSocketInstance($socketInstance); - } // END - if + } } else { // Generate object instance $clientInstance = self::createObjectByConfiguredName($registryKey, array($socketInstance)); diff --git a/application/hub/classes/factories/states/node/class_NodeStateFactory.php b/application/hub/classes/factories/states/node/class_NodeStateFactory.php index 2086cf0a4..8925966a3 100644 --- a/application/hub/classes/factories/states/node/class_NodeStateFactory.php +++ b/application/hub/classes/factories/states/node/class_NodeStateFactory.php @@ -59,7 +59,7 @@ class NodeStateFactory extends ObjectFactory { // Get node instance from registry /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NOTE-STATE-FACTORY: Creating node instance ...'); $nodeInstance = NodeObjectFactory::createNodeInstance(); - } // END - if + } // Get a class from that configuration entry $stateInstance = self::createObjectByConfiguredName($className, array($nodeInstance)); diff --git a/application/hub/classes/factories/states/peer/class_PeerStateFactory.php b/application/hub/classes/factories/states/peer/class_PeerStateFactory.php index 57672dbfe..43809e644 100644 --- a/application/hub/classes/factories/states/peer/class_PeerStateFactory.php +++ b/application/hub/classes/factories/states/peer/class_PeerStateFactory.php @@ -63,7 +63,7 @@ class PeerStateFactory extends ObjectFactory { if (is_null(self::$tableInstance)) { // Get a new one self::$tableInstance = self::createObjectByConfiguredName('peer_state_lookup_db_frontend_class'); - } // END - if + } // Return it return self::$tableInstance; diff --git a/application/hub/classes/filter/apt-proxy/class_AptProxyPhpRequirementsFilter.php b/application/hub/classes/filter/apt-proxy/class_AptProxyPhpRequirementsFilter.php index 980ca8ccd..af104b982 100644 --- a/application/hub/classes/filter/apt-proxy/class_AptProxyPhpRequirementsFilter.php +++ b/application/hub/classes/filter/apt-proxy/class_AptProxyPhpRequirementsFilter.php @@ -78,9 +78,7 @@ class AptProxyPhpRequirementsFilter extends BaseAptProxyFilter implements Filter if ($checkPassed === FALSE) { // Throw an exception throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED); - } // END - if + } } -} -// [EOF] -?> +} diff --git a/application/hub/classes/filter/chat/class_ChatPhpRequirementsFilter.php b/application/hub/classes/filter/chat/class_ChatPhpRequirementsFilter.php index f4f905013..49c52bcb2 100644 --- a/application/hub/classes/filter/chat/class_ChatPhpRequirementsFilter.php +++ b/application/hub/classes/filter/chat/class_ChatPhpRequirementsFilter.php @@ -78,9 +78,7 @@ class ChatPhpRequirementsFilter extends BaseChatFilter implements Filterable { if ($checkPassed === FALSE) { // Throw an exception throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED); - } // END - if + } } -} -// [EOF] -?> +} diff --git a/application/hub/classes/filter/class_BaseHubFilter.php b/application/hub/classes/filter/class_BaseHubFilter.php index a0252091c..e5f232222 100644 --- a/application/hub/classes/filter/class_BaseHubFilter.php +++ b/application/hub/classes/filter/class_BaseHubFilter.php @@ -100,14 +100,14 @@ abstract class BaseHubFilter extends BaseFilter { // Skip this part, don't write NULLs to the array continue; - } // END - if + } // Debug message /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: key=' . $key . ',value=' . $value); // Set it now $this->dataXmlNodes[$key] = $value; - } // END - foreach + } // Construct an array for pushing it on next stack $messageArray = array( diff --git a/application/hub/classes/filter/crawler/class_CrawlerPhpRequirementsFilter.php b/application/hub/classes/filter/crawler/class_CrawlerPhpRequirementsFilter.php index 8bdba5bef..758bafea7 100644 --- a/application/hub/classes/filter/crawler/class_CrawlerPhpRequirementsFilter.php +++ b/application/hub/classes/filter/crawler/class_CrawlerPhpRequirementsFilter.php @@ -81,9 +81,7 @@ class CrawlerPhpRequirementsFilter extends BaseCrawlerFilter implements Filterab if ($checkPassed === FALSE) { // Throw an exception throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED); - } // END - if + } } -} -// [EOF] -?> +} diff --git a/application/hub/classes/filter/cruncher/class_CruncherPhpRequirementsFilter.php b/application/hub/classes/filter/cruncher/class_CruncherPhpRequirementsFilter.php index 718fc0b5a..e9d18a5ea 100644 --- a/application/hub/classes/filter/cruncher/class_CruncherPhpRequirementsFilter.php +++ b/application/hub/classes/filter/cruncher/class_CruncherPhpRequirementsFilter.php @@ -81,9 +81,7 @@ class CruncherPhpRequirementsFilter extends BaseCruncherFilter implements Filter if ($checkPassed === FALSE) { // Throw an exception throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED); - } // END - if + } } -} -// [EOF] -?> +} diff --git a/application/hub/classes/filter/miner/class_MinerPhpRequirementsFilter.php b/application/hub/classes/filter/miner/class_MinerPhpRequirementsFilter.php index 2ac4b90e6..4c1a50bac 100644 --- a/application/hub/classes/filter/miner/class_MinerPhpRequirementsFilter.php +++ b/application/hub/classes/filter/miner/class_MinerPhpRequirementsFilter.php @@ -92,7 +92,7 @@ class MinerPhpRequirementsFilter extends BaseMinerFilter implements Filterable { if ($checkPassed === FALSE) { // Throw an exception throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED); - } // END - if + } } } diff --git a/application/hub/classes/filter/node/class_NodePhpRequirementsFilter.php b/application/hub/classes/filter/node/class_NodePhpRequirementsFilter.php index c4eee7dbc..962a4ef31 100644 --- a/application/hub/classes/filter/node/class_NodePhpRequirementsFilter.php +++ b/application/hub/classes/filter/node/class_NodePhpRequirementsFilter.php @@ -76,7 +76,7 @@ class NodePhpRequirementsFilter extends BaseNodeFilter implements Filterable { // Test failed $checkPassed = FALSE; $checksFailed++; - } // END - if + } // If scrypt() is not found (ext-scrypt) then the "Hubcoins reward" is not working if ((extension_loaded('scrypt')) && (is_callable('scrypt'))) { @@ -102,7 +102,7 @@ class NodePhpRequirementsFilter extends BaseNodeFilter implements Filterable { if ($checkPassed === FALSE) { // Throw an exception throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - if + } } } diff --git a/application/hub/classes/filter/task/crawler/class_CrawlerTaskHandlerInitializerFilter.php b/application/hub/classes/filter/task/crawler/class_CrawlerTaskHandlerInitializerFilter.php index 245447f0e..5bb3d3518 100644 --- a/application/hub/classes/filter/task/crawler/class_CrawlerTaskHandlerInitializerFilter.php +++ b/application/hub/classes/filter/task/crawler/class_CrawlerTaskHandlerInitializerFilter.php @@ -122,7 +122,7 @@ class CrawlerTaskHandlerInitializerFilter extends BaseCrawlerFilter implements F // And register it $handlerInstance->registerTask('crawler_url_source_' . $stack, $taskInstance); - } // END - foreach + } // Put the task handler in registry GenericRegistry::getRegistry()->addInstance('task_handler', $handlerInstance); diff --git a/application/hub/classes/handler/chunks/class_ChunkHandler.php b/application/hub/classes/handler/chunks/class_ChunkHandler.php index e295acd52..8da315670 100644 --- a/application/hub/classes/handler/chunks/class_ChunkHandler.php +++ b/application/hub/classes/handler/chunks/class_ChunkHandler.php @@ -703,7 +703,7 @@ class ChunkHandler extends BaseHubHandler implements HandleableChunks, Registera default: // Invalid step found self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CHUNK-HANDLER: Invalid step %d detected.', $this->finalPackageChunks['assemble_steps'])); break; - } // END - switch + } // Trace message /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: EXIT!'); diff --git a/application/hub/classes/handler/data/message-types/announcement/class_NodeMessageAnnouncementHandler.php b/application/hub/classes/handler/data/message-types/announcement/class_NodeMessageAnnouncementHandler.php index a52d142f3..b2701b261 100644 --- a/application/hub/classes/handler/data/message-types/announcement/class_NodeMessageAnnouncementHandler.php +++ b/application/hub/classes/handler/data/message-types/announcement/class_NodeMessageAnnouncementHandler.php @@ -118,7 +118,7 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl * announce his node to a non-bootstrap and non-master node. */ throw new AnnouncementNotAcceptedException(array($this, $nodeInstance, $messageInstance), BaseHubSystem::EXCEPTION_ANNOUNCEMENT_NOT_ACCEPTED); - } // END - if + } // Register the announcing node with this node $this->registerNodeByMessageInstance($messageInstance); @@ -146,7 +146,7 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl // Add it /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ANNOUNCEMENT-HANDLER: Adding messageData[' . $key . ']=' . $messageData[$key] . ' ...'); $dataSetInstance->addCriteria($key, $messageData[$key]); - } // END - foreach + } } } diff --git a/application/hub/classes/handler/data/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php b/application/hub/classes/handler/data/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php index 716c099f4..e016b6303 100644 --- a/application/hub/classes/handler/data/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php +++ b/application/hub/classes/handler/data/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php @@ -116,7 +116,7 @@ class NodeMessageAnnouncementAnswerHandler extends BaseMessageHandler implements * announcement answer messages. */ throw new NoAnnouncementAttemptedException(array($this, $nodeInstance, $messageInstance), self::EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED); - } // END - if + } // Register the announcing node with this node $this->registerNodeByMessageInstance($messageInstance); @@ -146,7 +146,7 @@ class NodeMessageAnnouncementAnswerHandler extends BaseMessageHandler implements * database layer. */ $dataSetInstance->addCriteria(str_replace('my-', '', $key), $messageData[$key]); - } // END - foreach + } } } diff --git a/application/hub/classes/handler/data/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php b/application/hub/classes/handler/data/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php index fcb3afda4..8925d34d5 100644 --- a/application/hub/classes/handler/data/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php +++ b/application/hub/classes/handler/data/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php @@ -114,7 +114,7 @@ class NodeMessageDhtBootstrapAnswerHandler extends BaseMessageHandler implements * announcement answer messages. */ throw new NoDhtBootstrapAttemptedException(array($this, $dhtInstance, $messageInstance), self::EXCEPTION_DHT_BOOTSTRAP_NOT_ATTEMPTED); - } // END - if + } // Unfinished $this->partialStub('UNHANDLED: messageInstance=' . print_r($messageInstance, TRUE)); @@ -141,7 +141,7 @@ class NodeMessageDhtBootstrapAnswerHandler extends BaseMessageHandler implements * database layer. */ $dataSetInstance->addCriteria(str_replace('my-', '', $key), $messageData[$key]); - } // END - foreach + } } } diff --git a/application/hub/classes/handler/data/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php b/application/hub/classes/handler/data/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php index d3ab2e9b6..0e51a128f 100644 --- a/application/hub/classes/handler/data/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php +++ b/application/hub/classes/handler/data/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php @@ -105,7 +105,7 @@ class NodeMessageRequestNodeListAnswerHandler extends BaseMessageHandler impleme * request-node-list answer messages. */ throw new NoRequestNodeListAttemptedException(array($this, $nodeInstance, $messageInstance), self::EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED); - } // END - if + } // Register the announcing node with this node $this->registerNodeByMessageInstance($messageInstance); @@ -141,7 +141,7 @@ class NodeMessageRequestNodeListAnswerHandler extends BaseMessageHandler impleme * database layer. */ $dataSetInstance->addCriteria(str_replace('my-', '', $key), $messageData[$key]); - } // END - foreach + } } } diff --git a/application/hub/classes/handler/data/message-types/class_BaseMessageHandler.php b/application/hub/classes/handler/data/message-types/class_BaseMessageHandler.php index be36b09f6..668171f16 100644 --- a/application/hub/classes/handler/data/message-types/class_BaseMessageHandler.php +++ b/application/hub/classes/handler/data/message-types/class_BaseMessageHandler.php @@ -60,7 +60,7 @@ abstract class BaseMessageHandler extends BaseDataHandler { if ($this->getLastException() instanceof FrameworkException) { // "Determine" the right status code (may differ from exception to exception) $this->debugInstance(sprintf('[%s:%d]: lastException=%s,message=%s is unfinished.', __METHOD__, __LINE__, $this->getLastException()->__toString(), $this->getLastException()->getMessage())); - } // END - if + } // Return the status code return $statusCode; diff --git a/application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php b/application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php index 6701a57ff..31024504f 100644 --- a/application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php +++ b/application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php @@ -109,7 +109,7 @@ class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements Handl * This node is not accepting DHT bootstrap requests. */ throw new DhtBootstrapNotAcceptedException(array($this, $messageInstance), self::EXCEPTION_DHT_BOOTSTRAP_NOT_ACCEPTED); - } // END - if + } // Register the DHT bootstrap requesting node with this node $this->registerNodeByMessageInstance($messageInstance); @@ -136,7 +136,7 @@ class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements Handl // Add it $dataSetInstance->addCriteria($key, $messageData[$key]); - } // END - foreach + } } } diff --git a/application/hub/classes/handler/data/message-types/requests/class_NodeMessageRequestNodeListHandler.php b/application/hub/classes/handler/data/message-types/requests/class_NodeMessageRequestNodeListHandler.php index ab644e7ad..55aea718f 100644 --- a/application/hub/classes/handler/data/message-types/requests/class_NodeMessageRequestNodeListHandler.php +++ b/application/hub/classes/handler/data/message-types/requests/class_NodeMessageRequestNodeListHandler.php @@ -97,7 +97,7 @@ class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements Ha * exception to abort any further processing. */ throw new RequestNotAcceptedException(array($this, $nodeInstance, $messageInstance), self::EXCEPTION_REQUEST_NOT_ACCEPTED); - } // END - if + } // Register the announcing node with this node $this->registerNodeByMessageInstance($messageInstance); @@ -124,7 +124,7 @@ class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements Ha // Add it $dataSetInstance->addCriteria($key, $messageData[$key]); - } // END - foreach + } } } diff --git a/application/hub/classes/handler/package/class_NetworkPackageHandler.php b/application/hub/classes/handler/package/class_NetworkPackageHandler.php index cc1ce6d1b..687b1d0d8 100644 --- a/application/hub/classes/handler/package/class_NetworkPackageHandler.php +++ b/application/hub/classes/handler/package/class_NetworkPackageHandler.php @@ -1102,10 +1102,8 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei * @return void */ public function sendEncodedData () { - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!'); - // Make sure there is pending encoded data + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!'); assert($this->isEncodedDataPending()); // Pop current data from stack @@ -1123,19 +1121,15 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei $socketInstance = $encodedDataArray[self::RAW_INDEX_SOCKET_INSTANCE]; $encodedDataArray[self::RAW_INDEX_SOCKET_INSTANCE] = NULL; - // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Calling socketInstance->writeBufferToSocketByArray(%d,%d) ...', count($encodedDataArray), $sentBytes)); - // And deliver it + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Calling socketInstance->writeBufferToSocketByArray(%d,%d) ...', count($encodedDataArray), $sentBytes)); if (!$socketInstance->writeBufferToSocketByArray($encodedDataArray, $sentBytes)) { // Something bad happened while writing to socket $socketInstance->handleSocketError(__METHOD__, __LINE__); } - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: sentBytes[%s]=%d', gettype($sentBytes), $sentBytes)); - // If there was an error, don't continue here + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: sentBytes[%s]=%d', gettype($sentBytes), $sentBytes)); if (($sentBytes === 0) && (strlen($encodedDataArray[self::RAW_INDEX_ENCODED_DATA]) > 0)) { // Nothing sent means all data has been sent /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: All sent! (LINE=' . __LINE__ . ')'); @@ -1149,13 +1143,11 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei // Set it back $encodedDataArray[self::RAW_INDEX_SOCKET_INSTANCE] = $socketInstance; - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Pushing raw data back to stacker, as still some data is pending delivery.'); - // Push array back in stack + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Pushing raw data back to stacker, as still some data is pending delivery.'); $this->getStackInstance()->pushNamed(self::STACKER_NAME_OUTGOING_STREAM, $encodedDataArray); - // Debug message + // Trace message /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!'); } @@ -1169,16 +1161,12 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei * @return $isPending Whether decoded raw data is pending */ private function isRawDataPending () { - // Trace message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!'); - // Just return whether the stack is not empty + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!'); $isPending = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_DECODED_INCOMING)); - // Trace message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: isPending=%d - EXIT!', intval($isPending))); - // Return the status + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: isPending=%d - EXIT!', intval($isPending))); return $isPending; } @@ -1188,19 +1176,15 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei * @return $hasArrived Whether new raw package data has arrived for processing */ public function isNewRawDataPending () { - // Trace message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Calling this->getListenerPoolInstance()->accept(%s) ... - CALLED!', $this->getVisitorInstance())); - // Visit the pool. This monitors the pool for incoming raw data. + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Calling this->getListenerPoolInstance()->accept(%s) ... - CALLED!', $this->getVisitorInstance())); $this->getListenerPoolInstance()->accept($this->getVisitorInstance()); // Check for new data arrival $hasArrived = $this->isRawDataPending(); - // Trace message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: hasArrived=%d - EXIT!', intval($hasArrived))); - // Return the status + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: hasArrived=%d - EXIT!', intval($hasArrived))); return $hasArrived; } diff --git a/application/hub/classes/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php b/application/hub/classes/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php index 2fa8598c7..924f060f3 100644 --- a/application/hub/classes/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php +++ b/application/hub/classes/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php @@ -103,7 +103,7 @@ abstract class BaseIpV4ProtocolHandler extends BaseProtocolHandler { // Set port $this->setPort($locatorInstance->getUnlPort()); - } // END - if + } // Return result /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('IPV4-PROTOCOL-HANDLER: isValid=%d - EXIT!', intval($isValid))); diff --git a/application/hub/classes/handler/raw_data/tcp/class_TcpRawDataHandler.php b/application/hub/classes/handler/raw_data/tcp/class_TcpRawDataHandler.php index a979a0344..9bf0af4e6 100644 --- a/application/hub/classes/handler/raw_data/tcp/class_TcpRawDataHandler.php +++ b/application/hub/classes/handler/raw_data/tcp/class_TcpRawDataHandler.php @@ -127,7 +127,7 @@ class TcpRawDataHandler extends BaseRawDataHandler implements Networkable { /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TCP-RAW-DATA-HANDLER: Adding %d(%s) bytes to stacker ...', strlen($rawData), $rawData)); $this->addRawDataToStacker($rawData); } - } // END - while + } // Trace message /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-RAW-DATA-HANDLER: EXIT!'); diff --git a/application/hub/classes/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php b/application/hub/classes/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php index 1609fe028..bd9f5df5b 100644 --- a/application/hub/classes/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php +++ b/application/hub/classes/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php @@ -101,7 +101,7 @@ class TcpConnectionHelper extends BaseIpV4ConnectionHelper implements Connection if (strpos($packageInstance->getRecipientUnl(), ':') === FALSE) { // No ip:port! $helperInstance->debugInstance(sprintf('[%s:%d]: recipient=%s does not contain ":". Please fix this.', __METHOD__, __LINE__, $packageInstance->getRecipientUnl())); - } // END - if + } // "explode" the ip:port, so index 1 will be the port number // @TODO Rewrite this test for UNLs diff --git a/application/hub/classes/info/connection/class_ConnectionInfo.php b/application/hub/classes/info/connection/class_ConnectionInfo.php index 31f46d3e3..e8da7f9f8 100644 --- a/application/hub/classes/info/connection/class_ConnectionInfo.php +++ b/application/hub/classes/info/connection/class_ConnectionInfo.php @@ -208,7 +208,7 @@ class ConnectionInfo extends BaseInfo implements ShareableInfo, Registerable { if (!$socketInstance->determineSocketPeerName($socketAddress, $socketPort)) { // Did not work throw new InvalidSocketException(array($this, $socketInstance->getSocketResource()), self::EXCEPTION_INVALID_SOCKET); - } // END - if + } // Fill the generic array with several data from the listener: /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-INFO: socketAddress=%s,socketPort=%d', $socketAddress, $socketPort)); diff --git a/application/hub/classes/iterator/network/class_NetworkListenIterator.php b/application/hub/classes/iterator/network/class_NetworkListenIterator.php index 82d446586..c4f17aef2 100644 --- a/application/hub/classes/iterator/network/class_NetworkListenIterator.php +++ b/application/hub/classes/iterator/network/class_NetworkListenIterator.php @@ -80,7 +80,7 @@ class NetworkListenIterator extends BaseIterator implements Iterator { if (!$this->valid()) { // Throw an exception here throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS); - } // END - if + } // Now get the entry $current = $this->getListInstance()->getEntry($this->key()); diff --git a/application/hub/classes/iterator/pool/handler/class_HandlerPoolIterator.php b/application/hub/classes/iterator/pool/handler/class_HandlerPoolIterator.php index 168a9e4f8..4466c7dd0 100644 --- a/application/hub/classes/iterator/pool/handler/class_HandlerPoolIterator.php +++ b/application/hub/classes/iterator/pool/handler/class_HandlerPoolIterator.php @@ -80,7 +80,7 @@ class HandlerPoolIterator extends BaseIterator implements Iterator { if (!$this->valid()) { // Throw an exception here throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS); - } // END - if + } // Now get the entry $current = $this->getListInstance()->getEntry($this->key()); diff --git a/application/hub/classes/iterator/pool/monitor/class_MonitorPoolIterator.php b/application/hub/classes/iterator/pool/monitor/class_MonitorPoolIterator.php index e08bd3ab7..f8784f211 100644 --- a/application/hub/classes/iterator/pool/monitor/class_MonitorPoolIterator.php +++ b/application/hub/classes/iterator/pool/monitor/class_MonitorPoolIterator.php @@ -81,7 +81,7 @@ class MonitorPoolIterator extends BaseIterator implements Iterator, Registerable if (!$this->valid()) { // Throw an exception here throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS); - } // END - if + } // Now get the entry $current = $this->getListInstance()->getEntry($this->key()); diff --git a/application/hub/classes/iterator/pool/shutdown/class_ShutdownPoolIterator.php b/application/hub/classes/iterator/pool/shutdown/class_ShutdownPoolIterator.php index 4613ed2d7..9300f66ae 100644 --- a/application/hub/classes/iterator/pool/shutdown/class_ShutdownPoolIterator.php +++ b/application/hub/classes/iterator/pool/shutdown/class_ShutdownPoolIterator.php @@ -78,7 +78,7 @@ class ShutdownPoolIterator extends BaseIterator implements Iterator { if (!$this->valid()) { // Throw an exception here throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS); - } // END - if + } // Now get the entry $current = $this->getListInstance()->getEntry($this->key()); diff --git a/application/hub/classes/iterator/pool/tasks/class_TaskPoolIterator.php b/application/hub/classes/iterator/pool/tasks/class_TaskPoolIterator.php index fd15e7a01..0957ffddd 100644 --- a/application/hub/classes/iterator/pool/tasks/class_TaskPoolIterator.php +++ b/application/hub/classes/iterator/pool/tasks/class_TaskPoolIterator.php @@ -81,7 +81,7 @@ class TaskPoolIterator extends BaseIterator implements Iterator, Registerable { if (!$this->valid()) { // Throw an exception here throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS); - } // END - if + } // Now get the entry $current = $this->getListInstance()->getEntry($this->key()); diff --git a/application/hub/classes/listener/class_BaseListener.php b/application/hub/classes/listener/class_BaseListener.php index c556b63fa..68c0fc45e 100644 --- a/application/hub/classes/listener/class_BaseListener.php +++ b/application/hub/classes/listener/class_BaseListener.php @@ -233,7 +233,7 @@ abstract class BaseListener extends BaseHubSystem implements Visitable { if ($this->isServerSocketRegistered($socketInstance)) { // Already registered throw new SocketAlreadyRegisteredException(array($this, $socketInstance->getSocketResource()), self::EXCEPTION_SOCKET_ALREADY_REGISTERED); - } // END - if + } // Get a connection info instance $infoInstance = ConnectionInfoFactory::createConnectionInfoInstance($this->getProtocolName(), StorableSocket::CONNECTION_TYPE_SERVER); @@ -242,7 +242,7 @@ abstract class BaseListener extends BaseHubSystem implements Visitable { if (!($infoInstance instanceof ShareableInfo)) { // Should not happen throw new LogicException(sprintf('infoInstance[]=%s does not implement ShareableInfo', gettype($infoInstance))); - } // END - if + } // Will the info instance with listener data $infoInstance->fillWithListenerInformation($this); @@ -307,7 +307,7 @@ abstract class BaseListener extends BaseHubSystem implements Visitable { if ($this->getPoolInstance() instanceof Poolable) { // Visit pool instance $this->getPoolInstance()->accept($visitorInstance); - } // END - if + } // Debug message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getProtocolName()) . '-LISTENER: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - EXIT!'); @@ -337,7 +337,7 @@ abstract class BaseListener extends BaseHubSystem implements Visitable { if (is_null($iteratorInstance)) { // Throw NPE throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } // END - if + } // Is it valid? /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-LISTENER: iteratorInstance->valid()=%d', strtoupper($this->getProtocolName()), intval($iteratorInstance->valid()))); @@ -345,7 +345,7 @@ abstract class BaseListener extends BaseHubSystem implements Visitable { // Then rewind it /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-LISTENER: Rewinding iterator ...', strtoupper($this->getProtocolName()))); $iteratorInstance->rewind(); - } // END - if + } // Get current instance $socketInstance = $iteratorInstance->current(); @@ -400,7 +400,7 @@ abstract class BaseListener extends BaseHubSystem implements Visitable { // Nothing has changed on the listener /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-LISTENER: No new connection on listener ... - EXIT!', strtoupper($this->getProtocolName()))); return; - } // END - if + } // Get a connection info instance $infoInstance = ConnectionInfoFactory::createConnectionInfoInstance($this->getProtocolName(), StorableSocket::CONNECTION_TYPE_INCOMING); @@ -410,7 +410,7 @@ abstract class BaseListener extends BaseHubSystem implements Visitable { if (!($infoInstance instanceof ShareableInfo)) { // Should not happen throw new LogicException(sprintf('infoInstance[]=%s does not implement ShareableInfo', gettype($infoInstance))); - } // END - if + } // Will the info instance with listener data $infoInstance->fillWithSocketPeerInformation($socketInstance); @@ -423,7 +423,7 @@ abstract class BaseListener extends BaseHubSystem implements Visitable { if (!$socketInstance->determineSocketPeerName($peerAddress, $peerPort)) { // Handle this socket error $socketInstance->handleSocketError(__METHOD__, __LINE__); - } // END - if + } // Set all required data //* DEBUG-DIE: */ $infoInstance->debugInstance(); diff --git a/application/hub/classes/listener/class_BaseListenerDecorator.php b/application/hub/classes/listener/class_BaseListenerDecorator.php index 2b942b67d..8ae45606f 100644 --- a/application/hub/classes/listener/class_BaseListenerDecorator.php +++ b/application/hub/classes/listener/class_BaseListenerDecorator.php @@ -186,7 +186,7 @@ abstract class BaseListenerDecorator extends BaseDecorator implements Visitable // No data is pending so skip further code silently /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getProtocolName()) . '-LISTENER-DECORATOR: No data pending on handlerInstance=' . $handlerInstance->__toString() . ' - EXIT!'); return; - } // END - if + } // Get receiver (network package) instance $receiverInstance = NetworkPackageHandlerFactory::createNetworkPackageHandlerInstance(); diff --git a/application/hub/classes/listener/socket/class_SocketFileListener.php b/application/hub/classes/listener/socket/class_SocketFileListener.php index 4a97d89ed..1b06630c6 100644 --- a/application/hub/classes/listener/socket/class_SocketFileListener.php +++ b/application/hub/classes/listener/socket/class_SocketFileListener.php @@ -135,7 +135,7 @@ class SocketFileListener extends BaseListener implements Listenable { // Is already different protocol return FALSE; - } // END - if + } // Debugging /* DEBUG-DIE: */ die(__METHOD__.':packageInstance='.print_r($packageInstance, TRUE)); diff --git a/application/hub/classes/listener/tcp/decorators/class_ClientTcpListenerDecorator.php b/application/hub/classes/listener/tcp/decorators/class_ClientTcpListenerDecorator.php index 532498afb..ccc76a089 100644 --- a/application/hub/classes/listener/tcp/decorators/class_ClientTcpListenerDecorator.php +++ b/application/hub/classes/listener/tcp/decorators/class_ClientTcpListenerDecorator.php @@ -107,7 +107,7 @@ class ClientTcpListenerDecorator extends BaseListenerDecorator implements Listen // Is already different protocol return FALSE; - } // END - if + } // Debugging /* DEBUG-DIE: */ die(__METHOD__ . ':packageInstance=' . print_r($packageInstance, TRUE)); diff --git a/application/hub/classes/listener/tcp/decorators/class_HubTcpListenerDecorator.php b/application/hub/classes/listener/tcp/decorators/class_HubTcpListenerDecorator.php index 66dab9fad..26c57679f 100644 --- a/application/hub/classes/listener/tcp/decorators/class_HubTcpListenerDecorator.php +++ b/application/hub/classes/listener/tcp/decorators/class_HubTcpListenerDecorator.php @@ -107,7 +107,7 @@ class HubTcpListenerDecorator extends BaseListenerDecorator implements Listenabl // Is already different protocol return FALSE; - } // END - if + } // Debugging //* DEBUG-DIE: */ die(__METHOD__ . ':packageInstance=' . print_r($packageInstance, TRUE)); diff --git a/application/hub/classes/listener/udp/decorators/class_ClientUdpListenerDecorator.php b/application/hub/classes/listener/udp/decorators/class_ClientUdpListenerDecorator.php index 028738c22..3a87327e7 100644 --- a/application/hub/classes/listener/udp/decorators/class_ClientUdpListenerDecorator.php +++ b/application/hub/classes/listener/udp/decorators/class_ClientUdpListenerDecorator.php @@ -107,7 +107,7 @@ class ClientUdpListenerDecorator extends BaseListenerDecorator implements Listen // Is already different protocol return FALSE; - } // END - if + } // Debugging /* DEBUG-DIE: */ die(__METHOD__ . ':packageInstance=' . print_r($packageInstance, TRUE)); diff --git a/application/hub/classes/listener/udp/decorators/class_HubUdpListenerDecorator.php b/application/hub/classes/listener/udp/decorators/class_HubUdpListenerDecorator.php index d67923d70..71a739c8f 100644 --- a/application/hub/classes/listener/udp/decorators/class_HubUdpListenerDecorator.php +++ b/application/hub/classes/listener/udp/decorators/class_HubUdpListenerDecorator.php @@ -107,7 +107,7 @@ class HubUdpListenerDecorator extends BaseListenerDecorator implements Listenabl // Is already different protocol return FALSE; - } // END - if + } // Debugging /* DEBUG-DIE: */ die(__METHOD__ . ':packageInstance=' . print_r($packageInstance, TRUE)); diff --git a/application/hub/classes/locator/class_UniversalNodeLocator.php b/application/hub/classes/locator/class_UniversalNodeLocator.php index b94120832..9659b55d3 100644 --- a/application/hub/classes/locator/class_UniversalNodeLocator.php +++ b/application/hub/classes/locator/class_UniversalNodeLocator.php @@ -137,7 +137,7 @@ class UniversalNodeLocator extends BaseHubSystem implements LocateableNode, Regi $this->unlData = []; // Copy all found entries - foreach (array( + foreach ([ LocateableNode::UNL_PART_PROTOCOL, LocateableNode::UNL_PART_ADDRESS, LocateableNode::UNL_PART_EXTRA, @@ -146,7 +146,7 @@ class UniversalNodeLocator extends BaseHubSystem implements LocateableNode, Regi NodeInformationDatabaseFrontend::DB_COLUMN_PRIVATE_KEY_HASH, NodeInformationDatabaseFrontend::DB_COLUMN_NODE_MODE, NodeInformationDatabaseFrontend::DB_COLUMN_INTERNAL_UNL, - NodeInformationDatabaseFrontend::DB_COLUMN_EXTERNAL_UNL) as $key) { + NodeInformationDatabaseFrontend::DB_COLUMN_EXTERNAL_UNL] as $key) { // Init entry /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNIVERSAL-NODE-LOCATOR: key=%s', $key)); $this->unlData[$key] = NULL; diff --git a/application/hub/classes/miner/chash/class_HubCoinMiner.php b/application/hub/classes/miner/chash/class_HubCoinMiner.php index 79316bddd..dcc7f61c4 100644 --- a/application/hub/classes/miner/chash/class_HubCoinMiner.php +++ b/application/hub/classes/miner/chash/class_HubCoinMiner.php @@ -92,7 +92,7 @@ class HubCoinMiner extends BaseHubMiner implements MinerHelper, Registerable { // ... and finally queue it to the in-buffer queue $this->queueUnitInstanceToInBuffer($unitInstance); - } // END - for + } } /** @@ -106,7 +106,7 @@ class HubCoinMiner extends BaseHubMiner implements MinerHelper, Registerable { if ($this->getStateInstance()->isMinerStateVirgin()) { // We can silently skip here, until the generation is finished return; - } // END - if + } // @TODO Implement this method $this->partialStub('Please implement this method.'); diff --git a/application/hub/classes/miner/class_BaseHubMiner.php b/application/hub/classes/miner/class_BaseHubMiner.php index efc25d476..95de4f941 100644 --- a/application/hub/classes/miner/class_BaseHubMiner.php +++ b/application/hub/classes/miner/class_BaseHubMiner.php @@ -218,8 +218,8 @@ abstract class BaseHubMiner extends BaseHubSystem implements Updateable { if ((!$this->isInBufferQueueFilled()) && (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('miner_test_units_enabled') == 'Y')) { // Then fill the in-buffer with (one) test-unit(s) $this->fillInBufferQueueWithTestUnits(); - } // END - if - } // END - if + } + } } /** @@ -255,7 +255,7 @@ abstract class BaseHubMiner extends BaseHubSystem implements Updateable { if (count($this->producersInitialized) == self::MAX_PRODUCERS) { // Change it to 'booting' MinerStateFactory::createMinerStateInstanceByName('booting'); - } // END - if + } } } diff --git a/application/hub/classes/package/assembler/class_PackageAssembler.php b/application/hub/classes/package/assembler/class_PackageAssembler.php index f5662d608..36be091c1 100644 --- a/application/hub/classes/package/assembler/class_PackageAssembler.php +++ b/application/hub/classes/package/assembler/class_PackageAssembler.php @@ -234,7 +234,7 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, // Push it on stack $this->getStackInstance()->pushNamed(self::STACKER_NAME_MULTIPLE_MESSAGE, $message); - } // END - foreach + } // Clear pending data $this->clearPendingData(); @@ -263,7 +263,7 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, if (substr($packageInstance->getRawData(), -1, 1) == PackageFragmenter::CHUNK_SEPARATOR) { // Remove it $packageInstance->setRawData(substr($packageInstance->getRawData(), 0, -1)); - } // END - if + } /* * "explode" the string from 'raw_data' with chunk separator to get an @@ -281,11 +281,17 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, * Handles multiple messages. * * @return void + * @throws BadMethodCallException If some bad method invocation has happened */ public function handleMultipleMessages () { - // Assert on condition - assert($this->ifMultipleMessagesPending()); - assert($this->isPendingDataEmpty()); + // Validate conditions + if (!$this->ifMultipleMessagesPending()) { + // Opps? + throw new BadMethodCallException('No multiple messages are pending but method called'); + } elseif (!$this->isPendingDataEmpty()) { + // Pending data is not empty but invoked + throw new BadMethodCallException(sprintf('this->pendingData()=%d still filled but method called', strlen($this->pendingData))); + } // "Pop" next entry from stack and set it as new pending data $this->pendingData = $this->getStackInstance()->popNamed(self::STACKER_NAME_MULTIPLE_MESSAGE); diff --git a/application/hub/classes/package/fragmenter/class_PackageFragmenter.php b/application/hub/classes/package/fragmenter/class_PackageFragmenter.php index ccd8c8a52..cf16ecd98 100644 --- a/application/hub/classes/package/fragmenter/class_PackageFragmenter.php +++ b/application/hub/classes/package/fragmenter/class_PackageFragmenter.php @@ -400,7 +400,7 @@ class PackageFragmenter extends BaseHubSystem implements Fragmentable, Registera // Add the chunk to the propper array and do all the stuff there $this->addChunkData($finalHash, $chunkData); - } // END - for + } // Debug output //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: Raw data of ' . strlen($rawData) . ' bytes has been fragmented into ' . count($this->chunks[$finalHash]) . ' chunk(s).'); @@ -452,7 +452,7 @@ class PackageFragmenter extends BaseHubSystem implements Fragmentable, Registera // Then initialize it $this->chunks[$finalHash] = []; $this->chunkHashes[$finalHash] = []; - } // END - if + } // Add both array_push($this->chunks[$finalHash] , $rawData); diff --git a/application/hub/classes/pools/class_BasePool.php b/application/hub/classes/pools/class_BasePool.php index 6bb95eadf..c2ba9855f 100644 --- a/application/hub/classes/pools/class_BasePool.php +++ b/application/hub/classes/pools/class_BasePool.php @@ -80,7 +80,7 @@ abstract class BasePool extends BaseHubSystem implements Poolable, Visitable { if (!$this->getPoolEntriesInstance()->isGroupSet($group)) { // Create the missing pool group $this->getPoolEntriesInstance()->addGroup($group); - } // END - if + } // Add it to given pool group $this->getPoolEntriesInstance()->addInstance($group, $poolName, $visitableInstance); @@ -154,7 +154,7 @@ abstract class BasePool extends BaseHubSystem implements Poolable, Visitable { // Rewind it $iteratorInstance->rewind(); - } // END - if + } // Get current entry $poolEntry = $iteratorInstance->current(); diff --git a/application/hub/classes/producer/cruncher/keys/cruncher/class_CruncherKeyProducer.php b/application/hub/classes/producer/cruncher/keys/cruncher/class_CruncherKeyProducer.php index 7f36ee430..21f7f9cd7 100644 --- a/application/hub/classes/producer/cruncher/keys/cruncher/class_CruncherKeyProducer.php +++ b/application/hub/classes/producer/cruncher/keys/cruncher/class_CruncherKeyProducer.php @@ -131,7 +131,7 @@ class CruncherKeyProducer extends BaseKeyProducer implements KeyProducer, Regist // At last re-init the stack $this->initOutgoingQueue(); - } // END - if + } // Continue with next one $this->getIteratorInstance()->next(); diff --git a/application/hub/classes/recipient/direct/class_DirectRecipient.php b/application/hub/classes/recipient/direct/class_DirectRecipient.php index 7a745b36e..f5c82777b 100644 --- a/application/hub/classes/recipient/direct/class_DirectRecipient.php +++ b/application/hub/classes/recipient/direct/class_DirectRecipient.php @@ -90,7 +90,7 @@ class DirectRecipient extends BaseRecipient implements Recipient { // Add it as recipient $listInstance->addEntry('unl', $unlData); - } // END - foreach + } // Trace message /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DIRECT-RECIPIENT: EXIT!'); diff --git a/application/hub/classes/recipient/self/class_SelfRecipient.php b/application/hub/classes/recipient/self/class_SelfRecipient.php index 63c0b0366..60e7317a9 100644 --- a/application/hub/classes/recipient/self/class_SelfRecipient.php +++ b/application/hub/classes/recipient/self/class_SelfRecipient.php @@ -79,7 +79,7 @@ class SelfRecipient extends BaseRecipient implements Recipient { if (!empty($unl)) { // Add it to the list $listInstance->addEntry('unl', $unl); - } // END - if + } // Trace message /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SELF-RECIPIENT: EXIT!'); diff --git a/application/hub/classes/recipient/upper/class_UpperRecipient.php b/application/hub/classes/recipient/upper/class_UpperRecipient.php index 38da98e95..75d4831cb 100644 --- a/application/hub/classes/recipient/upper/class_UpperRecipient.php +++ b/application/hub/classes/recipient/upper/class_UpperRecipient.php @@ -86,14 +86,14 @@ class UpperRecipient extends BaseRecipient implements Recipient { // Then stop adding more /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UPPER-RECIPIENT: Going to abort at maximum of ' . FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('package_recipient_max_count') . ' recipients!'); break; - } // END - if + } // Debug message /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UPPER-RECIPIENT: Adding node ' . print_r($unlData, TRUE) . ' as recipient.'); // Add the entry $listInstance->addEntry('unl', $unlData); - } // END - foreach + } // Trace message /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UPPER-RECIPIENT: EXIT!'); diff --git a/application/hub/classes/registry/objects/class_ObjectTypeRegistry.php b/application/hub/classes/registry/objects/class_ObjectTypeRegistry.php index cf1169ca9..09b1516b3 100644 --- a/application/hub/classes/registry/objects/class_ObjectTypeRegistry.php +++ b/application/hub/classes/registry/objects/class_ObjectTypeRegistry.php @@ -54,7 +54,7 @@ class ObjectTypeRegistry extends BaseRegistry implements Register { if (is_null(self::$registryInstance)) { // Not yet, so create one self::$registryInstance = new ObjectTypeRegistry(); - } // END - if + } // Return the instance return self::$registryInstance; diff --git a/application/hub/classes/resolver/controller/console/class_HubConsoleControllerResolver.php b/application/hub/classes/resolver/controller/console/class_HubConsoleControllerResolver.php index b9750b317..0818e710b 100644 --- a/application/hub/classes/resolver/controller/console/class_HubConsoleControllerResolver.php +++ b/application/hub/classes/resolver/controller/console/class_HubConsoleControllerResolver.php @@ -95,7 +95,7 @@ class HubConsoleControllerResolver extends BaseControllerResolver implements Con if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) { // This command has an invalid instance! throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); - } // END - if + } // Set last controller $this->setResolvedInstance($controllerInstance); diff --git a/application/hub/classes/resolver/controller/html/class_HubHtmlControllerResolver.php b/application/hub/classes/resolver/controller/html/class_HubHtmlControllerResolver.php index 71ad86c5e..ba1f74aa4 100644 --- a/application/hub/classes/resolver/controller/html/class_HubHtmlControllerResolver.php +++ b/application/hub/classes/resolver/controller/html/class_HubHtmlControllerResolver.php @@ -95,7 +95,7 @@ class HubHtmlControllerResolver extends BaseControllerResolver implements Contro if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) { // This command has an invalid instance! throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); - } // END - if + } // Set last controller $this->setResolvedInstance($controllerInstance); diff --git a/application/hub/classes/resolver/protocol/tcp/class_TcpProtocolResolver.php b/application/hub/classes/resolver/protocol/tcp/class_TcpProtocolResolver.php index 7b2a4fdb1..d4df9a941 100644 --- a/application/hub/classes/resolver/protocol/tcp/class_TcpProtocolResolver.php +++ b/application/hub/classes/resolver/protocol/tcp/class_TcpProtocolResolver.php @@ -127,8 +127,8 @@ class TcpProtocolResolver extends BaseProtocolResolver implements ProtocolResolv case 'internal': // Internal IP $address = ConsoleTools::acquireSelfIPAddress(); break; - } // END - switch - } // END - if + } + } // Put all together $unl = sprintf('%s://%s:%s', diff --git a/application/hub/classes/resolver/state/class_BaseStateResolver.php b/application/hub/classes/resolver/state/class_BaseStateResolver.php index e1a4dc1b6..7979bf563 100644 --- a/application/hub/classes/resolver/state/class_BaseStateResolver.php +++ b/application/hub/classes/resolver/state/class_BaseStateResolver.php @@ -113,7 +113,7 @@ abstract class BaseStateResolver extends BaseResolver { if (!class_exists($this->getClassName())) { // Throw an exception here throw new UnresolveableStateException(array($this, $stateName), self::EXCEPTION_INVALID_STATE); - } // END - if + } // Initialize the state $stateInstance = ObjectFactory::createObjectByName( @@ -141,7 +141,7 @@ abstract class BaseStateResolver extends BaseResolver { if (empty($stateName)) { // Then thrown an exception here throw new EmptyVariableException(array($this, 'stateName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } // END - if + } // Create class name $className = $this->statePrefix . StringUtils::convertToClassName($stateName) . 'State'; @@ -162,7 +162,7 @@ abstract class BaseStateResolver extends BaseResolver { // All is tried, give it up here throw new DefaultStateException($this, self::EXCEPTION_DEFAULT_STATE_GONE); } - } // END - while + } // Return the result return $isValid; diff --git a/application/hub/classes/resolver/state/peer/class_PeerStateResolver.php b/application/hub/classes/resolver/state/peer/class_PeerStateResolver.php index 0e5a93b6b..8e427324b 100644 --- a/application/hub/classes/resolver/state/peer/class_PeerStateResolver.php +++ b/application/hub/classes/resolver/state/peer/class_PeerStateResolver.php @@ -89,8 +89,8 @@ class PeerStateResolver extends BaseStateResolver implements StateResolver { if (!$socketInstance->isValidSocket()) { // Then abort here with an exception (may happen after socket_shutdown()) throw new InvalidSocketException(array($helperInstance, $socketInstance->getSocketResource()), self::EXCEPTION_INVALID_SOCKET); - } // END - if - } // END - if + } + } // Translate the error code to an own name $errorName = $socketInstance->translateLastSocketErrorCodeToName(); diff --git a/application/hub/classes/source/urls/class_CrawlerUploadedListUrlSource.php b/application/hub/classes/source/urls/class_CrawlerUploadedListUrlSource.php index e1aab13fa..60aaf6501 100644 --- a/application/hub/classes/source/urls/class_CrawlerUploadedListUrlSource.php +++ b/application/hub/classes/source/urls/class_CrawlerUploadedListUrlSource.php @@ -170,7 +170,7 @@ class CrawlerUploadedListUrlSource extends BaseUrlSource implements UrlSource, R // Rewind to start $this->getDirectoryInstance()->getDirectoryIteratorInstance()->rewind(); - } // END - if + } // Read next entry /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CRAWLER-UPLOADED-LIST-URL-SOURCE: this->csvFileImported=' . print_r($this->csvFileImported, TRUE)); @@ -182,7 +182,7 @@ class CrawlerUploadedListUrlSource extends BaseUrlSource implements UrlSource, R // Skip further processing /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CRAWLER-UPLOADED-LIST-URL-SOURCE: directoryEntry(' . strlen($directoryEntry) . ')=' . $directoryEntry . ' - SKIPPED!'); return FALSE; - } // END - if + } // Init SPL file instance $infoInstance = new SplFileInfo($this->csvFilePath . '/' . $directoryEntry); @@ -342,7 +342,7 @@ class CrawlerUploadedListUrlSource extends BaseUrlSource implements UrlSource, R // This file as been fully read, so don't push it back on stack. return; - } // END - if + } // ... with a fixed amount of elements, later enhancements may accept more assert(count($csvData) == self::CRAWL_ENTRY_SIZE); diff --git a/application/hub/classes/states/communicator/class_BaseCommunicatorState.php b/application/hub/classes/states/communicator/class_BaseCommunicatorState.php index 8b1ca9206..7a9b31ba3 100644 --- a/application/hub/classes/states/communicator/class_BaseCommunicatorState.php +++ b/application/hub/classes/states/communicator/class_BaseCommunicatorState.php @@ -60,7 +60,7 @@ abstract class BaseCommunicatorState extends BaseState { if (!$this instanceof CommunicatorActiveState) { // Throw the exception throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); - } // END - if + } } /** diff --git a/application/hub/classes/states/crawler/class_BaseCrawlerState.php b/application/hub/classes/states/crawler/class_BaseCrawlerState.php index f5d1d6535..4116debe1 100644 --- a/application/hub/classes/states/crawler/class_BaseCrawlerState.php +++ b/application/hub/classes/states/crawler/class_BaseCrawlerState.php @@ -52,7 +52,7 @@ abstract class BaseCrawlerState extends BaseState { if (!$this instanceof CrawlerActiveState) { // Throw the exception throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); - } // END - if + } } } diff --git a/application/hub/classes/states/cruncher/class_BaseCruncherState.php b/application/hub/classes/states/cruncher/class_BaseCruncherState.php index 82c9969ac..c5d6951f4 100644 --- a/application/hub/classes/states/cruncher/class_BaseCruncherState.php +++ b/application/hub/classes/states/cruncher/class_BaseCruncherState.php @@ -52,7 +52,7 @@ abstract class BaseCruncherState extends BaseState { if (!$this instanceof CruncherActiveState) { // Throw the exception throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); - } // END - if + } } /** diff --git a/application/hub/classes/states/dht/class_BaseDhtState.php b/application/hub/classes/states/dht/class_BaseDhtState.php index ed338938e..8556de969 100644 --- a/application/hub/classes/states/dht/class_BaseDhtState.php +++ b/application/hub/classes/states/dht/class_BaseDhtState.php @@ -53,7 +53,7 @@ abstract class BaseDhtState extends BaseState { if ((!$this instanceof DhtVirginState) && (!$this instanceof DhtInitState)) { // Throw the exception throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); - } // END - if + } } /** diff --git a/application/hub/classes/states/miner/booting/class_MinerBootingState.php b/application/hub/classes/states/miner/booting/class_MinerBootingState.php index 7b3522aa5..36908ef47 100644 --- a/application/hub/classes/states/miner/booting/class_MinerBootingState.php +++ b/application/hub/classes/states/miner/booting/class_MinerBootingState.php @@ -71,7 +71,7 @@ class MinerBootingState extends BaseMinerState implements Stateable { if (isset($this->bootedProducer[$executorInstance->__toString()])) { // Then silently skip this return; - } // END - if + } // Debug message /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MINER-STATE: Calling prepareBlockProduction() on ' . $executorInstance->__toString() . ' ...'); diff --git a/application/hub/classes/states/miner/class_BaseMinerState.php b/application/hub/classes/states/miner/class_BaseMinerState.php index 0a00fd948..c4a9bce87 100644 --- a/application/hub/classes/states/miner/class_BaseMinerState.php +++ b/application/hub/classes/states/miner/class_BaseMinerState.php @@ -56,7 +56,7 @@ abstract class BaseMinerState extends BaseState { if (!$this instanceof MinerActiveState) { // Throw the exception throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); - } // END - if + } } /** @@ -71,7 +71,7 @@ abstract class BaseMinerState extends BaseState { if (!$this instanceof MinerInitState) { // Throw the exception throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); - } // END - if + } } /** @@ -86,7 +86,7 @@ abstract class BaseMinerState extends BaseState { if (!$this instanceof MinerBootingState) { // Throw the exception throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); - } // END - if + } } /** diff --git a/application/hub/classes/states/node/class_BaseNodeState.php b/application/hub/classes/states/node/class_BaseNodeState.php index 3cb4588d4..32e116439 100644 --- a/application/hub/classes/states/node/class_BaseNodeState.php +++ b/application/hub/classes/states/node/class_BaseNodeState.php @@ -52,7 +52,7 @@ abstract class BaseNodeState extends BaseState { if (!$this instanceof NodeActiveState) { // Throw the exception throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); - } // END - if + } } /** @@ -67,7 +67,7 @@ abstract class BaseNodeState extends BaseState { if ((!$this instanceof NodeActiveState) && (!$this instanceof NodeAnnouncingState)) { // Throw the exception throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); - } // END - if + } } /** @@ -82,7 +82,7 @@ abstract class BaseNodeState extends BaseState { if ((!$this instanceof NodeActiveState) && (!$this instanceof NodeReachableState)) { // Throw the exception throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); - } // END - if + } } /** @@ -97,7 +97,7 @@ abstract class BaseNodeState extends BaseState { if (!$this instanceof NodeAnnouncementCompletedState) { // Throw the exception throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); - } // END - if + } } } diff --git a/application/hub/classes/states/peer/class_BasePeerState.php b/application/hub/classes/states/peer/class_BasePeerState.php index 6c608f265..8b4e6fe21 100644 --- a/application/hub/classes/states/peer/class_BasePeerState.php +++ b/application/hub/classes/states/peer/class_BasePeerState.php @@ -52,7 +52,7 @@ abstract class BasePeerState extends BaseState { if (!$this->isPeerStateConnected()) { // Throw the exception throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE); - } // END - if + } } /** diff --git a/application/hub/classes/streams/raw_data/input/class_RawDataInputStream.php b/application/hub/classes/streams/raw_data/input/class_RawDataInputStream.php index e4f8546de..c15bd1174 100644 --- a/application/hub/classes/streams/raw_data/input/class_RawDataInputStream.php +++ b/application/hub/classes/streams/raw_data/input/class_RawDataInputStream.php @@ -10,6 +10,9 @@ use Org\Shipsimu\Hub\Handler\Network\RawData\HandleableRawData; use Org\Mxchange\CoreFramework\Stream\BaseStream; use Org\Mxchange\CoreFramework\Stream\Input\InputStream; +// Import SPL stuff +use \InvalidArgumentException; + /** * A class for handling incoming (encoded) raw data with start and end markers. * The "stream" is being verified by its length (if modulo 4 of it is always @@ -67,25 +70,27 @@ class RawDataInputStream extends BaseStream implements InputStream { * @param $data The data (string mostly) to "stream" * @return $data The data (string mostly) to "stream" * @todo Do we need to do something more here? + * @throws InvalidArgumentException If $data is empty or does not contain start/end marker * @throws Base64EncodingModuloException If the data's length modulo 4 is not zero * @throws Base64EncodingBadException If the data contains characters which are not in the "alphabet" of BASE64 messages. * @throws MultipleMessageSentException If the sender has sent two messages and both end up here */ public function streamData (string $data) { - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-INPUT-STREAM: data(' . strlen($data) . ')=' . $data . ' - CALLED!'); - // Do we have start and end marker again? - assert($this->ifStartEndMarkersSet($data)); - - // Count of start and end markers must be the same - assert(substr_count($data, HandleableRawData::STREAM_START_MARKER) == substr_count($data, HandleableRawData::STREAM_END_MARKER)); - - // Check if more than two start markers exist and if so, split it. - if (substr_count($data, HandleableRawData::STREAM_START_MARKER) > 1) { + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-INPUT-STREAM: data(%d)=%s - CALLED!', strlen($data), $data)); + if (empty($data)) { + // Throw exception + throw new InvalidArgumentException('Parameter "data" is empty'); + } elseif (!$this->ifStartEndMarkersSet($data)) { + // No start/end marker set + throw new InvalidArgumentException(sprintf('data=%s has no start/end marker set', $data)); + } elseif (substr_count($data, HandleableRawData::STREAM_START_MARKER) !== substr_count($data, HandleableRawData::STREAM_END_MARKER)) { + // Start/end marker count not matching + throw new InvalidArgumentException(sprintf('data=%s has different count of start/end markers set', $data)); + } elseif (substr_count($data, HandleableRawData::STREAM_START_MARKER) > 1) { // Please do it outside this method throw new MultipleMessageSentException(array($this, $data), BaseHubSystem::EXCEPTION_MULTIPLE_MESSAGE_SENT); - } // END - if + } // Remove both $data = substr($data, strlen(HandleableRawData::STREAM_START_MARKER), -1 * strlen(HandleableRawData::STREAM_END_MARKER)); @@ -102,10 +107,8 @@ class RawDataInputStream extends BaseStream implements InputStream { $data = base64_decode($data); } - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-INPUT-STREAM: Length of data is now ' . strlen($data) . ' Bytes.'); - // Return it + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-INPUT-STREAM: data(%d)=%s - EXIT!', strlen($data), $data)); return $data; } diff --git a/application/hub/classes/tags/package/class_PackageTags.php b/application/hub/classes/tags/package/class_PackageTags.php index ab8cf6a00..66145e110 100644 --- a/application/hub/classes/tags/package/class_PackageTags.php +++ b/application/hub/classes/tags/package/class_PackageTags.php @@ -161,12 +161,12 @@ class PackageTags extends BaseTag implements Tagable { if ((!is_array($entry)) || (count($entry) == 0) || (!isset($entry[XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_PROTOCOL])) || (!isset($entry[XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_RECIPIENT_TYPE]))) { // Invalid entry found throw new InvalidTagException(array($this, $tag), self::EXCEPTION_INVALID_TAG); - } // END - if + } // Now save the last discovered protocol/recipient type $this->lastProtocol = ProtocolHandlerFactory::createProtocolHandlerFromPackageInstance($packageInstance); $this->lastRecipientType = $entry[XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_RECIPIENT_TYPE]; - } // END - foreach + } // Trace message /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-TAGS: EXIT!'); diff --git a/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceFoundRssTask.php b/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceFoundRssTask.php index 82cb0b76b..8ac6cd011 100644 --- a/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceFoundRssTask.php +++ b/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceFoundRssTask.php @@ -93,7 +93,7 @@ class CrawlerUrlSourceFoundRssTask extends BaseUrlSourceTask implements Taskable // And re-get it $sourceInstance = $this->getUrlSourceInstance(); - } // END - if + } // Debug message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CRAWLER-URL-SOURCE-UPLOADED-LIST-TASK: sourceInstance[]=' . gettype($sourceInstance)); diff --git a/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceLocalStartTask.php b/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceLocalStartTask.php index 10d4a9b1f..e9571ba1a 100644 --- a/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceLocalStartTask.php +++ b/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceLocalStartTask.php @@ -93,7 +93,7 @@ class CrawlerUrlSourceLocalStartTask extends BaseUrlSourceTask implements Taskab // And re-get it $sourceInstance = $this->getUrlSourceInstance(); - } // END - if + } // Debug message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CRAWLER-URL-SOURCE-UPLOADED-LIST-TASK: sourceInstance[]=' . gettype($sourceInstance)); diff --git a/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceRssStartTask.php b/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceRssStartTask.php index 33a36fd92..46a9e4a56 100644 --- a/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceRssStartTask.php +++ b/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceRssStartTask.php @@ -93,7 +93,7 @@ class CrawlerUrlSourceRssStartTask extends BaseUrlSourceTask implements Taskable // And re-get it $sourceInstance = $this->getUrlSourceInstance(); - } // END - if + } // Debug message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CRAWLER-URL-SOURCE-UPLOADED-LIST-TASK: sourceInstance[]=' . gettype($sourceInstance)); diff --git a/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceUploadedListTask.php b/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceUploadedListTask.php index 0b5e9b7fa..298177e96 100644 --- a/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceUploadedListTask.php +++ b/application/hub/classes/tasks/crawler/url_source/class_CrawlerUrlSourceUploadedListTask.php @@ -93,7 +93,7 @@ class CrawlerUrlSourceUploadedListTask extends BaseUrlSourceTask implements Task // And re-get it $sourceInstance = $this->getUrlSourceInstance(); - } // END - if + } // Debug message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CRAWLER-URL-SOURCE-UPLOADED-LIST-TASK: sourceInstance[]=' . gettype($sourceInstance)); diff --git a/application/hub/classes/tasks/node/dht/class_NodeDhtPublicationCheckTask.php b/application/hub/classes/tasks/node/dht/class_NodeDhtPublicationCheckTask.php index 0e08c0d55..6973c27cd 100644 --- a/application/hub/classes/tasks/node/dht/class_NodeDhtPublicationCheckTask.php +++ b/application/hub/classes/tasks/node/dht/class_NodeDhtPublicationCheckTask.php @@ -83,7 +83,7 @@ class NodeDhtPublicationCheckTask extends BaseHubTask implements Taskable, Visit if (($dhtInstance->hasFullyBootstrapped()) && ($dhtInstance->hasUnpublishedEntries())) { // Then initiate publishing them $dhtInstance->initEntryPublication(); - } // END - if + } } /** diff --git a/application/hub/classes/tasks/node/dht/class_NodeDhtPublicationTask.php b/application/hub/classes/tasks/node/dht/class_NodeDhtPublicationTask.php index b4c65c4e7..64cc9f70a 100644 --- a/application/hub/classes/tasks/node/dht/class_NodeDhtPublicationTask.php +++ b/application/hub/classes/tasks/node/dht/class_NodeDhtPublicationTask.php @@ -83,7 +83,7 @@ class NodeDhtPublicationTask extends BaseHubTask implements Taskable, Visitable if ($dhtInstance->hasEntriesPendingPublication()) { // Then publish next entry $dhtInstance->publishEntry(); - } // END - if + } } /** diff --git a/application/hub/classes/tasks/node/dht/class_NodeDhtQueryTask.php b/application/hub/classes/tasks/node/dht/class_NodeDhtQueryTask.php index ffc0950d5..976d32181 100644 --- a/application/hub/classes/tasks/node/dht/class_NodeDhtQueryTask.php +++ b/application/hub/classes/tasks/node/dht/class_NodeDhtQueryTask.php @@ -83,7 +83,7 @@ class NodeDhtQueryTask extends BaseHubTask implements Taskable, Visitable { if ($dhtInstance->ifInsertNodeDataPending()) { // Then insert a single entry $dhtInstance->insertSingleNodeData(); - } // END - if + } } /** diff --git a/application/hub/classes/template/xml/announcement/class_XmlAnnouncementTemplateEngine.php b/application/hub/classes/template/xml/announcement/class_XmlAnnouncementTemplateEngine.php index 5195d786f..4acaa486f 100644 --- a/application/hub/classes/template/xml/announcement/class_XmlAnnouncementTemplateEngine.php +++ b/application/hub/classes/template/xml/announcement/class_XmlAnnouncementTemplateEngine.php @@ -105,7 +105,7 @@ class XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements Com if (empty($characters)) { // Then skip it silently return; - } // END - if + } /* * Assign the found characters to variable and use the last entry from diff --git a/application/hub/classes/template/xml/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php b/application/hub/classes/template/xml/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php index 0a1ef4315..7c5aaecd4 100644 --- a/application/hub/classes/template/xml/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php +++ b/application/hub/classes/template/xml/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php @@ -113,7 +113,7 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im if (empty($characters)) { // Then skip it silently return; - } // END - if + } /* * Assign the found characters to variable and use the last entry from diff --git a/application/hub/classes/template/xml/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php b/application/hub/classes/template/xml/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php index c155bc8da..075c518c4 100644 --- a/application/hub/classes/template/xml/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php +++ b/application/hub/classes/template/xml/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php @@ -112,7 +112,7 @@ class XmlDhtBootstrapAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im if (empty($characters)) { // Then skip it silently return; - } // END - if + } /* * Assign the found characters to variable and use the last entry from diff --git a/application/hub/classes/template/xml/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php b/application/hub/classes/template/xml/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php index ae6307421..f66e39a93 100644 --- a/application/hub/classes/template/xml/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php +++ b/application/hub/classes/template/xml/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php @@ -104,7 +104,7 @@ class XmlRequestNodeListAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine if (empty($characters)) { // Then skip it silently return; - } // END - if + } /* * Assign the found characters to variable and use the last entry from diff --git a/application/hub/classes/template/xml/connect/class_XmlSelfConnectTemplateEngine.php b/application/hub/classes/template/xml/connect/class_XmlSelfConnectTemplateEngine.php index e6146ec86..8dbf42184 100644 --- a/application/hub/classes/template/xml/connect/class_XmlSelfConnectTemplateEngine.php +++ b/application/hub/classes/template/xml/connect/class_XmlSelfConnectTemplateEngine.php @@ -95,7 +95,7 @@ class XmlSelfConnectTemplateEngine extends BaseXmlTemplateEngine implements Comp if (empty($characters)) { // Then skip it silently return; - } // END - if + } /* * Assign the found characters to variable and use the last entry from diff --git a/application/hub/classes/template/xml/dht/publish/class_XmlDhtPublishEntryTemplateEngine.php b/application/hub/classes/template/xml/dht/publish/class_XmlDhtPublishEntryTemplateEngine.php index c00113a78..9bb316812 100644 --- a/application/hub/classes/template/xml/dht/publish/class_XmlDhtPublishEntryTemplateEngine.php +++ b/application/hub/classes/template/xml/dht/publish/class_XmlDhtPublishEntryTemplateEngine.php @@ -105,7 +105,7 @@ class XmlDhtPublishEntryTemplateEngine extends BaseXmlTemplateEngine implements if (empty($characters)) { // Then skip it silently return; - } // END - if + } /* * Assign the found characters to variable and use the last entry from diff --git a/application/hub/classes/template/xml/entries/class_XmlRequestNodeListEntryTemplateEngine.php b/application/hub/classes/template/xml/entries/class_XmlRequestNodeListEntryTemplateEngine.php index a79701fac..291612fcb 100644 --- a/application/hub/classes/template/xml/entries/class_XmlRequestNodeListEntryTemplateEngine.php +++ b/application/hub/classes/template/xml/entries/class_XmlRequestNodeListEntryTemplateEngine.php @@ -81,7 +81,7 @@ class XmlRequestNodeListEntryTemplateEngine extends BaseXmlTemplateEngine implem if (empty($characters)) { // Then skip it silently return; - } // END - if + } // Assign data with matching variable here parent::assignVariable($this->getStackInstance()->getNamed('node_request_node_list_entry'), $characters); diff --git a/application/hub/classes/template/xml/objects/class_XmlObjectRegistryTemplateEngine.php b/application/hub/classes/template/xml/objects/class_XmlObjectRegistryTemplateEngine.php index 8ae96ea15..72b5c9228 100644 --- a/application/hub/classes/template/xml/objects/class_XmlObjectRegistryTemplateEngine.php +++ b/application/hub/classes/template/xml/objects/class_XmlObjectRegistryTemplateEngine.php @@ -109,7 +109,7 @@ class XmlObjectRegistryTemplateEngine extends BaseXmlTemplateEngine implements C if (empty($characters)) { // Then skip it silently return; - } // END - if + } // Get current XML node name as an array index $nodeName = $this->getStackInstance()->getNamed('node_object_registry'); @@ -119,7 +119,7 @@ class XmlObjectRegistryTemplateEngine extends BaseXmlTemplateEngine implements C if ($nodeName == self::OBJECT_TYPE_DATA_NAME) { // Output debug message /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('XML-OBJECT-REGISTRY-TEMPLATE-ENGINE: Adding object type ' . $characters . ' to registry.'); - } // END - if + } // Add it to the registry //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('XML-OBJECT-REGISTRY-TEMPLATE-ENGINE: EXIT!'); diff --git a/application/hub/classes/template/xml/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php b/application/hub/classes/template/xml/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php index 634a825b7..7ad7e13dd 100644 --- a/application/hub/classes/template/xml/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php +++ b/application/hub/classes/template/xml/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php @@ -96,7 +96,7 @@ class XmlCruncherTestUnitTemplateEngine extends BaseXmlTemplateEngine implements if (empty($characters)) { // Then skip it silently return; - } // END - if + } // Assign the found characters to variable and use the last entry from // stack as the name diff --git a/application/hub/classes/template/xml/requests/class_XmlRequestNodeListTemplateEngine.php b/application/hub/classes/template/xml/requests/class_XmlRequestNodeListTemplateEngine.php index 19ef10e98..8d2c0eeb2 100644 --- a/application/hub/classes/template/xml/requests/class_XmlRequestNodeListTemplateEngine.php +++ b/application/hub/classes/template/xml/requests/class_XmlRequestNodeListTemplateEngine.php @@ -92,7 +92,7 @@ class XmlRequestNodeListTemplateEngine extends BaseXmlTemplateEngine implements if (empty($characters)) { // Then skip it silently return; - } // END - if + } // Assign data with matching variable here parent::assignVariable($this->getStackInstance()->getNamed('node_request_node_list'), $characters); diff --git a/application/hub/classes/tools/hub/class_HubTools.php b/application/hub/classes/tools/hub/class_HubTools.php index a4f4985ec..3bb8cb436 100644 --- a/application/hub/classes/tools/hub/class_HubTools.php +++ b/application/hub/classes/tools/hub/class_HubTools.php @@ -83,7 +83,7 @@ class HubTools extends BaseHubSystem { if (is_null(self::$selfInstance)) { // Then set it self::$selfInstance = new HubTools(); - } // END - if + } // Return own instance return self::$selfInstance; @@ -134,7 +134,7 @@ class HubTools extends BaseHubSystem { if ($nodeInstance->getSessionId() == $sessionId) { // Then get an instance of a LocateableNode class from it, assume TCP by default $recipientUnl = self::determineOwnExternalAddress() . ':' . FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('node_listen_port'); - } // END - if + } } // Return result @@ -327,7 +327,7 @@ class HubTools extends BaseHubSystem { // Make sure it is valid // @TODO Find a better validation than empty() assert(!empty($GLOBALS[__METHOD__])); - } // END - if + } // Return it //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!'); @@ -355,7 +355,7 @@ class HubTools extends BaseHubSystem { // Make sure it is valid // @TODO Find a better validation than empty() assert(!empty($GLOBALS[__METHOD__])); - } // END - if + } // Return it //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!'); diff --git a/application/hub/exceptions.php b/application/hub/exceptions.php index 8051930bc..784a3910d 100644 --- a/application/hub/exceptions.php +++ b/application/hub/exceptions.php @@ -44,7 +44,7 @@ function hub_exception_handler ($exceptionInstance) { // Convert arguments type into human-readable foreach ($traceArray['args'] as $arg) { $argsString .= ', ' . gettype($arg); - } // END - foreach + } $argsString = substr($argsString, 2); } @@ -67,7 +67,7 @@ Line : %d\n", basename($traceArray['file']), $traceArray['line'] ); - } // END - foreach + } // Construct the message $message = sprintf("-------------------------------------------------------------------------------- @@ -117,14 +117,14 @@ function hub_error_handler ($errno, $errstr, $errfile, $errline, array $errconte // Throw an exception here throw new FatalErrorException($message, BaseFrameworkSystem::EXCEPTION_FATAL_ERROR); -} // END - function +} // Assertion handler function hub_assert_handler ($file, $line, $code) { // Empty code? if ($code === '') { $code = 'Unknown'; - } // END - if + } // Create message $message = sprintf('File: %s, Line: %s, Code: %s', @@ -138,7 +138,7 @@ function hub_assert_handler ($file, $line, $code) { // Throw an exception here throw new AssertionException($message, BaseFrameworkSystem::EXCEPTION_ASSERTION_FAILED); -} // END - function +} // Set error handler //set_error_handler('hub_error_handler'); diff --git a/contrib/mhash-benchmark.php b/contrib/mhash-benchmark.php index ed44183f0..6e6dce192 100644 --- a/contrib/mhash-benchmark.php +++ b/contrib/mhash-benchmark.php @@ -47,16 +47,16 @@ foreach ($hasher as $hash) { if (!is_int($hash)) { $timers[str_replace('MHASH_', '', $hash)] = '- unavailable -'; continue; - } // END - if + } $time = microtime(true); for ($idx = 0; $idx <= $count; $idx++) { $dummy = bin2hex(mhash($hash, 'mhash-test-abc-123-foo-bar')); - } // END - for + } $timers[mhash_get_hash_name($hash)] = (microtime(true) - $time); print '.'; -} // END - foreach +} print "\r\n\r\n"; asort($timers); diff --git a/contrib/udp-client.php b/contrib/udp-client.php index a260db09d..72518f9fe 100644 --- a/contrib/udp-client.php +++ b/contrib/udp-client.php @@ -43,12 +43,12 @@ function sendBye ($socket) { if ($read == 'BYE') { // Okay $replied = true; - } // END - if - } // END - if + } + } // Sleep a little if (function_exists('time_nanosleep')) time_nanosleep(0, 500000); - } // END - while + } } $data = array(); @@ -84,7 +84,7 @@ while (!feof($socket)) { if ($failed == constant('MAX_FAILURES')) { //*DEBUG: */ out(__FILE__, __LINE__, "Too many failures! (failed={$failed})"); break; - } // END - if + } // Is the peer the same? if (empty($peer)) { @@ -116,7 +116,7 @@ while (!feof($socket)) { out(__FILE__, __LINE__, "Invalid packet {$read} received. count=".count($rec)); $invalid++; continue; - } // END - if + } $time = trim($rec[0]); $right = explode('=', trim($rec[1])); @@ -127,7 +127,7 @@ while (!feof($socket)) { out(__FILE__, __LINE__, "Invalid: ({$time}/{$hash}/{$hasher})"); $invalid++; continue; - } // END - if + } if (!isset($data[$rec[0]])) { if (count($data) > 0) { @@ -141,7 +141,7 @@ while (!feof($socket)) { // Sleep a little if (function_exists('time_nanosleep')) time_nanosleep(0, 500000); -} // END - while +} array_shift($data); @@ -162,11 +162,11 @@ foreach ($data as $cnt) { $min = $cnt; } $avg += $cnt; -} // END - foreach +} if (count($data) > 0) { $avg = round($avg / count($data)); -} // END - if +} out(__FILE__, __LINE__, 'MIN/AVG/MAX=' . $min . '/' . $avg . '/' . $max . ''); out(__FILE__, __LINE__, 'INVALID=' . $invalid . ''); diff --git a/core b/core index ac256a664..a0f090cd1 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit ac256a664aa490665d37705439807ab6d62a7e3a +Subproject commit a0f090cd1474ae446e0a480e22738cfa7b48412f