Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions classes/AjaxResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
namespace PrestaShop\Module\AutoUpgrade;

use PrestaShop\Module\AutoUpgrade\Log\Logger;
use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeConfiguration;
use PrestaShop\Module\AutoUpgrade\Parameters\UpdateConfiguration;
use PrestaShop\Module\AutoUpgrade\State\AbstractState;

/**
Expand Down Expand Up @@ -63,9 +63,9 @@ class AjaxResponse
const RESPONSE_FORMAT = 'json';

/**
* @var UpgradeConfiguration
* @var UpdateConfiguration
*/
private $upgradeConfiguration;
private $updateConfiguration;

/**
* @var Logger
Expand Down Expand Up @@ -101,7 +101,7 @@ public function getResponse(): array
$this->state->export(),
[
'typeResult' => self::RESPONSE_FORMAT,
'config' => $this->upgradeConfiguration->toArray(),
'config' => $this->updateConfiguration->toArray(),
]
),
];
Expand Down Expand Up @@ -145,9 +145,9 @@ public function getNextParams(): array
return $this->nextParams;
}

public function getUpgradeConfiguration(): UpgradeConfiguration
public function getUpdateConfiguration(): UpdateConfiguration
{
return $this->upgradeConfiguration;
return $this->updateConfiguration;
}

// SETTERS
Expand Down Expand Up @@ -183,9 +183,9 @@ public function setNextParams(array $nextParams): AjaxResponse
return $this;
}

public function setUpgradeConfiguration(UpgradeConfiguration $upgradeConfiguration): AjaxResponse
public function setUpdateConfiguration(UpdateConfiguration $updateConfiguration): AjaxResponse
{
$this->upgradeConfiguration = $upgradeConfiguration;
$this->updateConfiguration = $updateConfiguration;

return $this;
}
Expand Down
16 changes: 12 additions & 4 deletions classes/Analytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

namespace PrestaShop\Module\AutoUpgrade;

use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeConfiguration;
use PrestaShop\Module\AutoUpgrade\Parameters\BackupConfiguration;
use PrestaShop\Module\AutoUpgrade\Parameters\UpdateConfiguration;
use PrestaShop\Module\AutoUpgrade\State\RestoreState;
use PrestaShop\Module\AutoUpgrade\State\UpdateState;

Expand All @@ -48,10 +49,15 @@ class Analytics
private $properties;

/**
* @var UpgradeConfiguration
* @var UpdateConfiguration
*/
private $updateConfiguration;

/**
* @var BackupConfiguration
*/
private $backupConfiguration;

