From a554973ca2ec8d918a71cc65498ed91edbdb1d50 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 12 Dec 2024 09:20:18 +0100 Subject: [PATCH] test --- src/N98/Magento/Application.php | 20 +++++++++---------- src/N98/Magento/Application/Config.php | 2 +- src/N98/Magento/Application/ConfigLocator.php | 2 +- .../Application/ConfigurationLoader.php | 14 ++++++------- .../AbstractMagentoStoreConfigCommand.php | 4 ++-- .../Script/Repository/ScriptLoader.php | 2 +- src/N98/MagerunBootstrap.php | 7 +++---- src/N98/Util/Console/Helper/MagentoHelper.php | 6 +++--- 8 files changed, 27 insertions(+), 30 deletions(-) diff --git a/src/N98/Magento/Application.php b/src/N98/Magento/Application.php index 375a99440..04724cc11 100644 --- a/src/N98/Magento/Application.php +++ b/src/N98/Magento/Application.php @@ -72,14 +72,14 @@ class Application extends BaseApplication */ protected $autoloader; - protected ?Config $config; + protected ?Config $config = null; /** * @see Application::setConfigurationLoader */ - private ?ConfigurationLoader $configurationLoader; + private ?ConfigurationLoader $configurationLoader = null; - protected ?string $_magentoRootFolder; + protected string $_magentoRootFolder = ''; protected bool $_magentoEnterprise = false; @@ -89,7 +89,7 @@ class Application extends BaseApplication protected bool $_magerunStopFileFound = false; - protected string $_magerunStopFileFolder; + protected string $_magerunStopFileFolder = ''; protected bool $_magerunUseDeveloperMode; @@ -327,9 +327,7 @@ public function checkVarDir(OutputInterface $output): ?bool $this->detectMagento(null, $output); /* If magento is not installed yet, don't check */ - if ($this->_magentoRootFolder === null - || !file_exists($this->_magentoRootFolder . '/app/etc/local.xml') - ) { + if (!file_exists($this->_magentoRootFolder . '/app/etc/local.xml')) { return null; } @@ -571,10 +569,10 @@ public function init(array $initConfig = [], ?InputInterface $input = null, ?Out public function reinit(array $initConfig = [], ?InputInterface $input = null, ?OutputInterface $output = null): void { - $this->_isInitialized = false; - $this->_magentoDetected = false; - $this->_magentoRootFolder = null; - $this->config = null; + $this->_isInitialized = false; + $this->_magentoDetected = false; + $this->_magentoRootFolder = ''; + $this->config = null; $this->init($initConfig, $input, $output); } diff --git a/src/N98/Magento/Application/Config.php b/src/N98/Magento/Application/Config.php index 2a15d6984..002e7a6fd 100644 --- a/src/N98/Magento/Application/Config.php +++ b/src/N98/Magento/Application/Config.php @@ -37,7 +37,7 @@ class Config private array $partialConfig = []; - private ?ConfigurationLoader $configurationLoader; + private ?ConfigurationLoader $configurationLoader = null; private array $initConfig; diff --git a/src/N98/Magento/Application/ConfigLocator.php b/src/N98/Magento/Application/ConfigLocator.php index 77be60c7e..8026c2e31 100644 --- a/src/N98/Magento/Application/ConfigLocator.php +++ b/src/N98/Magento/Application/ConfigLocator.php @@ -21,7 +21,7 @@ class ConfigLocator { private string $customConfigFilename; - private string $magentoRootFolder; + private ?string $magentoRootFolder; public function __construct(string $configFilename, string $magentoRootFolder) { diff --git a/src/N98/Magento/Application/ConfigurationLoader.php b/src/N98/Magento/Application/ConfigurationLoader.php index 8faf00254..dd61b11c8 100644 --- a/src/N98/Magento/Application/ConfigurationLoader.php +++ b/src/N98/Magento/Application/ConfigurationLoader.php @@ -32,32 +32,32 @@ class ConfigurationLoader */ protected array $_initialConfig; - protected ?array $_configArray; + protected ?array $_configArray = null; /** * Cache */ - protected ?array $_distConfig; + protected ?array $_distConfig = null; /** * Cache */ - protected ?array $_pluginConfig; + protected ?array $_pluginConfig = null; /** * Cache */ - protected ?array $_systemConfig; + protected ?array $_systemConfig = null; /** * Cache */ - protected ?array $_userConfig; + protected ?array $_userConfig = null; /** * Cache */ - protected ?array $_projectConfig; + protected ?array $_projectConfig = null; protected string $_customConfigFilename = 'n98-magerun.yaml'; @@ -209,7 +209,7 @@ private function traversePluginFoldersForConfigFile(string $magentoRootFolder, $ /** * Check if there is a user config file. ~/.n98-magerun.yaml */ - public function loadUserConfig(array $config, ?string $magentoRootFolder = null): array + public function loadUserConfig(array $config, string $magentoRootFolder = ''): array { if (is_null($this->_userConfig)) { $this->_userConfig = []; diff --git a/src/N98/Magento/Command/AbstractMagentoStoreConfigCommand.php b/src/N98/Magento/Command/AbstractMagentoStoreConfigCommand.php index 9d165a779..5753dd0f0 100644 --- a/src/N98/Magento/Command/AbstractMagentoStoreConfigCommand.php +++ b/src/N98/Magento/Command/AbstractMagentoStoreConfigCommand.php @@ -26,8 +26,8 @@ */ abstract class AbstractMagentoStoreConfigCommand extends AbstractMagentoCommand { - public string $commandName; - public string $commandDescription; + public string $commandName = ''; + public string $commandDescription = ''; public const COMMAND_ARGUMENT_STORE = 'store'; diff --git a/src/N98/Magento/Command/Script/Repository/ScriptLoader.php b/src/N98/Magento/Command/Script/Repository/ScriptLoader.php index 934a3aa33..a537d6dfe 100644 --- a/src/N98/Magento/Command/Script/Repository/ScriptLoader.php +++ b/src/N98/Magento/Command/Script/Repository/ScriptLoader.php @@ -26,7 +26,7 @@ class ScriptLoader protected array $_scriptFolders = []; - public function __construct(array $scriptFolders, ?string $magentoRootFolder = null) + public function __construct(array $scriptFolders, string $magentoRootFolder = '') { $this->homeDir = OperatingSystem::getHomeDir(); diff --git a/src/N98/MagerunBootstrap.php b/src/N98/MagerunBootstrap.php index 2dd90dbc9..8a816388f 100644 --- a/src/N98/MagerunBootstrap.php +++ b/src/N98/MagerunBootstrap.php @@ -18,10 +18,9 @@ class MagerunBootstrap { /** - * @return Magento\Application * @throws ErrorException */ - public static function createApplication(?ClassLoader $classLoader = null) + public static function createApplication(?ClassLoader $classLoader = null): Application { if (!$classLoader instanceof ClassLoader) { $classLoader = self::getLoader(); @@ -33,7 +32,7 @@ public static function createApplication(?ClassLoader $classLoader = null) /** * @throws ErrorException */ - public static function getLoader(): string + public static function getLoader(): ClassLoader { $projectBasedir = __DIR__ . '/../..'; if (!($loader = self::includeIfExists($projectBasedir . '/vendor/autoload.php')) @@ -49,7 +48,7 @@ public static function getLoader(): string return $loader; } - public static function includeIfExists(string $file): ?string + public static function includeIfExists(string $file): ?ClassLoader { if (file_exists($file)) { return include $file; diff --git a/src/N98/Util/Console/Helper/MagentoHelper.php b/src/N98/Util/Console/Helper/MagentoHelper.php index ee588f413..0f2d7fdb8 100644 --- a/src/N98/Util/Console/Helper/MagentoHelper.php +++ b/src/N98/Util/Console/Helper/MagentoHelper.php @@ -20,7 +20,7 @@ */ class MagentoHelper extends AbstractHelper { - protected string $_magentoRootFolder; + protected string $_magentoRootFolder = ''; protected int $_magentoMajorVersion = 1; @@ -28,7 +28,7 @@ class MagentoHelper extends AbstractHelper protected bool $_magerunStopFileFound = false; - protected string $_magerunStopFileFolder; + protected string $_magerunStopFileFolder = ''; /** * @var InputInterface|ArgvInput @@ -121,7 +121,7 @@ public function isMagerunStopFileFound(): bool return $this->_magerunStopFileFound; } - public function getMagerunStopFileFolder(): string + public function getMagerunStopFileFolder(): ?string { return $this->_magerunStopFileFolder; }