diff --git a/src/BusinessLogic/DataAccess/PromotionalWidgets/Entities/WidgetSettings.php b/src/BusinessLogic/DataAccess/PromotionalWidgets/Entities/WidgetSettings.php index 980960d..2b91d02 100644 --- a/src/BusinessLogic/DataAccess/PromotionalWidgets/Entities/WidgetSettings.php +++ b/src/BusinessLogic/DataAccess/PromotionalWidgets/Entities/WidgetSettings.php @@ -31,7 +31,7 @@ class WidgetSettings extends Entity /** * @inheritDoc */ - public function inflate(array $data): void + public function inflate(array $data) { parent::inflate($data); diff --git a/src/BusinessLogic/Domain/OrderReport/OrderReporter.php b/src/BusinessLogic/Domain/OrderReport/OrderReporter.php index 6dca39d..83c024d 100644 --- a/src/BusinessLogic/Domain/OrderReport/OrderReporter.php +++ b/src/BusinessLogic/Domain/OrderReport/OrderReporter.php @@ -53,7 +53,7 @@ public function toArray(): array /** * @inheritDoc */ - public static function fromArray(array $array): Serializable + public static function fromArray(array $array) { $entity = parent::fromArray($array); $entity->page = intval($array['page']); diff --git a/src/BusinessLogic/Domain/OrderReport/Tasks/OrderReportTask.php b/src/BusinessLogic/Domain/OrderReport/Tasks/OrderReportTask.php index cc4db2c..537ba1a 100644 --- a/src/BusinessLogic/Domain/OrderReport/Tasks/OrderReportTask.php +++ b/src/BusinessLogic/Domain/OrderReport/Tasks/OrderReportTask.php @@ -64,7 +64,7 @@ public function __construct(string $merchantId, array $reportOrderIds, ?array $s * * @throws Exception */ - public static function fromArray(array $array): Serializable + public static function fromArray(array $array) { return StoreContext::doWithStore($array['storeId'], static function () use ($array) { return new static($array['merchantId'], $array['reportOrderIds'], $array['statisticsOrderIds'] ?? null); diff --git a/src/BusinessLogic/TransactionLog/Contracts/TransactionLogAwareInterface.php b/src/BusinessLogic/TransactionLog/Contracts/TransactionLogAwareInterface.php index e9fa9d1..23e1452 100644 --- a/src/BusinessLogic/TransactionLog/Contracts/TransactionLogAwareInterface.php +++ b/src/BusinessLogic/TransactionLog/Contracts/TransactionLogAwareInterface.php @@ -23,8 +23,10 @@ public function getTransactionLog(): TransactionLog; * Sets transaction log. * * @param TransactionLog $transactionLog + * + * @return void */ - public function setTransactionLog(TransactionLog $transactionLog): void; + public function setTransactionLog(TransactionLog $transactionLog); /** * Gets the store id for which the transactional task is created diff --git a/src/BusinessLogic/Webhook/Tasks/OrderUpdateTask.php b/src/BusinessLogic/Webhook/Tasks/OrderUpdateTask.php index f69b74c..0705f13 100644 --- a/src/BusinessLogic/Webhook/Tasks/OrderUpdateTask.php +++ b/src/BusinessLogic/Webhook/Tasks/OrderUpdateTask.php @@ -37,7 +37,7 @@ class OrderUpdateTask extends Task * * @throws Exception */ - public static function fromArray(array $array): Serializable + public static function fromArray(array $array) { return StoreContext::doWithStore($array['storeId'], static function () use ($array) { return new static( diff --git a/src/Infrastructure/AutoTest/AutoTestLogger.php b/src/Infrastructure/AutoTest/AutoTestLogger.php index 712a4c9..7263d35 100644 --- a/src/Infrastructure/AutoTest/AutoTestLogger.php +++ b/src/Infrastructure/AutoTest/AutoTestLogger.php @@ -23,13 +23,9 @@ class AutoTestLogger extends Singleton implements ShopLoggerAdapter protected static $instance; /** - * Logs a message in system. - * - * @param LogData $data Data to log. - * - * @throws RepositoryNotRegisteredException + * @inheritDoc */ - public function logMessage(LogData $data): void + public function logMessage(LogData $data) { $repo = RepositoryRegistry::getRepository(LogData::CLASS_NAME); $repo->save($data); diff --git a/src/Infrastructure/AutoTest/AutoTestService.php b/src/Infrastructure/AutoTest/AutoTestService.php index 703cb6f..bc39170 100644 --- a/src/Infrastructure/AutoTest/AutoTestService.php +++ b/src/Infrastructure/AutoTest/AutoTestService.php @@ -67,8 +67,10 @@ public function startAutoTest() * Activates the auto-test mode and registers the necessary components. * * @param bool $persist Indicates whether to store the mode change in configuration. + * + * @return void */ - public function setAutoTestMode($persist = false): void + public function setAutoTestMode($persist = false) { Logger::resetInstance(); ServiceRegister::registerService( @@ -133,8 +135,10 @@ public function getAutoTestTaskStatus($queueItemId = 0) * re-initialize shop logger. Otherwise, logs and async calls will still use auto-test mode. * * @param callable $loggerInitializerDelegate Delegate that will give instance of the shop logger service. + * + * @return void */ - public function stopAutoTestMode($loggerInitializerDelegate): void + public function stopAutoTestMode($loggerInitializerDelegate) { $this->getConfigService()->setAutoTestMode(false); ServiceRegister::registerService(ShopLoggerAdapter::CLASS_NAME, $loggerInitializerDelegate); @@ -144,9 +148,11 @@ public function stopAutoTestMode($loggerInitializerDelegate): void /** * Deletes previous auto-test logs. * + * @return void + * * @throws RepositoryNotRegisteredException */ - protected function deletePreviousLogs(): void + protected function deletePreviousLogs() { $repo = RepositoryRegistry::getRepository(LogData::getClassName()); $logs = $repo->select(); @@ -157,8 +163,10 @@ protected function deletePreviousLogs(): void /** * Logs current HTTP configuration options. + * + * @return void */ - protected function logHttpOptions(): void + protected function logHttpOptions() { $testDomain = parse_url($this->getConfigService()->getAsyncProcessUrl(''), PHP_URL_HOST); $options = array(); diff --git a/src/Infrastructure/AutoTest/AutoTestStatus.php b/src/Infrastructure/AutoTest/AutoTestStatus.php index b3f66b0..9e2d4e6 100644 --- a/src/Infrastructure/AutoTest/AutoTestStatus.php +++ b/src/Infrastructure/AutoTest/AutoTestStatus.php @@ -58,7 +58,7 @@ public function __construct($taskStatus, $finished, $error, $logs) * * @return mixed[] This object as an array. */ - public function toArray(): array + public function toArray() { return array( 'taskStatus' => $this->taskStatus, diff --git a/src/Infrastructure/AutoTest/AutoTestTask.php b/src/Infrastructure/AutoTest/AutoTestTask.php index 67f311d..179f63a 100644 --- a/src/Infrastructure/AutoTest/AutoTestTask.php +++ b/src/Infrastructure/AutoTest/AutoTestTask.php @@ -4,7 +4,6 @@ use SeQura\Core\Infrastructure\Logger\LogContextData; use SeQura\Core\Infrastructure\Logger\Logger; -use SeQura\Core\Infrastructure\Serializer\Interfaces\Serializable; use SeQura\Core\Infrastructure\Serializer\Serializer; use SeQura\Core\Infrastructure\TaskExecution\Task; @@ -39,7 +38,7 @@ public function __construct($data) /** * @inheritDoc */ - public static function fromArray(array $array): Serializable + public static function fromArray(array $array) { return new static($array['data']); } @@ -47,7 +46,7 @@ public static function fromArray(array $array): Serializable /** * @inheritDoc */ - public function toArray(): array + public function toArray() { return array('data' => $this->data); } @@ -63,17 +62,15 @@ public function __serialize() /** * @inheritDoc */ - public function __unserialize($data): void + public function __unserialize($data) { $this->data = $data['data']; } /** - * String representation of object. - * - * @return string The string representation of the object or null. + * @inheritDoc */ - public function serialize(): ?string + public function serialize() { return Serializer::serialize(array($this->data)); } @@ -91,9 +88,9 @@ public function unserialize($serialized) } /** - * Runs task logic. + * @inheritDoc */ - public function execute(): void + public function execute() { $this->reportProgress(5); Logger::logInfo('Auto-test task started'); diff --git a/src/Infrastructure/BootstrapComponent.php b/src/Infrastructure/BootstrapComponent.php index 14e30f1..010b5f8 100644 --- a/src/Infrastructure/BootstrapComponent.php +++ b/src/Infrastructure/BootstrapComponent.php @@ -29,8 +29,10 @@ class BootstrapComponent { /** * Initializes infrastructure components. + * + * @return void */ - public static function init(): void + public static function init() { static::initServices(); static::initRepositories(); @@ -39,8 +41,10 @@ public static function init(): void /** * Initializes services and utilities. + * + * @return void */ - protected static function initServices(): void + protected static function initServices() { ServiceRegister::registerService( ConfigurationManager::CLASS_NAME, @@ -118,15 +122,19 @@ function () { /** * Initializes repositories. + * + * @return void */ - protected static function initRepositories(): void + protected static function initRepositories() { } /** * Initializes events. + * + * @return void */ - protected static function initEvents(): void + protected static function initEvents() { } } diff --git a/src/Infrastructure/Configuration/Configuration.php b/src/Infrastructure/Configuration/Configuration.php index 15cd6a1..4077601 100644 --- a/src/Infrastructure/Configuration/Configuration.php +++ b/src/Infrastructure/Configuration/Configuration.php @@ -95,8 +95,10 @@ abstract public function getAsyncProcessUrl($guid); * Saves min log level in integration database. * * @param int $minLogLevel Min log level. + * + * @return void */ - public function saveMinLogLevel($minLogLevel): void + public function saveMinLogLevel($minLogLevel) { $this->saveConfigValue('minLogLevel', $minLogLevel); } @@ -115,8 +117,10 @@ public function getMinLogLevel() * Set default logger status (enabled/disabled). * * @param bool $status TRUE if default logger is enabled; otherwise, false. + * + * @return void */ - public function setDefaultLoggerEnabled($status): void + public function setDefaultLoggerEnabled($status) { $this->saveConfigValue('defaultLoggerEnabled', $status); } @@ -135,8 +139,10 @@ public function isDefaultLoggerEnabled() * Sets debug mode status (enabled/disabled). * * @param bool $status TRUE if debug mode is enabled; otherwise, false. + * + * @return void */ - public function setDebugModeEnabled($status): void + public function setDebugModeEnabled($status) { $this->saveConfigValue('debugModeEnabled', (bool)$status); } @@ -177,8 +183,10 @@ public function getMaxStartedTasksLimit() * can be in "in_progress" status at the same time. * * @param int $limit Max started tasks limit. + * + * @return void */ - public function setMaxStartedTasksLimit($limit): void + public function setMaxStartedTasksLimit($limit) { $this->saveConfigValue('maxStartedTasksLimit', $limit); } @@ -197,8 +205,10 @@ public function getAsyncStarterBatchSize() * Sets async process batch size. * * @param int $size + * + * @return void */ - public function setAsyncStarterBatchSize($size): void + public function setAsyncStarterBatchSize($size) { $this->saveConfigValue('asyncStarterBatchSize', $size); } @@ -218,8 +228,10 @@ public function getTaskRunnerWakeupDelay() * Sets task runner wakeup delay. * * @param int $delay Delay in seconds. + * + * @return void */ - public function setTaskRunnerWakeupDelay($delay): void + public function setTaskRunnerWakeupDelay($delay) { $this->saveConfigValue('taskRunnerWakeupDelay', $delay); } @@ -240,8 +252,10 @@ public function getTaskRunnerMaxAliveTime() * Sets max alive time. * * @param int $maxAliveTime Max alive time in seconds. + * + * @return void */ - public function setTaskRunnerMaxAliveTime($maxAliveTime): void + public function setTaskRunnerMaxAliveTime($maxAliveTime) { $this->saveConfigValue('taskRunnerMaxAliveTime', $maxAliveTime); } @@ -261,8 +275,10 @@ public function getMaxTaskExecutionRetries() * Sets max task execution retries. * * @param int $maxRetries Max number of retries. + * + * @return void */ - public function setMaxTaskExecutionRetries($maxRetries): void + public function setMaxTaskExecutionRetries($maxRetries) { $this->saveConfigValue('maxTaskExecutionRetries', $maxRetries); } @@ -282,8 +298,10 @@ public function getMaxTaskInactivityPeriod() * Sets max task inactivity period. * * @param int $maxInactivityPeriod Max inactivity period in seconds. + * + * @return void */ - public function setMaxTaskInactivityPeriod($maxInactivityPeriod): void + public function setMaxTaskInactivityPeriod($maxInactivityPeriod) { $this->saveConfigValue('maxTaskInactivityPeriod', $maxInactivityPeriod); } @@ -304,9 +322,11 @@ public function getTaskRunnerStatus() * @param string $guid Global unique identifier. * @param int|null $timestamp Timestamp. * + * @return void + * * @throws TaskRunnerStatusStorageUnavailableException */ - public function setTaskRunnerStatus($guid, $timestamp): void + public function setTaskRunnerStatus($guid, $timestamp) { $taskRunnerStatus = array('guid' => $guid, 'timestamp' => $timestamp); $config = $this->saveConfigValue('taskRunnerStatus', $taskRunnerStatus); @@ -340,8 +360,10 @@ public function getAutoConfigurationUrl() * Sets current auto-configuration state. * * @param string $state Current state. + * + * @return void */ - public function setAutoConfigurationState($state): void + public function setAutoConfigurationState($state) { $this->saveConfigValue('autoConfigurationState', $state); } @@ -368,8 +390,10 @@ public function getHttpConfigurationOptions($domain) * * @param string $domain A domain for which to save configuration options. * @param Options[] $options HTTP configuration options + * + * @return void */ - public function setHttpConfigurationOptions($domain, array $options): void + public function setHttpConfigurationOptions($domain, array $options) { // get all current options and append new ones for given domain $data = json_decode($this->getConfigValue('httpConfigurationOptions', '[]'), true); diff --git a/src/Infrastructure/Data/DataTransferObject.php b/src/Infrastructure/Data/DataTransferObject.php index 7db3f13..038184a 100644 --- a/src/Infrastructure/Data/DataTransferObject.php +++ b/src/Infrastructure/Data/DataTransferObject.php @@ -69,7 +69,7 @@ public static function toBatchArray(array $batch) * * @return mixed[] Array representation of data transfer object. */ - abstract public function toArray(): array; + abstract public function toArray(); /** * Retrieves value from raw data. diff --git a/src/Infrastructure/Logger/Interfaces/LoggerAdapter.php b/src/Infrastructure/Logger/Interfaces/LoggerAdapter.php index b866013..7122444 100644 --- a/src/Infrastructure/Logger/Interfaces/LoggerAdapter.php +++ b/src/Infrastructure/Logger/Interfaces/LoggerAdapter.php @@ -15,6 +15,8 @@ interface LoggerAdapter * Log message in system * * @param LogData $data + * + * @return void */ - public function logMessage(LogData $data): void; + public function logMessage(LogData $data); } diff --git a/src/Infrastructure/Logger/LogContextData.php b/src/Infrastructure/Logger/LogContextData.php index 8cf3b81..14b8498 100644 --- a/src/Infrastructure/Logger/LogContextData.php +++ b/src/Infrastructure/Logger/LogContextData.php @@ -67,7 +67,7 @@ public static function fromArray(array $data) /** * @inheritDoc */ - public function toArray(): array + public function toArray() { return array( 'name' => $this->getName(), diff --git a/src/Infrastructure/Logger/LogData.php b/src/Infrastructure/Logger/LogData.php index f8eb3d4..7cf41c1 100644 --- a/src/Infrastructure/Logger/LogData.php +++ b/src/Infrastructure/Logger/LogData.php @@ -101,7 +101,7 @@ public function __construct( * * @return EntityConfiguration Configuration object. */ - public function getConfig(): EntityConfiguration + public function getConfig() { $map = new IndexMap(); $map->addStringIndex('integration') @@ -116,8 +116,10 @@ public function getConfig(): EntityConfiguration * Transforms raw array data to this entity instance. * * @param mixed[] $data Raw array data. + * + * @return void */ - public function inflate(array $data): void + public function inflate(array $data) { parent::inflate($data); diff --git a/src/Infrastructure/Logger/Logger.php b/src/Infrastructure/Logger/Logger.php index 051f36a..446e9c8 100644 --- a/src/Infrastructure/Logger/Logger.php +++ b/src/Infrastructure/Logger/Logger.php @@ -67,8 +67,10 @@ protected function __construct() * @param string $message Message to log. * @param string $component Component for which to log message. * @param LogContextData[]|array $context Additional context data. + * + * @return void */ - public static function logError($message, $component = 'Core', array $context = array()): void + public static function logError($message, $component = 'Core', array $context = array()) { self::getInstance()->logMessage(self::ERROR, $message, $component, $context); } @@ -79,8 +81,10 @@ public static function logError($message, $component = 'Core', array $context = * @param string $message Message to log. * @param string $component Component for which to log message. * @param LogContextData[]|array $context Additional context data. + * + * @return void */ - public static function logWarning($message, $component = 'Core', array $context = array()): void + public static function logWarning($message, $component = 'Core', array $context = array()) { self::getInstance()->logMessage(self::WARNING, $message, $component, $context); } @@ -91,8 +95,10 @@ public static function logWarning($message, $component = 'Core', array $context * @param string $message Message to log. * @param string $component Component for which to log message. * @param LogContextData[]|array $context Additional context data. + * + * @return void */ - public static function logInfo($message, $component = 'Core', array $context = array()): void + public static function logInfo($message, $component = 'Core', array $context = array()) { self::getInstance()->logMessage(self::INFO, $message, $component, $context); } @@ -103,8 +109,10 @@ public static function logInfo($message, $component = 'Core', array $context = a * @param string $message Message to log. * @param string $component Component for which to log message. * @param LogContextData[]|array $context Additional context data. + * + * @return void */ - public static function logDebug($message, $component = 'Core', array $context = array()): void + public static function logDebug($message, $component = 'Core', array $context = array()) { self::getInstance()->logMessage(self::DEBUG, $message, $component, $context); } @@ -116,8 +124,10 @@ public static function logDebug($message, $component = 'Core', array $context = * @param string $message Message to log. * @param string $component Component for which to log message. * @param LogContextData[]|array $context Additional context data. + * + * @return void */ - protected function logMessage($level, $message, $component, array $context = array()): void + protected function logMessage($level, $message, $component, array $context = array()) { $config = LoggerConfiguration::getInstance(); $logData = new LogData( diff --git a/src/Infrastructure/Logger/LoggerConfiguration.php b/src/Infrastructure/Logger/LoggerConfiguration.php index 36bf6f1..c85be54 100644 --- a/src/Infrastructure/Logger/LoggerConfiguration.php +++ b/src/Infrastructure/Logger/LoggerConfiguration.php @@ -57,8 +57,10 @@ class LoggerConfiguration extends Singleton * Set default logger status (turning on/off). * * @param bool $status + * + * @return void */ - public static function setDefaultLoggerEnabled($status): void + public static function setDefaultLoggerEnabled($status) { self::getInstance()->setIsDefaultLoggerEnabled($status); } @@ -68,8 +70,10 @@ public static function setDefaultLoggerEnabled($status): void * * @return bool * Logger status true => enabled, false => disabled. + * + * @return bool */ - public function isDefaultLoggerEnabled(): bool + public function isDefaultLoggerEnabled() { if (empty($this->isDefaultLoggerEnabled)) { try { @@ -89,8 +93,10 @@ public function isDefaultLoggerEnabled(): bool * Set default logger status (enabled or disabled). * * @param bool $loggerStatus Logger status true => enabled, false => disabled. + * + * @return void */ - public function setIsDefaultLoggerEnabled($loggerStatus): void + public function setIsDefaultLoggerEnabled($loggerStatus) { $this->getShopConfiguration()->setDefaultLoggerEnabled($loggerStatus); $this->isDefaultLoggerEnabled = $loggerStatus; @@ -106,7 +112,7 @@ public function setIsDefaultLoggerEnabled($loggerStatus): void * - info => 2 * - debug => 3 */ - public function getMinLogLevel(): int + public function getMinLogLevel() { if ($this->minLogLevel === null) { try { @@ -125,8 +131,10 @@ public function getMinLogLevel(): int * Saves min log level in integration. * * @param int $minLogLevel Log level. + * + * @return void */ - public function setMinLogLevel($minLogLevel): void + public function setMinLogLevel($minLogLevel) { $this->getShopConfiguration()->saveMinLogLevel($minLogLevel); $this->minLogLevel = $minLogLevel; diff --git a/src/Infrastructure/ORM/Entity.php b/src/Infrastructure/ORM/Entity.php index 0233388..dd708d1 100644 --- a/src/Infrastructure/ORM/Entity.php +++ b/src/Infrastructure/ORM/Entity.php @@ -42,7 +42,7 @@ public function __construct() * * @return string Fully qualified class name. */ - public static function getClassName(): string + public static function getClassName() { return static::CLASS_NAME; } @@ -54,7 +54,7 @@ public static function getClassName(): string * * @return static Transformed entity object. */ - public static function fromArray(array $data): Entity + public static function fromArray(array $data) { $instance = new static(); $instance->inflate($data); @@ -67,14 +67,16 @@ public static function fromArray(array $data): Entity * * @return EntityConfiguration Configuration object. */ - abstract public function getConfig(): EntityConfiguration; + abstract public function getConfig(); /** * Sets raw array data to this entity instance properties. * * @param mixed[] $data Raw array data with keys for class fields. @see self::$fields for field names. + * + * @return void */ - public function inflate(array $data): void + public function inflate(array $data) { foreach ($this->fields as $fieldName) { $this->$fieldName = static::getArrayValue($data, $fieldName, $this->$fieldName); @@ -86,7 +88,7 @@ public function inflate(array $data): void * * @return mixed[] Entity in array format. */ - public function toArray(): array + public function toArray() { $data = array('class_name' => static::getClassName()); foreach ($this->fields as $fieldName) { @@ -110,8 +112,10 @@ public function getId() * Sets entity identifier. * * @param int $id entity identifier. + * + * @return void */ - public function setId($id): void + public function setId($id) { $this->id = $id; } diff --git a/src/Infrastructure/ORM/Interfaces/ConditionallyDeletes.php b/src/Infrastructure/ORM/Interfaces/ConditionallyDeletes.php index 2d106b5..79ebd95 100644 --- a/src/Infrastructure/ORM/Interfaces/ConditionallyDeletes.php +++ b/src/Infrastructure/ORM/Interfaces/ConditionallyDeletes.php @@ -11,5 +11,12 @@ */ interface ConditionallyDeletes { - public function deleteWhere(QueryFilter $queryFilter = null): void; + /** + * Deletes entities that match the given query filter. + * + * @param QueryFilter|null $queryFilter + * + * @return void + */ + public function deleteWhere(QueryFilter $queryFilter = null); } diff --git a/src/Infrastructure/ORM/Interfaces/MassInsert.php b/src/Infrastructure/ORM/Interfaces/MassInsert.php index 8d7e4c6..f8f6912 100644 --- a/src/Infrastructure/ORM/Interfaces/MassInsert.php +++ b/src/Infrastructure/ORM/Interfaces/MassInsert.php @@ -10,6 +10,8 @@ interface MassInsert * Executes mass insert query for all provided entities * * @param Entity[] $entities + * + * @return void */ - public function massInsert(array $entities): void; + public function massInsert(array $entities); } diff --git a/src/Infrastructure/ORM/Interfaces/QueueItemRepository.php b/src/Infrastructure/ORM/Interfaces/QueueItemRepository.php index e00df6b..4d81a9b 100644 --- a/src/Infrastructure/ORM/Interfaces/QueueItemRepository.php +++ b/src/Infrastructure/ORM/Interfaces/QueueItemRepository.php @@ -42,7 +42,7 @@ public function findOldestQueuedItems($priority, $limit = 10); * @return int Id of saved queue item * @throws QueueItemSaveException if queue item could not be saved */ - public function saveWithCondition(QueueItem $queueItem, array $additionalWhere = array()): int; + public function saveWithCondition(QueueItem $queueItem, array $additionalWhere = array()); /** * Updates status of a batch of queue items. @@ -52,5 +52,5 @@ public function saveWithCondition(QueueItem $queueItem, array $additionalWhere = * * @return void */ - public function batchStatusUpdate(array $ids, $status): void; + public function batchStatusUpdate(array $ids, $status); } diff --git a/src/Infrastructure/ORM/Interfaces/RepositoryInterface.php b/src/Infrastructure/ORM/Interfaces/RepositoryInterface.php index 44d2a41..4cb2ea6 100644 --- a/src/Infrastructure/ORM/Interfaces/RepositoryInterface.php +++ b/src/Infrastructure/ORM/Interfaces/RepositoryInterface.php @@ -28,8 +28,10 @@ public static function getClassName(); * Sets repository entity. * * @param string $entityClass Repository entity class. + * + * @return void */ - public function setEntityClass(string $entityClass): void; + public function setEntityClass($entityClass); /** * Executes select query. diff --git a/src/Infrastructure/ORM/IntermediateObject.php b/src/Infrastructure/ORM/IntermediateObject.php index 225e298..e2be66c 100644 --- a/src/Infrastructure/ORM/IntermediateObject.php +++ b/src/Infrastructure/ORM/IntermediateObject.php @@ -45,15 +45,17 @@ class IntermediateObject /** * @return string|null */ - public function getIndex1(): ?string + public function getIndex1() { return $this->index1; } /** * @param string $index1 + * + * @return void */ - public function setIndex1(string $index1): void + public function setIndex1($index1) { $this->index1 = $index1; } @@ -61,15 +63,17 @@ public function setIndex1(string $index1): void /** * @return string|null */ - public function getIndex2(): ?string + public function getIndex2() { return $this->index2; } /** * @param string $index2 + * + * @return void */ - public function setIndex2(string $index2): void + public function setIndex2($index2) { $this->index2 = $index2; } @@ -84,8 +88,10 @@ public function getIndex3(): ?string /** * @param string $index3 + * + * @return void */ - public function setIndex3(string $index3): void + public function setIndex3($index3) { $this->index3 = $index3; } @@ -93,15 +99,17 @@ public function setIndex3(string $index3): void /** * @return string|null */ - public function getIndex4(): ?string + public function getIndex4() { return $this->index4; } /** * @param string $index4 + * + * @return void */ - public function setIndex4(string $index4): void + public function setIndex4($index4) { $this->index4 = $index4; } @@ -109,15 +117,17 @@ public function setIndex4(string $index4): void /** * @return string|null */ - public function getIndex5(): ?string + public function getIndex5() { return $this->index5; } /** * @param string $index5 + * + * @return void */ - public function setIndex5(string $index5): void + public function setIndex5($index5) { $this->index5 = $index5; } @@ -125,15 +135,17 @@ public function setIndex5(string $index5): void /** * @return string|null */ - public function getIndex6(): ?string + public function getIndex6() { return $this->index6; } /** * @param string $index6 + * + * @return void */ - public function setIndex6(string $index6): void + public function setIndex6($index6) { $this->index6 = $index6; } @@ -141,15 +153,17 @@ public function setIndex6(string $index6): void /** * @return string|null */ - public function getData(): ?string + public function getData() { return $this->data; } /** * @param string $data + * + * @return void */ - public function setData(string $data): void + public function setData($data) { $this->data = $data; } @@ -159,8 +173,10 @@ public function setData(string $data): void * * @param mixed $index * @param mixed $value + * + * @return void */ - public function setIndexValue($index, $value): void + public function setIndexValue($index, $value) { if (!is_int($index) || $index < 1 || !is_string($value)) { return; @@ -181,7 +197,7 @@ public function setIndexValue($index, $value): void * * @return string|null */ - public function getIndexValue($index): ?string + public function getIndexValue($index) { $value = null; if (!is_int($index) || $index < 1) { diff --git a/src/Infrastructure/ORM/QueryFilter/QueryFilter.php b/src/Infrastructure/ORM/QueryFilter/QueryFilter.php index b8ce201..2365911 100644 --- a/src/Infrastructure/ORM/QueryFilter/QueryFilter.php +++ b/src/Infrastructure/ORM/QueryFilter/QueryFilter.php @@ -52,7 +52,7 @@ class QueryFilter * * @return int|null Limit for select. */ - public function getLimit(): ?int + public function getLimit() { return $this->limit; } @@ -64,7 +64,7 @@ public function getLimit(): ?int * * @return self This instance for chaining. */ - public function setLimit(int $limit): QueryFilter + public function setLimit($limit) { $this->limit = $limit; @@ -76,7 +76,7 @@ public function setLimit(int $limit): QueryFilter * * @return int|null Offset. */ - public function getOffset(): ?int + public function getOffset() { return $this->offset; } @@ -88,7 +88,7 @@ public function getOffset(): ?int * * @return self This instance for chaining. */ - public function setOffset(int $offset): QueryFilter + public function setOffset($offset) { $this->offset = $offset; @@ -105,7 +105,7 @@ public function setOffset(int $offset): QueryFilter * * @throws QueryFilterInvalidParamException */ - public function orderBy($column, string $direction = self::ORDER_ASC): QueryFilter + public function orderBy($column, $direction = self::ORDER_ASC) { if (!is_string($column) || !in_array($direction, array(self::ORDER_ASC, self::ORDER_DESC), false)) { throw new QueryFilterInvalidParamException( @@ -124,7 +124,7 @@ public function orderBy($column, string $direction = self::ORDER_ASC): QueryFilt * * @return string|null Order column name. */ - public function getOrderByColumn(): ?string + public function getOrderByColumn() { return $this->orderByColumn; } @@ -134,7 +134,7 @@ public function getOrderByColumn(): ?string * * @return string|null Order direction (@see self::ORDER_ASC or @see self::ORDER_DESC) */ - public function getOrderDirection(): ?string + public function getOrderDirection() { return $this->orderDirection; } @@ -144,7 +144,7 @@ public function getOrderDirection(): ?string * * @return QueryCondition[] Filter conditions. */ - public function getConditions(): array + public function getConditions() { return $this->conditions; } @@ -160,7 +160,7 @@ public function getConditions(): array * * @throws QueryFilterInvalidParamException */ - public function where(string $column, string $operator, $value = null): QueryFilter + public function where($column, $operator, $value = null) { $this->validateConditionParameters($column, $operator, $value); @@ -180,7 +180,7 @@ public function where(string $column, string $operator, $value = null): QueryFil * * @throws QueryFilterInvalidParamException */ - public function orWhere(string $column, string $operator, $value = null): QueryFilter + public function orWhere($column, $operator, $value = null) { $this->validateConditionParameters($column, $operator, $value); @@ -196,9 +196,11 @@ public function orWhere(string $column, string $operator, $value = null): QueryF * @param mixed $operator Operator. Use constants from @see Operator class. * @param mixed $value Value of condition. * + * @return void + * * @throws QueryFilterInvalidParamException */ - protected function validateConditionParameters($column, $operator, $value): void + protected function validateConditionParameters($column, $operator, $value) { if (!is_string($column) || !is_string($operator)) { throw new QueryFilterInvalidParamException('Column and operator values must be string types'); diff --git a/src/Infrastructure/ORM/RepositoryRegistry.php b/src/Infrastructure/ORM/RepositoryRegistry.php index 234bca9..17d32e1 100644 --- a/src/Infrastructure/ORM/RepositoryRegistry.php +++ b/src/Infrastructure/ORM/RepositoryRegistry.php @@ -33,7 +33,7 @@ class RepositoryRegistry * * @throws RepositoryNotRegisteredException */ - public static function getRepository(string $entityClass): RepositoryInterface + public static function getRepository($entityClass) { if (!static::isRegistered($entityClass)) { throw new RepositoryNotRegisteredException("Repository for entity $entityClass not found or registered."); @@ -58,9 +58,11 @@ public static function getRepository(string $entityClass): RepositoryInterface * @param string $entityClass Class name of entity. * @param string $repositoryClass Class name of repository. * + * @return void + * * @throws RepositoryClassException */ - public static function registerRepository(string $entityClass, string $repositoryClass): void + public static function registerRepository($entityClass, $repositoryClass) { if (!is_subclass_of($repositoryClass, RepositoryInterface::CLASS_NAME)) { throw new RepositoryClassException("Class $repositoryClass is not implementation of RepositoryInterface."); @@ -77,7 +79,7 @@ public static function registerRepository(string $entityClass, string $repositor * * @return boolean Returns TRUE if repository has been registered; FALSE otherwise. */ - public static function isRegistered(string $entityClass): bool + public static function isRegistered($entityClass) { return isset(static::$repositories[$entityClass]); } @@ -90,7 +92,7 @@ public static function isRegistered(string $entityClass): bool * @throws RepositoryClassException * @throws RepositoryNotRegisteredException */ - public static function getQueueItemRepository(): QueueItemRepository + public static function getQueueItemRepository() { /** * @var QueueItemRepository $repository diff --git a/src/Infrastructure/ORM/Utility/EntityTranslator.php b/src/Infrastructure/ORM/Utility/EntityTranslator.php index a5ba254..087afdb 100644 --- a/src/Infrastructure/ORM/Utility/EntityTranslator.php +++ b/src/Infrastructure/ORM/Utility/EntityTranslator.php @@ -21,9 +21,11 @@ class EntityTranslator /** * @param string $entityClass * + * @return void + * * @throws EntityClassException */ - public function init(string $entityClass): void + public function init($entityClass) { if (!is_subclass_of($entityClass, Entity::getClassName())) { throw new EntityClassException("Class $entityClass is not implementation of Entity"); diff --git a/src/Infrastructure/ORM/Utility/IndexHelper.php b/src/Infrastructure/ORM/Utility/IndexHelper.php index e977820..13e14e6 100644 --- a/src/Infrastructure/ORM/Utility/IndexHelper.php +++ b/src/Infrastructure/ORM/Utility/IndexHelper.php @@ -19,7 +19,7 @@ class IndexHelper * * @return array Map of property indexes */ - public static function mapFieldsToIndexes(Entity $entity): array + public static function mapFieldsToIndexes(Entity $entity) { $result = array(); $config = $entity->getConfig(); @@ -38,7 +38,7 @@ public static function mapFieldsToIndexes(Entity $entity): array * * @return string[] */ - public static function transformFieldsToIndexes(Entity $entity): array + public static function transformFieldsToIndexes(Entity $entity) { $result = array(); $config = $entity->getConfig(); @@ -59,7 +59,7 @@ public static function transformFieldsToIndexes(Entity $entity): array * * @return mixed[]|string|null */ - public static function castFieldValue($value, string $type) + public static function castFieldValue($value, $type) { if ($value === null || is_string($value)) { return $value; diff --git a/src/Infrastructure/Serializer/Interfaces/Serializable.php b/src/Infrastructure/Serializer/Interfaces/Serializable.php index 49410a9..90d0897 100644 --- a/src/Infrastructure/Serializer/Interfaces/Serializable.php +++ b/src/Infrastructure/Serializer/Interfaces/Serializable.php @@ -17,14 +17,14 @@ interface Serializable extends \Serializable * @return static * Instance of serialized object. */ - public static function fromArray(array $array): Serializable; + public static function fromArray(array $array); /** * Transforms serializable object into an array. * * @return array Array representation of a serializable object. */ - public function toArray(): array; + public function toArray(); /** * @return array @@ -36,5 +36,5 @@ public function __serialize(); * * @return void */ - public function __unserialize(array $data): void; + public function __unserialize(array $data); } diff --git a/src/Infrastructure/ServiceRegister.php b/src/Infrastructure/ServiceRegister.php index 81f956d..bf5d6d3 100644 --- a/src/Infrastructure/ServiceRegister.php +++ b/src/Infrastructure/ServiceRegister.php @@ -49,7 +49,7 @@ protected function __construct(array $services = array()) * * @return ServiceRegister */ - public static function getInstance(): ServiceRegister + public static function getInstance() { if (self::$instance === null) { self::$instance = new ServiceRegister(); @@ -67,7 +67,7 @@ public static function getInstance(): ServiceRegister * * @return T */ - public static function getService(string $type) + public static function getService($type) { return self::getInstance()->get($type); } @@ -78,10 +78,12 @@ public static function getService(string $type) * @param string $type Type of service. Should be fully qualified class name. * @param callable $delegate Delegate that will give instance of registered service. * + * @return void + * * @throws InvalidArgumentException * In case delegate is not a callable. */ - public static function registerService(string $type, callable $delegate): void + public static function registerService($type, $delegate) { self::getInstance()->register($type, $delegate); } @@ -92,10 +94,12 @@ public static function registerService(string $type, callable $delegate): void * @param string $type Type of service. Should be fully qualified class name. * @param callable $delegate Delegate that will give instance of registered service. * + * @return void + * * @throws InvalidArgumentException * In case delegate is not a callable. */ - protected function register(string $type, callable $delegate): void + protected function register(string $type, callable $delegate) { if (!is_callable($delegate)) { throw new InvalidArgumentException("$type delegate is not callable."); diff --git a/src/Infrastructure/Singleton.php b/src/Infrastructure/Singleton.php index dee2702..ad79863 100644 --- a/src/Infrastructure/Singleton.php +++ b/src/Infrastructure/Singleton.php @@ -47,8 +47,10 @@ public static function getInstance() /** * Resets singleton instance. Required for proper tests. + * + * @return void */ - public static function resetInstance(): void + public static function resetInstance() { static::$instance = null; } diff --git a/src/Infrastructure/TaskExecution/AsyncBatchStarter.php b/src/Infrastructure/TaskExecution/AsyncBatchStarter.php index 5375c6a..8115cde 100644 --- a/src/Infrastructure/TaskExecution/AsyncBatchStarter.php +++ b/src/Infrastructure/TaskExecution/AsyncBatchStarter.php @@ -48,7 +48,7 @@ class AsyncBatchStarter implements Runnable /** * @inheritDoc */ - public function serialize(): ?string + public function serialize() { return Serializer::serialize(array($this->batchSize, $this->subBatches, $this->runners, $this->addIndex)); } @@ -67,7 +67,7 @@ public function unserialize($data) /** * @inheritDoc */ - public static function fromArray(array $array): Serializable + public static function fromArray(array $array) { $runners = array(); $subBatches = array(); @@ -89,7 +89,7 @@ public static function fromArray(array $array): Serializable /** * @inheritDoc */ - public function toArray(): array + public function toArray() { $runners = array(); $subBatches = array(); @@ -120,7 +120,7 @@ public function __serialize() /** * @inheritDoc */ - public function __unserialize($data): void + public function __unserialize($data) { $this->batchSize = $data['batchSize']; $this->addIndex = $data['addIndex']; @@ -146,7 +146,7 @@ public function __unserialize($data): void * @param int $batchSize * @param Runnable[] $runners */ - public function __construct(int $batchSize, array $runners = array()) + public function __construct($batchSize, array $runners = array()) { $this->batchSize = $batchSize; foreach ($runners as $runner) { @@ -158,8 +158,10 @@ public function __construct(int $batchSize, array $runners = array()) * Add runnable to the batch * * @param Runnable $runner + * + * @return void */ - public function addRunner(Runnable $runner): void + public function addRunner(Runnable $runner) { if ($this->isCapacityFull()) { $this->subBatches[$this->addIndex]->addRunner($runner); @@ -181,7 +183,7 @@ public function addRunner(Runnable $runner): void * * @throws ProcessStarterSaveException */ - public function run(): void + public function run() { foreach ($this->subBatches as $subBatch) { $this->getAsyncProcessStarter()->start($subBatch); @@ -198,7 +200,7 @@ public function run(): void * * @return int Max number of nested sub-batch levels */ - public function getMaxNestingLevels(): int + public function getMaxNestingLevels() { if (empty($this->subBatches)) { return 0; @@ -223,17 +225,17 @@ public function getMaxNestingLevels(): int * * @return float Wait period in micro seconds that is required for whole batch (with sub-batches) to run */ - public function getWaitTime(float $requestDuration) + public function getWaitTime($requestDuration) { // Without sub-batches all requests are started as soon as run method is done if (empty($this->subBatches)) { - return 0; + return 0.0; } $subBatchWaitTime = $this->batchSize * $this->getMaxNestingLevels() * $requestDuration; $runnersStartupTime = count($this->runners) * $requestDuration; - return $subBatchWaitTime - $runnersStartupTime; + return (float) $subBatchWaitTime - $runnersStartupTime; } /** @@ -254,7 +256,7 @@ public function __toString() * @return bool * True if current batch cant take any more runners nor create any more sub-batches itself; False otherwise */ - protected function isCapacityFull(): bool + protected function isCapacityFull() { return $this->isRunnersCapacityFull() && $this->isSubBatchCapacityFull(); } @@ -263,7 +265,7 @@ protected function isCapacityFull(): bool * @return bool * True if current batch cant create any more sub-batches itself; False otherwise */ - protected function isSubBatchCapacityFull(): bool + protected function isSubBatchCapacityFull() { return count($this->subBatches) >= $this->batchSize; } @@ -283,7 +285,7 @@ protected function isRunnersCapacityFull(): bool * @return AsyncProcessService * Instance of async process starter. */ - protected function getAsyncProcessStarter(): AsyncProcessService + protected function getAsyncProcessStarter() { if ($this->asyncProcessStarter === null) { $this->asyncProcessStarter = ServiceRegister::getService(AsyncProcessService::CLASS_NAME); diff --git a/src/Infrastructure/TaskExecution/AsyncProcessStarterService.php b/src/Infrastructure/TaskExecution/AsyncProcessStarterService.php index 67b9dbd..b29348b 100644 --- a/src/Infrastructure/TaskExecution/AsyncProcessStarterService.php +++ b/src/Infrastructure/TaskExecution/AsyncProcessStarterService.php @@ -77,10 +77,12 @@ protected function __construct() * * @param Runnable $runner Runner that should be started async. * + * @return void + * * @throws HttpRequestException * @throws ProcessStarterSaveException */ - public function start(Runnable $runner): void + public function start(Runnable $runner) { $guid = trim($this->guidProvider->generateGuid()); @@ -92,8 +94,10 @@ public function start(Runnable $runner): void * Runs a process with provided identifier. * * @param string $guid Identifier of process. + * + * @return void */ - public function runProcess($guid): void + public function runProcess($guid) { try { $filter = new QueryFilter(); @@ -125,9 +129,11 @@ public function runProcess($guid): void * @param string $guid Unique process identifier. * @param Runnable $runner Runner instance. * + * @return void + * * @throws ProcessStarterSaveException */ - protected function saveGuidAndRunner(string $guid, Runnable $runner): void + protected function saveGuidAndRunner($guid, Runnable $runner) { try { $process = new Process(); @@ -146,9 +152,11 @@ protected function saveGuidAndRunner(string $guid, Runnable $runner): void * * @param string $guid Unique process identifier. * + * @return void + * * @throws HttpRequestException */ - protected function startRunnerAsynchronously(string $guid): void + protected function startRunnerAsynchronously($guid) { try { $this->httpClient->requestAsync( diff --git a/src/Infrastructure/TaskExecution/Composite/ExecutionDetails.php b/src/Infrastructure/TaskExecution/Composite/ExecutionDetails.php index 3407eb5..9e3b676 100644 --- a/src/Infrastructure/TaskExecution/Composite/ExecutionDetails.php +++ b/src/Infrastructure/TaskExecution/Composite/ExecutionDetails.php @@ -75,8 +75,10 @@ public function getProgress() /** * @param float $progress + * + * @return void */ - public function setProgress(float $progress): void + public function setProgress($progress) { $this->progress = $progress; } @@ -100,7 +102,7 @@ public function unserialize($data) /** * @inheritDoc */ - public function toArray(): array + public function toArray() { return [ 'progress' => $this->getProgress(), @@ -120,7 +122,7 @@ public function __serialize() /** * @inheritDoc */ - public function __unserialize($data): void + public function __unserialize($data) { $this->progress = $data['progress']; $this->executionId = $data['executionId']; @@ -130,7 +132,7 @@ public function __unserialize($data): void /** * @return ExecutionDetails */ - public static function fromArray(array $array): Serializable + public static function fromArray(array $array) { $entity = new static($array['executionId'], $array['weight']); $entity->setProgress($array['progress']); diff --git a/src/Infrastructure/TaskExecution/Composite/Orchestrator.php b/src/Infrastructure/TaskExecution/Composite/Orchestrator.php index 73b9015..29fe0d2 100644 --- a/src/Infrastructure/TaskExecution/Composite/Orchestrator.php +++ b/src/Infrastructure/TaskExecution/Composite/Orchestrator.php @@ -39,7 +39,7 @@ public function __construct() /** * @inheritDoc */ - public function serialize(): ?string + public function serialize() { $taskList = []; foreach ($this->taskList as $data) { @@ -63,7 +63,7 @@ public function unserialize($serialized) /** * @inheritDoc */ - public static function fromArray(array $array): \SeQura\Core\Infrastructure\Serializer\Interfaces\Serializable + public static function fromArray(array $array) { $entity = new static(); foreach ($array['taskList'] as $data) { @@ -97,7 +97,7 @@ public function __serialize() /** * @inheritDoc */ - public function __unserialize($data): void + public function __unserialize($data) { $taskList = array(); foreach ($data['taskList'] as $task) { @@ -110,9 +110,11 @@ public function __unserialize($data): void /** * Creates subtasks. * + * @return void + * * @final */ - public function execute(): void + public function execute() { while ($task = $this->getSubTask()) { $this->taskList[] = $task; @@ -136,16 +138,18 @@ public function execute(): void * @param int $executionId Sub-Job id. * @param int|float $progress Between 0 and 100, inclusive. * + * @return void + * * @final */ - public function updateSubJobProgress(int $executionId, $progress): void + public function updateSubJobProgress($executionId, $progress) { if ($progress > 100 || $progress < 0) { - throw new InvalidArgumentException("Invalid progress ${progress} provided. "); + throw new InvalidArgumentException("Invalid progress $progress provided. "); } if (!($subJob = $this->getSubJob($executionId))) { - throw new InvalidArgumentException("Provided execution with id ${executionId} not found in task list"); + throw new InvalidArgumentException("Provided execution with id $executionId not found in task list"); } $subJob->setProgress($progress); @@ -154,18 +158,20 @@ public function updateSubJobProgress(int $executionId, $progress): void /** * @inheritDoc + * * @final */ - public function onFail(): void + public function onFail() { $this->abortSubJobs(); } /** * @inheritDoc + * * @final */ - public function onAbort(): void + public function onAbort() { $this->abortSubJobs(); } @@ -175,7 +181,7 @@ public function onAbort(): void * * @return ExecutionDetails | null */ - abstract protected function getSubTask(): ?ExecutionDetails; + abstract protected function getSubTask(); /** * Creates sub-job. @@ -187,7 +193,7 @@ abstract protected function getSubTask(): ?ExecutionDetails; * * @throws QueueStorageUnavailableException */ - protected function createSubJob(Task $task, int $weight = 1): ExecutionDetails + protected function createSubJob(Task $task, $weight = 1) { $queueItem = $this->getQueueService()->create($this->getSubJobQueueName(), $task, $this->getContext(), Priority::NORMAL, $this->getExecutionId()); @@ -217,7 +223,7 @@ protected function calculateProgress() * * @return string */ - protected function getSubJobQueueName(): string + protected function getSubJobQueueName() { return static::QUEUE_NAME_PREFIX . $this->getExecutionId(); } @@ -227,7 +233,7 @@ protected function getSubJobQueueName(): string * * @return QueueService */ - protected function getQueueService(): QueueService + protected function getQueueService() { return ServiceRegister::getService(QueueService::CLASS_NAME); } @@ -254,7 +260,7 @@ protected function getContext(): string * * @return ExecutionDetails | false */ - protected function getSubJob(int $executionId) + protected function getSubJob($executionId) { return current(array_filter( $this->taskList, @@ -266,8 +272,10 @@ static function (ExecutionDetails $d) use ($executionId) { /** * Aborts incomplete sub-jobs. + * + * @return void */ - protected function abortSubJobs(): void + protected function abortSubJobs() { $ids = []; foreach ($this->taskList as $task) { @@ -285,8 +293,10 @@ protected function abortSubJobs(): void /** * Starts sub-jobs. + * + * @return void */ - protected function startSubJobs(): void + protected function startSubJobs() { $ids = array_map(static function (ExecutionDetails $d) { return $d->getExecutionId(); diff --git a/src/Infrastructure/TaskExecution/CompositeTask.php b/src/Infrastructure/TaskExecution/CompositeTask.php index 6f2348e..69b04e7 100644 --- a/src/Infrastructure/TaskExecution/CompositeTask.php +++ b/src/Infrastructure/TaskExecution/CompositeTask.php @@ -51,7 +51,7 @@ abstract class CompositeTask extends Task * @param mixed[] $subTasks List of all tasks for this composite task. Key is task FQN and value is percentage share. * @param int $initialProgress Initial progress in percents. */ - public function __construct(array $subTasks, int $initialProgress = 0) + public function __construct(array $subTasks, $initialProgress = 0) { parent::__construct(); $this->initialProgress = $initialProgress; @@ -76,7 +76,7 @@ public function __construct(array $subTasks, int $initialProgress = 0) * @return Serializable * Instance of serialized object. */ - public static function fromArray(array $array): Serializable + public static function fromArray(array $array) { $tasks = array(); @@ -103,7 +103,7 @@ public static function fromArray(array $array): Serializable * * @return static */ - protected static function createTask(array $tasks, int $initialProgress): CompositeTask + protected static function createTask(array $tasks, int $initialProgress) { return new static($tasks, $initialProgress); } @@ -113,7 +113,7 @@ protected static function createTask(array $tasks, int $initialProgress): Compos * * @return mixed[] Array representation of a serializable object. */ - public function toArray(): array + public function toArray() { $tasks = array(); @@ -140,7 +140,7 @@ public function __serialize() /** * @inheritDoc */ - public function __unserialize($data): void + public function __unserialize($data) { $this->initialProgress = $data['initial_progress']; $this->taskProgressMap = $data['task_progress_map']; @@ -159,7 +159,7 @@ public function __unserialize($data): void /** * @inheritdoc */ - public function serialize(): ?string + public function serialize() { return Serializer::serialize( array( @@ -189,8 +189,10 @@ public function unserialize($serialized) /** * Called upon composite task deserialization. * Allows bootstrapping operations to be completed when the deserialization is complete. + * + * @return void */ - public function onUnserialized(): void + public function onUnserialized() { $this->registerSubTasksEvents(); } @@ -200,9 +202,11 @@ public function onUnserialized(): void * * @final * + * @return void + * * @throws AbortTaskExecutionException */ - public function execute(): void + public function execute() { while ($activeTask = $this->getActiveTask()) { $this->executeSubTask($activeTask); @@ -214,7 +218,7 @@ public function execute(): void * * @return bool TRUE if active task can be reconfigures; otherwise, FALSE. */ - public function canBeReconfigured(): bool + public function canBeReconfigured() { $activeTask = $this->getActiveTask(); @@ -222,9 +226,9 @@ public function canBeReconfigured(): bool } /** - * Reconfigures the task. + * @inheritdoc */ - public function reconfigure(): void + public function reconfigure() { $activeTask = $this->getActiveTask(); @@ -238,7 +242,7 @@ public function reconfigure(): void * * @return mixed[] A map of progress per task. Array key is task FQN and current progress is value. */ - public function getProgressByTask(): array + public function getProgressByTask() { return $this->taskProgressMap; } @@ -250,14 +254,14 @@ public function getProgressByTask(): array * * @return Task Created task. */ - abstract protected function createSubTask(string $taskKey): Task; + abstract protected function createSubTask($taskKey); /** * Returns active task. * * @return Task|null Active task if any; otherwise, NULL. */ - protected function getActiveTask(): ?Task + protected function getActiveTask() { $task = null; foreach ($this->taskProgressMap as $taskKey => $taskProgress) { @@ -282,7 +286,7 @@ protected function getActiveTask(): ?Task * * @return Task An instance of task for given FQN. */ - protected function getSubTask(string $taskKey): Task + protected function getSubTask(string $taskKey) { if (empty($this->tasks[$taskKey])) { $this->tasks[$taskKey] = $this->createSubTask($taskKey); @@ -294,8 +298,10 @@ protected function getSubTask(string $taskKey): Task /** * Registers "report progress" and "report alive" events to all sub tasks. + * + * @return void */ - protected function registerSubTasksEvents(): void + protected function registerSubTasksEvents() { foreach ($this->tasks as $key => $task) { $this->registerSubTaskEvents($key); @@ -306,8 +312,10 @@ protected function registerSubTasksEvents(): void * Registers "report progress" and "report alive" events to a sub task. * * @param string $taskKey KeyA Task for which to register listener. + * + * @return void */ - protected function registerSubTaskEvents(string $taskKey): void + protected function registerSubTaskEvents($taskKey) { $task = $this->tasks[$taskKey]; $task->setExecutionId($this->getExecutionId()); @@ -320,8 +328,10 @@ protected function registerSubTaskEvents(string $taskKey): void * * @param float $subTaskProgress Progress for current sub task. * @param string $subTaskKey FQN of current task. + * + * @return void */ - protected function calculateProgress(float $subTaskProgress, string $subTaskKey): void + protected function calculateProgress($subTaskProgress, $subTaskKey) { // set current task progress to overall map $this->taskProgressMap[$subTaskKey] = $subTaskProgress; @@ -343,7 +353,7 @@ protected function calculateProgress(float $subTaskProgress, string $subTaskKey) * * @return bool TRUE if all tasks are completed; otherwise, FALSE. */ - protected function isProcessCompleted(): bool + protected function isProcessCompleted() { foreach (array_keys($this->tasksProgressShare) as $subTaskKey) { if ($this->taskProgressMap[$subTaskKey] < 100) { @@ -358,8 +368,10 @@ protected function isProcessCompleted(): bool * Registers "report alive" event listener so that this composite task can broadcast event. * * @param Task $task A Task for which to register listener. + * + * @return void */ - protected function registerReportAliveEvent(Task $task): void + protected function registerReportAliveEvent(Task $task) { $self = $this; @@ -375,8 +387,10 @@ function () use ($self) { * Registers "report progress" event listener so that this composite task can calculate and report overall progress. * * @param string $taskKey A Task for which to register listener. + * + * @return void */ - protected function registerReportProgressEvent(string $taskKey): void + protected function registerReportProgressEvent($taskKey) { $self = $this; $task = $this->tasks[$taskKey]; @@ -395,9 +409,11 @@ function (TaskProgressEvent $event) use ($self, $taskKey) { * * @param Task $activeTask * + * @return void + * * @throws AbortTaskExecutionException */ - protected function executeSubTask(Task $activeTask): void + protected function executeSubTask(Task $activeTask) { $activeTask->execute(); } diff --git a/src/Infrastructure/TaskExecution/Events/QueueItemAbortedEvent.php b/src/Infrastructure/TaskExecution/Events/QueueItemAbortedEvent.php index 68c9fab..679133a 100644 --- a/src/Infrastructure/TaskExecution/Events/QueueItemAbortedEvent.php +++ b/src/Infrastructure/TaskExecution/Events/QueueItemAbortedEvent.php @@ -22,7 +22,7 @@ class QueueItemAbortedEvent extends BaseQueueItemEvent * @param QueueItem $queueItem * @param string $abortDescription */ - public function __construct(QueueItem $queueItem, string $abortDescription) + public function __construct(QueueItem $queueItem, $abortDescription) { parent::__construct($queueItem); $this->abortDescription = $abortDescription; diff --git a/src/Infrastructure/TaskExecution/Interfaces/AsyncProcessService.php b/src/Infrastructure/TaskExecution/Interfaces/AsyncProcessService.php index f81c82b..8346ccd 100644 --- a/src/Infrastructure/TaskExecution/Interfaces/AsyncProcessService.php +++ b/src/Infrastructure/TaskExecution/Interfaces/AsyncProcessService.php @@ -21,14 +21,18 @@ interface AsyncProcessService * * @param Runnable $runner Runner that should be started async * + * @return void + * * @throws ProcessStarterSaveException */ - public function start(Runnable $runner): void; + public function start(Runnable $runner); /** * Runs a process with provided identifier. * * @param string $guid Identifier of process. + * + * @return void */ - public function runProcess($guid): void; + public function runProcess($guid); } diff --git a/src/Infrastructure/TaskExecution/Interfaces/Runnable.php b/src/Infrastructure/TaskExecution/Interfaces/Runnable.php index 016a1b2..78a7d49 100644 --- a/src/Infrastructure/TaskExecution/Interfaces/Runnable.php +++ b/src/Infrastructure/TaskExecution/Interfaces/Runnable.php @@ -13,6 +13,8 @@ interface Runnable extends Serializable { /** * Starts runnable run logic + * + * @return void */ - public function run(): void; + public function run(); } diff --git a/src/Infrastructure/TaskExecution/Interfaces/TaskRunnerManager.php b/src/Infrastructure/TaskExecution/Interfaces/TaskRunnerManager.php index a0fcbfa..359d033 100644 --- a/src/Infrastructure/TaskExecution/Interfaces/TaskRunnerManager.php +++ b/src/Infrastructure/TaskExecution/Interfaces/TaskRunnerManager.php @@ -13,11 +13,15 @@ interface TaskRunnerManager /** * Halts task runner. + * + * @return void */ - public function halt(): void; + public function halt(); /** * Resumes task execution. + * + * @return void */ - public function resume(): void; + public function resume(); } diff --git a/src/Infrastructure/TaskExecution/Interfaces/TaskRunnerStatusStorage.php b/src/Infrastructure/TaskExecution/Interfaces/TaskRunnerStatusStorage.php index 600a742..cfbdd3b 100644 --- a/src/Infrastructure/TaskExecution/Interfaces/TaskRunnerStatusStorage.php +++ b/src/Infrastructure/TaskExecution/Interfaces/TaskRunnerStatusStorage.php @@ -24,7 +24,7 @@ interface TaskRunnerStatusStorage * @return TaskRunnerStatus Current runner status * @throws TaskRunnerStatusStorageUnavailableException When task storage is not available */ - public function getStatus(): TaskRunnerStatus; + public function getStatus(); /** * Sets status of task runner to provided status. @@ -32,9 +32,11 @@ public function getStatus(): TaskRunnerStatus; * * @param TaskRunnerStatus $status * + * @return void + * * @throws TaskRunnerStatusChangeException Thrown when setting status operation fails because: * - Trying to set new task status to new nonempty guid but currently set guid is not empty * @throws TaskRunnerStatusStorageUnavailableException When task storage is not available */ - public function setStatus(TaskRunnerStatus $status): void; + public function setStatus(TaskRunnerStatus $status); } diff --git a/src/Infrastructure/TaskExecution/Interfaces/TaskRunnerWakeup.php b/src/Infrastructure/TaskExecution/Interfaces/TaskRunnerWakeup.php index 0064c84..c1b8ec3 100644 --- a/src/Infrastructure/TaskExecution/Interfaces/TaskRunnerWakeup.php +++ b/src/Infrastructure/TaskExecution/Interfaces/TaskRunnerWakeup.php @@ -16,6 +16,8 @@ interface TaskRunnerWakeup /** * Wakes up TaskRunner instance asynchronously if active instance is not already running. + * + * @return void */ - public function wakeup(): void; + public function wakeup(); } diff --git a/src/Infrastructure/TaskExecution/Process.php b/src/Infrastructure/TaskExecution/Process.php index 96b7cd8..bd4843f 100644 --- a/src/Infrastructure/TaskExecution/Process.php +++ b/src/Infrastructure/TaskExecution/Process.php @@ -38,9 +38,11 @@ class Process extends Entity * * @param mixed[] $data Raw array data with keys 'id', 'guid' and 'runner'. * + * @return void + * * @throws InvalidArgumentException In case when @see $data does not have all needed keys. */ - public function inflate(array $data): void + public function inflate(array $data) { if (!isset($data['guid'], $data['runner'])) { throw new InvalidArgumentException('Data array needs to have "guid" and "runner" keys.'); @@ -56,7 +58,7 @@ public function inflate(array $data): void * * @return mixed[] Entity in array format. */ - public function toArray(): array + public function toArray() { $data = parent::toArray(); $data['guid'] = $this->getGuid(); @@ -70,7 +72,7 @@ public function toArray(): array * * @return EntityConfiguration */ - public function getConfig(): EntityConfiguration + public function getConfig() { $indexMap = new IndexMap(); $indexMap->addStringIndex('guid'); @@ -83,7 +85,7 @@ public function getConfig(): EntityConfiguration * * @return string Guid. */ - public function getGuid(): string + public function getGuid() { return $this->guid; } @@ -92,8 +94,10 @@ public function getGuid(): string * Sets Guid. * * @param string $guid Guid. + * + * @return void */ - public function setGuid(string $guid): void + public function setGuid($guid) { $this->guid = $guid; } @@ -103,7 +107,7 @@ public function setGuid(string $guid): void * * @return Runnable Runner. */ - public function getRunner(): Runnable + public function getRunner() { return $this->runner; } @@ -112,8 +116,10 @@ public function getRunner(): Runnable * Sets Runner. * * @param Runnable $runner Runner. + * + * @return void */ - public function setRunner(Runnable $runner): void + public function setRunner(Runnable $runner) { $this->runner = $runner; } diff --git a/src/Infrastructure/TaskExecution/QueueItemStarter.php b/src/Infrastructure/TaskExecution/QueueItemStarter.php index c051700..65bbebb 100644 --- a/src/Infrastructure/TaskExecution/QueueItemStarter.php +++ b/src/Infrastructure/TaskExecution/QueueItemStarter.php @@ -61,7 +61,7 @@ public function __construct($queueItemId) * @return Serializable * Instance of serialized object. */ - public static function fromArray(array $array): Serializable + public static function fromArray(array $array) { return new static($array['queue_item_id']); } diff --git a/src/Infrastructure/TaskExecution/Task.php b/src/Infrastructure/TaskExecution/Task.php index cab587c..9533c73 100644 --- a/src/Infrastructure/TaskExecution/Task.php +++ b/src/Infrastructure/TaskExecution/Task.php @@ -60,14 +60,16 @@ public function __construct() /** * Runs task logic. * + * @return void + * * @throws AbortTaskExecutionException */ - abstract public function execute(): void; + abstract public function execute(); /** * @inheritdoc */ - public function serialize(): ?string + public function serialize() { return Serializer::serialize(array()); } @@ -84,7 +86,7 @@ public function unserialize($data) /** * @inheritDoc */ - public static function fromArray(array $array): Serializable + public static function fromArray(array $array) { return new static(); } @@ -92,7 +94,7 @@ public static function fromArray(array $array): Serializable /** * @inheritDoc */ - public function toArray(): array + public function toArray() { return array(); } @@ -115,10 +117,12 @@ public function getPriority(): int * * @param float|int $progressPercent * + * @return void + * * @throws InvalidArgumentException In case when progress percent is outside of 0 - 100 boundaries or not an float * @see TaskProgressEvent and defers next @see AliveAnnouncedTaskEvent. */ - public function reportProgress($progressPercent): void + public function reportProgress($progressPercent) { if (!is_int($progressPercent) && !is_float($progressPercent)) { throw new InvalidArgumentException('Progress percentage must be value integer or float value'); @@ -138,9 +142,11 @@ public function reportProgress($progressPercent): void * * @param boolean $force * + * @return void + * * @see AliveAnnouncedTaskEvent. */ - public function reportAlive(bool $force = false): void + public function reportAlive($force = false) { /** * @var TimeProvider $timeProvider @@ -161,7 +167,7 @@ public function reportAlive(bool $force = false): void * * @return int Max inactivity period for a task in seconds. */ - public function getMaxInactivityPeriod(): int + public function getMaxInactivityPeriod() { $configurationValue = $this->getConfigService()->getMaxTaskInactivityPeriod(); @@ -174,7 +180,7 @@ public function getMaxInactivityPeriod(): int * * @return string FQN of the task. */ - public function getType(): string + public function getType() { return static::getClassName(); } @@ -184,7 +190,7 @@ public function getType(): string * * @return string FQN of the task. */ - public static function getClassName(): string + public static function getClassName() { $namespaceParts = explode('\\', get_called_class()); $name = end($namespaceParts); @@ -201,15 +207,17 @@ public static function getClassName(): string * * @return bool TRUE if task can be reconfigured; otherwise, FALSE. */ - public function canBeReconfigured(): bool + public function canBeReconfigured() { return false; } /** * Reconfigures the task. + * + * @return void */ - public function reconfigure(): void + public function reconfigure() { } @@ -227,24 +235,30 @@ public function getExecutionId() * Sets Execution id. * * @param int|string $executionId Execution id. + * + * @return void */ - public function setExecutionId($executionId): void + public function setExecutionId($executionId) { $this->executionId = $executionId; } /** * Cleans up resources upon failure. + * + * @return void */ - public function onFail(): void + public function onFail() { // Extension stub. } /** * Cleans up resources upon abort. + * + * @return void */ - public function onAbort(): void + public function onAbort() { // Extension stub. } @@ -256,7 +270,7 @@ public function onAbort(): void * * @return int Base points representation of percentage. */ - protected function percentToBasePoints(float $percentValue): int + protected function percentToBasePoints($percentValue) { return (int)round($percentValue * 100, 2); } diff --git a/src/Infrastructure/TaskExecution/TaskRunnerStarter.php b/src/Infrastructure/TaskExecution/TaskRunnerStarter.php index 3cd8b8f..6f5d742 100644 --- a/src/Infrastructure/TaskExecution/TaskRunnerStarter.php +++ b/src/Infrastructure/TaskExecution/TaskRunnerStarter.php @@ -70,7 +70,7 @@ public function __construct($guid) * @return Serializable * Instance of serialized object. */ - public static function fromArray(array $array): Serializable + public static function fromArray(array $array) { return new static($array['guid']); } diff --git a/tests/Infrastructure/Common/TestComponents/ORM/MemoryRepository.php b/tests/Infrastructure/Common/TestComponents/ORM/MemoryRepository.php index b977d47..5e72305 100644 --- a/tests/Infrastructure/Common/TestComponents/ORM/MemoryRepository.php +++ b/tests/Infrastructure/Common/TestComponents/ORM/MemoryRepository.php @@ -170,11 +170,9 @@ public static function getClassName() } /** - * Sets repository entity - * - * @param string $entityClass + * @inheritdoc */ - public function setEntityClass(string $entityClass): void + public function setEntityClass($entityClass) { $this->entityClass = $entityClass; } diff --git a/tests/Infrastructure/Common/TestComponents/TaskExecution/AbortTask.php b/tests/Infrastructure/Common/TestComponents/TaskExecution/AbortTask.php index a6263d6..0d8bf05 100644 --- a/tests/Infrastructure/Common/TestComponents/TaskExecution/AbortTask.php +++ b/tests/Infrastructure/Common/TestComponents/TaskExecution/AbortTask.php @@ -21,7 +21,7 @@ public function execute(): void /** * @inheritDoc */ - public static function fromArray(array $array): Serializable + public static function fromArray(array $array) { return new static(); } diff --git a/tests/Infrastructure/Common/TestComponents/TaskExecution/FakeRunnable.php b/tests/Infrastructure/Common/TestComponents/TaskExecution/FakeRunnable.php index 605e670..61d77f0 100644 --- a/tests/Infrastructure/Common/TestComponents/TaskExecution/FakeRunnable.php +++ b/tests/Infrastructure/Common/TestComponents/TaskExecution/FakeRunnable.php @@ -40,7 +40,7 @@ public function unserialize($serialized) /** * @inheritDoc */ - public static function fromArray(array $array): Serializable + public static function fromArray(array $array) { $instance = new self($array['testProperty']); diff --git a/tests/Infrastructure/Common/TestComponents/TaskExecution/FooTask.php b/tests/Infrastructure/Common/TestComponents/TaskExecution/FooTask.php index a57a9b7..8faa784 100644 --- a/tests/Infrastructure/Common/TestComponents/TaskExecution/FooTask.php +++ b/tests/Infrastructure/Common/TestComponents/TaskExecution/FooTask.php @@ -141,7 +141,7 @@ public function reconfigure(): void $this->methodsCallCount['reconfigure']++; } - public function canBeReconfigured(): bool + public function canBeReconfigured() { return true; }