/**
* @var array{'restore': RestoreState, 'update': UpdateState}
*/
Expand All @@ -67,13 +73,15 @@ class Analytics
* @param array{'restore': RestoreState, 'update': UpdateState} $states
*/
public function __construct(
UpgradeConfiguration $updateConfiguration,
UpdateConfiguration $updateConfiguration,
BackupConfiguration $backupConfiguration,
Environment $environment,
array $states,
string $anonymousUserId,
array $options
) {
$this->updateConfiguration = $updateConfiguration;
$this->backupConfiguration = $backupConfiguration;
$this->states = $states;

$this->anonymousId = $anonymousUserId;
Expand Down Expand Up @@ -122,7 +130,7 @@ public function getProperties($type): array
switch ($type) {
case self::WITH_BACKUP_PROPERTIES:
$additionalProperties = [
'backup_images' => $this->updateConfiguration->shouldBackupImages(),
'backup_images' => $this->backupConfiguration->shouldBackupImages(),
];
$upgradeProperties = $this->properties[self::WITH_BACKUP_PROPERTIES] ?? [];
$additionalProperties = array_merge($upgradeProperties, $additionalProperties);
Expand Down
10 changes: 5 additions & 5 deletions classes/Commands/CheckModulesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

use Exception;
use PrestaShop\Module\AutoUpgrade\Exceptions\MarketplaceApiException;
use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeConfiguration;
use PrestaShop\Module\AutoUpgrade\Parameters\UpdateConfiguration;
use PrestaShop\Module\AutoUpgrade\Task\ExitCode;
use PrestaShop\Module\AutoUpgrade\UpgradeContainer;
use Symfony\Component\Console\Helper\ProgressIndicator;
Expand All @@ -46,7 +46,7 @@ protected function configure(): void
'channel',
null,
InputOption::VALUE_REQUIRED,
"Select which update channel to use ('" . UpgradeConfiguration::CHANNEL_LOCAL . "' / '" . UpgradeConfiguration::CHANNEL_ONLINE_RECOMMENDED . "' / '" . UpgradeConfiguration::CHANNEL_ONLINE . "')"
"Select which update channel to use ('" . UpdateConfiguration::CHANNEL_LOCAL . "' / '" . UpdateConfiguration::CHANNEL_ONLINE_RECOMMENDED . "' / '" . UpdateConfiguration::CHANNEL_ONLINE . "')"
)
->addOption('zip', null, InputOption::VALUE_REQUIRED, 'Sets the archive zip file for a local channel.')
->setHelp('This command checks the installed modules for compatibility with the target PrestaShop version and lists available updates.')
Expand All @@ -61,14 +61,14 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
{
try {
$this->setupEnvironment($input, $output);
$config[UpgradeConfiguration::CHANNEL] = $input->getOption('channel') ?? UpgradeConfiguration::CHANNEL_ONLINE_RECOMMENDED;
$config[UpdateConfiguration::CHANNEL] = $input->getOption('channel') ?? UpdateConfiguration::CHANNEL_ONLINE_RECOMMENDED;

$this->upgradeContainer->getConfigurationValidator()->validate($config);
$this->upgradeContainer->initPrestaShopAutoloader();
$this->upgradeContainer->initPrestaShopCore();
$channel = $config[UpgradeConfiguration::CHANNEL];
$channel = $config[UpdateConfiguration::CHANNEL];

if ($channel === UpgradeConfiguration::CHANNEL_ONLINE_RECOMMENDED || $channel === UpgradeConfiguration::CHANNEL_ONLINE) {
if ($channel === UpdateConfiguration::CHANNEL_ONLINE_RECOMMENDED || $channel === UpdateConfiguration::CHANNEL_ONLINE) {
$targetPsVersion = $this->upgradeContainer->getUpgrader()->getOnlineDestinationVersionForChannel($channel);
} else {
$zip = $input->getOption('zip');
Expand Down
8 changes: 4 additions & 4 deletions classes/Commands/CheckNewVersionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use Exception;
use PrestaShop\Module\AutoUpgrade\Exceptions\DistributionApiException;
use PrestaShop\Module\AutoUpgrade\Exceptions\ProcessException;
use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeConfiguration;
use PrestaShop\Module\AutoUpgrade\Parameters\UpdateConfiguration;
use PrestaShop\Module\AutoUpgrade\Services\LocalVersionFilesService;
use PrestaShop\Module\AutoUpgrade\Task\ExitCode;
use PrestaShop\Module\AutoUpgrade\UpgradeContainer;
Expand Down Expand Up @@ -70,7 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
$updateType = VersionUtils::getUpdateType($currentVersion, $localVersion);
$zipFiles = 'Zip: ' . implode(', ', $files[LocalVersionFilesService::TYPE_ZIP]) . "\n";
$xmlFiles = 'Xml: ' . implode(', ', $files[LocalVersionFilesService::TYPE_XML]);
$rows[] = [$localVersion, UpgradeConfiguration::CHANNEL_LOCAL, $updateType, $zipFiles . $xmlFiles];
$rows[] = [$localVersion, UpdateConfiguration::CHANNEL_LOCAL, $updateType, $zipFiles . $xmlFiles];
}

// sort by newest
Expand All @@ -86,13 +86,13 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
if ($onlineMaxRelease && ($onlineRecommendedRelease === null || $onlineMaxRelease->getVersion() !== $onlineRecommendedRelease->getVersion())) {
$destinationVersion = $onlineMaxRelease->getVersion();
$updateType = VersionUtils::getUpdateType($currentVersion, $destinationVersion);
array_unshift($rows, [$destinationVersion, UpgradeConfiguration::CHANNEL_ONLINE, $updateType, $onlineMaxRelease->getReleaseNoteUrl()]);
array_unshift($rows, [$destinationVersion, UpdateConfiguration::CHANNEL_ONLINE, $updateType, $onlineMaxRelease->getReleaseNoteUrl()]);
}

if ($onlineRecommendedRelease) {
$destinationVersion = $onlineRecommendedRelease->getVersion();
$updateType = VersionUtils::getUpdateType($currentVersion, $destinationVersion);
array_unshift($rows, [$destinationVersion, UpgradeConfiguration::CHANNEL_ONLINE_RECOMMENDED, $updateType, $onlineRecommendedRelease->getReleaseNoteUrl()]);
array_unshift($rows, [$destinationVersion, UpdateConfiguration::CHANNEL_ONLINE_RECOMMENDED, $updateType, $onlineRecommendedRelease->getReleaseNoteUrl()]);
}

$table = new Table($output);
Expand Down
6 changes: 3 additions & 3 deletions classes/Commands/CheckRequirementsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use Exception;
use PrestaShop\Module\AutoUpgrade\Exceptions\DistributionApiException;
use PrestaShop\Module\AutoUpgrade\Exceptions\ProcessException;
use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeConfiguration;
use PrestaShop\Module\AutoUpgrade\Parameters\UpdateConfiguration;
use PrestaShop\Module\AutoUpgrade\Task\ExitCode;
use PrestaShop\Module\AutoUpgrade\UpgradeSelfCheck;
use Symfony\Component\Console\Input\InputArgument;
Expand Down Expand Up @@ -62,8 +62,8 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
$this->output = $output;

$options = [
UpgradeConfiguration::ARCHIVE_ZIP => 'zip',
UpgradeConfiguration::ARCHIVE_XML => 'xml',
UpdateConfiguration::ARCHIVE_ZIP => 'zip',
UpdateConfiguration::ARCHIVE_XML => 'xml',
];
foreach ($options as $configKey => $optionName) {
$optionValue = $input->getOption($optionName);
Expand Down
4 changes: 2 additions & 2 deletions classes/Commands/CreateBackupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
namespace PrestaShop\Module\AutoUpgrade\Commands;

use Exception;
use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeConfiguration;
use PrestaShop\Module\AutoUpgrade\Parameters\BackupConfiguration;
use PrestaShop\Module\AutoUpgrade\Task\Runner\AllBackupTasks;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -55,7 +55,7 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
$includeImage = $input->getOption('include-images');

if ($includeImage !== null) {
$this->consoleInputConfiguration[UpgradeConfiguration::PS_AUTOUP_KEEP_IMAGES] = $includeImage;
$this->consoleInputConfiguration[BackupConfiguration::PS_AUTOUP_KEEP_IMAGES] = $includeImage;
}

$this->loadConfiguration($configPath);
Expand Down
30 changes: 15 additions & 15 deletions classes/Commands/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
use PrestaShop\Module\AutoUpgrade\DocumentationLinks;
use PrestaShop\Module\AutoUpgrade\Exceptions\DistributionApiException;
use PrestaShop\Module\AutoUpgrade\Exceptions\ProcessException;
use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeConfiguration;
use PrestaShop\Module\AutoUpgrade\Parameters\UpdateConfiguration;
use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeFileNames;
use PrestaShop\Module\AutoUpgrade\Task\ExitCode;
use PrestaShop\Module\AutoUpgrade\Task\Runner\AllUpdateTasks;
Expand Down Expand Up @@ -56,7 +56,7 @@ protected function configure(): void
->addArgument('admin-dir', InputArgument::REQUIRED, 'The admin directory name.')
->addOption('chain', null, InputOption::VALUE_NONE, 'True by default. Allows you to chain update commands automatically. The command will continue executing subsequent tasks without requiring manual intervention to restart the process.')
->addOption('no-chain', null, InputOption::VALUE_NONE, 'Prevents chaining of update commands. The command will execute a task and then stop, logging the next command that needs to be run. You will need to manually restart the process to continue with the next step.')
->addOption('channel', null, InputOption::VALUE_REQUIRED, "Selects what update to run ('" . UpgradeConfiguration::CHANNEL_LOCAL . "' / '" . UpgradeConfiguration::CHANNEL_ONLINE_RECOMMENDED . "' / '" . UpgradeConfiguration::CHANNEL_ONLINE . "')")
->addOption('channel', null, InputOption::VALUE_REQUIRED, "Selects what update to run ('" . UpdateConfiguration::CHANNEL_LOCAL . "' / '" . UpdateConfiguration::CHANNEL_ONLINE_RECOMMENDED . "' / '" . UpdateConfiguration::CHANNEL_ONLINE . "')")
->addOption('zip', null, InputOption::VALUE_REQUIRED, 'Sets the archive zip file for a local update')
->addOption('xml', null, InputOption::VALUE_REQUIRED, 'Sets the archive xml file for a local update')
->addOption('disable-non-native-modules', null, InputOption::VALUE_REQUIRED, 'Disable all modules installed after the store creation (1 for yes, 0 for no). Ignored for PrestaShop v9 and above.')
Expand Down Expand Up @@ -165,12 +165,12 @@ private function chainCommand(OutputInterface $output): int
private function processConsoleInputConfiguration(InputInterface $input): void
{
$options = [
UpgradeConfiguration::CHANNEL => 'channel',
UpgradeConfiguration::ARCHIVE_ZIP => 'zip',
UpgradeConfiguration::ARCHIVE_XML => 'xml',
UpgradeConfiguration::PS_AUTOUP_CUSTOM_MOD_DESACT => 'disable-non-native-modules',
UpgradeConfiguration::PS_AUTOUP_REGEN_EMAIL => 'regenerate-email-templates',
UpgradeConfiguration::PS_DISABLE_OVERRIDES => 'disable-all-overrides',
UpdateConfiguration::CHANNEL => 'channel',
UpdateConfiguration::ARCHIVE_ZIP => 'zip',
UpdateConfiguration::ARCHIVE_XML => 'xml',
UpdateConfiguration::PS_AUTOUP_CUSTOM_MOD_DESACT => 'disable-non-native-modules',
UpdateConfiguration::PS_AUTOUP_REGEN_EMAIL => 'regenerate-email-templates',
UpdateConfiguration::PS_DISABLE_OVERRIDES => 'disable-all-overrides',
];
foreach ($options as $configKey => $optionName) {
$optionValue = $input->getOption($optionName);
Expand All @@ -188,29 +188,29 @@ private function processConsoleInputConfiguration(InputInterface $input): void
private function calculateUpdateTypeAfterConfigLoad(): void
{
$updateConfiguration = $this->upgradeContainer->getUpdateConfiguration();
$channel = $this->consoleInputConfiguration[UpgradeConfiguration::CHANNEL] ?? $updateConfiguration->getChannelOrDefault();
$channel = $this->consoleInputConfiguration[UpdateConfiguration::CHANNEL] ?? $updateConfiguration->getChannelOrDefault();
$currentVersion = $this->upgradeContainer->getProperty(UpgradeContainer::PS_VERSION);
$destinationVersion = null;

switch ($channel) {
case UpgradeConfiguration::CHANNEL_LOCAL:
$zipFile = $this->consoleInputConfiguration[UpgradeConfiguration::ARCHIVE_ZIP] ?? $updateConfiguration->getLocalChannelZip();
case UpdateConfiguration::CHANNEL_LOCAL:
$zipFile = $this->consoleInputConfiguration[UpdateConfiguration::ARCHIVE_ZIP] ?? $updateConfiguration->getLocalChannelZip();
if ($zipFile) {
$fullFilePath = $this->upgradeContainer->getProperty(UpgradeContainer::DOWNLOAD_PATH) . DIRECTORY_SEPARATOR . $zipFile;
try {
$destinationVersion = $this->upgradeContainer->getPrestashopVersionService()->extractPrestashopVersionFromZip($fullFilePath);
$updateConfiguration->set(UpgradeConfiguration::ARCHIVE_VERSION_NUM, $destinationVersion);
$updateConfiguration->set(UpdateConfiguration::ARCHIVE_VERSION_NUM, $destinationVersion);
} catch (Exception $e) {
$this->logger->warning('Unable to extract PrestaShop version from ZIP file: ' . $e->getMessage());
}
}
break;
case UpgradeConfiguration::CHANNEL_ONLINE:
case UpdateConfiguration::CHANNEL_ONLINE:
$destinationVersion = $this->upgradeContainer->getUpgrader()->getOnlineMaxDestinationRelease()
? $this->upgradeContainer->getUpgrader()->getOnlineMaxDestinationRelease()->getVersion()
: null;
break;
case UpgradeConfiguration::CHANNEL_ONLINE_RECOMMENDED:
case UpdateConfiguration::CHANNEL_ONLINE_RECOMMENDED:
$destinationVersion = $this->upgradeContainer->getUpgrader()->getOnlineRecommendedDestinationRelease()
? $this->upgradeContainer->getUpgrader()->getOnlineRecommendedDestinationRelease()->getVersion()
: null;
Expand All @@ -219,7 +219,7 @@ private function calculateUpdateTypeAfterConfigLoad(): void

if (isset($destinationVersion)) {
$updateType = VersionUtils::getUpdateType($currentVersion, $destinationVersion);
$updateConfiguration->set(UpgradeConfiguration::UPDATE_TYPE, $updateType);
$updateConfiguration->set(UpdateConfiguration::UPDATE_TYPE, $updateType);
$this->upgradeContainer->getConfigurationStorage()->save($updateConfiguration);
}
}
Expand Down
83 changes: 83 additions & 0 deletions classes/Parameters/AbstractConfiguration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/

namespace PrestaShop\Module\AutoUpgrade\Parameters;

use Doctrine\Common\Collections\ArrayCollection;

/**
* Abstract for module configurations.
*
* @extends ArrayCollection<string, mixed>
*/
abstract class AbstractConfiguration extends ArrayCollection

Check failure on line 30 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.6)

Class PrestaShop\Module\AutoUpgrade\Parameters\AbstractConfiguration @extends tag contains incompatible type Doctrine\Common\Collections\ArrayCollection&iterable<string, mixed>.

Check failure on line 30 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.2.5)

Class PrestaShop\Module\AutoUpgrade\Parameters\AbstractConfiguration @extends tag contains incompatible type Doctrine\Common\Collections\ArrayCollection&iterable<string, mixed>.

Check failure on line 30 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.3.4)

Class PrestaShop\Module\AutoUpgrade\Parameters\AbstractConfiguration @extends tag contains incompatible type Doctrine\Common\Collections\ArrayCollection&iterable<string, mixed>.

Check failure on line 30 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.4.4)

Class PrestaShop\Module\AutoUpgrade\Parameters\AbstractConfiguration @extends tag contains incompatible type Doctrine\Common\Collections\ArrayCollection&iterable<string, mixed>.

Check failure on line 30 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.5.1)

Class PrestaShop\Module\AutoUpgrade\Parameters\AbstractConfiguration @extends tag contains incompatible type Doctrine\Common\Collections\ArrayCollection&iterable<string, mixed>.
{
/**
* @var array<string, mixed>
*/
const PS_CONST_DEFAULT_VALUE = [];

/**
* @return mixed
*/
protected function getDefaultValue(string $const)
{
return $this->PS_CONST_DEFAULT_VALUE[$const];

Check failure on line 42 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.6)

Access to an undefined property PrestaShop\Module\AutoUpgrade\Parameters\AbstractConfiguration::$PS_CONST_DEFAULT_VALUE.

Check failure on line 42 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.2.5)

Access to an undefined property PrestaShop\Module\AutoUpgrade\Parameters\AbstractConfiguration::$PS_CONST_DEFAULT_VALUE.

Check failure on line 42 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.8)

Access to an undefined property PrestaShop\Module\AutoUpgrade\Parameters\AbstractConfiguration::$PS_CONST_DEFAULT_VALUE.

Check failure on line 42 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.7)

Access to an undefined property PrestaShop\Module\AutoUpgrade\Parameters\AbstractConfiguration::$PS_CONST_DEFAULT_VALUE.

Check failure on line 42 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.3.4)

