From: Roland Häder Date: Sun, 6 Jul 2025 22:29:48 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=19e3bc9c8704510e08c14303c786b54bf0815e54;p=hub.git Continued: - changed deprecated `EmptyVariableException` to `InvalidArgumentException` - changed old array() to "new" [] style - updated 'core' framework --- diff --git a/application/hub/classes/container/socket/class_SocketContainer.php b/application/hub/classes/container/socket/class_SocketContainer.php index 6e6ca46ce..deb1f36fe 100644 --- a/application/hub/classes/container/socket/class_SocketContainer.php +++ b/application/hub/classes/container/socket/class_SocketContainer.php @@ -1073,7 +1073,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita // Is the call-back method there? if (!method_exists($this, $handlerName)) { // Please implement this - throw new UnsupportedSocketErrorHandlerException(array($this, $handlerName, $errorCode), BaseConnectionHelper::EXCEPTION_UNSUPPORTED_ERROR_HANDLER); + throw new UnsupportedSocketErrorHandlerException([$this, $handlerName, $errorCode], BaseConnectionHelper::EXCEPTION_UNSUPPORTED_ERROR_HANDLER); } // Return it 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 c61af6102..a00289b8d 100644 --- a/application/hub/classes/database/frontend/node_dht/class_NodeDistributedHashTableDatabaseFrontend.php +++ b/application/hub/classes/database/frontend/node_dht/class_NodeDistributedHashTableDatabaseFrontend.php @@ -484,7 +484,7 @@ class NodeDistributedHashTableDatabaseFrontend extends BaseHubDatabaseFrontend i // Is the node registered? if ($this->isNodeRegistered($nodeData)) { // Throw an exception - throw new NodeAlreadyRegisteredException(array($this, $nodeData), self::EXCEPTION_NODE_ALREADY_REGISTERED); + throw new NodeAlreadyRegisteredException([$this, $nodeData], self::EXCEPTION_NODE_ALREADY_REGISTERED); } // @TODO Unimplemented part @@ -517,7 +517,7 @@ class NodeDistributedHashTableDatabaseFrontend extends BaseHubDatabaseFrontend i // Is the node registered? if (!$this->isNodeRegistered($nodeData)) { // No, then throw an exception - throw new NodeDataMissingException(array($this, $nodeData), self::EXCEPTION_NODE_NOT_REGISTERED); + throw new NodeDataMissingException([$this, $nodeData], self::EXCEPTION_NODE_NOT_REGISTERED); } // Get a search instance diff --git a/application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseFrontend.php b/application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseFrontend.php index 8d2d6f905..b619549c5 100644 --- a/application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseFrontend.php +++ b/application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseFrontend.php @@ -145,7 +145,7 @@ class PeerStateLookupDatabaseFrontend extends BaseHubDatabaseFrontend implements // Make sure only new peers can be registered with package data if (!$this->isSenderNewPeer($packageInstance)) { // Throw an exception because this should normally not happen - throw new PeerAlreadyRegisteredException(array($this, $packageInstance), self::EXCEPTION_PEER_ALREADY_REGISTERED); + throw new PeerAlreadyRegisteredException([$this, $packageInstance], self::EXCEPTION_PEER_ALREADY_REGISTERED); } // Generate a dataset instance diff --git a/application/hub/classes/dht/node/class_NodeDhtFacade.php b/application/hub/classes/dht/node/class_NodeDhtFacade.php index 96067f75a..0dcbc4ac5 100644 --- a/application/hub/classes/dht/node/class_NodeDhtFacade.php +++ b/application/hub/classes/dht/node/class_NodeDhtFacade.php @@ -295,7 +295,7 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable { * Do not register non-existent nodes here. This is maybe fatal, * caused by "stolen" session id and/or not matching address. */ - throw new NodeSessionIdVerficationException(array($this, $messageInstance), DistributableNode::EXCEPTION_NODE_SESSION_ID_NOT_VERIFYING); + throw new NodeSessionIdVerficationException([$this, $messageInstance], DistributableNode::EXCEPTION_NODE_SESSION_ID_NOT_VERIFYING); } // Save last exception diff --git a/application/hub/classes/factories/states/communicator/class_CommunicatorStateFactory.php b/application/hub/classes/factories/states/communicator/class_CommunicatorStateFactory.php index eb0e3e790..47bb93df5 100644 --- a/application/hub/classes/factories/states/communicator/class_CommunicatorStateFactory.php +++ b/application/hub/classes/factories/states/communicator/class_CommunicatorStateFactory.php @@ -10,6 +10,9 @@ use Org\Mxchange\CoreFramework\Factory\BaseFactory; use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory; use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; +// Import SPL stuff +use \InvalidArgumentException; + /** * A factory class for communicator states * diff --git a/application/hub/classes/factories/states/node/class_NodeStateFactory.php b/application/hub/classes/factories/states/node/class_NodeStateFactory.php index 6d7125fbe..89369496c 100644 --- a/application/hub/classes/factories/states/node/class_NodeStateFactory.php +++ b/application/hub/classes/factories/states/node/class_NodeStateFactory.php @@ -67,7 +67,7 @@ class NodeStateFactory extends BaseFactory { } // Get a class from that configuration entry - $stateInstance = ObjectFactory::createObjectByConfiguredName('node_' . $stateName . '_state_class', array($nodeInstance)); + $stateInstance = ObjectFactory::createObjectByConfiguredName('node_' . $stateName . '_state_class', [$nodeInstance]); // Debug message self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE-STATE-FACTORY: Node state has changed from ' . $nodeInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); diff --git a/application/hub/classes/handler/chunks/class_ChunkHandler.php b/application/hub/classes/handler/chunks/class_ChunkHandler.php index e14a6b18e..19655093b 100644 --- a/application/hub/classes/handler/chunks/class_ChunkHandler.php +++ b/application/hub/classes/handler/chunks/class_ChunkHandler.php @@ -239,7 +239,7 @@ class ChunkHandler extends BaseHubHandler implements HandleableChunks, Registera /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CHUNK-HANDLER: chunkSplits()=%d - CALLED!', count($chunkSplits))); if (isset($this->finalPackageChunks[$chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL]])) { // Then throw an exception - throw new ChunkAlreadyAssembledException(array($this, $chunkSplits), HandleableChunks::EXCEPTION_CHUNK_ALREADY_ASSEMBLED); + throw new ChunkAlreadyAssembledException([$this, $chunkSplits], HandleableChunks::EXCEPTION_CHUNK_ALREADY_ASSEMBLED); } // Add the chunk data (index 2) to the final array and use the serial number as index @@ -506,9 +506,9 @@ class ChunkHandler extends BaseHubHandler implements HandleableChunks, Registera try { // Validate final chunk $this->isFinalChunkValid($chunks); - } catch (AssertionException $e) { + } catch (AssertionException $exception) { // Last chunk is not valid - throw new FinalChunkVerificationException(array($this, $chunks, $e), self::EXCEPTION_FINAL_CHUNK_VERIFICATION); + throw new FinalChunkVerificationException([$this, $chunks, $exception], self::EXCEPTION_FINAL_CHUNK_VERIFICATION); } // Do we have some pending chunks (no final)? 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 c965cc8b7..9e49ef7e7 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 @@ -116,7 +116,7 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl * This node is not accepting announcements, then someone wants to * announce his node to a non-bootstrap and non-master node. */ - throw new AnnouncementNotAcceptedException(array($this, $nodeInstance, $messageInstance), HandleableMessage::EXCEPTION_ANNOUNCEMENT_NOT_ACCEPTED); + throw new AnnouncementNotAcceptedException([$this, $nodeInstance, $messageInstance], HandleableMessage::EXCEPTION_ANNOUNCEMENT_NOT_ACCEPTED); } // Register the announcing node with this node 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 7b743f6f8..bb0366d29 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 @@ -115,7 +115,7 @@ class NodeMessageAnnouncementAnswerHandler extends BaseMessageHandler implements * This node has never announced itself, so it doesn't expect * announcement answer messages. */ - throw new NoAnnouncementAttemptedException(array($this, $nodeInstance, $messageInstance), HandleableMessage::EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED); + throw new NoAnnouncementAttemptedException([$this, $nodeInstance, $messageInstance], HandleableMessage::EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED); } // Register the announcing node with this node 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 5aaf1212d..92e7dd13f 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 * This DHT has never bootstrapped, so it doesn't expect * announcement answer messages. */ - throw new NoDhtBootstrapAttemptedException(array($this, $dhtInstance, $messageInstance), HandleableMessage::EXCEPTION_DHT_BOOTSTRAP_NOT_ATTEMPTED); + throw new NoDhtBootstrapAttemptedException([$this, $dhtInstance, $messageInstance], HandleableMessage::EXCEPTION_DHT_BOOTSTRAP_NOT_ATTEMPTED); } // Unfinished 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 3045dd953..d69bc30fa 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 @@ -104,7 +104,7 @@ class NodeMessageRequestNodeListAnswerHandler extends BaseMessageHandler impleme * This node has never announced itself, so it doesn't expect * request-node-list answer messages. */ - throw new NoRequestNodeListAttemptedException(array($this, $nodeInstance, $messageInstance), HandleableMessage::EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED); + throw new NoRequestNodeListAttemptedException([$this, $nodeInstance, $messageInstance], HandleableMessage::EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED); } // Register the announcing node with this node 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 83cf9eab6..07b64c83b 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 @@ -108,7 +108,7 @@ class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements Handl /* * This node is not accepting DHT bootstrap requests. */ - throw new DhtBootstrapNotAcceptedException(array($this, $messageInstance), HandleableMessage::EXCEPTION_DHT_BOOTSTRAP_NOT_ACCEPTED); + throw new DhtBootstrapNotAcceptedException([$this, $messageInstance], HandleableMessage::EXCEPTION_DHT_BOOTSTRAP_NOT_ACCEPTED); } // Register the DHT bootstrap requesting node with this node 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 b3bbb8694..63ac689ec 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 @@ -96,7 +96,7 @@ class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements Ha * This node is not accepting node list requests. Throw an * exception to abort any further processing. */ - throw new RequestNotAcceptedException(array($this, $nodeInstance, $messageInstance), HandleableMessage::EXCEPTION_REQUEST_NOT_ACCEPTED); + throw new RequestNotAcceptedException([$this, $nodeInstance, $messageInstance], HandleableMessage::EXCEPTION_REQUEST_NOT_ACCEPTED); } // Register the announcing node with this node diff --git a/application/hub/classes/handler/package/class_NetworkPackageHandler.php b/application/hub/classes/handler/package/class_NetworkPackageHandler.php index 474083834..5e565a2d2 100644 --- a/application/hub/classes/handler/package/class_NetworkPackageHandler.php +++ b/application/hub/classes/handler/package/class_NetworkPackageHandler.php @@ -1417,7 +1417,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei // Is the package status 'failed'? if ($packageInstance->getPackageStatus() != self::PACKAGE_STATUS_FAILED) { // Not failed! - throw new UnexpectedPackageStatusException(array($this, $packageInstance, self::PACKAGE_STATUS_FAILED), self::EXCEPTION_UNEXPECTED_PACKAGE_STATUS); + throw new UnexpectedPackageStatusException([$this, $packageInstance, self::PACKAGE_STATUS_FAILED], self::EXCEPTION_UNEXPECTED_PACKAGE_STATUS); } // Remove this entry @@ -1590,7 +1590,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei throw new InvalidArgumentException('messageInstance does not contain senderId'); } elseif (empty($messageInstance->getSenderPrivateKeyHash())) { // This needs fixing - throw new InvalidPrivateKeyHashException(array($this, $senderData, 'empty hash in decodedData'), DiscoverableUniversalNodeLocator::EXCEPTION_INVALID_PRIVATE_KEY_HASH); + throw new InvalidPrivateKeyHashException([$this, $senderData, 'empty hash in decodedData'], DiscoverableUniversalNodeLocator::EXCEPTION_INVALID_PRIVATE_KEY_HASH); } elseif (!$this->isMessageContentHashValid($messageInstance)) { // Is not valid, so throw an exception here ApplicationEntryPoint::exitApplication(__METHOD__ . ':INVALID HASH! UNDER CONSTRUCTION!' . PHP_EOL); @@ -1643,7 +1643,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei throw new InvalidArgumentException('packageInstance does not contain senderId'); } elseif (empty($packageInstance->getSenderPrivateKeyHash())) { // This needs fixing - throw new InvalidPrivateKeyHashException(array($this, $senderData, 'empty hash in decodedData'), DiscoverableUniversalNodeLocator::EXCEPTION_INVALID_PRIVATE_KEY_HASH); + throw new InvalidPrivateKeyHashException([$this, $senderData, 'empty hash in decodedData'], DiscoverableUniversalNodeLocator::EXCEPTION_INVALID_PRIVATE_KEY_HASH); } elseif (!$this->isPackageContentHashValid($packageInstance)) { // Is not valid, so throw an exception here ApplicationEntryPoint::exitApplication(__METHOD__ . ':INVALID HASH! UNDER CONSTRUCTION!' . PHP_EOL); diff --git a/application/hub/classes/locator/class_UniversalNodeLocator.php b/application/hub/classes/locator/class_UniversalNodeLocator.php index 1d4f859b7..6e0cc2a0f 100644 --- a/application/hub/classes/locator/class_UniversalNodeLocator.php +++ b/application/hub/classes/locator/class_UniversalNodeLocator.php @@ -177,7 +177,7 @@ class UniversalNodeLocator extends BaseHubSystem implements LocateableNode, Regi // Is the element there? if (!isset($unlData[NodeInformationDatabaseFrontend::DB_COLUMN_EXTERNAL_UNL])) { // Is not there - throw new MissingArrayElementsException(array($this, 'unlData', array(NodeInformationDatabaseFrontend::DB_COLUMN_EXTERNAL_UNL)), self::EXCEPTION_ARRAY_ELEMENTS_MISSING); + throw new MissingArrayElementsException([$this, 'unlData', [NodeInformationDatabaseFrontend::DB_COLUMN_EXTERNAL_UNL]], self::EXCEPTION_ARRAY_ELEMENTS_MISSING); } elseif ($unlData[NodeInformationDatabaseFrontend::DB_COLUMN_EXTERNAL_UNL] == 'invalid') { // Is not valid/method to early used throw new BadMethodCallException(sprintf('unlData[%s] is invalid. Maybe called this method to early?', NodeInformationDatabaseFrontend::DB_COLUMN_EXTERNAL_UNL), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); @@ -200,7 +200,7 @@ class UniversalNodeLocator extends BaseHubSystem implements LocateableNode, Regi // Is the element there? if (!isset($unlData[NodeInformationDatabaseFrontend::DB_COLUMN_INTERNAL_UNL])) { // Is not there - throw new MissingArrayElementsException(array($this, 'unlData', array(NodeInformationDatabaseFrontend::DB_COLUMN_INTERNAL_UNL)), self::EXCEPTION_ARRAY_ELEMENTS_MISSING); + throw new MissingArrayElementsException([$this, 'unlData', [NodeInformationDatabaseFrontend::DB_COLUMN_INTERNAL_UNL]], self::EXCEPTION_ARRAY_ELEMENTS_MISSING); } elseif ($unlData[NodeInformationDatabaseFrontend::DB_COLUMN_INTERNAL_UNL] == 'invalid') { // Is not valid/method to early used throw new BadMethodCallException(sprintf('unlData[%s] is invalid. Maybe called this method to early?', NodeInformationDatabaseFrontend::DB_COLUMN_INTERNAL_UNL), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); diff --git a/application/hub/classes/package/assembler/class_PackageAssembler.php b/application/hub/classes/package/assembler/class_PackageAssembler.php index 122d92ac3..d90c330a8 100644 --- a/application/hub/classes/package/assembler/class_PackageAssembler.php +++ b/application/hub/classes/package/assembler/class_PackageAssembler.php @@ -340,7 +340,7 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, // Abort if the call-back method is not there if (!method_exists($callable[0], $callable[1])) { // Throw an exception - throw new UnsupportedPackageCodeHandlerException(array($callable, $packageInstance), self::EXCEPTION_UNSUPPORTED_PACKAGE_CODE_HANDLER); + throw new UnsupportedPackageCodeHandlerException([$callable, $packageInstance], self::EXCEPTION_UNSUPPORTED_PACKAGE_CODE_HANDLER); } // Call it back diff --git a/application/hub/classes/pools/peer/class_DefaultPeerPool.php b/application/hub/classes/pools/peer/class_DefaultPeerPool.php index be0128585..27361313a 100644 --- a/application/hub/classes/pools/peer/class_DefaultPeerPool.php +++ b/application/hub/classes/pools/peer/class_DefaultPeerPool.php @@ -119,7 +119,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { // Is the connection type valid? if (!$socketInstance->isValidConnectionType($connectionType)) { // Is not a valid connection type! - throw new InvalidConnectionTypeException(array($this, $connectionType), StorableSocket::EXCEPTION_INVALID_CONNECTION_TYPE); + throw new InvalidConnectionTypeException([$this, $connectionType], StorableSocket::EXCEPTION_INVALID_CONNECTION_TYPE); } // Default is this peer's IP @@ -217,7 +217,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { // Is the connection type valid? if (!$socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->isValidConnectionType($connectionType)) { // Is not a valid connection type! - throw new InvalidConnectionTypeException(array($this, $connectionType), self::EXCEPTION_INVALID_CONNECTION_TYPE); + throw new InvalidConnectionTypeException([$this, $connectionType], self::EXCEPTION_INVALID_CONNECTION_TYPE); } // Add the socket @@ -270,7 +270,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { throw new LogicException(sprintf('socketArray[%s] is not set.', Poolable::SOCKET_ARRAY_CONN_TYPE)); } elseif ((!empty($connectionType)) && (!$socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->isValidConnectionType($connectionType))) { // Is not a valid connection type! - throw new InvalidConnectionTypeException(array($this, $connectionType), self::EXCEPTION_INVALID_CONNECTION_TYPE); + throw new InvalidConnectionTypeException([$this, $connectionType], self::EXCEPTION_INVALID_CONNECTION_TYPE); } elseif ((!empty($connectionType)) && ($socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE] !== $connectionType)) { // Skip unwanted sockets /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: Skipping unwanted socket %s of type %s/%s ...', $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getPrintableName(), $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE], $connectionType)); diff --git a/application/hub/classes/resolver/command/console/class_HubConsoleCommandResolver.php b/application/hub/classes/resolver/command/console/class_HubConsoleCommandResolver.php index 4abd82bcb..f663e9608 100644 --- a/application/hub/classes/resolver/command/console/class_HubConsoleCommandResolver.php +++ b/application/hub/classes/resolver/command/console/class_HubConsoleCommandResolver.php @@ -8,6 +8,9 @@ use Org\Mxchange\CoreFramework\Manager\ManageableApplication; use Org\Mxchange\CoreFramework\Resolver\Command\BaseCommandResolver; use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver; +// Import SPL stuff +use \InvalidArgumentException; + /** * A command resolver for local (non-hubbed) web commands * @@ -50,20 +53,20 @@ class HubConsoleCommandResolver extends BaseCommandResolver implements CommandRe * @param $commandName The default command we shall execute * @param $applicationInstance An instance of a manageable application helper class * @return $resolverInstance The prepared command resolver instance - * @throws EmptyVariableException Thrown if default command is not set + * @throws InvalidArgumentException Thrown if default command is not set * @throws InvalidCommandException Thrown if default command is invalid */ - public static final function createHubConsoleCommandResolver ($commandName, ManageableApplication $applicationInstance) { + public static final function createHubConsoleCommandResolver (string $commandName, ManageableApplication $applicationInstance) { // Create the new instance $resolverInstance = new HubConsoleCommandResolver(); // Is the variable $commandName set and the command is valid? if (empty($commandName)) { // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + throw new InvalidArgumentException('Parameter "commandName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif ($resolverInstance->isCommandValid('Org\Shipsimu\Hub\Command', $commandName) === FALSE) { // Invalid command found - throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); + throw new InvalidCommandException([$resolverInstance, $commandName], self::EXCEPTION_INVALID_COMMAND); } // Set namespace and application instance diff --git a/application/hub/classes/resolver/command/html/class_HubHtmlCommandResolver.php b/application/hub/classes/resolver/command/html/class_HubHtmlCommandResolver.php index 320c78c3a..e801392a5 100644 --- a/application/hub/classes/resolver/command/html/class_HubHtmlCommandResolver.php +++ b/application/hub/classes/resolver/command/html/class_HubHtmlCommandResolver.php @@ -8,6 +8,9 @@ use Org\Mxchange\CoreFramework\Manager\ManageableApplication; use Org\Mxchange\CoreFramework\Resolver\Command\BaseCommandResolver; use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver; +// Import SPL stuff +use \InvalidArgumentException; + /** * A command resolver for HTML commands * @@ -50,20 +53,20 @@ class HubHtmlCommandResolver extends BaseCommandResolver implements CommandResol * @param $commandName The default command we shall execute * @param $applicationInstance An instance of a manageable application helper class * @return $resolverInstance The prepared command resolver instance - * @throws EmptyVariableException Thrown if default command is not set + * @throws InvalidArgumentException Thrown if default command is not set * @throws InvalidCommandException Thrown if default command is invalid */ - public static final function createHubHtmlCommandResolver ($commandName, ManageableApplication $applicationInstance) { + public static final function createHubHtmlCommandResolver (string $commandName, ManageableApplication $applicationInstance) { // Create the new instance $resolverInstance = new HubHtmlCommandResolver(); // Is the variable $commandName set and the command is valid? if (empty($commandName)) { // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + throw new InvalidArgumentException('Parameter "commandName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif ($resolverInstance->isCommandValid('Org\Shipsimu\Hub\Command', $commandName) === FALSE) { // Invalid command found - throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); + throw new InvalidCommandException([$resolverInstance, $commandName], self::EXCEPTION_INVALID_COMMAND); } // Set namespace and application instance diff --git a/application/hub/classes/resolver/controller/console/class_HubConsoleControllerResolver.php b/application/hub/classes/resolver/controller/console/class_HubConsoleControllerResolver.php index e596642d0..38d9e5cca 100644 --- a/application/hub/classes/resolver/controller/console/class_HubConsoleControllerResolver.php +++ b/application/hub/classes/resolver/controller/console/class_HubConsoleControllerResolver.php @@ -48,7 +48,7 @@ class HubConsoleControllerResolver extends BaseControllerResolver implements Con * * @param $controllerName The controller we shall resolve * @return $resolverInstance The prepared controller resolver instance - * @throws EmptyVariableException Thrown if default command is not set + * @throws InvalidArgumentException Thrown if default command is not set * @throws InvalidControllerException Thrown if default controller is invalid */ public static final function createHubConsoleControllerResolver ($controllerName) { @@ -58,10 +58,10 @@ class HubConsoleControllerResolver extends BaseControllerResolver implements Con // Is the variable $controllerName set and the command is valid? if (empty($controllerName)) { // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + throw new InvalidArgumentException('Parameter "controllerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif ($resolverInstance->isControllerValid('Org\Shipsimu\Hub\Controller', $controllerName) === false) { // Invalid command found - throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); + throw new InvalidControllerException([$resolverInstance, $controllerName], self::EXCEPTION_INVALID_CONTROLLER); } // Set namespace and command name @@ -94,7 +94,7 @@ class HubConsoleControllerResolver extends BaseControllerResolver implements Con // And validate it if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) { // This command has an invalid instance! - throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); + throw new InvalidControllerInstanceException([$this, $controllerName], self::EXCEPTION_INVALID_CONTROLLER); } // Set last controller diff --git a/application/hub/classes/resolver/controller/html/class_HubHtmlControllerResolver.php b/application/hub/classes/resolver/controller/html/class_HubHtmlControllerResolver.php index 15c286ca8..ace224980 100644 --- a/application/hub/classes/resolver/controller/html/class_HubHtmlControllerResolver.php +++ b/application/hub/classes/resolver/controller/html/class_HubHtmlControllerResolver.php @@ -48,7 +48,7 @@ class HubHtmlControllerResolver extends BaseControllerResolver implements Contro * * @param $controllerName The controller we shall resolve * @return $resolverInstance The prepared controller resolver instance - * @throws EmptyVariableException Thrown if default command is not set + * @throws InvalidArgumentException Thrown if default command is not set * @throws InvalidControllerException Thrown if default controller is invalid */ public static final function createHubHtmlControllerResolver ($controllerName) { @@ -58,10 +58,10 @@ class HubHtmlControllerResolver extends BaseControllerResolver implements Contro // Is the variable $controllerName set and the command is valid? if (empty($controllerName)) { // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + throw new InvalidArgumentException('Parameter "controllerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } elseif ($resolverInstance->isControllerValid('Org\Shipsimu\Hub\Controller', $controllerName) === false) { // Invalid command found - throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); + throw new InvalidControllerException([$resolverInstance, $controllerName], self::EXCEPTION_INVALID_CONTROLLER); } // Set namespace and command name @@ -94,7 +94,7 @@ class HubHtmlControllerResolver extends BaseControllerResolver implements Contro // And validate it if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) { // This command has an invalid instance! - throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); + throw new InvalidControllerInstanceException([$this, $controllerName], self::EXCEPTION_INVALID_CONTROLLER); } // Set last controller diff --git a/application/hub/classes/resolver/state/class_BaseStateResolver.php b/application/hub/classes/resolver/state/class_BaseStateResolver.php index fd7e000de..72138f23d 100644 --- a/application/hub/classes/resolver/state/class_BaseStateResolver.php +++ b/application/hub/classes/resolver/state/class_BaseStateResolver.php @@ -57,7 +57,7 @@ abstract class BaseStateResolver extends BaseResolver { * @param $statePrefix Last validated statePrefix * @return void */ - protected final function setStatePrefix ($statePrefix) { + protected final function setStatePrefix (string $statePrefix): void { $this->statePrefix = $statePrefix; } @@ -67,7 +67,7 @@ abstract class BaseStateResolver extends BaseResolver { * @param $statePrefix Last validated statePrefix * @return void */ - protected final function getStatePrefix () { + protected final function getStatePrefix (): string { return $this->statePrefix; } @@ -77,7 +77,7 @@ abstract class BaseStateResolver extends BaseResolver { * @param $stateName Last validated state name * @return void */ - protected final function setStateName ($stateName) { + protected final function setStateName (string $stateName): void { $this->stateName = $stateName; } @@ -86,7 +86,7 @@ abstract class BaseStateResolver extends BaseResolver { * * @return $stateName Last validated state name */ - public final function getStateName () { + public final function getStateName (): string { return $this->stateName; } @@ -96,10 +96,17 @@ abstract class BaseStateResolver extends BaseResolver { * * @param $stateName A state name we shall look for * @return $stateInstance A loaded state instance + * @throws InvalidArgumentException Thrown if given state is not set * @throws UnresolveableStateException Thrown if even the requested * state class is missing (bad!) */ - protected function loadState ($stateName) { + protected function loadState (string $stateName) { + // Is a state set? + if (empty($stateName)) { + // Then thrown an exception here + throw new InvalidArgumentException('Parameter "stateName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); + } + // Init state instance $stateInstance = NULL; @@ -112,7 +119,7 @@ abstract class BaseStateResolver extends BaseResolver { // Is this class loaded? if (!class_exists($this->getClassName())) { // Throw an exception here - throw new UnresolveableStateException(array($this, $stateName), self::EXCEPTION_INVALID_STATE); + throw new UnresolveableStateException([$this, $stateName], self::EXCEPTION_INVALID_STATE); } // Initialize the state @@ -130,19 +137,19 @@ abstract class BaseStateResolver extends BaseResolver { * * @param $stateName The default state we shall execute * @return $isValid Whether the given state is valid - * @throws EmptyVariableException Thrown if given state is not set + * @throws InvalidArgumentException Thrown if given state is not set * @throws DefaultStateException Thrown if default state was not found */ - public function isStateValid ($stateName) { - // By default nothing shall be valid - $isValid = FALSE; - + public function isStateValid (string $stateName): bool { // Is a state set? if (empty($stateName)) { // Then thrown an exception here - throw new EmptyVariableException(array($this, 'stateName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + throw new InvalidArgumentException('Parameter "stateName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); } + // By default nothing shall be valid + $isValid = FALSE; + // Create class name $className = $this->statePrefix . StringUtils::convertToClassName($stateName) . 'State'; diff --git a/application/hub/classes/tags/package/class_PackageTags.php b/application/hub/classes/tags/package/class_PackageTags.php index 6e60a2a32..954b3be6e 100644 --- a/application/hub/classes/tags/package/class_PackageTags.php +++ b/application/hub/classes/tags/package/class_PackageTags.php @@ -161,7 +161,7 @@ class PackageTags extends BaseTag implements Tagable { //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d] entry=%s', __METHOD__, __LINE__, print_r($entry, TRUE))); 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); + throw new InvalidTagException([$this, $tag], self::EXCEPTION_INVALID_TAG); } // Now save the last discovered protocol/recipient type diff --git a/application/hub/interfaces/resolver/state/class_StateResolver.php b/application/hub/interfaces/resolver/state/class_StateResolver.php index 00bffa972..3f471466c 100644 --- a/application/hub/interfaces/resolver/state/class_StateResolver.php +++ b/application/hub/interfaces/resolver/state/class_StateResolver.php @@ -33,8 +33,8 @@ interface StateResolver extends Resolver { * * @param $stateName The default state we shall execute * @return $isValid Whether the given state is valid - * @throws EmptyVariableException Thrown if given state is not set + * @throws InvalidArgumentException Thrown if given state is not set */ - function isStateValid (string $stateName); + function isStateValid (string $stateName): void; } diff --git a/core b/core index ff2afec77..7c9c09a00 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit ff2afec772b7b5959d6225d70d2bd352d0f8c684 +Subproject commit 7c9c09a0065013ed20f8361e87ad6ceda7896cb9