Skip to content

Commit

Permalink
Restore some of the changed method's signatures to preserve compatibi…
Browse files Browse the repository at this point in the history
…lity with current integrations
  • Loading branch information
m1k3lm committed Oct 9, 2024
1 parent ea72a06 commit 26fec4a
Show file tree
Hide file tree
Showing 49 changed files with 380 additions and 210 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class WidgetSettings extends Entity
/**
* @inheritDoc
*/
public function inflate(array $data): void
public function inflate(array $data)
{
parent::inflate($data);

Expand Down
2 changes: 1 addition & 1 deletion src/BusinessLogic/Domain/OrderReport/OrderReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/BusinessLogic/Webhook/Tasks/OrderUpdateTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 2 additions & 6 deletions src/Infrastructure/AutoTest/AutoTestLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 12 additions & 4 deletions src/Infrastructure/AutoTest/AutoTestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/Infrastructure/AutoTest/AutoTestStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 7 additions & 10 deletions src/Infrastructure/AutoTest/AutoTestTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -39,15 +38,15 @@ public function __construct($data)
/**
* @inheritDoc
*/
public static function fromArray(array $array): Serializable
public static function fromArray(array $array)
{
return new static($array['data']);
}

/**
* @inheritDoc
*/
public function toArray(): array
public function toArray()
{
return array('data' => $this->data);
}
Expand All @@ -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));
}
Expand All @@ -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');
Expand Down
16 changes: 12 additions & 4 deletions src/Infrastructure/BootstrapComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ class BootstrapComponent
{
/**
* Initializes infrastructure components.
*
* @return void
*/
public static function init(): void
public static function init()
{
static::initServices();
static::initRepositories();
Expand All @@ -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,
Expand Down Expand Up @@ -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()
{
}
}
48 changes: 36 additions & 12 deletions src/Infrastructure/Configuration/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Infrastructure/Data/DataTransferObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion src/Infrastructure/Logger/Interfaces/LoggerAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion src/Infrastructure/Logger/LogContextData.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static function fromArray(array $data)
/**
* @inheritDoc
*/
public function toArray(): array
public function toArray()
{
return array(
'name' => $this->getName(),
Expand Down
Loading

0 comments on commit 26fec4a

Please sign in to comment.