Access to an undefined property PrestaShop\Module\AutoUpgrade\Parameters\AbstractConfiguration::$PS_CONST_DEFAULT_VALUE.

Check failure on line 42 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.4.4)

Access to an undefined property PrestaShop\Module\AutoUpgrade\Parameters\AbstractConfiguration::$PS_CONST_DEFAULT_VALUE.

Check failure on line 42 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0.0)

Access to an undefined property PrestaShop\Module\AutoUpgrade\Parameters\AbstractConfiguration::$PS_CONST_DEFAULT_VALUE.

Check failure on line 42 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (latest)

Access to an undefined property PrestaShop\Module\AutoUpgrade\Parameters\AbstractConfiguration::$PS_CONST_DEFAULT_VALUE.

Check failure on line 42 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.5.1)

Access to an undefined property PrestaShop\Module\AutoUpgrade\Parameters\AbstractConfiguration::$PS_CONST_DEFAULT_VALUE.

Check failure on line 42 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (9.0.0)

Access to an undefined property PrestaShop\Module\AutoUpgrade\Parameters\AbstractConfiguration::$PS_CONST_DEFAULT_VALUE.
}

/**
* @param array<string, mixed> $array
*
* @return void
*
* @throws UnexpectedValueException
*/
public function merge(array $array = []): void

