Skip to content

Commit

Permalink
last fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel committed Dec 16, 2024
1 parent b0d4ddf commit 6faf433
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/N98/Magento/Command/AbstractMagentoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ protected function isSourceTypeRepository(string $type): bool
return in_array($type, ['git', 'hg']);
}

protected function getOrAskForArgument(string $argument, InputInterface $input, OutputInterface $output, ?string $message = null): string
protected function getOrAskForArgument(string $argument, InputInterface $input, OutputInterface $output, ?string $message = null): ?string
{
$inputArgument = $input->getArgument($argument);
if ($inputArgument === null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
class OnCommand extends AbstractMagentoCommand
{
private ?array $modules;
private ?array $modules = null;

protected function configure(): void
{
Expand Down
11 changes: 6 additions & 5 deletions src/N98/Magento/Command/System/Setup/AbstractSetupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ public function getModule(InputInterface $input): string
{
$config = Mage::app()->getConfig();

/** @var Mage_Core_Model_Config_Element $modules */
$modules = $config->getNode('modules');
foreach ($modules->asArray() as $moduleName => $data) {
if (strtolower($moduleName) === strtolower($input->getArgument('module'))) {
return $moduleName;
if ($modules) {
foreach ($modules->asArray() as $moduleName => $data) {
if (strtolower($moduleName) === strtolower($input->getArgument('module'))) {
return $moduleName;
}
}
}
}

throw new InvalidArgumentException(sprintf('No module found with name: "%s"', $input->getArgument('module')));
}
Expand Down
4 changes: 2 additions & 2 deletions src/N98/Magento/Command/System/Url/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$input->setOption('add-cmspages', true);
}

$stores = explode(',', $input->getArgument('stores') ?? '');
$stores = explode(',', (string) $input->getArgument('stores') ?? '');

Check failure on line 86 in src/N98/Magento/Command/System/Url/ListCommand.php

View workflow job for this annotation

GitHub Actions / Analyze (20.10.2, ubuntu-latest, 7.4, 8.0)

Expression on left side of ?? is not nullable.

$urls = [];

/** @var Mage_Core_Model_Store $currentStore */
foreach ($stores as $store) {

Check failure on line 91 in src/N98/Magento/Command/System/Url/ListCommand.php

View workflow job for this annotation

GitHub Actions / Analyze (20.10.2, ubuntu-latest, 7.4, 8.0)

Variable $currentStore in PHPDoc tag @var does not match any variable in the foreach loop: $stores, $store
/** @var Mage_Core_Model_Store $currentStore */
$currentStore = Mage::app()->getStore($store);

// base url
Expand Down
11 changes: 9 additions & 2 deletions src/N98/Magento/DbSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,18 @@ public function setFile(string $file): void
private function parseResources(SimpleXMLElement $resources): void
{
// default values
$config = ['host' => null, 'port' => null, 'unix_socket' => null, 'dbname' => null, 'username' => null, 'password' => null];
$config = [
'host' => null,
'port' => null,
'unix_socket' => null,
'dbname' => null,
'username' => null,
'password' => null,
];

$connectionNode = $this->connectionNode;
/** @var string[] $config */
$config = array_merge($config, (array) $resources->$connectionNode->connection);
$config = array_merge($config, array_map('strval', (array) $resources->$connectionNode->connection));
$config['prefix'] = (string) $resources->db->table_prefix;

// known parameters: host, port, unix_socket, dbname, username, password, options, charset, persistent,
Expand Down
4 changes: 3 additions & 1 deletion src/N98/Magento/Initialiser.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ public function requireMage(): void

$this->requireOnce();

throw new RuntimeException(sprintf('Failed to load definition of "%s" class', self::CLASS_MAGE));
if (!class_exists(self::CLASS_MAGE, false)) {

Check failure on line 70 in src/N98/Magento/Initialiser.php

View workflow job for this annotation

GitHub Actions / Analyze (20.10.2, ubuntu-latest, 7.4, 8.0)

Negated boolean expression is always true.
throw new RuntimeException(sprintf('Failed to load definition of "%s" class', self::CLASS_MAGE));
}
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/N98/Util/Console/Helper/DatabaseHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
*/
class DatabaseHelper extends AbstractHelper
{
protected ?DbSettings $dbSettings;
protected ?DbSettings $dbSettings = null;

/**
* @deprecated since 1.97.9, use $dbSettings->isSocketConnect()
*/
protected bool $isSocketConnect = false;

protected ?PDO $_connection;
protected ?PDO $_connection = null;

protected ?array $_tables;
protected ?array $_tables = null;

public function detectDbSettings(OutputInterface $output, ?string $connectionNode = null): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class RendererFactory
'xml' => XmlRenderer::class,
];

public function create(string $format): ?RendererInterface
public function create(?string $format): ?RendererInterface
{
$format = strtolower($format);
$format = is_null($format) ? $format : strtolower($format);
if (isset(self::$formats[$format])) {
$rendererClass = self::$formats[$format];
/** @var RendererInterface $renderer */
Expand Down

0 comments on commit 6faf433

Please sign in to comment.