Check failure on line 52 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.6)

PHPDoc tag @throws with type PrestaShop\Module\AutoUpgrade\Parameters\UnexpectedValueException is not subtype of Throwable

Check failure on line 52 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.2.5)

PHPDoc tag @throws with type PrestaShop\Module\AutoUpgrade\Parameters\UnexpectedValueException is not subtype of Throwable

Check failure on line 52 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.8)

PHPDoc tag @throws with type PrestaShop\Module\AutoUpgrade\Parameters\UnexpectedValueException is not subtype of Throwable

Check failure on line 52 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.7)

PHPDoc tag @throws with type PrestaShop\Module\AutoUpgrade\Parameters\UnexpectedValueException is not subtype of Throwable

Check failure on line 52 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.3.4)

PHPDoc tag @throws with type PrestaShop\Module\AutoUpgrade\Parameters\UnexpectedValueException is not subtype of Throwable

Check failure on line 52 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.4.4)

PHPDoc tag @throws with type PrestaShop\Module\AutoUpgrade\Parameters\UnexpectedValueException is not subtype of Throwable

Check failure on line 52 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0.0)

PHPDoc tag @throws with type PrestaShop\Module\AutoUpgrade\Parameters\UnexpectedValueException is not subtype of Throwable

Check failure on line 52 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (latest)

PHPDoc tag @throws with type PrestaShop\Module\AutoUpgrade\Parameters\UnexpectedValueException is not subtype of Throwable

Check failure on line 52 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.5.1)

PHPDoc tag @throws with type PrestaShop\Module\AutoUpgrade\Parameters\UnexpectedValueException is not subtype of Throwable

Check failure on line 52 in classes/Parameters/AbstractConfiguration.php

View workflow job for this annotation

GitHub Actions / PHPStan (9.0.0)

PHPDoc tag @throws with type PrestaShop\Module\AutoUpgrade\Parameters\UnexpectedValueException is not subtype of Throwable
{
foreach ($array as $key => $value) {
$this->set($key, $value);
}
}

/**
* Resolves a configuration value into a boolean.
*
* This method attempts to retrieve the value for a given configuration key.
* If the value is missing or not a valid boolean (e.g., an invalid string),
* it falls back to the defined default value.
*
* @param string $const the configuration key to evaluate
*
* @return bool the resolved boolean value or the fallback default
*/
protected function computeBooleanConfiguration(string $const): bool
{
$currentValue = $this->get($const);
$defaultValue = $this->getDefaultValue($const);

if ($currentValue === null) {
return $defaultValue;
}

$currentValue = filter_var($currentValue, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);

return $currentValue !== null ? $currentValue : $defaultValue;
}
}
Loading
Loading