From 12f48b30d2c2fde61a98c6532820b02a6de78caa Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 9 Oct 2023 17:10:54 +0200 Subject: [PATCH 001/136] Remove Magento2 related code --- src/N98/Magento/Application.php | 80 +----------------- .../Command/AbstractMagentoCommand.php | 84 ++++--------------- .../Command/Admin/User/CreateUserCommand.php | 17 +--- .../Command/Cache/AbstractCacheCommand.php | 14 +--- .../Command/Config/AbstractConfigCommand.php | 9 +- .../Developer/Ide/PhpStorm/MetaCommand.php | 35 ++++---- .../Developer/Theme/DuplicatesCommand.php | 42 +++++----- .../Command/Developer/Theme/ListCommand.php | 10 --- src/N98/Util/Console/Helper/MagentoHelper.php | 24 ------ .../Admin/User/UnlockUserCommandTest.php | 4 +- .../Command/Cache/CleanCommandTest.php | 4 - .../Command/Cache/DisableCommandTest.php | 34 ++++---- .../Command/Cache/EnableCommandTest.php | 34 ++++---- .../Command/Cache/FlushCommandTest.php | 13 ++- .../Command/Customer/DeleteCommandTest.php | 23 ++--- .../Command/Database/DumpCommandTest.php | 3 - tests/N98/Magento/TestApplication.php | 4 +- .../N98/Util/Console/Helper/MagentoHelper.php | 26 ------ 18 files changed, 102 insertions(+), 358 deletions(-) diff --git a/src/N98/Magento/Application.php b/src/N98/Magento/Application.php index 0bf24206b..a215adc57 100644 --- a/src/N98/Magento/Application.php +++ b/src/N98/Magento/Application.php @@ -41,16 +41,6 @@ class Application extends BaseApplication */ public const APP_VERSION = '3.0.0-dev'; - /** - * @var int - */ - public const MAGENTO_MAJOR_VERSION_1 = 1; - - /** - * @var int - */ - public const MAGENTO_MAJOR_VERSION_2 = 2; - /** * @var string */ @@ -96,16 +86,6 @@ class Application extends BaseApplication */ protected $_magentoEnterprise = false; - /** - * @var int - */ - protected $_magentoMajorVersion = self::MAGENTO_MAJOR_VERSION_1; - - /** - * @var EntryPoint - */ - protected $_magento2EntryPoint = null; - /** * @var bool */ @@ -265,7 +245,6 @@ public function detectMagento(InputInterface $input = null, OutputInterface $out $this->_magentoDetected = $magentoHelper->detect($folder, $subFolders); $this->_magentoRootFolder = $magentoHelper->getRootFolder(); $this->_magentoEnterprise = $magentoHelper->isEnterpriseEdition(); - $this->_magentoMajorVersion = $magentoHelper->getMajorVersion(); $this->_magerunStopFileFound = $magentoHelper->isMagerunStopFileFound(); $this->_magerunStopFileFolder = $magentoHelper->getMagerunStopFileFolder(); $this->_magerunUseDeveloperMode = ($input->getParameterOption('--developer-mode')); @@ -460,12 +439,7 @@ public function initMagento($soft = false) return false; } - $isMagento2 = $this->_magentoMajorVersion === self::MAGENTO_MAJOR_VERSION_2; - if ($isMagento2) { - $this->_initMagento2(); - } else { - $this->_initMagento1($soft); - } + $this->_initMagento1($soft); return true; } @@ -507,14 +481,6 @@ public function setMagentoRootFolder($magentoRootFolder) $this->_magentoRootFolder = $magentoRootFolder; } - /** - * @return int - */ - public function getMagentoMajorVersion() - { - return $this->_magentoMajorVersion; - } - /** * @return ClassLoader */ @@ -786,50 +752,6 @@ protected function _initMagento1($soft = false) } } - /** - * @return void - */ - protected function _initMagento2() - { - $this->outputMagerunCompatibilityNotice('2'); - } - - /** - * Show a hint that this is Magento incompatible with Magerun and how to obtain the correct Magerun for it - * - * @param string $version of Magento, "1" or "2", that is incompatible - */ - private function outputMagerunCompatibilityNotice($version) - { - $file = $version === '2' ? $version : ''; - $magentoHint = <<Download with curl ------------------- - - curl -O https://files.magerun.net/n98-magerun$file.phar - -Download with wget ------------------- - - wget https://files.magerun.net/n98-magerun$file.phar - -MAGENTOHINT; - - $output = new ConsoleOutput(); - - /** @var FormatterHelper $formatter */ - $formatter = $this->getHelperSet()->get('formatter'); - - $output->writeln(['', $formatter->formatBlock('Compatibility Notice', 'bg=blue;fg=white', true), '', $magentoHint]); - - throw new RuntimeException('This version of n98-magerun is not compatible with Magento ' . $version); - } - /** * @return EventDispatcher */ diff --git a/src/N98/Magento/Command/AbstractMagentoCommand.php b/src/N98/Magento/Command/AbstractMagentoCommand.php index a022daf40..9a4bfd560 100644 --- a/src/N98/Magento/Command/AbstractMagentoCommand.php +++ b/src/N98/Magento/Command/AbstractMagentoCommand.php @@ -32,26 +32,11 @@ */ abstract class AbstractMagentoCommand extends Command { - /** - * @var int - */ - public const MAGENTO_MAJOR_VERSION_1 = 1; - - /** - * @var int - */ - public const MAGENTO_MAJOR_VERSION_2 = 2; - /** * @var string */ protected $_magentoRootFolder = null; - /** - * @var int - */ - protected $_magentoMajorVersion = self::MAGENTO_MAJOR_VERSION_1; - /** * @var bool */ @@ -181,7 +166,6 @@ public function detectMagento(OutputInterface $output, $silent = true) $this->_magentoEnterprise = $this->getApplication()->isMagentoEnterprise(); $this->_magentoRootFolder = $this->getApplication()->getMagentoRootFolder(); - $this->_magentoMajorVersion = $this->getApplication()->getMagentoMajorVersion(); if (!$silent) { $editionString = ($this->_magentoEnterprise ? ' (Enterprise Edition) ' : ''); @@ -213,9 +197,6 @@ protected function requireEnterprise(OutputInterface $output) */ protected function getCoreHelper() { - if ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) { - return Mage::helper('Mage_Core_Helper_Data'); - } return Mage::helper('core'); } @@ -369,83 +350,48 @@ protected function checkDeprecatedAliases(InputInterface $input, OutputInterface } /** - * Magento 1 / 2 switches - * - * @param string $mage1code Magento 1 class code - * @param string $mage2class Magento 2 class name + * @param string $class class code * @return \Mage_Core_Model_Abstract */ - protected function _getModel($mage1code, $mage2class) + protected function _getModel($class) { - if ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) { - return Mage::getModel($mage2class); - } else { - return Mage::getModel($mage1code); - } + return Mage::getModel($class); } /** - * Magento 1 / 2 switches - * - * @param string $mage1code Magento 1 class code - * @param string $mage2class Magento 2 class name + * @param string $class class code * @return \Mage_Core_Helper_Abstract */ - protected function _getHelper($mage1code, $mage2class) + protected function _getHelper($class) { - if ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) { - return Mage::helper($mage2class); - } else { - return Mage::helper($mage1code); - } + return Mage::helper($class); } /** - * Magento 1 / 2 switches - * - * @param string $mage1code Magento 1 class code - * @param string $mage2class Magento 2 class name + * @param string $class class code * @return \Mage_Core_Model_Abstract */ - protected function _getSingleton($mage1code, $mage2class) + protected function _getSingleton($class) { - if ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) { - return Mage::getModel($mage2class); - } else { - return Mage::getModel($mage1code); - } + return Mage::getModel($class); } /** - * Magento 1 / 2 switches - * - * @param string $mage1code Magento 1 class code - * @param string $mage2class Magento 2 class name + * @param string $class class code * @return \Mage_Core_Model_Abstract */ - protected function _getResourceModel($mage1code, $mage2class) + protected function _getResourceModel($class) { - if ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) { - return Mage::getResourceModel($mage2class); - } else { - return Mage::getResourceModel($mage1code); - } + return Mage::getResourceModel($class); } /** - * Magento 1 / 2 switches - * - * @param string $mage1code Magento 1 class code - * @param string $mage2class Magento 2 class name + * @param string $class class code * @return \Mage_Core_Model_Abstract */ - protected function _getResourceSingleton($mage1code, $mage2class) + protected function _getResourceSingleton($class) { - if ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) { - return Mage::getResourceSingleton($mage2class); - } else { - return Mage::getResourceSingleton($mage1code); - } + return Mage::getResourceSingleton($class); } /** diff --git a/src/N98/Magento/Command/Admin/User/CreateUserCommand.php b/src/N98/Magento/Command/Admin/User/CreateUserCommand.php index 860fbffe2..a43bf6dbc 100644 --- a/src/N98/Magento/Command/Admin/User/CreateUserCommand.php +++ b/src/N98/Magento/Command/Admin/User/CreateUserCommand.php @@ -60,14 +60,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int ->setRoleType('G') ->save(); - // @todo check cmuench correct class name? - $resourceAll = ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) ? - Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL : 'all'; - // give "all" privileges to role $this->getRulesModel() ->setRoleId($role->getId()) - ->setResources([$resourceAll]) + ->setResources(['all']) ->saveRel(); $output->writeln('The role Development was automatically created.'); @@ -78,14 +74,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $user = $this->getUserModel() ->setData(['username' => $username, 'firstname' => $firstname, 'lastname' => $lastname, 'email' => $email, 'password' => $password, 'is_active' => 1])->save(); - if ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) { - $user->setRoleId($role->getId()) - ->save(); - } else { - $user->setRoleIds([$role->getId()]) - ->setRoleUserId($user->getUserId()) - ->saveRelations(); - } + $user->setRoleIds([$role->getId()]) + ->setRoleUserId($user->getUserId()) + ->saveRelations(); $output->writeln('User ' . $username . ' successfully created'); } diff --git a/src/N98/Magento/Command/Cache/AbstractCacheCommand.php b/src/N98/Magento/Command/Cache/AbstractCacheCommand.php index 558160c94..bfb38b42f 100644 --- a/src/N98/Magento/Command/Cache/AbstractCacheCommand.php +++ b/src/N98/Magento/Command/Cache/AbstractCacheCommand.php @@ -18,11 +18,7 @@ class AbstractCacheCommand extends AbstractMagentoCommand */ protected function _getCacheModel() { - if ($this->_magentoMajorVersion == AbstractMagentoCommand::MAGENTO_MAJOR_VERSION_2) { - throw new RuntimeException('There global Mage class was removed from Magento 2. What should we do here?'); - } else { - return Mage::app()->getCacheInstance(); - } + return Mage::app()->getCacheInstance(); } /** @@ -93,12 +89,4 @@ protected function _canUseBanCacheFunction() { return method_exists('\Mage_Core_Model_App', 'baseInit'); } - - /** - * @return bool - */ - public function isEnabled() - { - return $this->getApplication()->getMagentoMajorVersion() === Application::MAGENTO_MAJOR_VERSION_1; - } } diff --git a/src/N98/Magento/Command/Config/AbstractConfigCommand.php b/src/N98/Magento/Command/Config/AbstractConfigCommand.php index f644fa62d..ebcfe5114 100644 --- a/src/N98/Magento/Command/Config/AbstractConfigCommand.php +++ b/src/N98/Magento/Command/Config/AbstractConfigCommand.php @@ -16,16 +16,11 @@ abstract class AbstractConfigCommand extends AbstractMagentoCommand protected $_scopes = ['default', 'websites', 'stores']; /** - * @return \Mage_Core_Model_Encryption|null returns null for Magento2 + * @return \Mage_Core_Model_Encryption */ protected function getEncryptionModel() { - if ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) { - // @TODO Magento 2 support - return null; - } else { - return Mage::helper('core')->getEncryptor(); - } + return Mage::helper('core')->getEncryptor(); } /** diff --git a/src/N98/Magento/Command/Developer/Ide/PhpStorm/MetaCommand.php b/src/N98/Magento/Command/Developer/Ide/PhpStorm/MetaCommand.php index d8a54b43d..d20e4e899 100644 --- a/src/N98/Magento/Command/Developer/Ide/PhpStorm/MetaCommand.php +++ b/src/N98/Magento/Command/Developer/Ide/PhpStorm/MetaCommand.php @@ -73,30 +73,27 @@ protected function execute(InputInterface $input, OutputInterface $output): int return 0; } - if ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_1) { - $classMaps = []; + $classMaps = []; - foreach ($this->groups as $group) { - $classMaps[$group] = $this->getClassMapForGroup($group, $output); + foreach ($this->groups as $group) { + $classMaps[$group] = $this->getClassMapForGroup($group, $output); - if (!$input->getOption('stdout') && count($classMaps[$group]) > 0) { - $output->writeln( - 'Generated definitions for ' . $group . ' group' - ); - } + if (!$input->getOption('stdout') && count($classMaps[$group]) > 0) { + $output->writeln( + 'Generated definitions for ' . $group . ' group' + ); } + } - $version = $input->getOption('meta-version'); - if ($version == self::VERSION_OLD) { - $this->writeToOutputOld($input, $output, $classMaps); - } elseif ($version == self::VERSION_2017) { - $this->writeToOutputV2017($input, $output, $classMaps); - } elseif ($version == self::VERSION_2019) { - $this->writeToOutputV2019($input, $output, $classMaps); - } - } else { - $output->write('Magento 2 is currently not supported'); + $version = $input->getOption('meta-version'); + if ($version == self::VERSION_OLD) { + $this->writeToOutputOld($input, $output, $classMaps); + } elseif ($version == self::VERSION_2017) { + $this->writeToOutputV2017($input, $output, $classMaps); + } elseif ($version == self::VERSION_2019) { + $this->writeToOutputV2019($input, $output, $classMaps); } + return 0; } diff --git a/src/N98/Magento/Command/Developer/Theme/DuplicatesCommand.php b/src/N98/Magento/Command/Developer/Theme/DuplicatesCommand.php index 8809a17f7..ec41260e7 100644 --- a/src/N98/Magento/Command/Developer/Theme/DuplicatesCommand.php +++ b/src/N98/Magento/Command/Developer/Theme/DuplicatesCommand.php @@ -49,35 +49,33 @@ protected function execute(InputInterface $input, OutputInterface $output): int { $time = microtime(true); $this->detectMagento($output); - if ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) { - $output->writeln('Magento 2 is currently not supported.'); - } else { - $referenceFiles = $this->getChecksums( - $this->_magentoRootFolder . '/app/design/frontend/' . $input->getArgument('originalTheme') - ); - $themeFolder = $this->_magentoRootFolder . '/app/design/frontend/' . $input->getArgument('theme'); - $themeFiles = $this->getChecksums($themeFolder); + $referenceFiles = $this->getChecksums( + $this->_magentoRootFolder . '/app/design/frontend/' . $input->getArgument('originalTheme') + ); + + $themeFolder = $this->_magentoRootFolder . '/app/design/frontend/' . $input->getArgument('theme'); + $themeFiles = $this->getChecksums($themeFolder); - $duplicates = []; - foreach ($themeFiles as $themeFilename => $themeFileChecksum) { - if (isset($referenceFiles[$themeFilename]) - && $themeFileChecksum == $referenceFiles[$themeFilename] - ) { - $duplicates[] = $themeFolder . '/' . $themeFilename; - } + $duplicates = []; + foreach ($themeFiles as $themeFilename => $themeFileChecksum) { + if (isset($referenceFiles[$themeFilename]) + && $themeFileChecksum == $referenceFiles[$themeFilename] + ) { + $duplicates[] = $themeFolder . '/' . $themeFilename; } + } - if ($input->getOption('log-junit')) { - $this->logJUnit($input, $duplicates, $input->getOption('log-junit'), microtime($time) - $time); + if ($input->getOption('log-junit')) { + $this->logJUnit($input, $duplicates, $input->getOption('log-junit'), microtime($time) - $time); + } else { + if (count($duplicates) === 0) { + $output->writeln('No duplicates were found'); } else { - if (count($duplicates) === 0) { - $output->writeln('No duplicates were found'); - } else { - $output->writeln($duplicates); - } + $output->writeln($duplicates); } } + return 0; } diff --git a/src/N98/Magento/Command/Developer/Theme/ListCommand.php b/src/N98/Magento/Command/Developer/Theme/ListCommand.php index 5f5aaec37..ba4c1d34b 100644 --- a/src/N98/Magento/Command/Developer/Theme/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Theme/ListCommand.php @@ -59,16 +59,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int */ protected function getThemes() { - if ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) { - $collection = Mage::getModel('Mage_Core_Model_Theme')->getLabelsCollection(); - $themes = []; - foreach ($collection as $theme) { - $themes[] = $theme['label']; - } - - return [$themes]; - } - return Mage::getModel('core/design_package')->getThemeList(); } } diff --git a/src/N98/Util/Console/Helper/MagentoHelper.php b/src/N98/Util/Console/Helper/MagentoHelper.php index 18d2e9300..50f707e47 100644 --- a/src/N98/Util/Console/Helper/MagentoHelper.php +++ b/src/N98/Util/Console/Helper/MagentoHelper.php @@ -23,11 +23,6 @@ class MagentoHelper extends AbstractHelper */ protected $_magentoRootFolder = null; - /** - * @var int - */ - protected $_magentoMajorVersion = Application::MAGENTO_MAJOR_VERSION_1; - /** * @var bool */ @@ -124,11 +119,6 @@ public function getRootFolder() return $this->_magentoRootFolder; } - public function getEdition() - { - return $this->_magentoMajorVersion; - } - /** * @return bool */ @@ -137,14 +127,6 @@ public function isEnterpriseEdition() return $this->_magentoEnterprise; } - /** - * @return int - */ - public function getMajorVersion() - { - return $this->_magentoMajorVersion; - } - /** * @return boolean */ @@ -320,12 +302,6 @@ protected function _search($searchFolder) $this->_magentoRootFolder = $searchFolder; - // Magento 2 does not have a god class and thus if this file is not there it is version 2 - if ($hasMageFile === false) { - $this->_magentoMajorVersion = Application::MAGENTO_MAJOR_VERSION_2; - return true; // the rest of this does not matter since we are simply exiting with a notice - } - if (is_callable(['\Mage', 'getEdition'])) { $this->_magentoEnterprise = (Mage::getEdition() == 'Enterprise'); } else { diff --git a/tests/N98/Magento/Command/Admin/User/UnlockUserCommandTest.php b/tests/N98/Magento/Command/Admin/User/UnlockUserCommandTest.php index b0a0d337a..635fd4fe2 100644 --- a/tests/N98/Magento/Command/Admin/User/UnlockUserCommandTest.php +++ b/tests/N98/Magento/Command/Admin/User/UnlockUserCommandTest.php @@ -16,9 +16,7 @@ private function getCommand() { $command = new UnlockCommand(); $command->setApplication($this->getApplication()); - if (!$command->isEnabled()) { - self::markTestSkipped('UnlockCommand is not enabled.'); - } + return $command; } diff --git a/tests/N98/Magento/Command/Cache/CleanCommandTest.php b/tests/N98/Magento/Command/Cache/CleanCommandTest.php index de1c4b3b3..92c1945c0 100644 --- a/tests/N98/Magento/Command/Cache/CleanCommandTest.php +++ b/tests/N98/Magento/Command/Cache/CleanCommandTest.php @@ -19,10 +19,6 @@ public function getApplication() { $application = parent::getApplication(); - if ($application::MAGENTO_MAJOR_VERSION_1 !== $application->getMagentoMajorVersion()) { - return $application; - } - // FIXME #613 make install command work with 1.9+ and cache initialization $version = Mage::getVersion(); $against = '1.9.0.0'; diff --git a/tests/N98/Magento/Command/Cache/DisableCommandTest.php b/tests/N98/Magento/Command/Cache/DisableCommandTest.php index 5e1200aed..e5cdca618 100644 --- a/tests/N98/Magento/Command/Cache/DisableCommandTest.php +++ b/tests/N98/Magento/Command/Cache/DisableCommandTest.php @@ -11,31 +11,27 @@ class DisableCommandTest extends TestCase public function testExecute() { $application = $this->getApplication(); - if ($application->getMagentoMajorVersion() == Application::MAGENTO_MAJOR_VERSION_1) { - $application->add(new DisableCommand()); + $application->add(new DisableCommand()); - $command = $this->getApplication()->find('cache:disable'); - $commandTester = new CommandTester($command); - $commandTester->execute(['command' => $command->getName()]); + $command = $this->getApplication()->find('cache:disable'); + $commandTester = new CommandTester($command); + $commandTester->execute(['command' => $command->getName()]); - self::assertMatchesRegularExpression('/Caches disabled/', $commandTester->getDisplay()); - } + self::assertMatchesRegularExpression('/Caches disabled/', $commandTester->getDisplay()); } public function testExecuteMultipleCaches() { $application = $this->getApplication(); - if ($application->getMagentoMajorVersion() == Application::MAGENTO_MAJOR_VERSION_1) { - $application->add(new DisableCommand()); - - $command = $this->getApplication()->find('cache:disable'); - $commandTester = new CommandTester($command); - $commandTester->execute( - ['command' => $command->getName(), 'code' => 'eav,config'] - ); - - self::assertMatchesRegularExpression('/Cache config disabled/', $commandTester->getDisplay()); - self::assertMatchesRegularExpression('/Cache eav disabled/', $commandTester->getDisplay()); - } + $application->add(new DisableCommand()); + + $command = $this->getApplication()->find('cache:disable'); + $commandTester = new CommandTester($command); + $commandTester->execute( + ['command' => $command->getName(), 'code' => 'eav,config'] + ); + + self::assertMatchesRegularExpression('/Cache config disabled/', $commandTester->getDisplay()); + self::assertMatchesRegularExpression('/Cache eav disabled/', $commandTester->getDisplay()); } } diff --git a/tests/N98/Magento/Command/Cache/EnableCommandTest.php b/tests/N98/Magento/Command/Cache/EnableCommandTest.php index b50ef1656..63ba10e0c 100644 --- a/tests/N98/Magento/Command/Cache/EnableCommandTest.php +++ b/tests/N98/Magento/Command/Cache/EnableCommandTest.php @@ -11,31 +11,27 @@ class EnableCommandTest extends TestCase public function testExecute() { $application = $this->getApplication(); - if ($application->getMagentoMajorVersion() == Application::MAGENTO_MAJOR_VERSION_1) { - $application->add(new EnableCommand()); - $command = $this->getApplication()->find('cache:enable'); + $application->add(new EnableCommand()); - $commandTester = new CommandTester($command); - $commandTester->execute(['command' => $command->getName()]); + $command = $this->getApplication()->find('cache:enable'); + $commandTester = new CommandTester($command); + $commandTester->execute(['command' => $command->getName()]); - self::assertMatchesRegularExpression('/Caches enabled/', $commandTester->getDisplay()); - } + self::assertMatchesRegularExpression('/Caches enabled/', $commandTester->getDisplay()); } public function testExecuteMultipleCaches() { $application = $this->getApplication(); - if ($application->getMagentoMajorVersion() == Application::MAGENTO_MAJOR_VERSION_1) { - $application->add(new DisableCommand()); - - $command = $this->getApplication()->find('cache:enable'); - $commandTester = new CommandTester($command); - $commandTester->execute( - ['command' => $command->getName(), 'code' => 'eav,config'] - ); - - self::assertMatchesRegularExpression('/Cache config enabled/', $commandTester->getDisplay()); - self::assertMatchesRegularExpression('/Cache eav enabled/', $commandTester->getDisplay()); - } + $application->add(new DisableCommand()); + + $command = $this->getApplication()->find('cache:enable'); + $commandTester = new CommandTester($command); + $commandTester->execute( + ['command' => $command->getName(), 'code' => 'eav,config'] + ); + + self::assertMatchesRegularExpression('/Cache config enabled/', $commandTester->getDisplay()); + self::assertMatchesRegularExpression('/Cache eav enabled/', $commandTester->getDisplay()); } } diff --git a/tests/N98/Magento/Command/Cache/FlushCommandTest.php b/tests/N98/Magento/Command/Cache/FlushCommandTest.php index 51b00e001..bbba8dd7f 100644 --- a/tests/N98/Magento/Command/Cache/FlushCommandTest.php +++ b/tests/N98/Magento/Command/Cache/FlushCommandTest.php @@ -11,15 +11,12 @@ class FlushCommandTest extends TestCase public function testExecute() { $application = $this->getApplication(); - if ($application->getMagentoMajorVersion() == Application::MAGENTO_MAJOR_VERSION_1) { - $application = $this->getApplication(); - $application->add(new FlushCommand()); - $command = $this->getApplication()->find('cache:flush'); + $application->add(new FlushCommand()); - $commandTester = new CommandTester($command); - $commandTester->execute(['command' => $command->getName()]); + $command = $this->getApplication()->find('cache:flush'); + $commandTester = new CommandTester($command); + $commandTester->execute(['command' => $command->getName()]); - self::assertMatchesRegularExpression('/Cache cleared/', $commandTester->getDisplay()); - } + self::assertMatchesRegularExpression('/Cache cleared/', $commandTester->getDisplay()); } } diff --git a/tests/N98/Magento/Command/Customer/DeleteCommandTest.php b/tests/N98/Magento/Command/Customer/DeleteCommandTest.php index 87b27c5ea..baed68423 100644 --- a/tests/N98/Magento/Command/Customer/DeleteCommandTest.php +++ b/tests/N98/Magento/Command/Customer/DeleteCommandTest.php @@ -22,29 +22,19 @@ class DeleteCommandTest extends TestCase protected $website; protected $application; - protected function getResourceClassName($mage1Code, $mage2Code) + protected function getResourceClassName($class) { - // Get correct model classes to mock - if ($this->application->getMagentoMajorVersion() == 2) { - return get_class(Mage::getResourceModel($mage2Code)); - } else { - return get_class(Mage::getResourceModel($mage1Code)); - } + return get_class(Mage::getResourceModel($class)); } - protected function getModelClassName($mage1Code, $mage2Code) + protected function getModelClassName($class) { - // Get correct model classes to mock - if ($this->application->getMagentoMajorVersion() == 2) { - return get_class(Mage::getModel($mage2Code)); - } else { - return get_class(Mage::getModel($mage1Code)); - } + return get_class(Mage::getModel($class)); } protected function getCustomerModel(array $methods) { - $className = $this->getModelClassName('customer/customer', 'Mage_Customer_Model_Customer'); + $className = $this->getModelClassName('customer/customer'); return $this->getMockBuilder($className) ->setMethods($methods) ->disableOriginalConstructor() @@ -54,8 +44,7 @@ protected function getCustomerModel(array $methods) protected function getCustomerCollection(array $methods) { $className = $this->getResourceClassName( - 'customer/customer_collection', - 'Mage_Customer_Model_Resource_Customer_Collection' + 'customer/customer_collection' ); return $this->getMockBuilder($className) diff --git a/tests/N98/Magento/Command/Database/DumpCommandTest.php b/tests/N98/Magento/Command/Database/DumpCommandTest.php index 338f37e0c..fd0ec4a04 100644 --- a/tests/N98/Magento/Command/Database/DumpCommandTest.php +++ b/tests/N98/Magento/Command/Database/DumpCommandTest.php @@ -19,9 +19,6 @@ class DumpCommandTest extends TestCase protected function getCommand() { $dumpCommand = new DumpCommand(); - if (!$dumpCommand->isEnabled()) { - self::markTestSkipped('DumpCommand is not enabled.'); - } $application = $this->getApplication(); $application->add($dumpCommand); diff --git a/tests/N98/Magento/TestApplication.php b/tests/N98/Magento/TestApplication.php index 150ef2698..4387b86ad 100644 --- a/tests/N98/Magento/TestApplication.php +++ b/tests/N98/Magento/TestApplication.php @@ -171,9 +171,7 @@ public function getApplication() $application->init(); $application->initMagento(); - if ($application->getMagentoMajorVersion() == Application::MAGENTO_MAJOR_VERSION_1) { - spl_autoload_unregister([Varien_Autoload::instance(), 'autoload']); - } + spl_autoload_unregister([Varien_Autoload::instance(), 'autoload']); $this->application = $application; } diff --git a/tests/N98/Util/Console/Helper/MagentoHelper.php b/tests/N98/Util/Console/Helper/MagentoHelper.php index 19f1b4398..b90bcef44 100644 --- a/tests/N98/Util/Console/Helper/MagentoHelper.php +++ b/tests/N98/Util/Console/Helper/MagentoHelper.php @@ -40,7 +40,6 @@ public function detectMagentoInStandardFolder() $helper->detect(vfsStream::url('root'), []); self::assertEquals(vfsStream::url('root'), $helper->getRootFolder()); - self::assertEquals(Application::MAGENTO_MAJOR_VERSION_1, $helper->getMajorVersion()); } /** @@ -62,7 +61,6 @@ public function detectMagentoInHtdocsSubfolder() ); self::assertEquals(vfsStream::url('root/htdocs'), $helper->getRootFolder()); - self::assertEquals(Application::MAGENTO_MAJOR_VERSION_1, $helper->getMajorVersion()); } /** @@ -104,29 +102,5 @@ public function detectMagentoInModmanInfrastructure() // Verify if this could be checked with more elegance self::assertEquals(vfsStream::url('root/../root/htdocs/magento_root'), $helper->getRootFolder()); - - self::assertEquals(Application::MAGENTO_MAJOR_VERSION_1, $helper->getMajorVersion()); - } - - /** - * @test - */ - public function detectMagento2InHtdocsSubfolder() - { - vfsStream::setup('root'); - vfsStream::create( - ['htdocs' => ['app' => ['autoload.php' => '', 'bootstrap.php' => '']]] - ); - - $helper = $this->getHelper(); - - // vfs cannot resolve relative path so we do 'root/htdocs' etc. - $helper->detect( - vfsStream::url('root'), - [vfsStream::url('root/www'), vfsStream::url('root/public'), vfsStream::url('root/htdocs')] - ); - - self::assertEquals(vfsStream::url('root/htdocs'), $helper->getRootFolder()); - self::assertEquals(Application::MAGENTO_MAJOR_VERSION_2, $helper->getMajorVersion()); } } From e8da83f4f3a8a267f78b9ec9ea44f53983dc7b2f Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 16 Oct 2023 22:45:38 +0200 Subject: [PATCH 002/136] [skip ci] Updated cms:block commands --- .../Cms/Block/AbstractCmsBlockCommand.php | 29 ++++++ .../Magento/Command/Cms/Block/ListCommand.php | 92 +++++++++---------- .../Command/Cms/Block/ToggleCommand.php | 82 +++++++++-------- 3 files changed, 115 insertions(+), 88 deletions(-) create mode 100644 src/N98/Magento/Command/Cms/Block/AbstractCmsBlockCommand.php diff --git a/src/N98/Magento/Command/Cms/Block/AbstractCmsBlockCommand.php b/src/N98/Magento/Command/Cms/Block/AbstractCmsBlockCommand.php new file mode 100644 index 000000000..919ee0c99 --- /dev/null +++ b/src/N98/Magento/Command/Cms/Block/AbstractCmsBlockCommand.php @@ -0,0 +1,29 @@ +_getModel('cms/block'); + if (!$model instanceof Mage_Cms_Model_Block) { + throw new UnexpectedValueException($model, Mage_Cms_Model_Block::class); + } + return $model; + } +} diff --git a/src/N98/Magento/Command/Cms/Block/ListCommand.php b/src/N98/Magento/Command/Cms/Block/ListCommand.php index b0874e621..77fad829f 100644 --- a/src/N98/Magento/Command/Cms/Block/ListCommand.php +++ b/src/N98/Magento/Command/Cms/Block/ListCommand.php @@ -1,80 +1,70 @@ >|null */ - protected function configure() - { - $this - ->setName('cms:block:list') - ->setDescription('List all cms blocks') - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' - ) - ; - } + private ?array $data = null; /** - * Get an instance of cms/block - * - * @return \Mage_Cms_Model_Block + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand */ - protected function _getBlockModel() - { - return $this->_getModel('cms/block', '\Mage_Cms_Model_Block'); - } + protected static $defaultName = 'cms:block:list'; /** - * Execute the command - * - * @param InputInterface $input + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultDescription = 'List all cms blocks'; + + /** + * @param InputInterface $input * @param OutputInterface $output - * - * @return int + * @return array> + * @throws Mage_Core_Exception */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getData(InputInterface $input, OutputInterface $output): array { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } - - $cmsBlockCollection = $this->_getBlockModel()->getCollection()->addFieldToSelect('*'); + if (is_null($this->data)) { + /** @var Mage_Cms_Model_Block[] $cmsBlockCollection */ + $cmsBlockCollection = $this->_getBlockModel()->getCollection()->addFieldToSelect('*'); - /** @var \Mage_Cms_Model_Resource_Block $resourceModel */ - $resourceModel = $this->_getBlockModel()->getResource(); + $resourceModel = $this->_getBlockModel()->getResource(); - $table = []; - foreach ($cmsBlockCollection as $cmsBlock) { - $storeIds = implode(',', $resourceModel->lookupStoreIds($cmsBlock->getId())); + $this->data = []; + foreach ($cmsBlockCollection as $cmsBlock) { + $storeIds = implode(',', $resourceModel->lookupStoreIds((int)$cmsBlock->getId())); - $table[] = [$cmsBlock->getData('block_id'), $cmsBlock->getData('identifier'), $cmsBlock->getData('title'), $cmsBlock->getData('is_active') ? 'active' : 'inactive', $storeIds]; + $this->data[] = [ + 'block_id' => $cmsBlock->getBlockId(), + 'title' => $cmsBlock->getTitle(), + 'identifier' => $cmsBlock->getIdentifier(), + 'is_active' => $cmsBlock->getIsActive() ? 'active' : 'inactive', + 'store_ids' => $storeIds + ]; + } } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); - $tableHelper - ->setHeaders(['block_id', 'identifier', 'title', 'is_active', 'store_ids']) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + return $this->data; } } diff --git a/src/N98/Magento/Command/Cms/Block/ToggleCommand.php b/src/N98/Magento/Command/Cms/Block/ToggleCommand.php index 50f9bf8cd..0ea4ba111 100644 --- a/src/N98/Magento/Command/Cms/Block/ToggleCommand.php +++ b/src/N98/Magento/Command/Cms/Block/ToggleCommand.php @@ -1,72 +1,80 @@ setName('cms:block:toggle') - ->addArgument('block_id', InputArgument::REQUIRED, 'Block ID or Identifier') - ->setDescription('Toggle a cms block') - ; - } + protected static $defaultName = 'cms:block:toggle'; + + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultDescription = 'Toggle a cms block.'; /** - * Get an instance of cms/block - * - * @return \Mage_Cms_Model_Block + * @return void */ - protected function _getBlockModel() + protected function configure() { - return $this->_getModel('cms/block', '\Mage_Cms_Model_Block'); + $this->addArgument( + self::COMMAND_ARGUMENT_BLOCK_ID, + InputArgument::REQUIRED, + 'Block ID or Identifier' + ); } /** - * Execute the command - * - * @param InputInterface $input + * @param InputInterface $input * @param OutputInterface $output - * * @return int + * @throws Throwable */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } - $blockId = $input->getArgument('block_id'); - if (is_numeric($blockId)) { - $block = $this->_getBlockModel()->load($blockId); - } else { - $block = $this->_getBlockModel()->load($blockId, 'identifier'); - } + $this->detectMagento($output); + $this->initMagento(); + + $blockId = $this->getArgumentString($input, self::COMMAND_ARGUMENT_BLOCK_ID); + $block = $this->_getBlockModel()->load($blockId, is_numeric($blockId) ? null : 'identifier'); + if (!$block->getId()) { - return (int) $output->writeln('Block was not found'); + $output->writeln('Block was not found'); + return Command::INVALID; } - $newStatus = !$block->getIsActive(); + $block - ->setIsActive($newStatus) + ->setIsActive(!$block->getIsActive()) ->save(); + $output->writeln(sprintf( - 'Block %s', - $newStatus ? 'enabled' : 'disabled' + 'Block "%s" %s', + $block->getTitle(), + $block->getIsActive() ? 'enabled' : 'disabled' )); - return 0; + + return Command::SUCCESS; } } From 6b4075cda9f5943b6b189065f1d5f71ef9d453c4 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 17 Oct 2023 00:58:56 +0200 Subject: [PATCH 003/136] [skip ci] Updated sys:website:list command --- .../Command/System/Website/ListCommand.php | 79 +++++++++---------- 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/src/N98/Magento/Command/System/Website/ListCommand.php b/src/N98/Magento/Command/System/Website/ListCommand.php index 61e3a2d67..7d77630e3 100644 --- a/src/N98/Magento/Command/System/Website/ListCommand.php +++ b/src/N98/Magento/Command/System/Website/ListCommand.php @@ -1,62 +1,61 @@ >|null */ - protected $infos; + private ?array $data = null; - protected function configure() - { - $this - ->setName('sys:website:list') - ->setDescription('Lists all websites') - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' - ) - ; - } + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultName = 'sys:website:list'; + + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultDescription = 'Lists all websites'; /** * @param InputInterface $input * @param OutputInterface $output - * - * @return int + * @return array> */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getData(InputInterface $input, OutputInterface $output): array { - $table = []; - $this->detectMagento($output, true); - - if ($input->getOption('format') === null) { - $this->writeSection($output, 'Magento Websites'); - } - $this->initMagento(); - - foreach (Mage::app()->getWebsites() as $store) { - $table[$store->getId()] = [$store->getId(), $store->getCode()]; + if (is_null($this->data)) { + $this->data = []; + foreach ($this->_getMage()->getWebsites() as $store) { + $storeId = (string) $store->getId(); + $this->data[$storeId] = [ + 'id' => $storeId, + 'code' => $store->getCode() + ]; + } + + ksort($this->data); } - ksort($table); - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); - $tableHelper - ->setHeaders(['id', 'code']) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + return $this->data; } } From ed63ea2746107e3eba41bd273acfd56d74b08c9b Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 17 Oct 2023 01:00:42 +0200 Subject: [PATCH 004/136] [skip ci] Updated sys:store commands --- .../Store/Config/BaseUrlListCommand.php | 82 +++++++++++-------- .../Command/System/Store/ListCommand.php | 73 +++++++++-------- 2 files changed, 84 insertions(+), 71 deletions(-) diff --git a/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php b/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php index 47cd43706..2112e3cdc 100644 --- a/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php +++ b/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php @@ -1,57 +1,67 @@ setName('sys:store:config:base-url:list') - ->setDescription('Lists all base urls') - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' - ) - ; - } + public const COMMAND_SECTION_TITLE_TEXT = 'Stores - Base URLs'; + + /** + * @var array>|null + */ + private ?array $data = null; + + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultName = 'sys:store:config:base-url:list'; + + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultDescription = 'Lists all base urls.'; /** * @param InputInterface $input * @param OutputInterface $output - * - * @return int + * @return array> */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getData(InputInterface $input, OutputInterface $output): array { - $table = []; - $this->detectMagento($output, true); - - if (!$input->getOption('format')) { - $this->writeSection($output, 'Magento Stores - Base URLs'); - } - $this->initMagento(); + if (is_null($this->data)) { + $this->data = []; + foreach ($this->_getMage()->getStores() as $store) { + $storeId = (string) $store->getId(); + $this->data[$storeId] = [ + 'ID' => $storeId, + 'Code' => $store->getCode(), + 'Unsecure base URL' => Mage::getStoreConfig(Store::XML_PATH_UNSECURE_BASE_URL, $store), + 'Secure base URL' => Mage::getStoreConfig(Store::XML_PATH_SECURE_BASE_URL, $store) + ]; + } - foreach (Mage::app()->getStores() as $store) { - $table[$store->getId()] = [$store->getId(), $store->getCode(), Mage::getStoreConfig('web/unsecure/base_url', $store), Mage::getStoreConfig('web/secure/base_url', $store)]; + ksort($this->data); } - ksort($table); - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); - $tableHelper - ->setHeaders(['id', 'code', 'unsecure_baseurl', 'secure_baseurl']) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + return $this->data; } } diff --git a/src/N98/Magento/Command/System/Store/ListCommand.php b/src/N98/Magento/Command/System/Store/ListCommand.php index 1c3642618..e72f47064 100644 --- a/src/N98/Magento/Command/System/Store/ListCommand.php +++ b/src/N98/Magento/Command/System/Store/ListCommand.php @@ -1,58 +1,61 @@ >|null */ - protected $infos; + private ?array $data = null; - protected function configure() - { - $this - ->setName('sys:store:list') - ->setDescription('Lists all installed store-views') - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' - ) - ; - } + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultName = 'sys:store:list'; + + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultDescription = 'Lists all installed store-views'; /** * @param InputInterface $input * @param OutputInterface $output - * - * @return int + * @return array> */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getData(InputInterface $input, OutputInterface $output): array { - $table = []; - $this->detectMagento($output, true); - $this->initMagento(); + if (is_null($this->data)) { + $this->data = []; + foreach ($this->_getMage()->getStores() as $store) { + $storeId = (string) $store->getId(); + $this->data[$storeId] = [ + 'id' => $storeId, + 'code' => $store->getCode() + ]; + } - foreach (Mage::app()->getStores() as $store) { - $table[$store->getId()] = [$store->getId(), $store->getCode()]; + ksort($this->data); } - ksort($table); - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); - $tableHelper - ->setHeaders(['id', 'code']) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + return $this->data; } } From d51660026a68d4f223ab05c24ebca01e5dec4d32 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 17 Oct 2023 01:08:25 +0200 Subject: [PATCH 005/136] [skip ci] Updated sys:maintenance command --- .../Command/System/MaintenanceCommand.php | 64 +++++++++++++++---- 1 file changed, 50 insertions(+), 14 deletions(-) diff --git a/src/N98/Magento/Command/System/MaintenanceCommand.php b/src/N98/Magento/Command/System/MaintenanceCommand.php index a7ad7084d..e8feb89bc 100644 --- a/src/N98/Magento/Command/System/MaintenanceCommand.php +++ b/src/N98/Magento/Command/System/MaintenanceCommand.php @@ -1,22 +1,57 @@ setName('sys:maintenance') - ->addOption('on', null, InputOption::VALUE_NONE, 'Enable maintenance mode') - ->addOption('off', null, InputOption::VALUE_NONE, 'Disable maintenance mode') - ->setDescription('Toggles maintenance mode.') + ->addOption( + self::COMMAND_OPTION_ON, + null, + InputOption::VALUE_NONE, + 'Enable maintenance mode' + ) + ->addOption( + self::COMMAND_OPTION_OFF, + null, + InputOption::VALUE_NONE, + 'Disable maintenance mode' + ) ; } @@ -31,25 +66,26 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->detectMagento($output); $flagFile = $this->_magentoRootFolder . '/maintenance.flag'; - if ($input->getOption('off')) { - $this->_switchOff($output, $flagFile); - } elseif ($input->getOption('on')) { - $this->_switchOn($output, $flagFile); + if ($input->getOption(self::COMMAND_OPTION_OFF)) { + $this->switchOff($output, $flagFile); + } elseif ($input->getOption(self::COMMAND_OPTION_ON)) { + $this->switchOn($output, $flagFile); } else { if (file_exists($flagFile)) { - $this->_switchOff($output, $flagFile); + $this->switchOff($output, $flagFile); } else { - $this->_switchOn($output, $flagFile); + $this->switchOn($output, $flagFile); } } - return 0; + + return Command::SUCCESS; } /** * @param OutputInterface $output - * @param $flagFile + * @param string $flagFile */ - protected function _switchOn(OutputInterface $output, $flagFile) + private function switchOn(OutputInterface $output, string $flagFile): void { if (!file_exists($flagFile)) { if (!touch($flagFile)) { @@ -63,7 +99,7 @@ protected function _switchOn(OutputInterface $output, $flagFile) * @param OutputInterface $output * @param string $flagFile */ - protected function _switchOff($output, $flagFile) + private function switchOff(OutputInterface $output, string $flagFile): void { if (file_exists($flagFile)) { if (!unlink($flagFile)) { From ea140a0d032432f7a02339c70b134da97fa7960d Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 17 Oct 2023 02:09:31 +0200 Subject: [PATCH 006/136] [skip ci] Updated media commands --- .../Media/Cache/Image/ClearCommand.php | 39 +++++++--- .../Media/Cache/JsCss/ClearCommand.php | 39 +++++++--- src/N98/Magento/Command/Media/DumpCommand.php | 73 ++++++++++++++++--- 3 files changed, 118 insertions(+), 33 deletions(-) diff --git a/src/N98/Magento/Command/Media/Cache/Image/ClearCommand.php b/src/N98/Magento/Command/Media/Cache/Image/ClearCommand.php index 532864bca..a66d1a085 100644 --- a/src/N98/Magento/Command/Media/Cache/Image/ClearCommand.php +++ b/src/N98/Magento/Command/Media/Cache/Image/ClearCommand.php @@ -1,19 +1,36 @@ setName('media:cache:image:clear') - ->setDescription('Clears image cache'); - } + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultName = 'media:cache:image:clear'; + + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultDescription = 'Clears image cache'; /** * @param InputInterface $input @@ -23,12 +40,12 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output); + $this->initMagento(); + + Mage::getModel('catalog/product_image')->clearCache(); + Mage::dispatchEvent('clean_catalog_images_cache_after'); + $output->writeln('Image cache cleared'); - if ($this->initMagento()) { - Mage::getModel('catalog/product_image')->clearCache(); - Mage::dispatchEvent('clean_catalog_images_cache_after'); - $output->writeln('Image cache cleared'); - } - return 0; + return Command::SUCCESS; } } diff --git a/src/N98/Magento/Command/Media/Cache/JsCss/ClearCommand.php b/src/N98/Magento/Command/Media/Cache/JsCss/ClearCommand.php index eede2bda4..571efc257 100644 --- a/src/N98/Magento/Command/Media/Cache/JsCss/ClearCommand.php +++ b/src/N98/Magento/Command/Media/Cache/JsCss/ClearCommand.php @@ -1,19 +1,36 @@ setName('media:cache:jscss:clear') - ->setDescription('Clears JS/CSS cache'); - } + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultName = 'media:cache:jscss:clear'; + + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultDescription = 'Clears JS/CSS cache.'; /** * @param InputInterface $input @@ -23,12 +40,12 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output); + $this->initMagento(); + + Mage::getModel('core/design_package')->cleanMergedJsCss(); + Mage::dispatchEvent('clean_media_cache_after'); + $output->writeln('Js/CSS cache cleared'); - if ($this->initMagento()) { - Mage::getModel('core/design_package')->cleanMergedJsCss(); - Mage::dispatchEvent('clean_media_cache_after'); - $output->writeln('Js/CSS cache cleared'); - } - return 0; + return Command::SUCCESS; } } diff --git a/src/N98/Magento/Command/Media/DumpCommand.php b/src/N98/Magento/Command/Media/DumpCommand.php index 6f51c4c0c..4e1bca629 100644 --- a/src/N98/Magento/Command/Media/DumpCommand.php +++ b/src/N98/Magento/Command/Media/DumpCommand.php @@ -1,8 +1,14 @@ setName('media:dump') - ->addOption('strip', '', InputOption::VALUE_NONE, 'Excludes image cache') - ->addArgument('filename', InputArgument::OPTIONAL, 'Dump filename') - ->setDescription('Creates an archive with content of media folder.') + ->addOption( + self::COMMAND_OPTION_STRIP, + '', + InputOption::VALUE_NONE, + 'Excludes image cache' + ) + ->addArgument( + self::COMMAND_ARGUMENT_FILENAME, + InputArgument::OPTIONAL, + 'Dump filename' + ) ; } /** - * @param InputInterface $input + * @param InputInterface $input * @param OutputInterface $output - * * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int { + $this->detectMagento($output); + + /** @var Application $app */ + $app = $this->getApplication(); + if (!$app) { + throw new RuntimeException('Could not run application.'); + } + + $rootFolder = $app->getMagentoRootFolder(); + if (!$rootFolder) { + throw new RuntimeException('Could not find root folder.'); + } + $commandConfig = $this->getCommandConfig(); - $this->detectMagento($output); $finder = new Finder(); $finder ->files()->followLinks() - ->in($this->getApplication()->getMagentoRootFolder() . DIRECTORY_SEPARATOR . 'media'); - if ($input->getOption('strip')) { + ->in($rootFolder . DIRECTORY_SEPARATOR . 'media'); + + if ($input->getOption(self::COMMAND_OPTION_STRIP)) { $finder->exclude($commandConfig['strip']['folders']); } - $filename = (string) $input->getArgument('filename'); + $filename = $this->getArgumentString($input, self::COMMAND_ARGUMENT_FILENAME); if (is_dir($filename)) { // support for dot dir $filename = realpath($filename); $filename .= '/'; @@ -69,6 +119,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $zip->close(); - return 0; + + return Command::SUCCESS; } } From 06a08d6ffa87fbff03bd008bf14f0d969c7a9c47 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 17 Oct 2023 04:18:26 +0200 Subject: [PATCH 007/136] [skip ci] Updated local-config:generate command --- .../Command/LocalConfig/GenerateCommand.php | 165 ++++++++++++------ 1 file changed, 112 insertions(+), 53 deletions(-) diff --git a/src/N98/Magento/Command/LocalConfig/GenerateCommand.php b/src/N98/Magento/Command/LocalConfig/GenerateCommand.php index 14087f317..d00991e13 100644 --- a/src/N98/Magento/Command/LocalConfig/GenerateCommand.php +++ b/src/N98/Magento/Command/LocalConfig/GenerateCommand.php @@ -1,46 +1,109 @@ setName('local-config:generate') - ->setDescription('Generates local.xml config') - ->addArgument('db-host', InputArgument::OPTIONAL, 'Database host') - ->addArgument('db-user', InputArgument::OPTIONAL, 'Database user') - ->addArgument('db-pass', InputArgument::OPTIONAL, 'Database password') - ->addArgument('db-name', InputArgument::OPTIONAL, 'Database name') - ->addArgument('session-save', InputArgument::OPTIONAL, 'Session storage adapter') - ->addArgument('admin-frontname', InputArgument::OPTIONAL, 'Admin front name') - ->addArgument('encryption-key', InputArgument::OPTIONAL, 'Encryption Key') + ->addArgument( + self::COMMAND_ARGUMENT_DB_HOST, + InputArgument::OPTIONAL, + 'Database host' + ) + ->addArgument( + self::COMMAND_ARGUMENT_DB_USER, + InputArgument::OPTIONAL, + 'Database user' + ) + ->addArgument( + self::COMMAND_ARGUMENT_DB_PASS, + InputArgument::OPTIONAL, + 'Database password' + ) + ->addArgument( + self::COMMAND_ARGUMENT_DB_NAME, + InputArgument::OPTIONAL, + 'Database name' + ) + ->addArgument( + self::COMMAND_ARGUMENT_SESSION_SAVE, + InputArgument::OPTIONAL, + 'Session storage adapter' + ) + ->addArgument( + self::COMMAND_ARGUMENT_ADMIN_FRONTNAME, + InputArgument::OPTIONAL, + 'Admin front name' + ) + ->addArgument( + self::COMMAND_ARGUMENT_ENCRYPTION_KEY, + InputArgument::OPTIONAL, + 'Encryption Key' + ) ; + } - $help = <<setHelp($help); } /** * @param InputInterface $input * @param OutputInterface $output - * * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int @@ -53,84 +116,88 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln( sprintf('local.xml file already exists in folder "%s/app/etc"', dirname($configFile)) ); - return 0; + return Command::INVALID; } - $this->writeSection($output, 'Generate Magento local.xml'); + $this->writeSection($output, 'Generate local.xml'); $this->askForArguments($input, $output); if (!file_exists($configFileTemplate)) { $output->writeln(sprintf('File %s does not exist.', $configFileTemplate)); - return 0; + return Command::FAILURE; } if (!is_writable(dirname($configFileTemplate))) { $output->writeln(sprintf('Folder %s is not writeable', dirname($configFileTemplate))); - return 0; + return Command::FAILURE; } $content = file_get_contents($configFileTemplate); - $key = $input->getArgument('encryption-key') ?: md5(uniqid()); + if (!$content) { + $output->writeln(sprintf('File %s has no content', dirname($configFileTemplate))); + return Command::FAILURE; + } + + $key = $this->getArgumentString($input, self::COMMAND_ARGUMENT_ENCRYPTION_KEY) ?: md5(uniqid()); $replace = [ - '{{date}}' => $this->_wrapCData(date(DateTime::RFC2822)), + '{{date}}' => $this->_wrapCData(date(DateTimeInterface::RFC2822)), '{{key}}' => $this->_wrapCData($key), '{{db_prefix}}' => $this->_wrapCData(''), - '{{db_host}}' => $this->_wrapCData($input->getArgument('db-host')), - '{{db_user}}' => $this->_wrapCData($input->getArgument('db-user')), - '{{db_pass}}' => $this->_wrapCData($input->getArgument('db-pass')), - '{{db_name}}' => $this->_wrapCData($input->getArgument('db-name')), - // typo intended -> magento has a little typo bug "statemants". + '{{db_host}}' => $this->_wrapCData($this->getArgumentString($input, self::COMMAND_ARGUMENT_DB_HOST)), + '{{db_user}}' => $this->_wrapCData($this->getArgumentString($input, self::COMMAND_ARGUMENT_DB_USER,)), + '{{db_pass}}' => $this->_wrapCData($this->getArgumentString($input, self::COMMAND_ARGUMENT_DB_PASS)), + '{{db_name}}' => $this->_wrapCData($this->getArgumentString($input, self::COMMAND_ARGUMENT_DB_NAME)), + // typo intended -> magento has a little typo bug "statements". '{{db_init_statemants}}' => $this->_wrapCData('SET NAMES utf8'), '{{db_model}}' => $this->_wrapCData('mysql4'), '{{db_type}}' => $this->_wrapCData('pdo_mysql'), '{{db_pdo_type}}' => $this->_wrapCData(''), - '{{session_save}}' => $this->_wrapCData($input->getArgument('session-save')), - '{{admin_frontname}}' => $this->_wrapCData($input->getArgument('admin-frontname')), + '{{session_save}}' => $this->_wrapCData($this->getArgumentString($input, self::COMMAND_ARGUMENT_SESSION_SAVE)), + '{{admin_frontname}}' => $this->_wrapCData($this->getArgumentString($input, self::COMMAND_ARGUMENT_ADMIN_FRONTNAME)), ]; $newFileContent = str_replace(array_keys($replace), array_values($replace), $content); if (false === file_put_contents($configFile, $newFileContent)) { $output->writeln('could not save config'); - return 0; + return Command::FAILURE; } $output->writeln('Generated config'); - return 0; + return Command::SUCCESS; } /** * @param InputInterface $input * @param OutputInterface $output */ - protected function askForArguments(InputInterface $input, OutputInterface $output) + protected function askForArguments(InputInterface $input, OutputInterface $output): void { - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $messagePrefix = 'Please enter the '; $arguments = [ - 'db-host' => [ + self::COMMAND_ARGUMENT_DB_HOST => [ 'prompt' => 'database host', 'required' => true ], - 'db-user' => [ + self::COMMAND_ARGUMENT_DB_USER => [ 'prompt' => 'database username', 'required' => true ], - 'db-pass' => [ + self::COMMAND_ARGUMENT_DB_PASS => [ 'prompt' => 'database password', 'required' => false ], - 'db-name' => [ + self::COMMAND_ARGUMENT_DB_NAME => [ 'prompt' => 'database name', 'required' => true ], - 'session-save' => [ + self::COMMAND_ARGUMENT_SESSION_SAVE => [ 'prompt' => 'session save', 'required' => true, 'default' => 'files' ], - 'admin-frontname' => [ + self::COMMAND_ARGUMENT_ADMIN_FRONTNAME => [ 'prompt' => 'admin frontname', 'required' => true, 'default' => 'admin' @@ -139,17 +206,11 @@ protected function askForArguments(InputInterface $input, OutputInterface $outpu foreach ($arguments as $argument => $options) { if (isset($options['default']) && $input->getArgument($argument) === null) { - $input->setArgument( - $argument, - $dialog->ask( - $input, - $output, - new Question( - sprintf('%s%s: ', $messagePrefix, $options['prompt']), - (string) $options['default'] - ), - ) + $question = new Question( + sprintf('%s%s: ', $messagePrefix, $options['prompt']), + (string) $options['default'] ); + $input->setArgument($argument, $dialog->ask($input, $output, $question)); } else { $input->setArgument( $argument, @@ -166,10 +227,9 @@ protected function askForArguments(InputInterface $input, OutputInterface $outpu /** * @return string */ - protected function _getLocalConfigFilename() + protected function _getLocalConfigFilename(): string { - $configFile = $this->_magentoRootFolder . '/app/etc/local.xml'; - return $configFile; + return $this->_magentoRootFolder . '/app/etc/local.xml'; } /** @@ -179,10 +239,9 @@ protected function _getLocalConfigFilename() * a sequence that can not be part of a CDATA section "]]>") the part that can well be. * * @param string $string - * * @return string CDATA section or equivalent */ - protected function _wrapCData($string) + protected function _wrapCData(string $string): string { $buffer = strtr($string, [']]>' => ']]>]]>'; From 7fff0a999d1e3f62f4d4661cdf52e2fbca092fe7 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 10 Jun 2024 05:46:54 +0200 Subject: [PATCH 008/136] [skip ci] Added AbstractMagentoCommandFormatInterface --- .../AbstractMagentoCommandFormatInterface.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/N98/Magento/Command/AbstractMagentoCommandFormatInterface.php diff --git a/src/N98/Magento/Command/AbstractMagentoCommandFormatInterface.php b/src/N98/Magento/Command/AbstractMagentoCommandFormatInterface.php new file mode 100644 index 000000000..15f4939df --- /dev/null +++ b/src/N98/Magento/Command/AbstractMagentoCommandFormatInterface.php @@ -0,0 +1,18 @@ +> + */ + public function getData(InputInterface $input, OutputInterface $output): array; +} From 5c0db45be0cc3f5e0e370d0917b990904fed440d Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 10 Jun 2024 05:58:16 +0200 Subject: [PATCH 009/136] [skip ci] Updated admin:user:list command --- .../Command/Admin/User/ListCommand.php | 74 +++++++++---------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/N98/Magento/Command/Admin/User/ListCommand.php b/src/N98/Magento/Command/Admin/User/ListCommand.php index 4d5915f91..041e48016 100644 --- a/src/N98/Magento/Command/Admin/User/ListCommand.php +++ b/src/N98/Magento/Command/Admin/User/ListCommand.php @@ -1,55 +1,55 @@ setName('admin:user:list') - ->setDescription('List admin users.') - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' - ) - ; - } + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultName = 'admin:user:list'; /** - * @param InputInterface $input - * @param OutputInterface $output + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultDescription = 'List admin users.'; + + /** + * {@inheritdoc} + * @return array> * - * @return int + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getData(InputInterface $input, OutputInterface $output): array { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + if (is_null($this->data)) { + $this->data = []; - /** @var \Mage_Admin_Model_User $userModel */ - $userModel = $this->getUserModel(); - $userList = $userModel->getCollection(); - $table = []; - foreach ($userList as $user) { - $table[] = [$user->getId(), $user->getUsername(), $user->getEmail(), $user->getIsActive() ? 'active' : 'inactive']; + /** @var Mage_Admin_Model_User $userModel */ + $userModel = $this->getUserModel(); + $userList = $userModel->getCollection(); + foreach ($userList as $user) { + $this->data[] = [ + 'id' => $user->getId(), + 'username' => $user->getUsername(), + 'email' => $user->getEmail(), + 'status' => $user->getIsActive() ? 'active' : 'inactive' + ]; + } } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); - $tableHelper - ->setHeaders(['id', 'username', 'email', 'status']) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + return $this->data; } } From b35c235b541367e34f55efc261dba151cdd02edc Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 10 Jun 2024 06:01:44 +0200 Subject: [PATCH 010/136] [skip ci] Updated cache:list command --- src/N98/Magento/Command/Cache/ListCommand.php | 68 +++++++++---------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/src/N98/Magento/Command/Cache/ListCommand.php b/src/N98/Magento/Command/Cache/ListCommand.php index c4b32e312..b702e6825 100644 --- a/src/N98/Magento/Command/Cache/ListCommand.php +++ b/src/N98/Magento/Command/Cache/ListCommand.php @@ -1,52 +1,48 @@ setName('cache:list') - ->setDescription('Lists all magento caches') - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' - ) - ; - } + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultName = 'cache:list'; /** - * @param InputInterface $input - * @param OutputInterface $output - * @return int + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + protected static $defaultDescription = 'Lists all magento caches.'; - $cacheTypes = $this->_getCacheModel()->getTypes(); - $table = []; - foreach ($cacheTypes as $cacheCode => $cacheInfo) { - $table[] = [$cacheCode, $cacheInfo['status'] ? 'enabled' : 'disabled']; + /** + * {@inheritdoc} + * @return array> + * + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter + */ + public function getData(InputInterface $input, OutputInterface $output): array + { + if (is_null($this->data)) { + $this->data = []; + foreach ($this->_getCacheModel()->getTypes() as $cacheCode => $cacheInfo) { + $this->data[] = [ + 'code' => $cacheCode, + 'status' => $cacheInfo['status'] ? 'enabled' : 'disabled' + ]; + } } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); - $tableHelper - ->setHeaders(['code', 'status']) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + return $this->data; } } From 571ce684add78b8959d29996301979c8a4e597cf Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 10 Jun 2024 06:06:40 +0200 Subject: [PATCH 011/136] [skip ci] Updated cms:block:list command --- .../Magento/Command/Cms/Block/ListCommand.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/N98/Magento/Command/Cms/Block/ListCommand.php b/src/N98/Magento/Command/Cms/Block/ListCommand.php index 77fad829f..e537d7243 100644 --- a/src/N98/Magento/Command/Cms/Block/ListCommand.php +++ b/src/N98/Magento/Command/Cms/Block/ListCommand.php @@ -18,11 +18,6 @@ */ class ListCommand extends AbstractCmsBlockCommand implements AbstractMagentoCommandFormatInterface { - /** - * @var array>|null - */ - private ?array $data = null; - /** * @var string * @deprecated with symfony 6.1 @@ -35,23 +30,23 @@ class ListCommand extends AbstractCmsBlockCommand implements AbstractMagentoComm * @deprecated with symfony 6.1 * @see AsCommand */ - protected static $defaultDescription = 'List all cms blocks'; + protected static $defaultDescription = 'List all cms blocks.'; /** - * @param InputInterface $input - * @param OutputInterface $output - * @return array> + * {@inheritdoc} + * @return array> * @throws Mage_Core_Exception + * + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ public function getData(InputInterface $input, OutputInterface $output): array { if (is_null($this->data)) { + $this->data = []; + /** @var Mage_Cms_Model_Block[] $cmsBlockCollection */ $cmsBlockCollection = $this->_getBlockModel()->getCollection()->addFieldToSelect('*'); - $resourceModel = $this->_getBlockModel()->getResource(); - - $this->data = []; foreach ($cmsBlockCollection as $cmsBlock) { $storeIds = implode(',', $resourceModel->lookupStoreIds((int)$cmsBlock->getId())); From f7404df5e02b0cb0947ffa55251d0aa115fbe2f6 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 10 Jun 2024 06:53:46 +0200 Subject: [PATCH 012/136] [skip ci] Updated customer:list command --- .../Magento/Command/Customer/ListCommand.php | 109 ++++++++++-------- 1 file changed, 60 insertions(+), 49 deletions(-) diff --git a/src/N98/Magento/Command/Customer/ListCommand.php b/src/N98/Magento/Command/Customer/ListCommand.php index f31dd25cc..116c4f1dd 100644 --- a/src/N98/Magento/Command/Customer/ListCommand.php +++ b/src/N98/Magento/Command/Customer/ListCommand.php @@ -1,77 +1,88 @@ setName('customer:list') - ->addArgument('search', InputArgument::OPTIONAL, 'Search query') - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' - ) - ->setDescription('Lists customers') - ; - - $help = <<addArgument('search', InputArgument::OPTIONAL, 'Search query'); + + parent::configure(); + } + + public function getHelp() + { + return <<setHelp($help); } /** - * @param InputInterface $input - * @param OutputInterface $output + * {@inheritdoc} + * @return array> + * @throws Mage_Core_Exception * - * @return int + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getData(InputInterface $input, OutputInterface $output): array { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + if (is_null($this->data)) { + $this->data = []; - $config = $this->getCommandConfig(); + $config = $this->getCommandConfig(); - $collection = $this->getCustomerCollection(); - $collection->addAttributeToSelect(['entity_id', 'email', 'firstname', 'lastname', 'website_id']); + $collection = $this->getCustomerCollection(); + $collection->addAttributeToSelect(['entity_id', 'email', 'firstname', 'lastname', 'website_id']); - if ($input->getArgument('search')) { - $collection->addAttributeToFilter( - [['attribute' => 'email', 'like' => '%' . $input->getArgument('search') . '%'], ['attribute' => 'firstname', 'like' => '%' . $input->getArgument('search') . '%'], ['attribute' => 'lastname', 'like' => '%' . $input->getArgument('search') . '%']] - ); - } + if ($input->getArgument('search')) { + $collection->addAttributeToFilter( + [ + ['attribute' => 'email', 'like' => '%' . $input->getArgument('search') . '%'], + ['attribute' => 'firstname', 'like' => '%' . $input->getArgument('search') . '%'], + ['attribute' => 'lastname', 'like' => '%' . $input->getArgument('search') . '%'] + ] + ); + } - $collection->setPageSize($config['limit']); + $collection->setPageSize($config['limit']); - $table = []; - foreach ($collection as $customer) { - $table[] = [$customer->getId(), $customer->getEmail(), $customer->getFirstname(), $customer->getLastname(), $this->_getWebsiteCodeById($customer->getwebsiteId())]; + foreach ($collection as $customer) { + $this->data[] = [ + 'id' => $customer->getId(), + 'email' => $customer->getEmail(), + 'firstname' => $customer->getFirstname(), + 'lastname' => $customer->getLastname(), + 'website' => $this->_getWebsiteCodeById($customer->getwebsiteId()) + ]; + } } - if (count($table) > 0) { - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); - $tableHelper - ->setHeaders(['id', 'email', 'firstname', 'lastname', 'website']) - ->renderByFormat($output, $table, $input->getOption('format')); - } else { - $output->writeln('No customers found'); - } - return 0; + return $this->data; } } From 49101288ec1b101527de4815d5537a1b5e65f8a3 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 10 Jun 2024 06:53:46 +0200 Subject: [PATCH 013/136] [skip ci] Updated customer:list command --- .../Magento/Command/Customer/ListCommand.php | 110 ++++++++++-------- 1 file changed, 61 insertions(+), 49 deletions(-) diff --git a/src/N98/Magento/Command/Customer/ListCommand.php b/src/N98/Magento/Command/Customer/ListCommand.php index f31dd25cc..cae861c41 100644 --- a/src/N98/Magento/Command/Customer/ListCommand.php +++ b/src/N98/Magento/Command/Customer/ListCommand.php @@ -1,77 +1,89 @@ setName('customer:list') - ->addArgument('search', InputArgument::OPTIONAL, 'Search query') - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' - ) - ->setDescription('Lists customers') - ; - - $help = <<addArgument('search', InputArgument::OPTIONAL, 'Search query'); + + parent::configure(); + } + + public function getHelp() + { + return <<setHelp($help); } /** - * @param InputInterface $input - * @param OutputInterface $output + * {@inheritdoc} + * @return array> + * @throws Mage_Core_Exception * - * @return int + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getData(InputInterface $input, OutputInterface $output): array { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + if (is_null($this->data)) { + $this->data = []; - $config = $this->getCommandConfig(); + $config = $this->getCommandConfig(); - $collection = $this->getCustomerCollection(); - $collection->addAttributeToSelect(['entity_id', 'email', 'firstname', 'lastname', 'website_id']); + $collection = $this->getCustomerCollection(); + $collection->addAttributeToSelect(['entity_id', 'email', 'firstname', 'lastname', 'website_id']); - if ($input->getArgument('search')) { - $collection->addAttributeToFilter( - [['attribute' => 'email', 'like' => '%' . $input->getArgument('search') . '%'], ['attribute' => 'firstname', 'like' => '%' . $input->getArgument('search') . '%'], ['attribute' => 'lastname', 'like' => '%' . $input->getArgument('search') . '%']] - ); - } + if ($input->getArgument('search')) { + $collection->addAttributeToFilter( + [ + ['attribute' => 'email', 'like' => '%' . $input->getArgument('search') . '%'], + ['attribute' => 'firstname', 'like' => '%' . $input->getArgument('search') . '%'], + ['attribute' => 'lastname', 'like' => '%' . $input->getArgument('search') . '%'] + ] + ); + } - $collection->setPageSize($config['limit']); + $collection->setPageSize($config['limit']); - $table = []; - foreach ($collection as $customer) { - $table[] = [$customer->getId(), $customer->getEmail(), $customer->getFirstname(), $customer->getLastname(), $this->_getWebsiteCodeById($customer->getwebsiteId())]; + foreach ($collection as $customer) { + $this->data[] = [ + 'id' => $customer->getId(), + 'email' => $customer->getEmail(), + 'firstname' => $customer->getFirstname(), + 'lastname' => $customer->getLastname(), + 'website' => $this->_getWebsiteCodeById($customer->getwebsiteId()) + ]; + } } - if (count($table) > 0) { - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); - $tableHelper - ->setHeaders(['id', 'email', 'firstname', 'lastname', 'website']) - ->renderByFormat($output, $table, $input->getOption('format')); - } else { - $output->writeln('No customers found'); - } - return 0; + return $this->data; } } From 4e2657bd25a51c85a889fd34cf363260e985d30d Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 10 Jun 2024 07:46:35 +0200 Subject: [PATCH 014/136] [skip ci] Updated dev:module:list command --- .../Command/Developer/Module/ListCommand.php | 64 +++++++++---------- src/N98/Magento/Modules.php | 18 +++--- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Module/ListCommand.php b/src/N98/Magento/Command/Developer/Module/ListCommand.php index 1802a1a6d..2fbb53974 100644 --- a/src/N98/Magento/Command/Developer/Module/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Module/ListCommand.php @@ -1,62 +1,60 @@ setName('dev:module:list') ->addOption('codepool', null, InputOption::VALUE_OPTIONAL, 'Show modules in a specific codepool') ->addOption('status', null, InputOption::VALUE_OPTIONAL, 'Show modules with a specific status') ->addOption('vendor', null, InputOption::VALUE_OPTIONAL, 'Show modules of a specified vendor') ->setAliases(['sys:modules:list'])// deprecated - ->setDescription('List all installed modules') - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' - ); + ; + + parent::configure(); } /** - * @param InputInterface $input - * @param OutputInterface $output + * {@inheritdoc} + * @return array> * - * @return int + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getData(InputInterface $input, OutputInterface $output): array { - $this->detectMagento($output, true); - - if ($input->getOption('format') === null) { - $this->writeSection($output, 'Magento Modules'); - } - $this->initMagento(); - $modules = $this->filterModules($input); - if (!count($modules)) { - $output->writeln("No modules match the specified criteria."); - return 0; - } - - /* @var TableHelper $table */ - $table = $this->getHelper('table'); - $table - ->setHeaders(['codePool', 'Name', 'Version', 'Status']) - ->renderByFormat($output, iterator_to_array($modules), $input->getOption('format')); - return 0; + return iterator_to_array($modules); } /** diff --git a/src/N98/Magento/Modules.php b/src/N98/Magento/Modules.php index 8c6181af4..73637dd86 100644 --- a/src/N98/Magento/Modules.php +++ b/src/N98/Magento/Modules.php @@ -1,9 +1,6 @@ - */ + +declare(strict_types=1); namespace N98\Magento; @@ -40,7 +37,7 @@ public function __construct(array $list = null) /** * @return Modules */ - public function findInstalledModules() + public function findInstalledModules(): Modules { $list = []; @@ -50,7 +47,12 @@ public function findInstalledModules() $version = $moduleInfo['version'] ?? ''; $active = $moduleInfo['active'] ?? ''; - $list[] = ['codePool' => trim($codePool), 'Name' => trim($moduleName), 'Version' => trim($version), 'Status' => StringTyped::formatActive($active)]; + $list[] = [ + 'codePool' => trim($codePool), + 'Name' => trim($moduleName), + 'Version' => trim($version), + 'Status' => StringTyped::formatActive($active) + ]; } return new Modules($list); @@ -62,7 +64,7 @@ public function findInstalledModules() * @param InputInterface $input * @return Modules */ - public function filterModules(InputInterface $input) + public function filterModules(InputInterface $input): Modules { $filtered = $this->list; From de31d3a2d92890e57b9a0474911c3808c332fbd3 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 10 Jun 2024 08:24:44 +0200 Subject: [PATCH 015/136] [skip ci] Updated sys:website:list command --- .../Magento/Command/System/Website/ListCommand.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/N98/Magento/Command/System/Website/ListCommand.php b/src/N98/Magento/Command/System/Website/ListCommand.php index 7d77630e3..e7ab8f139 100644 --- a/src/N98/Magento/Command/System/Website/ListCommand.php +++ b/src/N98/Magento/Command/System/Website/ListCommand.php @@ -17,11 +17,6 @@ */ class ListCommand extends AbstractMagentoCommand implements AbstractMagentoCommandFormatInterface { - /** - * @var array>|null - */ - private ?array $data = null; - /** * @var string * @deprecated with symfony 6.1 @@ -34,12 +29,13 @@ class ListCommand extends AbstractMagentoCommand implements AbstractMagentoComma * @deprecated with symfony 6.1 * @see AsCommand */ - protected static $defaultDescription = 'Lists all websites'; + protected static $defaultDescription = 'Lists all websites.'; /** - * @param InputInterface $input - * @param OutputInterface $output - * @return array> + * {@inheritdoc} + * @return array> + * + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ public function getData(InputInterface $input, OutputInterface $output): array { From 720eace342d0e2df75868833641aee2fb6cff017 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 10 Jun 2024 08:25:53 +0200 Subject: [PATCH 016/136] [skip ci] Updated sys:store:config:base-url:list command --- .../System/Store/Config/BaseUrlListCommand.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php b/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php index 2112e3cdc..70f2fa95d 100644 --- a/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php +++ b/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php @@ -19,12 +19,7 @@ */ class BaseUrlListCommand extends AbstractMagentoCommand implements AbstractMagentoCommandFormatInterface { - public const COMMAND_SECTION_TITLE_TEXT = 'Stores - Base URLs'; - - /** - * @var array>|null - */ - private ?array $data = null; + protected const COMMAND_SECTION_TITLE_TEXT = 'Stores - Base URLs'; /** * @var string @@ -41,9 +36,10 @@ class BaseUrlListCommand extends AbstractMagentoCommand implements AbstractMagen protected static $defaultDescription = 'Lists all base urls.'; /** - * @param InputInterface $input - * @param OutputInterface $output - * @return array> + * {@inheritdoc} + * @return array> + * + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ public function getData(InputInterface $input, OutputInterface $output): array { From 42bcb2387ec095e8a19149860b456074d9c08558 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 10 Jun 2024 08:26:51 +0200 Subject: [PATCH 017/136] [skip ci] Updated sys:store:list command --- src/N98/Magento/Command/System/Store/ListCommand.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/N98/Magento/Command/System/Store/ListCommand.php b/src/N98/Magento/Command/System/Store/ListCommand.php index e72f47064..70c2754f2 100644 --- a/src/N98/Magento/Command/System/Store/ListCommand.php +++ b/src/N98/Magento/Command/System/Store/ListCommand.php @@ -17,11 +17,6 @@ */ class ListCommand extends AbstractMagentoCommand implements AbstractMagentoCommandFormatInterface { - /** - * @var array>|null - */ - private ?array $data = null; - /** * @var string * @deprecated with symfony 6.1 @@ -37,9 +32,10 @@ class ListCommand extends AbstractMagentoCommand implements AbstractMagentoComma protected static $defaultDescription = 'Lists all installed store-views'; /** - * @param InputInterface $input - * @param OutputInterface $output + * {@inheritdoc} * @return array> + * + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ public function getData(InputInterface $input, OutputInterface $output): array { From 828e3fe93bc7aaf693bd606ee940132c12d624f6 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 10 Jun 2024 08:41:34 +0200 Subject: [PATCH 018/136] [skip ci] Updated index:list command --- .../Magento/Command/Indexer/ListCommand.php | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/N98/Magento/Command/Indexer/ListCommand.php b/src/N98/Magento/Command/Indexer/ListCommand.php index 914de531f..92684831b 100644 --- a/src/N98/Magento/Command/Indexer/ListCommand.php +++ b/src/N98/Magento/Command/Indexer/ListCommand.php @@ -1,57 +1,57 @@ setName('index:list') - ->setDescription('Lists all magento indexes') - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' - ) - ; - - $help = <<setHelp($help); } /** - * @param InputInterface $input - * @param OutputInterface $output + * {@inheritdoc} + * @return array> * - * @return int + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getData(InputInterface $input, OutputInterface $output): array { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + if (is_null($this->data)) { + $this->data = []; - $table = []; - foreach ($this->getIndexerList() as $index) { - $table[] = [$index['code'], $index['status'], $index['last_runtime']]; + foreach ($this->getIndexerList() as $index) { + $this->data[] = [ + 'code' => $index['code'], + 'status' => $index['status'], + 'time' => $index['last_runtime'] + ]; + } } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); - $tableHelper - ->setHeaders(['code', 'status', 'time']) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + return $this->data; } } From 5098a17209880be115cd633a5558f454d2ddcdcf Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 10 Jun 2024 08:51:44 +0200 Subject: [PATCH 019/136] [skip ci] Updated sys:cron:list command --- .../Command/System/Cron/ListCommand.php | 61 +++++++------------ 1 file changed, 22 insertions(+), 39 deletions(-) diff --git a/src/N98/Magento/Command/System/Cron/ListCommand.php b/src/N98/Magento/Command/System/Cron/ListCommand.php index ea41721bb..22f3a4f47 100644 --- a/src/N98/Magento/Command/System/Cron/ListCommand.php +++ b/src/N98/Magento/Command/System/Cron/ListCommand.php @@ -1,57 +1,40 @@ setName('sys:cron:list') - ->setDescription('Lists all cronjobs') - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' - ) - ; - } + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultDescription = 'Lists all cronjobs.'; /** - * @param InputInterface $input - * @param OutputInterface $output + * {@inheritdoc} + * @return array> * - * @return int + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getData(InputInterface $input, OutputInterface $output): array { - $this->detectMagento($output, true); - - if ($input->getOption('format') === null) { - $this->writeSection($output, 'Cronjob List'); - } - - $this->initMagento(); - - $table = $this->getJobs(); - - /** @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); - $tableHelper - ->setHeaders(array_keys(current($table))) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + return $this->getJobs(); } } From ff81aee6c7778bea20c7f7caafa387ab08d1f316 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 10 Jun 2024 09:02:06 +0200 Subject: [PATCH 020/136] [skip ci] Updated dev:theme:list command --- .../Command/Developer/Theme/ListCommand.php | 70 +++++++++---------- 1 file changed, 33 insertions(+), 37 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Theme/ListCommand.php b/src/N98/Magento/Command/Developer/Theme/ListCommand.php index ba4c1d34b..f27887cb5 100644 --- a/src/N98/Magento/Command/Developer/Theme/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Theme/ListCommand.php @@ -1,63 +1,59 @@ setName('dev:theme:list') - ->setDescription('Lists all available themes') - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' - ) - ; - } + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultName = 'dev:theme:list'; /** - * @param InputInterface $input - * @param OutputInterface $output - * @return int + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand */ - protected function execute(InputInterface $input, OutputInterface $output): int + protected static $defaultDescription = 'Lists all available themes.'; + + /** + * {@inheritdoc} + * @return array> + * + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter + */ + public function getData(InputInterface $input, OutputInterface $output): array { - $this->detectMagento($output); - if (!$this->initMagento()) { - return 0; - } + if (is_null($this->data)) { + $this->data = []; - $packages = $this->getThemes(); - $table = []; - foreach ($packages as $package => $themes) { - foreach ($themes as $theme) { - $table[] = [($package ? $package . '/' : '') . $theme]; + foreach ($this->getThemes() as $package => $themes) { + foreach ($themes as $theme) { + $this->data[] = [ + 'Theme' => ($package ? $package . '/' : '') . $theme + ]; + } } } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); - $tableHelper - ->setHeaders(['Theme']) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + return $this->data; } /** * @return array */ - protected function getThemes() + protected function getThemes(): array { return Mage::getModel('core/design_package')->getThemeList(); } From 703ba39ea3f068877db9a5050a5e463f522bd8a2 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 10 Jun 2024 09:16:13 +0200 Subject: [PATCH 021/136] [skip ci] Updated AbstractMagentoCommand.php [WIP] --- .../Command/AbstractMagentoCommand.php | 77 +++++++++++++++++-- 1 file changed, 72 insertions(+), 5 deletions(-) diff --git a/src/N98/Magento/Command/AbstractMagentoCommand.php b/src/N98/Magento/Command/AbstractMagentoCommand.php index 9a4bfd560..9de52a9fd 100644 --- a/src/N98/Magento/Command/AbstractMagentoCommand.php +++ b/src/N98/Magento/Command/AbstractMagentoCommand.php @@ -11,16 +11,20 @@ use Composer\Package\PackageInterface; use InvalidArgumentException; use Mage; +use Mage_Core_Model_App; use N98\Magento\Application; use N98\Magento\Command\SubCommand\ConfigBag; use N98\Magento\Command\SubCommand\SubCommandFactory; use N98\Util\Console\Helper\MagentoHelper; +use N98\Util\Console\Helper\Table\Renderer\RendererFactory; +use N98\Util\Console\Helper\TableHelper; use N98\Util\OperatingSystem; use N98\Util\StringTyped; use RuntimeException; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ChoiceQuestion; use Symfony\Component\Console\Question\Question; @@ -32,31 +36,40 @@ */ abstract class AbstractMagentoCommand extends Command { + protected const COMMAND_SECTION_TITLE_TEXT = ''; + + protected const NO_DATA_MESSAGE = 'No data found'; + /** - * @var string + * @var string|null */ - protected $_magentoRootFolder = null; + protected ?string $_magentoRootFolder = null; /** * @var bool */ - protected $_magentoEnterprise = false; + protected bool $_magentoEnterprise = false; /** * @var array */ - protected $_deprecatedAlias = []; + protected array $_deprecatedAlias = []; /** * @var array */ - protected $_websiteCodeMap = []; + protected array $_websiteCodeMap = []; /** * @var array */ protected $config; + /** + * @var array>|null + */ + protected ?array $data = null; + /** * Initializes the command just after the input has been validated. * @@ -617,4 +630,58 @@ protected function createSubCommandFactory( $configBag ); } + + public function getTableHelper(): TableHelper + { + return $this->getHelper('table'); + } + + protected function configure() + { + if ($this instanceof AbstractMagentoCommandFormatInterface) { + $this->addOption( + 'format', + null, + InputOption::VALUE_OPTIONAL, + 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' + ); + } + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + * + * @return int + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->detectMagento($output); + if (!$this->initMagento()) { + return Command::FAILURE; + } + + if (static::COMMAND_SECTION_TITLE_TEXT && $input->getOption('format') === null) { + $this->writeSection($output, static::COMMAND_SECTION_TITLE_TEXT); + } + + $data = $this->getData($input, $output); + + if (count($data) > 0) { + $header = array_keys(reset($data)); + $tableHelper = $this->getTableHelper(); + $tableHelper + ->setHeaders($header) + ->renderByFormat($output, $data, $input->getOption('format')); + } else { + $output->writeln(sprintf('%s', static::NO_DATA_MESSAGE)); + } + + return Command::SUCCESS; + } + + protected function _getMage(): Mage_Core_Model_App + { + return Mage::app(); + } } From 3e2403ebbba27d9e9a5c4c330f71e61d4f960b65 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 10 Jun 2024 11:42:18 +0200 Subject: [PATCH 022/136] [skip ci] Updated script:repo:list command --- .../Command/Script/Repository/ListCommand.php | 89 +++++++++++-------- 1 file changed, 51 insertions(+), 38 deletions(-) diff --git a/src/N98/Magento/Command/Script/Repository/ListCommand.php b/src/N98/Magento/Command/Script/Repository/ListCommand.php index 014a9ae5f..9b02dd208 100644 --- a/src/N98/Magento/Command/Script/Repository/ListCommand.php +++ b/src/N98/Magento/Command/Script/Repository/ListCommand.php @@ -1,31 +1,37 @@ setName('script:repo:list') - ->setDescription('Lists all scripts in repository') - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' - ) - ; + protected const NO_DATA_MESSAGE = 'No script file found'; + + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultName = 'script:repo:list'; + + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultDescription = 'Lists all scripts in repository.'; - $help = <</.n98-magerun/scripts*. @@ -37,36 +43,43 @@ protected function configure() $ n98-magerun.phar script:repo:list HELP; - $this->setHelp($help); } /** - * @param InputInterface $input - * @param OutputInterface $output + * {@inheritdoc} + * @return array> * - * @return int + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getData(InputInterface $input, OutputInterface $output): array { - $files = $this->getScripts(); - if (count($files) > 0) { - $table = []; - foreach ($files as $file) { - $table[] = [substr($file['fileinfo']->getFilename(), 0, -strlen(self::MAGERUN_EXTENSION)), $file['location'], $file['description']]; + if (is_null($this->data)) { + $this->data = []; + + foreach ($this->getScripts() as $file) { + $this->data[] = [ + 'Script' => substr( + $file['fileinfo']->getFilename(), + 0, + -strlen(self::MAGERUN_EXTENSION) + ), + Location::class => $file['location'], + Description::class => $file['description'] + ]; } - } else { - $table = []; } - if ($input->getOption('format') === null && count($table) === 0) { - $output->writeln('no script file found'); - } + return $this->data; + } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); - $tableHelper - ->setHeaders(['Script', Location::class, Description::class]) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + /** + * Skip initialisation + * + * @param bool $soft + * @return true + */ + public function initMagento(bool $soft = false) + { + return true; } } From 08a2e1145e372de4c2cc5a5dc30516f14b974785 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 10 Jun 2024 13:37:06 +0200 Subject: [PATCH 023/136] [skip ci] Updated sys:cron:history command --- .../Command/System/Cron/HistoryCommand.php | 106 ++++++++++-------- 1 file changed, 57 insertions(+), 49 deletions(-) diff --git a/src/N98/Magento/Command/System/Cron/HistoryCommand.php b/src/N98/Magento/Command/System/Cron/HistoryCommand.php index 675ca47cc..14635a49a 100644 --- a/src/N98/Magento/Command/System/Cron/HistoryCommand.php +++ b/src/N98/Magento/Command/System/Cron/HistoryCommand.php @@ -1,79 +1,87 @@ setName('sys:cron:history') - ->setDescription('Last executed cronjobs with status.') - ->addOption( - 'timezone', - null, - InputOption::VALUE_OPTIONAL, - 'Timezone to show finished at in' - ) - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' - ) - ; + $this->addOption( + 'timezone', + null, + InputOption::VALUE_OPTIONAL, + 'Timezone to show finished at in' + ); + + parent::configure(); } /** - * @param InputInterface $input - * @param OutputInterface $output + * {@inheritdoc} + * @return array> * - * @return int + * @return array + * @throws Mage_Core_Model_Store_Exception + * @throws Mage_Core_Exception */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getData(InputInterface $input, OutputInterface $output): array { - $this->detectMagento($output, true); - - if ($input->getOption('format') === null) { - $this->writeSection($output, 'Last executed jobs'); - } - $this->initMagento(); + if (is_null($this->data)) { + $this->data = []; - $timezone = $input->getOption('timezone') ?: Mage::app()->getStore()->getConfig('general/locale/timezone'); + $timezone = $input->getOption('timezone') + ?: $this->_getMage()->getStore()->getConfig('general/locale/timezone'); - $output->writeln('Times shown in ' . $timezone . ''); + $output->writeln('Times shown in ' . $timezone . ''); - $date = Mage::getSingleton('core/date'); - $offset = $date->calculateOffset($timezone); - $collection = Mage::getModel('cron/schedule')->getCollection(); - $collection - ->addFieldToFilter('status', ['neq' => Mage_Cron_Model_Schedule::STATUS_PENDING]) - ->addOrder('finished_at', Varien_Data_Collection_Db::SORT_ORDER_DESC); + $date = Mage::getSingleton('core/date'); + $offset = $date->calculateOffset($timezone); + $collection = Mage::getModel('cron/schedule')->getCollection(); + $collection + ->addFieldToFilter('status', ['neq' => Mage_Cron_Model_Schedule::STATUS_PENDING]) + ->addOrder('finished_at'); - $table = []; - foreach ($collection as $job) { - $table[] = [$job->getJobCode(), $job->getStatus(), $job->getFinishedAt() ? $date->gmtDate(null, $date->timestamp($job->getFinishedAt()) + $offset) : '']; + foreach ($collection as $job) { + $this->data[] = [ + 'Job' => $job->getJobCode(), + 'Status' => $job->getStatus(), + 'Finished' => $job->getFinishedAt() ? $date->gmtDate( + null, + $date->timestamp($job->getFinishedAt()) + $offset + ) : '' + ]; + } } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); - $tableHelper - ->setHeaders(['Job', 'Status', 'Finished']) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + + return $this->data; } } From d4fbacc84796b32f481a4b5bd73bb7e54464adbb Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 10 Jun 2024 14:32:58 +0200 Subject: [PATCH 024/136] [skip ci] Updated eav:attribute:list command --- .../Command/Eav/Attribute/ListCommand.php | 137 ++++++++++-------- 1 file changed, 75 insertions(+), 62 deletions(-) diff --git a/src/N98/Magento/Command/Eav/Attribute/ListCommand.php b/src/N98/Magento/Command/Eav/Attribute/ListCommand.php index fb01f5363..5119a5d47 100644 --- a/src/N98/Magento/Command/Eav/Attribute/ListCommand.php +++ b/src/N98/Magento/Command/Eav/Attribute/ListCommand.php @@ -1,103 +1,116 @@ setName('eav:attribute:list') - ->setDescription('Lists all EAV attributes') - ->addOption('filter-type', null, InputOption::VALUE_OPTIONAL, 'Filter attributes by entity type') - ->addOption('add-source', null, InputOption::VALUE_NONE, 'Add source models to list') - ->addOption('add-backend', null, InputOption::VALUE_NONE, 'Add backend type to list') ->addOption( - 'format', + self::COMMAND_OPTION_FILTER_TYPE, null, InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' + 'Filter attributes by entity type' + ) + ->addOption( + self::COMMAND_OPTION_ADD_SOURCE, + null, + InputOption::VALUE_NONE, + 'Add source models to list' + ) + ->addOption( + 'add-backend', + null, + InputOption::VALUE_NONE, + 'Add backend type to list' ); + + parent::configure(); } /** - * @param InputInterface $input - * @param OutputInterface $output + * {@inheritdoc} + * @return array> * - * @return int + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getData(InputInterface $input, OutputInterface $output): array { - $this->detectMagento($output); - if (!$this->initMagento()) { - return 0; - } - $table = []; - $attributesCollection = Mage::getResourceModel('eav/entity_attribute_collection'); - $attributesCollection->setOrder('attribute_code', 'asc'); - foreach ($attributesCollection as $attribute) { - $entityType = $this->_getEntityType($attribute); - - /** - * Filter by type - */ - if ($input->getOption('filter-type') !== null - && $input->getOption('filter-type') !== $entityType - ) { - continue; - } + if (is_null($this->data)) { + $this->data = []; - $row = []; - $row[] = $attribute->getAttributeCode(); - $row[] = $attribute->getId(); - $row[] = $entityType; - $row[] = $attribute->getFrontendLabel(); + $attributesCollection = Mage::getResourceModel('eav/entity_attribute_collection'); + $attributesCollection->setOrder('attribute_code', 'asc'); + foreach ($attributesCollection as $attribute) { + $entityType = $this->_getEntityType($attribute); - if ($input->getOption('add-source')) { - $row[] = $attribute->getSourceModel() ?: ''; - } - if ($input->getOption('add-backend')) { - $row[] = $attribute->getBackendType(); - } + /** + * Filter by type + */ + if ($input->getOption(self::COMMAND_OPTION_FILTER_TYPE) !== null + && $input->getOption(self::COMMAND_OPTION_FILTER_TYPE) !== $entityType + ) { + continue; + } - $table[] = $row; - } + $row = []; + $row['code'] = $attribute->getAttributeCode(); + $row['id'] = $attribute->getId(); + $row['entity_type'] = $entityType; + $row['label'] = $attribute->getFrontendLabel(); - $headers = []; - $headers[] = 'code'; - $headers[] = 'id'; - $headers[] = 'entity_type'; - $headers[] = 'label'; - if ($input->getOption('add-source')) { - $headers[] = 'source'; - } - if ($input->getOption('add-backend')) { - $headers[] = 'backend_type'; + if ($input->getOption(self::COMMAND_OPTION_ADD_SOURCE)) { + $row['source'] = $attribute->getSourceModel() ?: ''; + } + if ($input->getOption(self::COMMAND_OPTION_ADD_BACKEND)) { + $row['backend_type'] = $attribute->getBackendType(); + } + + $this->data[] = $row; + } } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); - $tableHelper - ->setHeaders($headers) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + return $this->data; } /** * @param $attribute * @return null|string */ - protected function _getEntityType($attribute) + protected function _getEntityType($attribute): ?string { $entityTypeCode = ''; try { From 065d17c778bb8a4a3246b921a049d5052387de38 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 11 Jun 2024 01:47:24 +0200 Subject: [PATCH 025/136] [skip ci] Updated sys:cron:history command --- src/N98/Magento/Command/System/Cron/HistoryCommand.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/N98/Magento/Command/System/Cron/HistoryCommand.php b/src/N98/Magento/Command/System/Cron/HistoryCommand.php index 14635a49a..ddeb963a8 100644 --- a/src/N98/Magento/Command/System/Cron/HistoryCommand.php +++ b/src/N98/Magento/Command/System/Cron/HistoryCommand.php @@ -19,6 +19,8 @@ class HistoryCommand extends AbstractMagentoCommand implements AbstractMagentoCo { protected const COMMAND_SECTION_TITLE_TEXT = 'Last executed jobs'; + protected const COMMAND_OPTION_TIMEZONE = 'timezone'; + /** * @var string * @deprecated with symfony 6.1 @@ -36,7 +38,7 @@ class HistoryCommand extends AbstractMagentoCommand implements AbstractMagentoCo protected function configure() { $this->addOption( - 'timezone', + self::COMMAND_OPTION_TIMEZONE, null, InputOption::VALUE_OPTIONAL, 'Timezone to show finished at in' @@ -47,9 +49,8 @@ protected function configure() /** * {@inheritdoc} - * @return array> + * @return array * - * @return array * @throws Mage_Core_Model_Store_Exception * @throws Mage_Core_Exception */ @@ -58,7 +59,7 @@ public function getData(InputInterface $input, OutputInterface $output): array if (is_null($this->data)) { $this->data = []; - $timezone = $input->getOption('timezone') + $timezone = $input->getOption(self::COMMAND_OPTION_TIMEZONE) ?: $this->_getMage()->getStore()->getConfig('general/locale/timezone'); $output->writeln('Times shown in ' . $timezone . ''); From 5198d8219dfe43a32bbfb27e334c8ece58cc8d76 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 11 Jun 2024 03:28:37 +0200 Subject: [PATCH 026/136] [skip ci] Added section headers and command constants --- .../Command/Admin/User/ListCommand.php | 2 + .../Command/Cache/AbstractCacheCommand.php | 27 ++++++++++--- src/N98/Magento/Command/Cache/ListCommand.php | 4 +- .../Magento/Command/Cms/Block/ListCommand.php | 4 +- .../Command/Cms/Block/ToggleCommand.php | 16 +++++--- .../Magento/Command/Customer/ListCommand.php | 19 ++++++--- .../Command/Developer/Module/ListCommand.php | 39 +++++++++++++------ .../Command/Developer/Theme/ListCommand.php | 2 + .../Command/Eav/Attribute/ListCommand.php | 10 +++-- .../Magento/Command/Indexer/ListCommand.php | 2 + .../Command/System/Cron/HistoryCommand.php | 2 +- .../Command/System/Cron/ListCommand.php | 2 +- .../Command/System/Store/ListCommand.php | 2 + .../Command/System/Website/ListCommand.php | 2 + src/N98/Magento/Modules.php | 18 +++++---- 15 files changed, 109 insertions(+), 42 deletions(-) diff --git a/src/N98/Magento/Command/Admin/User/ListCommand.php b/src/N98/Magento/Command/Admin/User/ListCommand.php index 041e48016..838351cb1 100644 --- a/src/N98/Magento/Command/Admin/User/ListCommand.php +++ b/src/N98/Magento/Command/Admin/User/ListCommand.php @@ -12,6 +12,8 @@ class ListCommand extends AbstractAdminUserCommand implements AbstractMagentoCommandFormatInterface { + protected const COMMAND_SECTION_TITLE_TEXT = 'Admin users'; + /** * @var string * @deprecated with symfony 6.1 diff --git a/src/N98/Magento/Command/Cache/AbstractCacheCommand.php b/src/N98/Magento/Command/Cache/AbstractCacheCommand.php index bfb38b42f..6eb5a318a 100644 --- a/src/N98/Magento/Command/Cache/AbstractCacheCommand.php +++ b/src/N98/Magento/Command/Cache/AbstractCacheCommand.php @@ -1,31 +1,46 @@ addArgument( + self::COMMAND_ARGUMENT_CODE, + InputArgument::OPTIONAL, + 'Code of cache (Multiple codes operated by comma)' + ); + + parent::configure(); + } + /** * @return Mage_Core_Model_Cache * * @throws RuntimeException */ - protected function _getCacheModel() + protected function _getCacheModel(): Mage_Core_Model_Cache { return Mage::app()->getCacheInstance(); } /** * @param array $codeArgument - * @param bool $status + * @param bool $status */ - protected function saveCacheStatus($codeArgument, $status) + protected function saveCacheStatus(array $codeArgument, bool $status) { $this->validateCacheCodes($codeArgument); @@ -44,7 +59,7 @@ protected function saveCacheStatus($codeArgument, $status) * @param array $codes * @throws InvalidArgumentException */ - protected function validateCacheCodes(array $codes) + protected function validateCacheCodes(array $codes): void { $cacheTypes = $this->_getCacheModel()->getTypes(); foreach ($codes as $cacheCode) { @@ -85,7 +100,7 @@ protected function reinitCache() /** * @return bool */ - protected function _canUseBanCacheFunction() + protected function _canUseBanCacheFunction(): bool { return method_exists('\Mage_Core_Model_App', 'baseInit'); } diff --git a/src/N98/Magento/Command/Cache/ListCommand.php b/src/N98/Magento/Command/Cache/ListCommand.php index b702e6825..74f95c0a7 100644 --- a/src/N98/Magento/Command/Cache/ListCommand.php +++ b/src/N98/Magento/Command/Cache/ListCommand.php @@ -11,6 +11,8 @@ class ListCommand extends AbstractCacheCommand implements AbstractMagentoCommandFormatInterface { + protected const COMMAND_SECTION_TITLE_TEXT = 'Caches'; + /** * @var string * @deprecated with symfony 6.1 @@ -23,7 +25,7 @@ class ListCommand extends AbstractCacheCommand implements AbstractMagentoCommand * @deprecated with symfony 6.1 * @see AsCommand */ - protected static $defaultDescription = 'Lists all magento caches.'; + protected static $defaultDescription = 'Lists all caches.'; /** * {@inheritdoc} diff --git a/src/N98/Magento/Command/Cms/Block/ListCommand.php b/src/N98/Magento/Command/Cms/Block/ListCommand.php index e537d7243..d90581a8c 100644 --- a/src/N98/Magento/Command/Cms/Block/ListCommand.php +++ b/src/N98/Magento/Command/Cms/Block/ListCommand.php @@ -18,6 +18,8 @@ */ class ListCommand extends AbstractCmsBlockCommand implements AbstractMagentoCommandFormatInterface { + protected const COMMAND_SECTION_TITLE_TEXT = 'CMS blocks'; + /** * @var string * @deprecated with symfony 6.1 @@ -30,7 +32,7 @@ class ListCommand extends AbstractCmsBlockCommand implements AbstractMagentoComm * @deprecated with symfony 6.1 * @see AsCommand */ - protected static $defaultDescription = 'List all cms blocks.'; + protected static $defaultDescription = 'List all CMS blocks.'; /** * {@inheritdoc} diff --git a/src/N98/Magento/Command/Cms/Block/ToggleCommand.php b/src/N98/Magento/Command/Cms/Block/ToggleCommand.php index 0ea4ba111..43d00c2f9 100644 --- a/src/N98/Magento/Command/Cms/Block/ToggleCommand.php +++ b/src/N98/Magento/Command/Cms/Block/ToggleCommand.php @@ -18,7 +18,9 @@ */ class ToggleCommand extends AbstractCmsBlockCommand { - private const COMMAND_ARGUMENT_BLOCK_ID = 'block_id'; + protected const COMMAND_SECTION_TITLE_TEXT = 'Enable/disable CMS block'; + + protected const COMMAND_ARGUMENT_BLOCK_ID = 'block_id'; /** * @var string @@ -32,7 +34,7 @@ class ToggleCommand extends AbstractCmsBlockCommand * @deprecated with symfony 6.1 * @see AsCommand */ - protected static $defaultDescription = 'Toggle a cms block.'; + protected static $defaultDescription = 'Toggle a CMS block.'; /** * @return void @@ -54,10 +56,14 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output): int { + $this->writeSection($output, static::COMMAND_SECTION_TITLE_TEXT); + $this->detectMagento($output); - $this->initMagento(); + if (!$this->initMagento()) { + return Command::FAILURE; + } - $blockId = $this->getArgumentString($input, self::COMMAND_ARGUMENT_BLOCK_ID); + $blockId = $input->getArgument(self::COMMAND_ARGUMENT_BLOCK_ID); $block = $this->_getBlockModel()->load($blockId, is_numeric($blockId) ? null : 'identifier'); if (!$block->getId()) { @@ -66,7 +72,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $block - ->setIsActive(!$block->getIsActive()) + ->setIsActive((int)!$block->getIsActive()) ->save(); $output->writeln(sprintf( diff --git a/src/N98/Magento/Command/Customer/ListCommand.php b/src/N98/Magento/Command/Customer/ListCommand.php index cae861c41..0ab3c9c4f 100644 --- a/src/N98/Magento/Command/Customer/ListCommand.php +++ b/src/N98/Magento/Command/Customer/ListCommand.php @@ -13,6 +13,10 @@ class ListCommand extends AbstractCustomerCommand implements AbstractMagentoCommandFormatInterface { + protected const COMMAND_SECTION_TITLE_TEXT = 'Customers'; + + public const COMMAND_ARGUMENT_SEARCH = 'search'; + protected const NO_DATA_MESSAGE = 'No customers found'; /** @@ -31,7 +35,11 @@ class ListCommand extends AbstractCustomerCommand implements AbstractMagentoComm protected function configure() { - $this->addArgument('search', InputArgument::OPTIONAL, 'Search query'); + $this->addArgument( + self::COMMAND_ARGUMENT_SEARCH, + InputArgument::OPTIONAL, + 'Search query' + ); parent::configure(); } @@ -61,12 +69,13 @@ public function getData(InputInterface $input, OutputInterface $output): array $collection = $this->getCustomerCollection(); $collection->addAttributeToSelect(['entity_id', 'email', 'firstname', 'lastname', 'website_id']); - if ($input->getArgument('search')) { + $search = $input->getArgument(self::COMMAND_ARGUMENT_SEARCH); + if ($search) { $collection->addAttributeToFilter( [ - ['attribute' => 'email', 'like' => '%' . $input->getArgument('search') . '%'], - ['attribute' => 'firstname', 'like' => '%' . $input->getArgument('search') . '%'], - ['attribute' => 'lastname', 'like' => '%' . $input->getArgument('search') . '%'] + ['attribute' => 'email', 'like' => '%' . $search . '%'], + ['attribute' => 'firstname', 'like' => '%' . $search . '%'], + ['attribute' => 'lastname', 'like' => '%' . $search . '%'] ] ); } diff --git a/src/N98/Magento/Command/Developer/Module/ListCommand.php b/src/N98/Magento/Command/Developer/Module/ListCommand.php index 2fbb53974..0cfe1cc7f 100644 --- a/src/N98/Magento/Command/Developer/Module/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Module/ListCommand.php @@ -16,6 +16,12 @@ class ListCommand extends AbstractMagentoCommand implements AbstractMagentoComma { protected const COMMAND_SECTION_TITLE_TEXT = 'Installed Modules'; + public const COMMAND_OPTION_COODPOOL = 'codepool'; + + public const COMMAND_OPTION_STATUS = 'status'; + + public const COMMAND_OPTION_VENDOR = 'vendor'; + protected const NO_DATA_MESSAGE = 'No modules match the specified criteria.'; /** @@ -35,11 +41,25 @@ class ListCommand extends AbstractMagentoCommand implements AbstractMagentoComma protected function configure() { $this - ->addOption('codepool', null, InputOption::VALUE_OPTIONAL, 'Show modules in a specific codepool') - ->addOption('status', null, InputOption::VALUE_OPTIONAL, 'Show modules with a specific status') - ->addOption('vendor', null, InputOption::VALUE_OPTIONAL, 'Show modules of a specified vendor') - ->setAliases(['sys:modules:list'])// deprecated - ; + ->addOption( + self::COMMAND_OPTION_COODPOOL, + null, + InputOption::VALUE_OPTIONAL, + 'Show modules in a specific codepool' + ) + ->addOption( + self::COMMAND_OPTION_STATUS, + null, + InputOption::VALUE_OPTIONAL, + 'Show modules with a specific status' + ) + ->addOption( + self::COMMAND_OPTION_VENDOR, + null, + InputOption::VALUE_OPTIONAL, + 'Show modules of a specified vendor' + ) + ->setAliases(['sys:modules:list']); // deprecated parent::configure(); } @@ -52,9 +72,7 @@ protected function configure() */ public function getData(InputInterface $input, OutputInterface $output): array { - $modules = $this->filterModules($input); - - return iterator_to_array($modules); + return iterator_to_array($this->filterModules($input)); } /** @@ -65,9 +83,8 @@ public function getData(InputInterface $input, OutputInterface $output): array private function filterModules(InputInterface $input) { $modules = new Modules(); - $modules = $modules->findInstalledModules() + return $modules + ->findInstalledModules() ->filterModules($input); - - return $modules; } } diff --git a/src/N98/Magento/Command/Developer/Theme/ListCommand.php b/src/N98/Magento/Command/Developer/Theme/ListCommand.php index f27887cb5..df324dc7c 100644 --- a/src/N98/Magento/Command/Developer/Theme/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Theme/ListCommand.php @@ -13,6 +13,8 @@ class ListCommand extends AbstractMagentoCommand implements AbstractMagentoCommandFormatInterface { + protected const COMMAND_SECTION_TITLE_TEXT = 'Themes'; + /** * @var string * @deprecated with symfony 6.1 diff --git a/src/N98/Magento/Command/Eav/Attribute/ListCommand.php b/src/N98/Magento/Command/Eav/Attribute/ListCommand.php index 5119a5d47..28446804e 100644 --- a/src/N98/Magento/Command/Eav/Attribute/ListCommand.php +++ b/src/N98/Magento/Command/Eav/Attribute/ListCommand.php @@ -16,11 +16,13 @@ class ListCommand extends AbstractMagentoCommand implements AbstractMagentoCommandFormatInterface { - protected const COMMAND_OPTION_FILTER_TYPE = 'filter-type'; + protected const COMMAND_SECTION_TITLE_TEXT = 'EAV attributes'; - protected const COMMAND_OPTION_ADD_SOURCE = 'add-source'; + public const COMMAND_OPTION_FILTER_TYPE = 'filter-type'; - protected const COMMAND_OPTION_ADD_BACKEND = 'add-backend'; + public const COMMAND_OPTION_ADD_SOURCE = 'add-source'; + + public const COMMAND_OPTION_ADD_BACKEND = 'add-backend'; /** * @var string @@ -52,7 +54,7 @@ protected function configure() 'Add source models to list' ) ->addOption( - 'add-backend', + self::COMMAND_OPTION_ADD_BACKEND, null, InputOption::VALUE_NONE, 'Add backend type to list' diff --git a/src/N98/Magento/Command/Indexer/ListCommand.php b/src/N98/Magento/Command/Indexer/ListCommand.php index 92684831b..f8dc38069 100644 --- a/src/N98/Magento/Command/Indexer/ListCommand.php +++ b/src/N98/Magento/Command/Indexer/ListCommand.php @@ -11,6 +11,8 @@ class ListCommand extends AbstractIndexerCommand implements AbstractMagentoCommandFormatInterface { + protected const COMMAND_SECTION_TITLE_TEXT = 'Indexes'; + /** * @var string * @deprecated with symfony 6.1 diff --git a/src/N98/Magento/Command/System/Cron/HistoryCommand.php b/src/N98/Magento/Command/System/Cron/HistoryCommand.php index ddeb963a8..4ebf590ac 100644 --- a/src/N98/Magento/Command/System/Cron/HistoryCommand.php +++ b/src/N98/Magento/Command/System/Cron/HistoryCommand.php @@ -19,7 +19,7 @@ class HistoryCommand extends AbstractMagentoCommand implements AbstractMagentoCo { protected const COMMAND_SECTION_TITLE_TEXT = 'Last executed jobs'; - protected const COMMAND_OPTION_TIMEZONE = 'timezone'; + public const COMMAND_OPTION_TIMEZONE = 'timezone'; /** * @var string diff --git a/src/N98/Magento/Command/System/Cron/ListCommand.php b/src/N98/Magento/Command/System/Cron/ListCommand.php index 22f3a4f47..30001dfe8 100644 --- a/src/N98/Magento/Command/System/Cron/ListCommand.php +++ b/src/N98/Magento/Command/System/Cron/ListCommand.php @@ -11,7 +11,7 @@ class ListCommand extends AbstractCronCommand implements AbstractMagentoCommandFormatInterface { - protected const COMMAND_SECTION_TITLE_TEXT = 'Cronjob List'; + protected const COMMAND_SECTION_TITLE_TEXT = 'Cronjobs'; /** * @var string diff --git a/src/N98/Magento/Command/System/Store/ListCommand.php b/src/N98/Magento/Command/System/Store/ListCommand.php index 70c2754f2..465d78a3d 100644 --- a/src/N98/Magento/Command/System/Store/ListCommand.php +++ b/src/N98/Magento/Command/System/Store/ListCommand.php @@ -17,6 +17,8 @@ */ class ListCommand extends AbstractMagentoCommand implements AbstractMagentoCommandFormatInterface { + protected const COMMAND_SECTION_TITLE_TEXT = 'Stores'; + /** * @var string * @deprecated with symfony 6.1 diff --git a/src/N98/Magento/Command/System/Website/ListCommand.php b/src/N98/Magento/Command/System/Website/ListCommand.php index e7ab8f139..94ae59bd0 100644 --- a/src/N98/Magento/Command/System/Website/ListCommand.php +++ b/src/N98/Magento/Command/System/Website/ListCommand.php @@ -17,6 +17,8 @@ */ class ListCommand extends AbstractMagentoCommand implements AbstractMagentoCommandFormatInterface { + protected const COMMAND_SECTION_TITLE_TEXT = 'Websites'; + /** * @var string * @deprecated with symfony 6.1 diff --git a/src/N98/Magento/Modules.php b/src/N98/Magento/Modules.php index 73637dd86..5b41b4430 100644 --- a/src/N98/Magento/Modules.php +++ b/src/N98/Magento/Modules.php @@ -8,6 +8,7 @@ use Countable; use IteratorAggregate; use Mage; +use N98\Magento\Command\Developer\Module\ListCommand; use N98\Util\ArrayFunctions; use N98\Util\StringTyped; use Symfony\Component\Console\Input\InputInterface; @@ -23,7 +24,7 @@ class Modules implements IteratorAggregate, Countable /** * @var array */ - private $list; + private array $list; public function __construct(array $list = null) { @@ -68,16 +69,19 @@ public function filterModules(InputInterface $input): Modules { $filtered = $this->list; - if ($input->getOption('codepool')) { - $filtered = ArrayFunctions::matrixFilterByValue($filtered, 'codePool', $input->getOption('codepool')); + $codepool = $input->getOption(ListCommand::COMMAND_OPTION_COODPOOL); + if ($codepool) { + $filtered = ArrayFunctions::matrixFilterByValue($filtered, 'codePool', $codepool); } - if ($input->getOption('status')) { - $filtered = ArrayFunctions::matrixFilterByValue($filtered, 'Status', $input->getOption('status')); + $status = $input->getOption(ListCommand::COMMAND_OPTION_STATUS); + if ($status) { + $filtered = ArrayFunctions::matrixFilterByValue($filtered, 'Status', $status); } - if ($input->getOption('vendor')) { - $filtered = ArrayFunctions::matrixFilterStartswith($filtered, 'Name', $input->getOption('vendor')); + $vendor = $input->getOption(ListCommand::COMMAND_OPTION_VENDOR); + if ($vendor) { + $filtered = ArrayFunctions::matrixFilterStartswith($filtered, 'Name', $vendor); } return new self($filtered); From 595cd1738dd51ad9bc12f0c45d04bfa2c3ce017c Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 11 Jun 2024 05:46:11 +0200 Subject: [PATCH 027/136] [skip ci] Updated dev:template-hints command --- .../Developer/TemplateHintsCommand.php | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/N98/Magento/Command/Developer/TemplateHintsCommand.php b/src/N98/Magento/Command/Developer/TemplateHintsCommand.php index 00b10c102..91a321399 100644 --- a/src/N98/Magento/Command/Developer/TemplateHintsCommand.php +++ b/src/N98/Magento/Command/Developer/TemplateHintsCommand.php @@ -1,51 +1,63 @@ detectAskAndSetDeveloperIp($store, $disabled); } From 6a9896563d46926785b7fe256530d2cb410530d2 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 11 Jun 2024 05:47:15 +0200 Subject: [PATCH 028/136] [skip ci] Updated dev:template-hints-blocks command --- .../Developer/TemplateHintsBlocksCommand.php | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/N98/Magento/Command/Developer/TemplateHintsBlocksCommand.php b/src/N98/Magento/Command/Developer/TemplateHintsBlocksCommand.php index f1dd11fd4..c1dff3910 100644 --- a/src/N98/Magento/Command/Developer/TemplateHintsBlocksCommand.php +++ b/src/N98/Magento/Command/Developer/TemplateHintsBlocksCommand.php @@ -1,51 +1,63 @@ detectAskAndSetDeveloperIp($store, $disabled); } From 605eeff008fe1f0133869fe301a849fafb516b30 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 11 Jun 2024 05:48:12 +0200 Subject: [PATCH 029/136] [skip ci] Updated dev:symlinks command --- .../Command/Developer/SymlinksCommand.php | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/N98/Magento/Command/Developer/SymlinksCommand.php b/src/N98/Magento/Command/Developer/SymlinksCommand.php index 003c2ba31..48fb22a3f 100644 --- a/src/N98/Magento/Command/Developer/SymlinksCommand.php +++ b/src/N98/Magento/Command/Developer/SymlinksCommand.php @@ -1,50 +1,62 @@ Date: Tue, 11 Jun 2024 05:48:50 +0200 Subject: [PATCH 030/136] [skip ci] Updated dev:profiler command --- .../Command/Developer/ProfilerCommand.php | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/N98/Magento/Command/Developer/ProfilerCommand.php b/src/N98/Magento/Command/Developer/ProfilerCommand.php index 4e34caa71..1342af86e 100644 --- a/src/N98/Magento/Command/Developer/ProfilerCommand.php +++ b/src/N98/Magento/Command/Developer/ProfilerCommand.php @@ -1,33 +1,45 @@ Date: Tue, 11 Jun 2024 05:51:17 +0200 Subject: [PATCH 031/136] [skip ci] Updated dev:merge-js command --- .../Command/Developer/MergeJsCommand.php | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/N98/Magento/Command/Developer/MergeJsCommand.php b/src/N98/Magento/Command/Developer/MergeJsCommand.php index 8e7004aca..0548073fc 100644 --- a/src/N98/Magento/Command/Developer/MergeJsCommand.php +++ b/src/N98/Magento/Command/Developer/MergeJsCommand.php @@ -1,33 +1,45 @@ Date: Tue, 11 Jun 2024 05:52:05 +0200 Subject: [PATCH 032/136] [skip ci] Updated dev:merge-css command --- .../Command/Developer/MergeCssCommand.php | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/N98/Magento/Command/Developer/MergeCssCommand.php b/src/N98/Magento/Command/Developer/MergeCssCommand.php index fbc36b936..f35ca1ff2 100644 --- a/src/N98/Magento/Command/Developer/MergeCssCommand.php +++ b/src/N98/Magento/Command/Developer/MergeCssCommand.php @@ -1,33 +1,45 @@ Date: Tue, 11 Jun 2024 05:54:25 +0200 Subject: [PATCH 033/136] [skip ci] Updated dev:translate:shop command --- .../Developer/Translate/InlineShopCommand.php | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Translate/InlineShopCommand.php b/src/N98/Magento/Command/Developer/Translate/InlineShopCommand.php index 13bbe6805..85f170fd1 100644 --- a/src/N98/Magento/Command/Developer/Translate/InlineShopCommand.php +++ b/src/N98/Magento/Command/Developer/Translate/InlineShopCommand.php @@ -1,39 +1,51 @@ detectAskAndSetDeveloperIp($store, $disabled); } From e625c84c5954423eba013d5c4fa024cd99ccdf07 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 11 Jun 2024 05:55:23 +0200 Subject: [PATCH 034/136] [skip ci] Updated dev:translate:admin command --- .../Translate/InlineAdminCommand.php | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Translate/InlineAdminCommand.php b/src/N98/Magento/Command/Developer/Translate/InlineAdminCommand.php index 9d10c2292..c0a8a85fb 100644 --- a/src/N98/Magento/Command/Developer/Translate/InlineAdminCommand.php +++ b/src/N98/Magento/Command/Developer/Translate/InlineAdminCommand.php @@ -1,44 +1,56 @@ detectAskAndSetDeveloperIp($store, $disabled); } From 358e00ec263e09e7c0165e654a66b38356c334ba Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 11 Jun 2024 05:57:20 +0200 Subject: [PATCH 035/136] [skip ci] Updated dev:log command --- .../Command/Developer/Log/LogCommand.php | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Log/LogCommand.php b/src/N98/Magento/Command/Developer/Log/LogCommand.php index 82b939f9d..232df91fa 100644 --- a/src/N98/Magento/Command/Developer/Log/LogCommand.php +++ b/src/N98/Magento/Command/Developer/Log/LogCommand.php @@ -1,33 +1,45 @@ Date: Tue, 11 Jun 2024 05:58:46 +0200 Subject: [PATCH 036/136] [skip ci] Updated design:demo-notice command --- .../Command/Design/DemoNoticeCommand.php | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/N98/Magento/Command/Design/DemoNoticeCommand.php b/src/N98/Magento/Command/Design/DemoNoticeCommand.php index 9ebfc4f13..fcbfa4037 100644 --- a/src/N98/Magento/Command/Design/DemoNoticeCommand.php +++ b/src/N98/Magento/Command/Design/DemoNoticeCommand.php @@ -1,30 +1,42 @@ Date: Tue, 11 Jun 2024 06:00:05 +0200 Subject: [PATCH 037/136] [skip ci] Updated cms:block:toggle command --- src/N98/Magento/Command/Cms/Block/ToggleCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/N98/Magento/Command/Cms/Block/ToggleCommand.php b/src/N98/Magento/Command/Cms/Block/ToggleCommand.php index 43d00c2f9..5969e32ae 100644 --- a/src/N98/Magento/Command/Cms/Block/ToggleCommand.php +++ b/src/N98/Magento/Command/Cms/Block/ToggleCommand.php @@ -20,7 +20,7 @@ class ToggleCommand extends AbstractCmsBlockCommand { protected const COMMAND_SECTION_TITLE_TEXT = 'Enable/disable CMS block'; - protected const COMMAND_ARGUMENT_BLOCK_ID = 'block_id'; + public const COMMAND_ARGUMENT_BLOCK_ID = 'block_id'; /** * @var string From be961c4efb007c30e3cad7cf9bdfd28307e4e7fe Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 11 Jun 2024 06:02:25 +0200 Subject: [PATCH 038/136] [skip ci] Updated admin:notifications command --- .../Admin/DisableNotificationsCommand.php | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/N98/Magento/Command/Admin/DisableNotificationsCommand.php b/src/N98/Magento/Command/Admin/DisableNotificationsCommand.php index 87f4087b7..108a7b456 100644 --- a/src/N98/Magento/Command/Admin/DisableNotificationsCommand.php +++ b/src/N98/Magento/Command/Admin/DisableNotificationsCommand.php @@ -1,43 +1,55 @@ Date: Tue, 11 Jun 2024 08:26:29 +0200 Subject: [PATCH 039/136] [skip ci] Updated cache:view command --- src/N98/Magento/Command/Cache/ViewCommand.php | 62 +++++++++++++++---- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/src/N98/Magento/Command/Cache/ViewCommand.php b/src/N98/Magento/Command/Cache/ViewCommand.php index 8c2c26a9a..55d455eaa 100644 --- a/src/N98/Magento/Command/Cache/ViewCommand.php +++ b/src/N98/Magento/Command/Cache/ViewCommand.php @@ -1,26 +1,63 @@ setName('cache:view') - ->addArgument('id', InputArgument::REQUIRED, 'Cache-ID') - ->addOption('unserialize', '', InputOption::VALUE_NONE, 'Unserialize output') - ->setDescription('Prints a cache entry') + ->addArgument( + self::COMMAND_ARGUMENT_ID, + InputArgument::REQUIRED, + 'Cache-ID' + ) ->addOption( - 'fpc', + self::COMMAND_OPTION_UNSERIALZE, + null, + InputOption::VALUE_NONE, + 'Unserialize output' + ) + ->addOption( + self::COMMAND_OPTION_FPC, null, InputOption::VALUE_NONE, 'Use full page cache instead of core cache (Enterprise only!)' @@ -35,12 +72,12 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output, true); + $this->detectMagento($output); if (!$this->initMagento()) { - return 0; + return Command::FAILURE; } - if ($input->hasOption('fpc') && $input->getOption('fpc')) { + if ($input->hasOption(self::COMMAND_OPTION_FPC) && $input->getOption(self::COMMAND_OPTION_FPC)) { if (!class_exists('\Enterprise_PageCache_Model_Cache')) { throw new RuntimeException('Enterprise page cache not found'); } @@ -48,14 +85,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int } else { $cacheInstance = Mage::app()->getCache(); } - /* @var \Varien_Cache_Core $cacheInstance */ - $cacheData = $cacheInstance->load($input->getArgument('id')); - if ($input->getOption('unserialize')) { + /** @var Varien_Cache_Core $cacheInstance */ + $cacheData = $cacheInstance->load($input->getArgument(self::COMMAND_ARGUMENT_ID)); + if ($input->getOption(self::COMMAND_OPTION_UNSERIALZE)) { $cacheData = unserialize($cacheData); $cacheData = print_r($cacheData, true); } $output->writeln($cacheData); - return 0; + + return Command::SUCCESS; } } From 0e3cfb71c3b66a78a8d0a522457729bd91c060e8 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 11 Jun 2024 08:34:34 +0200 Subject: [PATCH 040/136] [skip ci] Updated cache:view command --- .../Command/Admin/User/ListCommand.php | 2 +- .../Command/Cache/AbstractCacheCommand.php | 41 +++++++++++++++---- src/N98/Magento/Command/Cache/ViewCommand.php | 20 ++------- 3 files changed, 37 insertions(+), 26 deletions(-) diff --git a/src/N98/Magento/Command/Admin/User/ListCommand.php b/src/N98/Magento/Command/Admin/User/ListCommand.php index 838351cb1..4b6b6bdf0 100644 --- a/src/N98/Magento/Command/Admin/User/ListCommand.php +++ b/src/N98/Magento/Command/Admin/User/ListCommand.php @@ -32,7 +32,7 @@ class ListCommand extends AbstractAdminUserCommand implements AbstractMagentoCom * {@inheritdoc} * @return array> * - * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ public function getData(InputInterface $input, OutputInterface $output): array { diff --git a/src/N98/Magento/Command/Cache/AbstractCacheCommand.php b/src/N98/Magento/Command/Cache/AbstractCacheCommand.php index 6eb5a318a..d3656357f 100644 --- a/src/N98/Magento/Command/Cache/AbstractCacheCommand.php +++ b/src/N98/Magento/Command/Cache/AbstractCacheCommand.php @@ -4,16 +4,25 @@ namespace N98\Magento\Command\Cache; +use Enterprise_PageCache_Model_Cache; use InvalidArgumentException; -use Mage; use Mage_Core_Model_Cache; use N98\Magento\Command\AbstractMagentoCommand; use RuntimeException; use Symfony\Component\Console\Input\InputArgument; - +use Symfony\Component\Console\Input\InputInterface; +use Zend_Cache_Core; + +/** + * Abstract cache command + * + * @package N98\Magento\Command\Cache + */ class AbstractCacheCommand extends AbstractMagentoCommand { - protected const COMMAND_ARGUMENT_CODE = 'code'; + public const COMMAND_ARGUMENT_CODE = 'code'; + + public const COMMAND_OPTION_FPC = 'fpc'; protected function configure() { @@ -33,7 +42,23 @@ protected function configure() */ protected function _getCacheModel(): Mage_Core_Model_Cache { - return Mage::app()->getCacheInstance(); + return $this->_getMage()->getCacheInstance(); + } + + /** + * @param InputInterface $input + * @return Zend_Cache_Core + */ + protected function getCacheInstance(InputInterface $input): Zend_Cache_Core + { + if ($input->hasOption(static::COMMAND_OPTION_FPC) && $input->getOption(static::COMMAND_OPTION_FPC)) { + if (!class_exists('\Enterprise_PageCache_Model_Cache')) { + throw new RuntimeException('Enterprise page cache not found'); + } + return Enterprise_PageCache_Model_Cache::getCacheInstance()->getFrontend(); + } + + return $this->_getMage()->getCache(); } /** @@ -45,14 +70,14 @@ protected function saveCacheStatus(array $codeArgument, bool $status) $this->validateCacheCodes($codeArgument); $cacheTypes = $this->_getCacheModel()->getTypes(); - $enable = Mage::app()->useCache(); + $enable = $this->_getMage()->useCache(); foreach ($cacheTypes as $cacheCode => $cacheModel) { if (empty($codeArgument) || in_array($cacheCode, $codeArgument)) { $enable[$cacheCode] = $status ? 1 : 0; } } - Mage::app()->saveUseCache($enable); + $this->_getMage()->saveUseCache($enable); } /** @@ -93,8 +118,8 @@ protected function reinitCache() return; } - Mage::getConfig()->getOptions()->setData('global_ban_use_cache', false); - Mage::getConfig()->reinit(); + $this->_getMage()->getConfig()->getOptions()->setData('global_ban_use_cache', false); + $this->_getMage()->getConfig()->reinit(); } /** diff --git a/src/N98/Magento/Command/Cache/ViewCommand.php b/src/N98/Magento/Command/Cache/ViewCommand.php index 55d455eaa..03e86ea07 100644 --- a/src/N98/Magento/Command/Cache/ViewCommand.php +++ b/src/N98/Magento/Command/Cache/ViewCommand.php @@ -4,16 +4,12 @@ namespace N98\Magento\Command\Cache; -use Enterprise_PageCache_Model_Cache; -use Mage; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Attribute\AsCommand; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Validator\Exception\RuntimeException; -use Varien_Cache_Core; /** * View cache command @@ -24,9 +20,7 @@ class ViewCommand extends AbstractCacheCommand { public const COMMAND_ARGUMENT_ID = 'id'; - public const COMMAND_OPTION_UNSERIALZE = 'id'; - - public const COMMAND_OPTION_FPC = 'id'; + public const COMMAND_OPTION_UNSERIALZE = 'unserialize'; /** * @var string @@ -77,15 +71,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int return Command::FAILURE; } - if ($input->hasOption(self::COMMAND_OPTION_FPC) && $input->getOption(self::COMMAND_OPTION_FPC)) { - if (!class_exists('\Enterprise_PageCache_Model_Cache')) { - throw new RuntimeException('Enterprise page cache not found'); - } - $cacheInstance = Enterprise_PageCache_Model_Cache::getCacheInstance()->getFrontend(); - } else { - $cacheInstance = Mage::app()->getCache(); - } - /** @var Varien_Cache_Core $cacheInstance */ + $cacheInstance = $this->getCacheInstance($input); $cacheData = $cacheInstance->load($input->getArgument(self::COMMAND_ARGUMENT_ID)); if ($input->getOption(self::COMMAND_OPTION_UNSERIALZE)) { $cacheData = unserialize($cacheData); From 6604b8b8adc0ada97a274dd0ebd48e4d252c990a Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 11 Jun 2024 09:20:56 +0200 Subject: [PATCH 041/136] [skip ci] Updated cache:report command --- .../Magento/Command/Cache/ReportCommand.php | 168 ++++++++++-------- 1 file changed, 98 insertions(+), 70 deletions(-) diff --git a/src/N98/Magento/Command/Cache/ReportCommand.php b/src/N98/Magento/Command/Cache/ReportCommand.php index faa0f3795..156d42841 100644 --- a/src/N98/Magento/Command/Cache/ReportCommand.php +++ b/src/N98/Magento/Command/Cache/ReportCommand.php @@ -1,109 +1,137 @@ setName('cache:report') - ->setDescription('View inside the cache') - ->addOption('tags', 't', InputOption::VALUE_NONE, 'Output tags') - ->addOption('mtime', 'm', InputOption::VALUE_NONE, 'Output last modification time') - ->addOption('filter-id', '', InputOption::VALUE_OPTIONAL, 'Filter output by ID (substring)') ->addOption( - 'filter-tag', + self::COMMAND_OPTION_TAGS, + 't', InputOption::VALUE_NONE, + 'Output tags' + ) + ->addOption( + self::COMMAND_OPTION_MTIME, + 'm', + InputOption::VALUE_NONE, + 'Output last modification time' + ) + ->addOption( + self::COMMAND_OPTION_FILTER_ID, '', InputOption::VALUE_OPTIONAL, - 'Filter output by TAG (seperate multiple tags by comma)' + 'Filter output by ID (substring)' ) ->addOption( - 'fpc', - null, - InputOption::VALUE_NONE, - 'Use full page cache instead of core cache (Enterprise only!)' + self::COMMAND_OPTION_FILTER_TAG, + '', + InputOption::VALUE_OPTIONAL, + 'Filter output by TAG (separate multiple tags by comma)' ) ->addOption( - 'format', + self::COMMAND_OPTION_FPC, null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' + InputOption::VALUE_NONE, + 'Use full page cache instead of core cache (Enterprise only!)' ) ; + + parent::configure(); } - protected function isTagFiltered($metaData, $input) + /** + * @param array $metaData + * @param InputInterface $input + * @return bool + */ + protected function isTagFiltered(array $metaData, InputInterface $input): bool { - return (bool) count(array_intersect($metaData['tags'], explode(',', $input->getOption('filter-tag')))); + return (bool) count(array_intersect( + $metaData['tags'], explode(',', $input->getOption(self::COMMAND_OPTION_FILTER_TAG))) + ); } /** - * @param InputInterface $input - * @param OutputInterface $output - * @return int + * {@inheritdoc} + * @return array> + * + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getData(InputInterface $input, OutputInterface $output): array { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + if (is_null($this->data)) { + $this->data = []; - if ($input->hasOption('fpc') && $input->getOption('fpc')) { - if (!class_exists('\Enterprise_PageCache_Model_Cache')) { - throw new RuntimeException('Enterprise page cache not found'); - } - $cacheInstance = Enterprise_PageCache_Model_Cache::getCacheInstance()->getFrontend(); - } else { - $cacheInstance = Mage::app()->getCache(); - } - /* @var \Varien_Cache_Core $cacheInstance */ - $cacheIds = $cacheInstance->getIds(); - $table = []; - foreach ($cacheIds as $cacheId) { - if ($input->getOption('filter-id') !== null && !stristr($cacheId, (string) $input->getOption('filter-id'))) { - continue; - } + $filterId = $input->getOption(self::COMMAND_OPTION_FILTER_ID); + $cacheInstance = $this->getCacheInstance($input); + foreach ($cacheInstance->getIds() as $cacheId) { + if ($filterId !== null && !stristr($cacheId, (string) $filterId)) { + continue; + } - $metaData = $cacheInstance->getMetadatas($cacheId); - if ($input->getOption('filter-tag') !== null && !$this->isTagFiltered($metaData, $input)) { - continue; - } + $metaData = $cacheInstance->getMetadatas($cacheId); + if ($input->getOption(self::COMMAND_OPTION_FILTER_TAG) !== null + && !$this->isTagFiltered($metaData, $input) + ) { + continue; + } - $row = [$cacheId, date('Y-m-d H:i:s', $metaData['expire'])]; - if ($input->getOption('mtime')) { - $row[] = date('Y-m-d H:i:s', $metaData['mtime']); - } - if ($input->getOption('tags')) { - $row[] = implode(',', $metaData['tags']); - } + $row = [ + 'ID' => $cacheId, + 'EXPIRE' => date(self::DATE_FORMAT, $metaData['expire']) + ]; - $table[] = $row; - } + if ($input->getOption(self::COMMAND_OPTION_MTIME)) { + $row['MTIME'] = date(self::DATE_FORMAT, $metaData['mtime']); + } - $headers = ['ID', 'EXPIRE']; - if ($input->getOption('mtime')) { - $headers[] = 'MTIME'; - } - if ($input->getOption('tags')) { - $headers[] = 'TAGS'; + if ($input->getOption(self::COMMAND_OPTION_TAGS)) { + $row['TAGS'] = implode(',', $metaData['tags']); + } + + $this->data[] = $row; + } } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); - $tableHelper - ->setHeaders($headers) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + return $this->data; } } From c5943a9560045d65daf9a302c71024c3ea334d46 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 11 Jun 2024 11:16:32 +0200 Subject: [PATCH 042/136] [skip ci] Updated dev:module:enable command --- .../Module/Disableenable/EnableCommand.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Module/Disableenable/EnableCommand.php b/src/N98/Magento/Command/Developer/Module/Disableenable/EnableCommand.php index 36455c1c7..f5d46467c 100644 --- a/src/N98/Magento/Command/Developer/Module/Disableenable/EnableCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Disableenable/EnableCommand.php @@ -1,14 +1,29 @@ Date: Tue, 11 Jun 2024 11:16:56 +0200 Subject: [PATCH 043/136] [skip ci] Updated dev:module:disable command --- .../Module/Disableenable/AbstractCommand.php | 87 +++++++++++++------ .../Module/Disableenable/DisableCommand.php | 19 +++- 2 files changed, 77 insertions(+), 29 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Module/Disableenable/AbstractCommand.php b/src/N98/Magento/Command/Developer/Module/Disableenable/AbstractCommand.php index fec61e825..5dfaa6964 100644 --- a/src/N98/Magento/Command/Developer/Module/Disableenable/AbstractCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Disableenable/AbstractCommand.php @@ -1,11 +1,16 @@ getCommandAction(); + $this - ->setName('dev:module:' . $this->commandName) - ->addArgument('moduleName', InputArgument::OPTIONAL, 'Name of module to ' . $this->commandName) - ->addOption('codepool', null, InputOption::VALUE_OPTIONAL, 'Name of codePool to ' . $this->commandName) - ->setDescription(ucwords($this->commandName) . ' a module or all modules in codePool'); + ->addArgument( + self::COMMAND_ARGUMENT_MODULE, + InputArgument::OPTIONAL, + 'Name of module to ' . $action + ) + ->addOption( + self::COMMAND_OPTION_CODEPOOL, + null, + InputOption::VALUE_OPTIONAL, + 'Name of codePool to ' . $action + ) + ; } /** * Execute command * - * @param InputInterface $input + * @param InputInterface $input * @param OutputInterface $output * * @return int - * * @throws InvalidArgumentException + * @throws Exception */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output, true); - if (false === $this->initMagento()) { - throw new RuntimeException('Magento could not be loaded'); + $this->detectMagento($output); + if (!$this->initMagento()) { + throw new RuntimeException('Application could not be loaded'); } + $this->config = Mage::getConfig(); $this->modulesDir = $this->config->getOptions()->getEtcDir() . DS . 'modules' . DS; - if ($codePool = $input->getOption('codepool')) { - $output->writeln('' . ($this->commandName == 'enable' ? 'Enabling' : 'Disabling') . + + if ($codePool = $input->getOption(self::COMMAND_OPTION_CODEPOOL)) { + $output->writeln('' . ($this->getCommandAction() == 'enable' ? 'Enabling' : 'Disabling') . ' modules in ' . $codePool . ' codePool...'); $this->enableCodePool($codePool, $output); - } elseif ($module = $input->getArgument('moduleName')) { + } elseif ($module = $input->getArgument(self::COMMAND_ARGUMENT_MODULE)) { $this->enableModule($module, $output); } else { throw new InvalidArgumentException('No code-pool option nor module-name argument'); } - return 0; + + return Command::SUCCESS; } /** @@ -81,8 +100,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int * * @param string $codePool * @param OutputInterface $output + * @throws Exception */ - protected function enableCodePool($codePool, OutputInterface $output) + protected function enableCodePool(string $codePool, OutputInterface $output): void { $modules = $this->config->getNode('modules')->asArray(); foreach ($modules as $module => $data) { @@ -97,8 +117,9 @@ protected function enableCodePool($codePool, OutputInterface $output) * * @param string $module * @param OutputInterface $output + * @throws Exception */ - protected function enableModule($module, OutputInterface $output) + protected function enableModule(string $module, OutputInterface $output): void { $xml = null; $validDecFile = false; @@ -115,11 +136,11 @@ protected function enableModule($module, OutputInterface $output) } elseif (!is_writable($validDecFile)) { $msg = sprintf('%s: Can\'t write to declaration file', $module); } else { - $setTo = $this->commandName == 'enable' ? 'true' : 'false'; + $setTo = $this->getCommandAction() == 'enable' ? 'true' : 'false'; if ((string) $xml->modules->{$module}->active != $setTo) { $xml->modules->{$module}->active = $setTo; if (file_put_contents($validDecFile, $xml->asXML()) !== false) { - $msg = sprintf('%s: %sd', $module, $this->commandName); + $msg = sprintf('%s: %sd', $module, $this->getCommandAction()); } else { $msg = sprintf( '%s: Failed to update declaration file [%s]', @@ -128,7 +149,7 @@ protected function enableModule($module, OutputInterface $output) ); } } else { - $msg = sprintf('%s: already %sd', $module, $this->commandName); + $msg = sprintf('%s: already %sd', $module, $this->getCommandAction()); } } @@ -141,9 +162,13 @@ protected function enableModule($module, OutputInterface $output) * * @return array */ - protected function getDeclaredModuleFiles() + protected function getDeclaredModuleFiles(): array { - $collectModuleFiles = ['base' => [], 'mage' => [], 'custom' => []]; + $collectModuleFiles = [ + 'base' => [], + 'mage' => [], + 'custom' => [] + ]; foreach (glob($this->modulesDir . '*.xml') as $v) { $name = explode(DIRECTORY_SEPARATOR, $v); @@ -164,4 +189,12 @@ protected function getDeclaredModuleFiles() $collectModuleFiles['custom'] )); } + + /** + * @return string + */ + protected function getCommandAction(): string + { + return substr(static::$defaultName, strrpos(static::$defaultName, ':') + 1); + } } diff --git a/src/N98/Magento/Command/Developer/Module/Disableenable/DisableCommand.php b/src/N98/Magento/Command/Developer/Module/Disableenable/DisableCommand.php index 377ea83fb..281cd72f6 100644 --- a/src/N98/Magento/Command/Developer/Module/Disableenable/DisableCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Disableenable/DisableCommand.php @@ -1,14 +1,29 @@ Date: Tue, 11 Jun 2024 11:39:33 +0200 Subject: [PATCH 044/136] [skip ci] Updated dev:theme:info command --- .../Command/Developer/Theme/InfoCommand.php | 69 +++++++++++++------ 1 file changed, 48 insertions(+), 21 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Theme/InfoCommand.php b/src/N98/Magento/Command/Developer/Theme/InfoCommand.php index beaa52194..9635bbf97 100644 --- a/src/N98/Magento/Command/Developer/Theme/InfoCommand.php +++ b/src/N98/Magento/Command/Developer/Theme/InfoCommand.php @@ -1,64 +1,87 @@ 'design/theme/locale']; + protected array $_configNodes = ['Theme translations' => 'design/theme/locale']; /** * @var array */ - protected $_configNodesWithExceptions = ['Design Package Name' => 'design/package/name', 'Theme template' => 'design/theme/template', 'Theme skin' => 'design/theme/skin', 'Theme layout' => 'design/theme/layout', 'Theme default' => 'design/theme/default']; - - protected function configure() - { - $this - ->setName('dev:theme:info') - ->setDescription('Displays settings of current design on particular store view'); - } + protected array $_configNodesWithExceptions = [ + 'Design Package Name' => 'design/package/name', + 'Theme template' => 'design/theme/template', + 'Theme skin' => 'design/theme/skin', + 'Theme layout' => 'design/theme/layout', + 'Theme default' => 'design/theme/default' + ]; /** * @param InputInterface $input * @param OutputInterface $output * @return int + * + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output); if (!$this->initMagento()) { - return 0; + return Command::FAILURE; } - foreach (Mage::app()->getWebsites() as $website) { - /* @var \Mage_Core_Model_Website $website */ + foreach ($this->_getMage()->getWebsites() as $website) { foreach ($website->getStores() as $store) { - /* @var \Mage_Core_Model_Store $store */ $this->_displayTable($output, $store); } } - return 0; + + return Command::SUCCESS; } - protected function _displayTable(OutputInterface $output, Mage_Core_Model_Store $store) + /** + * @param OutputInterface $output + * @param Mage_Core_Model_Store $store + * @return $this + */ + protected function _displayTable(OutputInterface $output, Mage_Core_Model_Store $store): InfoCommand { $this->writeSection( $output, @@ -67,8 +90,7 @@ protected function _displayTable(OutputInterface $output, Mage_Core_Model_Store $storeInfoLines = $this->_parse($this->_configNodesWithExceptions, $store, true); $storeInfoLines = array_merge($storeInfoLines, $this->_parse($this->_configNodes, $store)); - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders([Parameter::class, 'Value']) ->renderByFormat($output, $storeInfoLines); @@ -77,9 +99,12 @@ protected function _displayTable(OutputInterface $output, Mage_Core_Model_Store } /** + * @param array $nodes + * @param Mage_Core_Model_Store $store + * @param bool $withExceptions * @return array */ - protected function _parse(array $nodes, Mage_Core_Model_Store $store, $withExceptions = false) + protected function _parse(array $nodes, Mage_Core_Model_Store $store, bool $withExceptions = false): array { $result = []; @@ -98,9 +123,11 @@ protected function _parse(array $nodes, Mage_Core_Model_Store $store, $withExcep } /** + * @param string $node + * @param Mage_Core_Model_Store $store * @return string */ - protected function _parseException($node, Mage_Core_Model_Store $store) + protected function _parseException(string $node, Mage_Core_Model_Store $store): string { $exception = (string) Mage::getConfig()->getNode( $node . self::THEMES_EXCEPTION, From 57c7283d75e0cb5a2d4e73ae09db6f80154e1476 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 11 Jun 2024 12:52:26 +0200 Subject: [PATCH 045/136] [skip ci] CS fix --- src/N98/Magento/Command/Eav/Attribute/ListCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/N98/Magento/Command/Eav/Attribute/ListCommand.php b/src/N98/Magento/Command/Eav/Attribute/ListCommand.php index 28446804e..77c5ab92a 100644 --- a/src/N98/Magento/Command/Eav/Attribute/ListCommand.php +++ b/src/N98/Magento/Command/Eav/Attribute/ListCommand.php @@ -67,7 +67,7 @@ protected function configure() * {@inheritdoc} * @return array> * - * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ public function getData(InputInterface $input, OutputInterface $output): array { From 1d53831661a242a0bed7e097742651ccc462648d Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 11 Jun 2024 12:53:13 +0200 Subject: [PATCH 046/136] [skip ci] Changed initMagento() --- src/N98/Magento/Command/Cache/FlushCommand.php | 11 ++++++++--- src/N98/Magento/Command/Cache/ListCommand.php | 7 ++++++- src/N98/Magento/Command/Cache/ViewCommand.php | 4 +--- .../Magento/Command/Eav/Attribute/RemoveCommand.php | 4 +--- src/N98/Magento/Command/Eav/Attribute/ViewCommand.php | 4 +--- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/N98/Magento/Command/Cache/FlushCommand.php b/src/N98/Magento/Command/Cache/FlushCommand.php index c89be2be7..051fde727 100644 --- a/src/N98/Magento/Command/Cache/FlushCommand.php +++ b/src/N98/Magento/Command/Cache/FlushCommand.php @@ -1,5 +1,7 @@ banUseCache(); } - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); try { Mage::app()->loadAreaPart('adminhtml', 'events'); diff --git a/src/N98/Magento/Command/Cache/ListCommand.php b/src/N98/Magento/Command/Cache/ListCommand.php index 74f95c0a7..e628f44ee 100644 --- a/src/N98/Magento/Command/Cache/ListCommand.php +++ b/src/N98/Magento/Command/Cache/ListCommand.php @@ -9,6 +9,11 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +/** + * List cache command + * + * @package N98\Magento\Command\Cache + */ class ListCommand extends AbstractCacheCommand implements AbstractMagentoCommandFormatInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Caches'; @@ -31,7 +36,7 @@ class ListCommand extends AbstractCacheCommand implements AbstractMagentoCommand * {@inheritdoc} * @return array> * - * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ public function getData(InputInterface $input, OutputInterface $output): array { diff --git a/src/N98/Magento/Command/Cache/ViewCommand.php b/src/N98/Magento/Command/Cache/ViewCommand.php index 03e86ea07..6df2b571a 100644 --- a/src/N98/Magento/Command/Cache/ViewCommand.php +++ b/src/N98/Magento/Command/Cache/ViewCommand.php @@ -67,9 +67,7 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output); - if (!$this->initMagento()) { - return Command::FAILURE; - } + $this->initMagento(); $cacheInstance = $this->getCacheInstance($input); $cacheData = $cacheInstance->load($input->getArgument(self::COMMAND_ARGUMENT_ID)); diff --git a/src/N98/Magento/Command/Eav/Attribute/RemoveCommand.php b/src/N98/Magento/Command/Eav/Attribute/RemoveCommand.php index f104ebb9b..68e71dcbd 100644 --- a/src/N98/Magento/Command/Eav/Attribute/RemoveCommand.php +++ b/src/N98/Magento/Command/Eav/Attribute/RemoveCommand.php @@ -36,9 +36,7 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); $entityType = $input->getArgument('entityType'); diff --git a/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php b/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php index 6528a0c73..476eb8804 100644 --- a/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php +++ b/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php @@ -37,9 +37,7 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output); - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); $entityType = $input->getArgument('entityType'); $attributeCode = $input->getArgument('attributeCode'); From 9053071974795def4892c9aeb1432965f1109788 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 11 Jun 2024 13:02:34 +0200 Subject: [PATCH 047/136] [skip ci] Changed initMagento() --- .../Command/Cache/Dir/FlushCommand.php | 11 ++---- .../Magento/Command/Cache/DisableCommand.php | 31 ++++++++------- .../Magento/Command/Cache/EnableCommand.php | 39 ++++++++++++------- .../Customer/ChangePasswordCommand.php | 9 +++-- .../Command/Customer/CreateCommand.php | 13 ++++--- .../Command/Customer/CreateDummyCommand.php | 9 +++-- .../Command/Customer/DeleteCommand.php | 7 ++-- .../Magento/Command/Customer/InfoCommand.php | 9 +++-- .../Magento/Command/Customer/ListCommand.php | 5 +++ 9 files changed, 79 insertions(+), 54 deletions(-) diff --git a/src/N98/Magento/Command/Cache/Dir/FlushCommand.php b/src/N98/Magento/Command/Cache/Dir/FlushCommand.php index 4ad025ce6..9c8595cb7 100644 --- a/src/N98/Magento/Command/Cache/Dir/FlushCommand.php +++ b/src/N98/Magento/Command/Cache/Dir/FlushCommand.php @@ -1,9 +1,6 @@ - */ + +declare(strict_types=1); namespace N98\Magento\Command\Cache\Dir; @@ -64,9 +61,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->output = $output; $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); $workingDirectory = getcwd(); $magentoRootFolder = $this->getApplication()->getMagentoRootFolder(); diff --git a/src/N98/Magento/Command/Cache/DisableCommand.php b/src/N98/Magento/Command/Cache/DisableCommand.php index f1f835c6c..4f851f852 100644 --- a/src/N98/Magento/Command/Cache/DisableCommand.php +++ b/src/N98/Magento/Command/Cache/DisableCommand.php @@ -1,22 +1,29 @@ setName('cache:disable') - ->addArgument('code', InputArgument::OPTIONAL, 'Code of cache (Multiple codes sperated by comma)') - ->setDescription('Disables magento caches') - ; - } + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultName = 'cache:disable'; + + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultDescription = 'Disables caches.'; /** * @param InputInterface $input @@ -27,11 +34,9 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); - $codeArgument = BinaryString::trimExplodeEmpty(',', $input->getArgument('code')); + $codeArgument = BinaryString::trimExplodeEmpty(',', $input->getArgument(self::COMMAND_ARGUMENT_CODE)); $this->saveCacheStatus($codeArgument, false); if (empty($codeArgument)) { diff --git a/src/N98/Magento/Command/Cache/EnableCommand.php b/src/N98/Magento/Command/Cache/EnableCommand.php index a302ca298..f04d43c1c 100644 --- a/src/N98/Magento/Command/Cache/EnableCommand.php +++ b/src/N98/Magento/Command/Cache/EnableCommand.php @@ -1,22 +1,34 @@ setName('cache:enable') - ->addArgument('code', InputArgument::OPTIONAL, 'Code of cache (Multiple codes sperated by comma)') - ->setDescription('Enables magento caches') - ; - } + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultName = 'cache:enable'; + + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultDescription = 'Enables caches.'; /** * @param InputInterface $input @@ -27,20 +39,19 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); - $codeArgument = BinaryString::trimExplodeEmpty(',', $input->getArgument('code')); + $codeArgument = BinaryString::trimExplodeEmpty(',', $input->getArgument(self::COMMAND_ARGUMENT_CODE)); $this->saveCacheStatus($codeArgument, true); - if (count($codeArgument) > 0) { + if ($codeArgument !== []) { foreach ($codeArgument as $code) { $output->writeln('Cache ' . $code . ' enabled'); } } else { $output->writeln('Caches enabled'); } + return 0; } } diff --git a/src/N98/Magento/Command/Customer/ChangePasswordCommand.php b/src/N98/Magento/Command/Customer/ChangePasswordCommand.php index 66132e53d..9095772f2 100644 --- a/src/N98/Magento/Command/Customer/ChangePasswordCommand.php +++ b/src/N98/Magento/Command/Customer/ChangePasswordCommand.php @@ -11,6 +11,11 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\Question; +/** + * Change password command + * + * @package N98\Magento\Command\Customer + */ class ChangePasswordCommand extends AbstractCustomerCommand { protected function configure() @@ -38,9 +43,7 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output); - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); // Password if (($password = $input->getArgument('password')) == null) { diff --git a/src/N98/Magento/Command/Customer/CreateCommand.php b/src/N98/Magento/Command/Customer/CreateCommand.php index e63df8b13..4585695e4 100644 --- a/src/N98/Magento/Command/Customer/CreateCommand.php +++ b/src/N98/Magento/Command/Customer/CreateCommand.php @@ -5,13 +5,17 @@ use N98\Util\Console\Helper\ParameterHelper; use N98\Util\Console\Helper\Table\Renderer\RendererFactory; use N98\Util\Console\Helper\TableHelper; -use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\Question; +/** + * Create customer command + * + * @package N98\Magento\Command\Customer + */ class CreateCommand extends AbstractCustomerCommand { protected function configure() @@ -41,12 +45,9 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); // Password if (($password = $input->getArgument('password')) == null) { diff --git a/src/N98/Magento/Command/Customer/CreateDummyCommand.php b/src/N98/Magento/Command/Customer/CreateDummyCommand.php index 62fc15521..bbe41cbff 100644 --- a/src/N98/Magento/Command/Customer/CreateDummyCommand.php +++ b/src/N98/Magento/Command/Customer/CreateDummyCommand.php @@ -13,6 +13,11 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +/** + * Create dummy customer command + * + * @package N98\Magento\Command\Customer + */ class CreateDummyCommand extends AbstractCustomerCommand { protected function configure() @@ -67,9 +72,7 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); $res = $this->getCustomerModel()->getResource(); diff --git a/src/N98/Magento/Command/Customer/DeleteCommand.php b/src/N98/Magento/Command/Customer/DeleteCommand.php index 5d6ee4da3..e38d09b81 100644 --- a/src/N98/Magento/Command/Customer/DeleteCommand.php +++ b/src/N98/Magento/Command/Customer/DeleteCommand.php @@ -17,7 +17,8 @@ use Symfony\Component\Console\Question\Question; /** - * Class DeleteCommand + * Delete customer command + * * @package N98\Magento\Command\Customer */ class DeleteCommand extends AbstractCustomerCommand @@ -74,9 +75,7 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); $this->input = $input; $this->output = $output; diff --git a/src/N98/Magento/Command/Customer/InfoCommand.php b/src/N98/Magento/Command/Customer/InfoCommand.php index e79bd5c29..59fba2fdc 100644 --- a/src/N98/Magento/Command/Customer/InfoCommand.php +++ b/src/N98/Magento/Command/Customer/InfoCommand.php @@ -10,6 +10,11 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +/** + * Info customer command + * + * @package N98\Magento\Command\Customer + */ class InfoCommand extends AbstractCustomerCommand { /** @@ -35,9 +40,7 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output); - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); /** @var ParameterHelper $parameterHelper */ $parameterHelper = $this->getHelper('parameter'); diff --git a/src/N98/Magento/Command/Customer/ListCommand.php b/src/N98/Magento/Command/Customer/ListCommand.php index 0ab3c9c4f..b107fd7ef 100644 --- a/src/N98/Magento/Command/Customer/ListCommand.php +++ b/src/N98/Magento/Command/Customer/ListCommand.php @@ -11,6 +11,11 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +/** + * List customer command + * + * @package N98\Magento\Command\Customer + */ class ListCommand extends AbstractCustomerCommand implements AbstractMagentoCommandFormatInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Customers'; From 88525d66bdebf3473f604fc02d136fedbd804042 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 11 Jun 2024 13:38:50 +0200 Subject: [PATCH 048/136] [skip ci] Updated admin:user:change-password command --- .../Admin/User/ChangePasswordCommand.php | 60 ++++++++++++++----- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/src/N98/Magento/Command/Admin/User/ChangePasswordCommand.php b/src/N98/Magento/Command/Admin/User/ChangePasswordCommand.php index 8fa97d053..30b79e3ea 100644 --- a/src/N98/Magento/Command/Admin/User/ChangePasswordCommand.php +++ b/src/N98/Magento/Command/Admin/User/ChangePasswordCommand.php @@ -1,24 +1,57 @@ setName('admin:user:change-password') - ->addArgument('username', InputArgument::OPTIONAL, 'Username') - ->addArgument('password', InputArgument::OPTIONAL, 'Password') - ->setDescription('Changes the password of a adminhtml user.') + ->addArgument( + self::COMMAND_ARGUMENT_USERNAME, + InputArgument::OPTIONAL, + 'Username' + ) + ->addArgument( + self::COMMAND_ARGUMENT_PASSWORD, + InputArgument::OPTIONAL, + 'Password' + ) ; } @@ -27,19 +60,17 @@ protected function configure() * @param OutputInterface $output * * @return int + * @throws Throwable */ protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output); - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); // Username - if (($username = $input->getArgument('username')) == null) { + if (($username = $input->getArgument(self::COMMAND_ARGUMENT_USERNAME)) == null) { $username = $dialog->ask($input, $output, new Question('Username: ')); } @@ -47,11 +78,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($user->getId() <= 0) { $output->writeln('User was not found'); - return 0; + return Command::SUCCESS; } // Password - if (($password = $input->getArgument('password')) == null) { + if (($password = $input->getArgument(self::COMMAND_ARGUMENT_PASSWORD)) == null) { $question = new Question('Password: '); $question->setHidden(true); $question->setHiddenFallback(false); @@ -69,6 +100,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } catch (Exception $e) { $output->writeln('' . $e->getMessage() . ''); } - return 0; + + return Command::SUCCESS; } } From be193a5306cdd07e9dfd86e98c85d4551aaf09cb Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 12 Jun 2024 05:53:21 +0200 Subject: [PATCH 049/136] [skip ci] Updated media:dump command --- src/N98/Magento/Command/Media/DumpCommand.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/N98/Magento/Command/Media/DumpCommand.php b/src/N98/Magento/Command/Media/DumpCommand.php index 4e1bca629..bb5953fe3 100644 --- a/src/N98/Magento/Command/Media/DumpCommand.php +++ b/src/N98/Magento/Command/Media/DumpCommand.php @@ -44,7 +44,7 @@ class DumpCommand extends AbstractMagentoCommand /** * @return void */ - protected function configure() + protected function configure(): void { $this ->addOption( @@ -56,7 +56,8 @@ protected function configure() ->addArgument( self::COMMAND_ARGUMENT_FILENAME, InputArgument::OPTIONAL, - 'Dump filename' + 'Dump filename', + '' ) ; } @@ -92,7 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $finder->exclude($commandConfig['strip']['folders']); } - $filename = $this->getArgumentString($input, self::COMMAND_ARGUMENT_FILENAME); + $filename = $input->getArgument(self::COMMAND_ARGUMENT_FILENAME); if (is_dir($filename)) { // support for dot dir $filename = realpath($filename); $filename .= '/'; @@ -120,6 +121,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $zip->close(); + $output->writeln(sprintf('Media dumped to: %s', $filename)); + return Command::SUCCESS; } } From 2ee07e6284c82a722f40bc063ec5f057e269c533 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 12 Jun 2024 07:18:03 +0200 Subject: [PATCH 050/136] [skip ci] Updated cache:report command --- .../Magento/Command/Cache/ReportCommand.php | 39 ++++++++----------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/src/N98/Magento/Command/Cache/ReportCommand.php b/src/N98/Magento/Command/Cache/ReportCommand.php index 156d42841..f913aa531 100644 --- a/src/N98/Magento/Command/Cache/ReportCommand.php +++ b/src/N98/Magento/Command/Cache/ReportCommand.php @@ -41,7 +41,7 @@ class ReportCommand extends AbstractCacheCommand implements AbstractMagentoComma */ protected static $defaultDescription = 'View inside the cache.'; - protected function configure() + protected function configure(): void { $this ->addOption( @@ -78,18 +78,6 @@ protected function configure() parent::configure(); } - /** - * @param array $metaData - * @param InputInterface $input - * @return bool - */ - protected function isTagFiltered(array $metaData, InputInterface $input): bool - { - return (bool) count(array_intersect( - $metaData['tags'], explode(',', $input->getOption(self::COMMAND_OPTION_FILTER_TAG))) - ); - } - /** * {@inheritdoc} * @return array> @@ -101,19 +89,24 @@ public function getData(InputInterface $input, OutputInterface $output): array if (is_null($this->data)) { $this->data = []; - $filterId = $input->getOption(self::COMMAND_OPTION_FILTER_ID); $cacheInstance = $this->getCacheInstance($input); - foreach ($cacheInstance->getIds() as $cacheId) { - if ($filterId !== null && !stristr($cacheId, (string) $filterId)) { - continue; - } + $filterTag = $input->getOption(self::COMMAND_OPTION_FILTER_TAG); + if ($filterTag !== null) { + $cacheIds = $cacheInstance->getIdsMatchingAnyTags([$filterTag]); + } else { + $cacheIds = $cacheInstance->getIds(); + } + + $filterId = $input->getOption(self::COMMAND_OPTION_FILTER_ID); + if ($filterId !== null) { + $cacheIds = array_filter($cacheIds, function ($cacheId) use ($filterId) { + return stristr($cacheId, (string)$filterId); + }); + } + + foreach ($cacheIds as $cacheId) { $metaData = $cacheInstance->getMetadatas($cacheId); - if ($input->getOption(self::COMMAND_OPTION_FILTER_TAG) !== null - && !$this->isTagFiltered($metaData, $input) - ) { - continue; - } $row = [ 'ID' => $cacheId, From cf716ac37bd3b3ae7dbc1311b8a7e9bae293399c Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 12 Jun 2024 07:33:10 +0200 Subject: [PATCH 051/136] [skip ci] Updated cache:view command --- src/N98/Magento/Command/Cache/ViewCommand.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/N98/Magento/Command/Cache/ViewCommand.php b/src/N98/Magento/Command/Cache/ViewCommand.php index 6df2b571a..4b87081b5 100644 --- a/src/N98/Magento/Command/Cache/ViewCommand.php +++ b/src/N98/Magento/Command/Cache/ViewCommand.php @@ -36,7 +36,7 @@ class ViewCommand extends AbstractCacheCommand */ protected static $defaultDescription = 'Prints a cache entry.'; - protected function configure() + protected function configure(): void { $this ->addArgument( @@ -61,7 +61,6 @@ protected function configure() /** * @param InputInterface $input * @param OutputInterface $output - * * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int From 553e32fc6aac9e7b48404d63e750cc8934e3a903 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 12 Jun 2024 11:21:46 +0200 Subject: [PATCH 052/136] [skip ci] Updated cache:view command --- src/N98/Magento/Command/Cache/ViewCommand.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/N98/Magento/Command/Cache/ViewCommand.php b/src/N98/Magento/Command/Cache/ViewCommand.php index 4b87081b5..451869d84 100644 --- a/src/N98/Magento/Command/Cache/ViewCommand.php +++ b/src/N98/Magento/Command/Cache/ViewCommand.php @@ -69,7 +69,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->initMagento(); $cacheInstance = $this->getCacheInstance($input); - $cacheData = $cacheInstance->load($input->getArgument(self::COMMAND_ARGUMENT_ID)); + /** @var string $cacheId */ + $cacheId = $input->getArgument(self::COMMAND_ARGUMENT_ID); + /** @var string $cacheData */ + $cacheData = $cacheInstance->load($cacheId); if ($input->getOption(self::COMMAND_OPTION_UNSERIALZE)) { $cacheData = unserialize($cacheData); $cacheData = print_r($cacheData, true); From 1a78d885b187b1b1ae51a533421cf152e2ce038e Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 12 Jun 2024 11:22:47 +0200 Subject: [PATCH 053/136] [skip ci] Updated cache:report command --- src/N98/Magento/Command/Cache/ReportCommand.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/N98/Magento/Command/Cache/ReportCommand.php b/src/N98/Magento/Command/Cache/ReportCommand.php index f913aa531..e75f2b1f5 100644 --- a/src/N98/Magento/Command/Cache/ReportCommand.php +++ b/src/N98/Magento/Command/Cache/ReportCommand.php @@ -46,7 +46,8 @@ protected function configure(): void $this ->addOption( self::COMMAND_OPTION_TAGS, - 't', InputOption::VALUE_NONE, + 't', + InputOption::VALUE_NONE, 'Output tags' ) ->addOption( @@ -98,13 +99,16 @@ public function getData(InputInterface $input, OutputInterface $output): array $cacheIds = $cacheInstance->getIds(); } + /** @var string $filterId */ $filterId = $input->getOption(self::COMMAND_OPTION_FILTER_ID); if ($filterId !== null) { + // @phpstan-ignore argument.type (@todo SR) $cacheIds = array_filter($cacheIds, function ($cacheId) use ($filterId) { - return stristr($cacheId, (string)$filterId); + return stristr($cacheId, $filterId); }); } + /** @var string[] $cacheIds */ foreach ($cacheIds as $cacheId) { $metaData = $cacheInstance->getMetadatas($cacheId); From b530bb2dbfd711b4f0e57fe6c270d323eb71a67e Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 12 Jun 2024 11:23:48 +0200 Subject: [PATCH 054/136] [skip ci] Updated cache:list command --- src/N98/Magento/Command/Cache/ListCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/N98/Magento/Command/Cache/ListCommand.php b/src/N98/Magento/Command/Cache/ListCommand.php index e628f44ee..edf509926 100644 --- a/src/N98/Magento/Command/Cache/ListCommand.php +++ b/src/N98/Magento/Command/Cache/ListCommand.php @@ -34,7 +34,7 @@ class ListCommand extends AbstractCacheCommand implements AbstractMagentoCommand /** * {@inheritdoc} - * @return array> + * @return array|string, array> * * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ From 6a0e40ddb3118473043538d80287fd61f82bd32c Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 12 Jun 2024 11:24:52 +0200 Subject: [PATCH 055/136] [skip ci] Updated cache:flush command --- .../Cache/CacheCommandReinitInterface.php | 14 +++++ .../Magento/Command/Cache/FlushCommand.php | 57 ++++++++++--------- 2 files changed, 44 insertions(+), 27 deletions(-) create mode 100644 src/N98/Magento/Command/Cache/CacheCommandReinitInterface.php diff --git a/src/N98/Magento/Command/Cache/CacheCommandReinitInterface.php b/src/N98/Magento/Command/Cache/CacheCommandReinitInterface.php new file mode 100644 index 000000000..097e95dab --- /dev/null +++ b/src/N98/Magento/Command/Cache/CacheCommandReinitInterface.php @@ -0,0 +1,14 @@ +setName('cache:flush') - ->addOption( - 'reinit', - null, - InputOption::VALUE_NONE, - 'Reinitialise the config cache after flushing' - ) - ->addOption( - 'no-reinit', - null, - InputOption::VALUE_NONE, - "Don't reinitialise the config cache after flushing" - ) - ->setDescription('Flush magento cache storage') - ; - - $help = <<setHelp($help); } /** * @param InputInterface $input * @param OutputInterface $output - * * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output, true); + $this->detectMagento($output); - $noReinitOption = $input->getOption('no-reinit'); + $noReinitOption = $input->getOption(self::COMMAND_OPTION_NO_REINIT); if (!$noReinitOption) { $this->banUseCache(); } @@ -93,10 +92,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Failed to clear FPC'); } } - return 0; + + return Command::SUCCESS; } - protected function isEnterpriseFullPageCachePresent() + /** + * @return bool + */ + protected function isEnterpriseFullPageCachePresent(): bool { $isModuleEnabled = Mage::helper('core')->isModuleEnabled('Enterprise_PageCache'); return $this->_magentoEnterprise && $isModuleEnabled && version_compare(Mage::getVersion(), '1.11.0.0', '>='); From c063d986a6b2973156982f4235aa40662f0f5100 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 12 Jun 2024 11:25:58 +0200 Subject: [PATCH 056/136] [skip ci] Updated cache:clean command --- .../Command/Cache/AbstractCacheCommand.php | 61 +++++++++++----- .../Magento/Command/Cache/CleanCommand.php | 72 ++++++++++++------- 2 files changed, 90 insertions(+), 43 deletions(-) diff --git a/src/N98/Magento/Command/Cache/AbstractCacheCommand.php b/src/N98/Magento/Command/Cache/AbstractCacheCommand.php index d3656357f..125bde52c 100644 --- a/src/N98/Magento/Command/Cache/AbstractCacheCommand.php +++ b/src/N98/Magento/Command/Cache/AbstractCacheCommand.php @@ -10,6 +10,7 @@ use N98\Magento\Command\AbstractMagentoCommand; use RuntimeException; use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Zend_Cache_Core; @@ -24,13 +25,36 @@ class AbstractCacheCommand extends AbstractMagentoCommand public const COMMAND_OPTION_FPC = 'fpc'; - protected function configure() + public const COMMAND_OPTION_REINIT = 'reinit'; + + public const COMMAND_OPTION_NO_REINIT = 'no-reinit'; + + protected function configure(): void { - $this->addArgument( - self::COMMAND_ARGUMENT_CODE, - InputArgument::OPTIONAL, - 'Code of cache (Multiple codes operated by comma)' - ); + if ($this instanceof CacheCommandToggleInterface) { + $this + ->addArgument( + self::COMMAND_ARGUMENT_CODE, + InputArgument::OPTIONAL, + 'Code of cache (Multiple codes operated by comma)' + ); + } + + if ($this instanceof CacheCommandReinitInterface) { + $this + ->addOption( + self::COMMAND_OPTION_REINIT, + null, + InputOption::VALUE_NONE, + 'Reinitialise the config cache after cleaning or flushing.' + ) + ->addOption( + self::COMMAND_OPTION_NO_REINIT, + null, + InputOption::VALUE_NONE, + "Don't reinitialise the config cache after cleaning or flushing." + ); + } parent::configure(); } @@ -62,26 +86,30 @@ protected function getCacheInstance(InputInterface $input): Zend_Cache_Core } /** - * @param array $codeArgument + * @param string[] $codeArgument * @param bool $status + * @return void */ - protected function saveCacheStatus(array $codeArgument, bool $status) + protected function saveCacheStatus(array $codeArgument, bool $status): void { $this->validateCacheCodes($codeArgument); $cacheTypes = $this->_getCacheModel()->getTypes(); $enable = $this->_getMage()->useCache(); - foreach ($cacheTypes as $cacheCode => $cacheModel) { - if (empty($codeArgument) || in_array($cacheCode, $codeArgument)) { - $enable[$cacheCode] = $status ? 1 : 0; + + if (is_array($enable)) { + foreach ($cacheTypes as $cacheCode => $cacheModel) { + if (empty($codeArgument) || in_array($cacheCode, $codeArgument)) { + $enable[$cacheCode] = $status ? 1 : 0; + } } - } - $this->_getMage()->saveUseCache($enable); + $this->_getMage()->saveUseCache($enable); + } } /** - * @param array $codes + * @param string[] $codes * @throws InvalidArgumentException */ protected function validateCacheCodes(array $codes): void @@ -99,7 +127,7 @@ protected function validateCacheCodes(array $codes): void * * @see https://github.com/netz98/n98-magerun/issues/483 */ - protected function banUseCache() + protected function banUseCache(): void { if (!$this->_canUseBanCacheFunction()) { return; @@ -112,7 +140,7 @@ protected function banUseCache() } } - protected function reinitCache() + protected function reinitCache(): void { if (!$this->_canUseBanCacheFunction()) { return; @@ -127,6 +155,7 @@ protected function reinitCache() */ protected function _canUseBanCacheFunction(): bool { + // @phpstan-ignore function.alreadyNarrowedType (Phpstan Bleeding edge only) return method_exists('\Mage_Core_Model_App', 'baseInit'); } } diff --git a/src/N98/Magento/Command/Cache/CleanCommand.php b/src/N98/Magento/Command/Cache/CleanCommand.php index 0fd03d32f..7ea822777 100644 --- a/src/N98/Magento/Command/Cache/CleanCommand.php +++ b/src/N98/Magento/Command/Cache/CleanCommand.php @@ -1,37 +1,57 @@ setName('cache:clean') - ->addArgument('type', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Cache type code like "config"') - ->addOption( - 'reinit', - null, - InputOption::VALUE_NONE, - 'Reinitialise the config cache after cleaning' + ->addArgument( + self::COMMAND_ARGUMENT_TYPE, + InputArgument::IS_ARRAY | InputArgument::OPTIONAL, + 'Cache type code like "config"' ) - ->addOption( - 'no-reinit', - null, - InputOption::VALUE_NONE, - "Don't reinitialise the config cache after flushing" - ) - ->setDescription('Clean magento cache') ; + } - $help = <<setHelp($help); } /** * @param InputInterface $input * @param OutputInterface $output - * * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int { - $noReinitOption = $input->getOption('no-reinit'); + $noReinitOption = $input->getOption(self::COMMAND_OPTION_NO_REINIT); if (!$noReinitOption) { $this->banUseCache(); } - $this->detectMagento($output, true); - if (!$this->initMagento(true)) { - return 0; - } + $this->detectMagento($output); + $this->initMagento(true); try { Mage::app()->loadAreaPart('adminhtml', 'events'); @@ -76,7 +92,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $allTypes = Mage::app()->getCacheInstance()->getTypes(); - $typesToClean = $input->getArgument('type'); + /** @var array $typesToClean */ + $typesToClean = $input->getArgument(self::COMMAND_ARGUMENT_TYPE); $this->validateCacheCodes($typesToClean); $typeKeys = array_keys($allTypes); @@ -91,6 +108,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (!$noReinitOption) { $this->reinitCache(); } - return 0; + + return Command::SUCCESS; } } From e752235cbfaec43b0a25b50d0cbc2fa823b44708 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 12 Jun 2024 12:06:10 +0200 Subject: [PATCH 057/136] [skip ci] Updated cache:dir:flush command --- .../Command/Cache/Dir/FlushCommand.php | 92 +++++++++---------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/src/N98/Magento/Command/Cache/Dir/FlushCommand.php b/src/N98/Magento/Command/Cache/Dir/FlushCommand.php index 9c8595cb7..a70b533a7 100644 --- a/src/N98/Magento/Command/Cache/Dir/FlushCommand.php +++ b/src/N98/Magento/Command/Cache/Dir/FlushCommand.php @@ -8,31 +8,34 @@ use N98\Magento\Command\AbstractMagentoCommand; use N98\Util\Filesystem; use RuntimeException; +use SplFileInfo; +use Symfony\Component\Console\Attribute\AsCommand; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; /** - * Class FlushCommand + * Flush cache directory command * - * @package N98\Magento\Command\Cache + * @package N98\Magento\Command\Cache\Dir */ class FlushCommand extends AbstractMagentoCommand { /** - * @var OutputInterface + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand */ - private $output; + protected static $defaultName = 'cache:dir:flush'; - public const NAME = 'cache:dir:flush'; - - protected function configure() - { - $this - ->setName(FlushCommand::NAME) - ->setDescription('Flush (empty) Magento cache directory'); - } + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultDescription = 'Flush (empty) cache directory.'; - public function getHelp() + public function getHelp(): string { return <<output = $output; - $this->detectMagento($output, true); - + $this->detectMagento($output); $this->initMagento(); $workingDirectory = getcwd(); @@ -69,38 +71,52 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln(sprintf('Flushing cache directory %s', $cacheDir)); - $this->verbose(sprintf('root-dir: %s', $magentoRootFolder)); - $this->verbose(sprintf('cwd: %s', $workingDirectory)); + if ($output->isVerbose()) { + $output->writeln(sprintf('root-dir: %s', $magentoRootFolder)); + $output->writeln(sprintf('cwd: %s', $workingDirectory)); + } + + $this->emptyDirectory($output, $cacheDir); - $this->emptyDirectory($cacheDir); + $output->writeln('Cache directory flushed'); - $output->writeln('Cache directory flushed'); - return 0; + return Command::SUCCESS; } /** + * @param OutputInterface $output * @param string $path - * * @return bool */ - private function emptyDirectory($path) + private function emptyDirectory(OutputInterface $output, string $path) { $errors = []; $dir = new FilesystemIterator($path); foreach ($dir as $file => $info) { + /** @var SplFileInfo $info */ if ($info->isDir()) { - $this->verbose( - 'Filesystem::recursiveRemoveDirectory() ' . $file . '' - ); + if ($output->isVerbose()) { + $output->writeln( + sprintf( + 'Filesystem::recursiveRemoveDirectory() %s', + $file + ) + ); + } + if (!isset($fs)) { $fs = new Filesystem(); } + if (!$fs->recursiveRemoveDirectory($file)) { $errors[] = $file; - }; + } } else { - $this->verbose('unlink() ' . $file . ''); + if ($output->isVerbose()) { + $output->writeln(sprintf('unlink() %s', $file)); + } + if (!unlink($file)) { $errors[] = $file; } @@ -118,20 +134,4 @@ private function emptyDirectory($path) throw new RuntimeException($message); } - - /** - * @param string $message - */ - private function verbose($message) - { - $output = $this->output; - - if (!$output) { - return; - } - - if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { - $output->writeln($message); - } - } } From a267dff2c6683d15b8e51778f32dec557d4b16d7 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 12 Jun 2024 12:23:41 +0200 Subject: [PATCH 058/136] [skip ci] Updated cache:flush command --- .../Cache/AbstractCacheCommandReinit.php | 75 +++++++++++++++++++ .../Cache/CacheCommandReinitInterface.php | 14 ---- .../Magento/Command/Cache/FlushCommand.php | 2 +- 3 files changed, 76 insertions(+), 15 deletions(-) create mode 100644 src/N98/Magento/Command/Cache/AbstractCacheCommandReinit.php delete mode 100644 src/N98/Magento/Command/Cache/CacheCommandReinitInterface.php diff --git a/src/N98/Magento/Command/Cache/AbstractCacheCommandReinit.php b/src/N98/Magento/Command/Cache/AbstractCacheCommandReinit.php new file mode 100644 index 000000000..922734496 --- /dev/null +++ b/src/N98/Magento/Command/Cache/AbstractCacheCommandReinit.php @@ -0,0 +1,75 @@ +addOption( + self::COMMAND_OPTION_REINIT, + null, + InputOption::VALUE_NONE, + 'Reinitialise the config cache after cleaning or flushing.' + ) + ->addOption( + self::COMMAND_OPTION_NO_REINIT, + null, + InputOption::VALUE_NONE, + "Don't reinitialise the config cache after cleaning or flushing." + ); + + parent::configure(); + } + + /** + * Ban cache usage before cleanup to get the latest values. + * + * @see https://github.com/netz98/n98-magerun/issues/483 + */ + protected function banUseCache(): void + { + if (!$this->_canUseBanCacheFunction()) { + return; + } + + $config = $this->getApplication()->getConfig(); + if (empty($config['init']['options'])) { + $config['init']['options'] = ['global_ban_use_cache' => true]; + $this->getApplication()->setConfig($config); + } + } + + protected function reinitCache(): void + { + if (!$this->_canUseBanCacheFunction()) { + return; + } + + $this->_getMage()->getConfig()->getOptions()->setData('global_ban_use_cache', false); + $this->_getMage()->getConfig()->reinit(); + } + + /** + * @return bool + */ + protected function _canUseBanCacheFunction(): bool + { + // @phpstan-ignore function.alreadyNarrowedType (Phpstan Bleeding edge only) + return method_exists('\Mage_Core_Model_App', 'baseInit'); + } +} diff --git a/src/N98/Magento/Command/Cache/CacheCommandReinitInterface.php b/src/N98/Magento/Command/Cache/CacheCommandReinitInterface.php deleted file mode 100644 index 097e95dab..000000000 --- a/src/N98/Magento/Command/Cache/CacheCommandReinitInterface.php +++ /dev/null @@ -1,14 +0,0 @@ - Date: Wed, 12 Jun 2024 12:24:09 +0200 Subject: [PATCH 059/136] [skip ci] Updated cache:clean command --- src/N98/Magento/Command/Cache/CleanCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/N98/Magento/Command/Cache/CleanCommand.php b/src/N98/Magento/Command/Cache/CleanCommand.php index 7ea822777..9ff3f9fb0 100644 --- a/src/N98/Magento/Command/Cache/CleanCommand.php +++ b/src/N98/Magento/Command/Cache/CleanCommand.php @@ -17,7 +17,7 @@ * * @package N98\Magento\Command\Cache */ -class CleanCommand extends AbstractCacheCommand implements CacheCommandReinitInterface +class CleanCommand extends AbstractCacheCommandReinit { public const COMMAND_ARGUMENT_TYPE = 'type'; From 8018d176d409397a7c9e5fc6f7d6453e42fc866c Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 12 Jun 2024 12:49:54 +0200 Subject: [PATCH 060/136] [skip ci] Updated cache:... commands --- .../Command/Cache/AbstractCacheCommand.php | 100 +---------------- .../Cache/AbstractCacheCommandToggle.php | 101 ++++++++++++++++++ .../Magento/Command/Cache/DisableCommand.php | 44 +++----- .../Magento/Command/Cache/EnableCommand.php | 37 ++----- 4 files changed, 124 insertions(+), 158 deletions(-) create mode 100644 src/N98/Magento/Command/Cache/AbstractCacheCommandToggle.php diff --git a/src/N98/Magento/Command/Cache/AbstractCacheCommand.php b/src/N98/Magento/Command/Cache/AbstractCacheCommand.php index 125bde52c..bef36bed9 100644 --- a/src/N98/Magento/Command/Cache/AbstractCacheCommand.php +++ b/src/N98/Magento/Command/Cache/AbstractCacheCommand.php @@ -9,8 +9,6 @@ use Mage_Core_Model_Cache; use N98\Magento\Command\AbstractMagentoCommand; use RuntimeException; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Zend_Cache_Core; @@ -19,46 +17,10 @@ * * @package N98\Magento\Command\Cache */ -class AbstractCacheCommand extends AbstractMagentoCommand +abstract class AbstractCacheCommand extends AbstractMagentoCommand { - public const COMMAND_ARGUMENT_CODE = 'code'; - public const COMMAND_OPTION_FPC = 'fpc'; - public const COMMAND_OPTION_REINIT = 'reinit'; - - public const COMMAND_OPTION_NO_REINIT = 'no-reinit'; - - protected function configure(): void - { - if ($this instanceof CacheCommandToggleInterface) { - $this - ->addArgument( - self::COMMAND_ARGUMENT_CODE, - InputArgument::OPTIONAL, - 'Code of cache (Multiple codes operated by comma)' - ); - } - - if ($this instanceof CacheCommandReinitInterface) { - $this - ->addOption( - self::COMMAND_OPTION_REINIT, - null, - InputOption::VALUE_NONE, - 'Reinitialise the config cache after cleaning or flushing.' - ) - ->addOption( - self::COMMAND_OPTION_NO_REINIT, - null, - InputOption::VALUE_NONE, - "Don't reinitialise the config cache after cleaning or flushing." - ); - } - - parent::configure(); - } - /** * @return Mage_Core_Model_Cache * @@ -85,29 +47,6 @@ protected function getCacheInstance(InputInterface $input): Zend_Cache_Core return $this->_getMage()->getCache(); } - /** - * @param string[] $codeArgument - * @param bool $status - * @return void - */ - protected function saveCacheStatus(array $codeArgument, bool $status): void - { - $this->validateCacheCodes($codeArgument); - - $cacheTypes = $this->_getCacheModel()->getTypes(); - $enable = $this->_getMage()->useCache(); - - if (is_array($enable)) { - foreach ($cacheTypes as $cacheCode => $cacheModel) { - if (empty($codeArgument) || in_array($cacheCode, $codeArgument)) { - $enable[$cacheCode] = $status ? 1 : 0; - } - } - - $this->_getMage()->saveUseCache($enable); - } - } - /** * @param string[] $codes * @throws InvalidArgumentException @@ -121,41 +60,4 @@ protected function validateCacheCodes(array $codes): void } } } - - /** - * Ban cache usage before cleanup to get the latest values. - * - * @see https://github.com/netz98/n98-magerun/issues/483 - */ - protected function banUseCache(): void - { - if (!$this->_canUseBanCacheFunction()) { - return; - } - - $config = $this->getApplication()->getConfig(); - if (empty($config['init']['options'])) { - $config['init']['options'] = ['global_ban_use_cache' => true]; - $this->getApplication()->setConfig($config); - } - } - - protected function reinitCache(): void - { - if (!$this->_canUseBanCacheFunction()) { - return; - } - - $this->_getMage()->getConfig()->getOptions()->setData('global_ban_use_cache', false); - $this->_getMage()->getConfig()->reinit(); - } - - /** - * @return bool - */ - protected function _canUseBanCacheFunction(): bool - { - // @phpstan-ignore function.alreadyNarrowedType (Phpstan Bleeding edge only) - return method_exists('\Mage_Core_Model_App', 'baseInit'); - } } diff --git a/src/N98/Magento/Command/Cache/AbstractCacheCommandToggle.php b/src/N98/Magento/Command/Cache/AbstractCacheCommandToggle.php new file mode 100644 index 000000000..daa2b01c8 --- /dev/null +++ b/src/N98/Magento/Command/Cache/AbstractCacheCommandToggle.php @@ -0,0 +1,101 @@ +addArgument( + self::COMMAND_ARGUMENT_CODE, + InputArgument::OPTIONAL, + 'Code of cache (Multiple codes operated by comma)' + ); + + parent::configure(); + } + + + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return int + */ + protected function execute(InputInterface $input, OutputInterface $output): int + { + $this->detectMagento($output); + $this->initMagento(); + + $codeArgument = BinaryString::trimExplodeEmpty(',', $input->getArgument(self::COMMAND_ARGUMENT_CODE)); + $this->saveCacheStatus($codeArgument, static::$cacheStatus); + + if (static::$cacheStatus === false) { + if (empty($codeArgument)) { + $this->_getCacheModel()->flush(); + } else { + foreach ($codeArgument as $type) { + $this->_getCacheModel()->cleanType($type); + } + } + } + + if (count($codeArgument) > 0) { + foreach ($codeArgument as $code) { + $output->writeln(sprintf('Cache %s %s', $code, static::$toggleName)); + } + } else { + $output->writeln(sprintf('Caches %s', static::$toggleName)); + } + + return Command::SUCCESS; + } + + /** + * @param string[] $codeArgument + * @param bool $status + * @return void + */ + protected function saveCacheStatus(array $codeArgument, bool $status): void + { + $this->validateCacheCodes($codeArgument); + + $cacheTypes = $this->_getCacheModel()->getTypes(); + $enable = $this->_getMage()->useCache(); + + if (is_array($enable)) { + foreach ($cacheTypes as $cacheCode => $cacheModel) { + if (empty($codeArgument) || in_array($cacheCode, $codeArgument)) { + $enable[$cacheCode] = $status ? 1 : 0; + } + } + + $this->_getMage()->saveUseCache($enable); + } + } +} diff --git a/src/N98/Magento/Command/Cache/DisableCommand.php b/src/N98/Magento/Command/Cache/DisableCommand.php index 4f851f852..6cf5bc57e 100644 --- a/src/N98/Magento/Command/Cache/DisableCommand.php +++ b/src/N98/Magento/Command/Cache/DisableCommand.php @@ -4,12 +4,14 @@ namespace N98\Magento\Command\Cache; -use N98\Util\BinaryString; use Symfony\Component\Console\Attribute\AsCommand; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -class DisableCommand extends AbstractCacheCommand +/** + * Disable cache command + * + * @package N98\Magento\Command\Cache + */ +class DisableCommand extends AbstractCacheCommandToggle { /** * @var string @@ -26,34 +28,12 @@ class DisableCommand extends AbstractCacheCommand protected static $defaultDescription = 'Disables caches.'; /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int + * @var bool */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->detectMagento($output, true); - $this->initMagento(); + protected static bool $cacheStatus = false; - $codeArgument = BinaryString::trimExplodeEmpty(',', $input->getArgument(self::COMMAND_ARGUMENT_CODE)); - $this->saveCacheStatus($codeArgument, false); - - if (empty($codeArgument)) { - $this->_getCacheModel()->flush(); - } else { - foreach ($codeArgument as $type) { - $this->_getCacheModel()->cleanType($type); - } - } - - if (count($codeArgument) > 0) { - foreach ($codeArgument as $code) { - $output->writeln('Cache ' . $code . ' disabled'); - } - } else { - $output->writeln('Caches disabled'); - } - return 0; - } + /** + * @var string + */ + protected static string $toggleName = 'disabled'; } diff --git a/src/N98/Magento/Command/Cache/EnableCommand.php b/src/N98/Magento/Command/Cache/EnableCommand.php index f04d43c1c..aae204513 100644 --- a/src/N98/Magento/Command/Cache/EnableCommand.php +++ b/src/N98/Magento/Command/Cache/EnableCommand.php @@ -4,17 +4,14 @@ namespace N98\Magento\Command\Cache; -use N98\Util\BinaryString; use Symfony\Component\Console\Attribute\AsCommand; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; /** - * View cache command + * Enable cache command * * @package N98\Magento\Command\Cache */ -class EnableCommand extends AbstractCacheCommand +class EnableCommand extends AbstractCacheCommandToggle { /** * @var string @@ -31,27 +28,13 @@ class EnableCommand extends AbstractCacheCommand protected static $defaultDescription = 'Enables caches.'; /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int + * @var bool */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->detectMagento($output, true); - $this->initMagento(); - - $codeArgument = BinaryString::trimExplodeEmpty(',', $input->getArgument(self::COMMAND_ARGUMENT_CODE)); - $this->saveCacheStatus($codeArgument, true); - - if ($codeArgument !== []) { - foreach ($codeArgument as $code) { - $output->writeln('Cache ' . $code . ' enabled'); - } - } else { - $output->writeln('Caches enabled'); - } - - return 0; - } + protected static bool $cacheStatus = true; + + + /** + * @var string + */ + protected static string $toggleName = 'enabled'; } From df2cd4bdf3b1128260f8c1ef75174c81bf7e3f52 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 12 Jun 2024 12:54:21 +0200 Subject: [PATCH 061/136] [skip ci] Updated cms:block:toggle command --- src/N98/Magento/Command/Cms/Block/ToggleCommand.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/N98/Magento/Command/Cms/Block/ToggleCommand.php b/src/N98/Magento/Command/Cms/Block/ToggleCommand.php index 5969e32ae..66f2fe9a7 100644 --- a/src/N98/Magento/Command/Cms/Block/ToggleCommand.php +++ b/src/N98/Magento/Command/Cms/Block/ToggleCommand.php @@ -39,7 +39,7 @@ class ToggleCommand extends AbstractCmsBlockCommand /** * @return void */ - protected function configure() + protected function configure(): void { $this->addArgument( self::COMMAND_ARGUMENT_BLOCK_ID, @@ -59,9 +59,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->writeSection($output, static::COMMAND_SECTION_TITLE_TEXT); $this->detectMagento($output); - if (!$this->initMagento()) { - return Command::FAILURE; - } + $this->initMagento(); $blockId = $input->getArgument(self::COMMAND_ARGUMENT_BLOCK_ID); $block = $this->_getBlockModel()->load($blockId, is_numeric($blockId) ? null : 'identifier'); From 8d67f1d0fead25d9fd9b4fc5aa12312894309061 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 12 Jun 2024 13:05:49 +0200 Subject: [PATCH 062/136] [skip ci] Updated cms:... commands --- src/N98/Magento/Command/Cms/Banner/ToggleCommand.php | 11 +++++------ src/N98/Magento/Command/Cms/Block/ToggleCommand.php | 1 + src/N98/Magento/Command/Cms/Page/PublishCommand.php | 12 +++++++----- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/N98/Magento/Command/Cms/Banner/ToggleCommand.php b/src/N98/Magento/Command/Cms/Banner/ToggleCommand.php index 9381f28de..376efd183 100644 --- a/src/N98/Magento/Command/Cms/Banner/ToggleCommand.php +++ b/src/N98/Magento/Command/Cms/Banner/ToggleCommand.php @@ -2,6 +2,7 @@ namespace N98\Magento\Command\Cms\Banner; +use Enterprise_Banner_Model_Banner; use N98\Magento\Command\AbstractMagentoCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -17,7 +18,7 @@ */ class ToggleCommand extends AbstractMagentoCommand { - protected function configure() + protected function configure(): void { $this ->setName('cms:banner:toggle') @@ -35,11 +36,11 @@ public function isEnabled() } /** - * @return \Enterprise_Banner_Model_Banner + * @return Enterprise_Banner_Model_Banner */ protected function _getBannerModel() { - return $this->_getModel('enterprise_banner/banner', '\Enterprise_Banner_Model_Banner'); + return $this->_getModel('enterprise_banner/banner'); } /** @@ -52,9 +53,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output, true); $this->requireEnterprise($output); - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); $this->writeSection($output, 'Banner Toggle'); $bannerId = $input->getArgument('banner_id'); diff --git a/src/N98/Magento/Command/Cms/Block/ToggleCommand.php b/src/N98/Magento/Command/Cms/Block/ToggleCommand.php index 66f2fe9a7..2b911928b 100644 --- a/src/N98/Magento/Command/Cms/Block/ToggleCommand.php +++ b/src/N98/Magento/Command/Cms/Block/ToggleCommand.php @@ -61,6 +61,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->detectMagento($output); $this->initMagento(); + /** @var string $blockId */ $blockId = $input->getArgument(self::COMMAND_ARGUMENT_BLOCK_ID); $block = $this->_getBlockModel()->load($blockId, is_numeric($blockId) ? null : 'identifier'); diff --git a/src/N98/Magento/Command/Cms/Page/PublishCommand.php b/src/N98/Magento/Command/Cms/Page/PublishCommand.php index 66ca3e9be..8658ac183 100644 --- a/src/N98/Magento/Command/Cms/Page/PublishCommand.php +++ b/src/N98/Magento/Command/Cms/Page/PublishCommand.php @@ -2,6 +2,8 @@ namespace N98\Magento\Command\Cms\Page; +use Enterprise_Cms_Model_Page_Revision; +use Mage_Cms_Model_Page; use N98\Magento\Command\AbstractMagentoCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -17,7 +19,7 @@ */ class PublishCommand extends AbstractMagentoCommand { - protected function configure() + protected function configure(): void { $this ->setName('cms:page:publish') @@ -39,19 +41,19 @@ public function isEnabled() } /** - * @return \Mage_Cms_Model_Page + * @return Mage_Cms_Model_Page */ protected function _getPageModel() { - return $this->_getModel('cms/page', 'Mage_Cms_Model_Page'); + return $this->_getModel('cms/page'); } /** - * @return \Enterprise_Cms_Model_Page_Revision + * @return Enterprise_Cms_Model_Page_Revision */ protected function _getPageRevisionModel() { - return $this->_getModel('enterprise_cms/page_revision', '\Enterprise_Cms_Model_Page_Revision'); + return $this->_getModel('enterprise_cms/page_revision'); } /** From 3500ebd95b126cf09b3eb7a2966233e2d3f6b020 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 12 Jun 2024 13:28:27 +0200 Subject: [PATCH 063/136] [skip ci] Updated media:dump command --- src/N98/Magento/Command/Media/DumpCommand.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/N98/Magento/Command/Media/DumpCommand.php b/src/N98/Magento/Command/Media/DumpCommand.php index bb5953fe3..060e4ad95 100644 --- a/src/N98/Magento/Command/Media/DumpCommand.php +++ b/src/N98/Magento/Command/Media/DumpCommand.php @@ -24,8 +24,9 @@ */ class DumpCommand extends AbstractMagentoCommand { - private const COMMAND_ARGUMENT_FILENAME = 'filename'; - private const COMMAND_OPTION_STRIP = 'strip'; + public const COMMAND_ARGUMENT_FILENAME = 'filename'; + + public const COMMAND_OPTION_STRIP = 'strip'; /** * @var string @@ -93,6 +94,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $finder->exclude($commandConfig['strip']['folders']); } + /** @var string $filename */ $filename = $input->getArgument(self::COMMAND_ARGUMENT_FILENAME); if (is_dir($filename)) { // support for dot dir $filename = realpath($filename); From 6166423bb913d441c61ea6d0485ee1e6375d5fd0 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 12 Jun 2024 13:45:07 +0200 Subject: [PATCH 064/136] [skip ci] Updated db:variables command --- .../Command/Database/VariablesCommand.php | 78 +++++++++++++++---- 1 file changed, 63 insertions(+), 15 deletions(-) diff --git a/src/N98/Magento/Command/Database/VariablesCommand.php b/src/N98/Magento/Command/Database/VariablesCommand.php index eab485c3b..7e004926b 100644 --- a/src/N98/Magento/Command/Database/VariablesCommand.php +++ b/src/N98/Magento/Command/Database/VariablesCommand.php @@ -1,42 +1,90 @@ recommended size (but this value must be calculated depending on the server size * @see https://launchpadlibrarian.net/78745738/tuning-primer.sh convert that to PHP ... ? * http://www.slideshare.net/shinguz/mysql-configuration-the-most-important-variables GERMAN * @var array */ - protected $_importantVars = ['have_query_cache' => '', 'innodb_additional_mem_pool_size' => '', 'innodb_buffer_pool_size' => '', 'innodb_log_buffer_size' => '', 'innodb_log_file_size' => '', 'innodb_thread_concurrency' => '', 'join_buffer_size' => '', 'key_buffer_size' => '', 'max_allowed_packet' => '', 'max_connections' => '', 'max_heap_table_size' => '', 'open_files_limit' => '', 'query_cache_size' => '', 'query_cache_type' => '', 'read_rnd_buffer_size' => '', 'read_buffer_size' => '', 'sort_buffer_size' => '', 'table_definition_cache' => '', 'table_open_cache' => '', 'thread_cache_size' => '', 'tmp_table_size' => [ + protected array $_importantVars = [ + 'have_query_cache' => '', + 'innodb_additional_mem_pool_size' => '', + 'innodb_buffer_pool_size' => '', + 'innodb_log_buffer_size' => '', + 'innodb_log_file_size' => '', + 'innodb_thread_concurrency' => '', + 'join_buffer_size' => '', + 'key_buffer_size' => '', + 'max_allowed_packet' => '', + 'max_connections' => '', + 'max_heap_table_size' => '', + 'open_files_limit' => '', + 'query_cache_size' => '', + 'query_cache_type' => '', + 'read_rnd_buffer_size' => '', + 'read_buffer_size' => '', + 'sort_buffer_size' => '', + 'table_definition_cache' => '', + 'table_open_cache' => '', + 'thread_cache_size' => '', + 'tmp_table_size' => [ 'desc' => '', - // @todo add description everywhere - 'opt' => '', - ]]; + // @todo add description everywhere + 'opt' => '', + ] + ]; - protected function configure() + /** + * @return string + */ + public function getHelp(): string { - parent::configure(); - $this - ->setName('db:variables') - ->setDescription('Shows important variables or custom selected'); - - $help = <<setHelp($help); } /** * @param string $name - * * @return bool */ - protected function allowRounding($name) + protected function allowRounding(string $name): bool { - $toHuman = ['max_length_for_sort_data' => 1, 'max_allowed_packet' => 1, 'max_seeks_for_key' => 1, 'max_write_lock_count' => 1, 'slave_max_allowed_packet' => 1]; + $toHuman = [ + 'max_length_for_sort_data' => 1, + 'max_allowed_packet' => 1, + 'max_seeks_for_key' => 1, + 'max_write_lock_count' => 1, + 'slave_max_allowed_packet' => 1 + ]; + $isSize = false !== strpos($name, '_size'); return $isSize || isset($toHuman[$name]); From eb43511fb53c6d310d4d189815f1df9cea101bb1 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 12 Jun 2024 13:48:03 +0200 Subject: [PATCH 065/136] [skip ci] Updated db:status command --- .../Command/Database/StatusCommand.php | 79 +++++++++++++++---- 1 file changed, 62 insertions(+), 17 deletions(-) diff --git a/src/N98/Magento/Command/Database/StatusCommand.php b/src/N98/Magento/Command/Database/StatusCommand.php index 2e77efe2f..af1d18497 100644 --- a/src/N98/Magento/Command/Database/StatusCommand.php +++ b/src/N98/Magento/Command/Database/StatusCommand.php @@ -3,6 +3,7 @@ namespace N98\Magento\Command\Database; use DateTime; +use Exception; class StatusCommand extends AbstractShowCommand { @@ -13,18 +14,58 @@ class StatusCommand extends AbstractShowCommand * * @var array */ - protected $_importantVars = ['Threads_connected' => ['desc' => 'Total number of clients that have currently open connections to the server.'], 'Created_tmp_disk_tables' => ['desc' => 'Number of temporary tables that have been created on disk instead of in-memory. Lower is - better.'], 'Handler_read_first' => ['desc' => 'Number of times a table handler made a request to read the first row of a table index.'], 'Handler_read_rnd_next' => ['desc' => 'Number of requests to read the next row in the data file. This value is high if you + protected array $_importantVars = [ + 'Threads_connected' => [ + 'desc' => 'Total number of clients that have currently open connections to the server.' + ], + 'Created_tmp_disk_tables' => [ + 'desc' => 'Number of temporary tables that have been created on disk instead of in-memory. Lower is better.' + ], + 'Handler_read_first' => [ + 'desc' => 'Number of times a table handler made a request to read the first row of a table index.' + ], + 'Handler_read_rnd_next' => [ + 'desc' => 'Number of requests to read the next row in the data file. This value is high if you are doing a lot of table scans. Generally this suggests that your tables are not properly indexed or - that your queries are not written to take advantage of the indexes you have.'], 'Innodb_buffer_pool_wait_free' => ['desc' => 'Number of times MySQL has to wait for memory pages to be flushed.'], 'Innodb_buffer_pool_pages_dirty' => ['desc' => 'Indicates the number of InnoDB buffer pool data pages that have been changed in memory, - but the changes are not yet written (flushed) to the InnoDB data files'], 'Key_reads' => ['desc' => 'Number of filesystem accesses MySQL performed to fetch database indexes.'], 'Max_used_connections' => ['desc' => 'Max number of connections MySQL has had open at the same time since the server was - last restarted.'], 'Open_tables' => ['desc' => 'Number of tables that are currently open.'], 'Select_full_join' => ['desc' => 'Number of full joins MySQL has performed to satisfy client queries.'], 'Slow_queries' => ['desc' => 'Number of queries that have taken longer than usual to execute.'], 'Uptime' => ['desc' => 'Time since the server was last restarted.'], 'Aborted_connects' => ['desc' => 'Total number of failed attempts to connect to MySQL.']]; + that your queries are not written to take advantage of the indexes you have.' + ], + 'Innodb_buffer_pool_wait_free' => [ + 'desc' => 'Number of times MySQL has to wait for memory pages to be flushed.' + ], + 'Innodb_buffer_pool_pages_dirty' => [ + 'desc' => 'Indicates the number of InnoDB buffer pool data pages that have been changed in memory, + but the changes are not yet written (flushed) to the InnoDB data files' + ], + 'Key_reads' => [ + 'desc' => 'Number of filesystem accesses MySQL performed to fetch database indexes.' + ], + 'Max_used_connections' => [ + 'desc' => 'Max number of connections MySQL has had open at the same time since the server was + last restarted.' + ], + 'Open_tables' => [ + 'desc' => 'Number of tables that are currently open.' + ], + 'Select_full_join' => [ + 'desc' => 'Number of full joins MySQL has performed to satisfy client queries.' + ], + 'Slow_queries' => [ + 'desc' => 'Number of queries that have taken longer than usual to execute.' + ], + 'Uptime' => [ + 'desc' => 'Time since the server was last restarted.' + ], + 'Aborted_connects' => [ + 'desc' => 'Total number of failed attempts to connect to MySQL.' + ] + ]; + /** * @var array */ - protected $_specialFormat = ['Uptime' => 'timeElapsedString']; + protected array $_specialFormat = ['Uptime' => 'timeElapsedString']; - protected function configure() + protected function configure(): void { parent::configure(); $this @@ -40,10 +81,9 @@ protected function configure() /** * @param array $outputVars * @param bool $hasDescription - * * @return array */ - protected function generateRows(array $outputVars, $hasDescription) + protected function generateRows(array $outputVars, bool $hasDescription): array { $rows = parent::generateRows($outputVars, $hasDescription); @@ -87,14 +127,11 @@ protected function generateRows(array $outputVars, $hasDescription) /** * @param string $name - * * @return bool */ - protected function allowRounding($name) + protected function allowRounding(string $name): bool { - $isSize = false !== strpos($name, '_size'); - - return $isSize; + return false !== strpos($name, '_size'); } /** @@ -106,10 +143,10 @@ protected function allowRounding($name) * * @param $datetime * @param bool $full - * * @return string + * @throws Exception */ - protected function timeElapsedString($datetime, $full = false) + protected function timeElapsedString($datetime, bool $full = false): string { if (is_numeric($datetime)) { $datetime = time() - $datetime; @@ -123,7 +160,15 @@ protected function timeElapsedString($datetime, $full = false) $diff->w = floor($diff->d / 7); $diff->d -= $diff->w * 7; - $string = ['y' => 'year', 'm' => 'month', 'w' => 'week', 'd' => 'day', 'h' => 'hour', 'i' => 'minute', 's' => 'second']; + $string = [ + 'y' => 'year', + 'm' => 'month', + 'w' => 'week', + 'd' => 'day', + 'h' => 'hour', + 'i' => 'minute', + 's' => 'second' + ]; foreach ($string as $k => &$v) { if ($diff->$k) { $v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 's' : ''); From 7014192b473aff9ad540a65dfcead266ad614989 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 19 Jun 2024 14:05:41 +0200 Subject: [PATCH 066/136] [skip ci] Updated dev:module:observer:list command --- .../Developer/Module/Observer/ListCommand.php | 141 ++++++++++-------- 1 file changed, 78 insertions(+), 63 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Module/Observer/ListCommand.php b/src/N98/Magento/Command/Developer/Module/Observer/ListCommand.php index 76759e23a..cfd8a4086 100644 --- a/src/N98/Magento/Command/Developer/Module/Observer/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Observer/ListCommand.php @@ -1,99 +1,118 @@ setName('dev:module:observer:list') - ->addArgument('type', InputArgument::OPTIONAL, 'Observer type (global, admin, frontend, crontab)') - ->setDescription('Lists all registered observers') - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' + ->addArgument( + self::COMMAND_ARGUMENT_TYPE, + InputArgument::OPTIONAL, + 'Observer type (global, admin, frontend, crontab)' ) ->addOption( - 'sort', + self::COMMAND_OPTION_SORT, null, InputOption::VALUE_NONE, 'Sort by event name ascending' ); + + parent::configure(); } /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int + * {@inheritdoc} + * @return array> */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getData(InputInterface $input, OutputInterface $output): array { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + if (is_null($this->data)) { + $this->data = []; - $type = $input->getArgument('type'); + /** @var string $type */ + $type = $input->getArgument(self::COMMAND_ARGUMENT_TYPE); - $areas = ['global', 'adminhtml', 'frontend', 'crontab']; + $areas = ['global', 'adminhtml', 'frontend', 'crontab']; - if ($type === null) { - $type = $this->askForArrayEntry($areas, $input, $output, 'Please select an area:'); - } + if ($type === null) { + /** @var string $type */ + $type = $this->askForArrayEntry($areas, $input, $output, 'Please select an area:'); + } - if (!in_array($type, $areas)) { - throw new InvalidArgumentException('Invalid type! Use one of: ' . implode(', ', $areas)); - } + if (!in_array($type, $areas)) { + throw new InvalidArgumentException('Invalid type! Use one of: ' . implode(', ', $areas)); + } - if ($input->getOption('format') === null) { - $this->writeSection($output, 'Observers: ' . $type); - } - $frontendEvents = Mage::getConfig()->getNode($type . '/events')->asArray(); - if (true === $input->getOption('sort')) { - // sorting for Observers is a bad idea because the order in which observers will be called is important. - ksort($frontendEvents); - } - $table = []; - foreach ($frontendEvents as $eventName => $eventData) { - $observerList = []; - foreach ($eventData['observers'] as $observer) { - $observerList[] = $this->getObserver($observer, $type); + if ($input->getOption(parent::COMMAND_OPTION_FORMAT) === null) { + $this->writeSection($output, 'Observers: ' . $type); + } + + $frontendEvents = $this->_getMageConfigNode($type . '/events')->asArray(); + if (true === $input->getOption(self::COMMAND_OPTION_SORT)) { + // sorting for Observers is a bad idea because the order in which observers will be called is important. + ksort($frontendEvents); + } + + foreach ($frontendEvents as $eventName => $eventData) { + $observerList = []; + foreach ($eventData['observers'] as $observer) { + $observerList[] = $this->getObserver($observer, $type); + } + $this->data[] = [ + 'Event' => $eventName, + 'Observers' => implode("\n", $observerList) + ]; } - $table[] = [$eventName, implode("\n", $observerList)]; } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); - $tableHelper - ->setHeaders(['Event', 'Observers']) - ->setRows($table) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + return $this->data; } /** - * get observer string (list entry) + * Get observer string (list entry) * - * @param array $observer + * @param array $observer * @param string $area - * * @return string */ - protected function getObserver(array $observer, $area) + protected function getObserver(array $observer, string $area): string { $type = $this->getObserverType($observer, $area); @@ -106,18 +125,15 @@ protected function getObserver(array $observer, $area) $method = isset($observer['method']) ? '::' . $observer['method'] : ''; - $observer = $type . $class . $method; - - return $observer; + return $type . $class . $method; } /** - * @param array $observer + * @param array $observer * @param string $area - * * @return string */ - private function getObserverType(array $observer, $area) + private function getObserverType(array $observer, string $area): string { // singleton is the default type Mage_Core_Model_App::dispatchEvent $type = 'singleton'; @@ -129,8 +145,7 @@ private function getObserverType(array $observer, $area) if (isset($observer['type'])) { $type = $observer['type']; } - $type = str_pad($type, 11, ' ', STR_PAD_RIGHT); - return $type; + return str_pad($type, 11); } } From 76d5580d7204a69bae65a79b0df9d889313483c8 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 19 Jun 2024 14:39:55 +0200 Subject: [PATCH 067/136] [skip ci] Updated dev:module:disable/enable commands (phpstan) --- .../Module/Disableenable/AbstractCommand.php | 121 ++++++++++-------- .../Module/Disableenable/DisableCommand.php | 5 + .../Module/Disableenable/EnableCommand.php | 5 + 3 files changed, 80 insertions(+), 51 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Module/Disableenable/AbstractCommand.php b/src/N98/Magento/Command/Developer/Module/Disableenable/AbstractCommand.php index 5dfaa6964..528719c5c 100644 --- a/src/N98/Magento/Command/Developer/Module/Disableenable/AbstractCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Disableenable/AbstractCommand.php @@ -6,10 +6,8 @@ use Exception; use InvalidArgumentException; -use Mage; use Mage_Core_Model_Config; use N98\Magento\Command\AbstractMagentoCommand; -use RuntimeException; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -28,10 +26,15 @@ class AbstractCommand extends AbstractMagentoCommand public const COMMAND_OPTION_CODEPOOL = 'codepool'; + /** + * @var string + */ + protected string $commandName = ''; + /** * @var Mage_Core_Model_Config */ - protected $config; + protected Mage_Core_Model_Config $mageConfig; /** * @var string @@ -43,21 +46,19 @@ class AbstractCommand extends AbstractMagentoCommand * * @return void */ - protected function configure() + protected function configure(): void { - $action = $this->getCommandAction(); - $this ->addArgument( self::COMMAND_ARGUMENT_MODULE, InputArgument::OPTIONAL, - 'Name of module to ' . $action + 'Name of module to ' . $this->commandName ) ->addOption( self::COMMAND_OPTION_CODEPOOL, null, InputOption::VALUE_OPTIONAL, - 'Name of codePool to ' . $action + 'Name of codePool to ' . $this->commandName ) ; } @@ -75,24 +76,32 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output); - if (!$this->initMagento()) { - throw new RuntimeException('Application could not be loaded'); - } + $this->initMagento(); - $this->config = Mage::getConfig(); - $this->modulesDir = $this->config->getOptions()->getEtcDir() . DS . 'modules' . DS; + $this->mageConfig = $this->_getMageConfig(); + $this->modulesDir = $this->mageConfig->getOptions()->getEtcDir() . DS . 'modules' . DS; - if ($codePool = $input->getOption(self::COMMAND_OPTION_CODEPOOL)) { - $output->writeln('' . ($this->getCommandAction() == 'enable' ? 'Enabling' : 'Disabling') . + /** @var string $codePool */ + $codePool = $input->getOption(self::COMMAND_OPTION_CODEPOOL); + if ($codePool) { + $output->writeln('' . ($this->commandName == 'enable' ? 'Enabling' : 'Disabling') . ' modules in ' . $codePool . ' codePool...'); $this->enableCodePool($codePool, $output); - } elseif ($module = $input->getArgument(self::COMMAND_ARGUMENT_MODULE)) { + + return Command::SUCCESS; + } + + /** @var string $module */ + $module = $input->getArgument(self::COMMAND_ARGUMENT_MODULE); + if ($module) { + $output->writeln('' . ($this->commandName == 'enable' ? 'Enabling' : 'Disabling') . + ' module ' . $module . ''); $this->enableModule($module, $output); - } else { - throw new InvalidArgumentException('No code-pool option nor module-name argument'); + + return Command::SUCCESS; } - return Command::SUCCESS; + throw new InvalidArgumentException('No code-pool option nor module-name argument'); } /** @@ -104,10 +113,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int */ protected function enableCodePool(string $codePool, OutputInterface $output): void { - $modules = $this->config->getNode('modules')->asArray(); - foreach ($modules as $module => $data) { - if (isset($data['codePool']) && $data['codePool'] == $codePool) { - $this->enableModule($module, $output); + $modules = $this->mageConfig->getNode('modules'); + if ($modules) { + foreach ($modules->asArray() as $module => $data) { + if (isset($data['codePool']) && $data['codePool'] == $codePool) { + $this->enableModule($module, $output); + } } } } @@ -124,23 +135,36 @@ protected function enableModule(string $module, OutputInterface $output): void $xml = null; $validDecFile = false; foreach ($this->getDeclaredModuleFiles() as $decFile) { - $xml = new Varien_Simplexml_Element(file_get_contents($decFile)); - if ($xml->modules->{$module}) { - $validDecFile = $decFile; - break; + $content = file_get_contents($decFile); + if ($content) { + $xml = new Varien_Simplexml_Element($content); + if ($xml->modules->{$module}) { + $validDecFile = $decFile; + break; + } } } if (!$validDecFile) { - $msg = sprintf('%s: Couldn\'t find declaration file', $module); + $msg = sprintf( + '%s: Couldn\'t find declaration file', + $module + ); } elseif (!is_writable($validDecFile)) { - $msg = sprintf('%s: Can\'t write to declaration file', $module); + $msg = sprintf( + '%s: Can\'t write to declaration file', + $module + ); } else { - $setTo = $this->getCommandAction() == 'enable' ? 'true' : 'false'; - if ((string) $xml->modules->{$module}->active != $setTo) { + $setTo = $this->commandName == 'enable' ? 'true' : 'false'; + if ($xml && (string) $xml->modules->{$module}->active != $setTo) { $xml->modules->{$module}->active = $setTo; if (file_put_contents($validDecFile, $xml->asXML()) !== false) { - $msg = sprintf('%s: %sd', $module, $this->getCommandAction()); + $msg = sprintf( + '%s: %sd', + $module, + $this->commandName + ); } else { $msg = sprintf( '%s: Failed to update declaration file [%s]', @@ -149,7 +173,7 @@ protected function enableModule(string $module, OutputInterface $output): void ); } } else { - $msg = sprintf('%s: already %sd', $module, $this->getCommandAction()); + $msg = sprintf('%s: already %sd', $module, $this->commandName); } } @@ -160,7 +184,7 @@ protected function enableModule(string $module, OutputInterface $output): void * Load module files in the opposite order to core Magento, so that we find the last loaded declaration * of a module first. * - * @return array + * @return array */ protected function getDeclaredModuleFiles(): array { @@ -170,16 +194,19 @@ protected function getDeclaredModuleFiles(): array 'custom' => [] ]; - foreach (glob($this->modulesDir . '*.xml') as $v) { - $name = explode(DIRECTORY_SEPARATOR, $v); - $name = substr($name[count($name) - 1], 0, -4); + $moduleDirs = glob($this->modulesDir . '*.xml'); + if ($moduleDirs) { + foreach ($moduleDirs as $v) { + $name = explode(DIRECTORY_SEPARATOR, $v); + $name = substr($name[count($name) - 1], 0, -4); - if ($name == 'Mage_All') { - $collectModuleFiles['base'][] = $v; - } elseif (substr($name, 0, 5) == 'Mage_') { - $collectModuleFiles['mage'][] = $v; - } else { - $collectModuleFiles['custom'][] = $v; + if ($name == 'Mage_All') { + $collectModuleFiles['base'][] = $v; + } elseif (substr($name, 0, 5) == 'Mage_') { + $collectModuleFiles['mage'][] = $v; + } else { + $collectModuleFiles['custom'][] = $v; + } } } @@ -189,12 +216,4 @@ protected function getDeclaredModuleFiles(): array $collectModuleFiles['custom'] )); } - - /** - * @return string - */ - protected function getCommandAction(): string - { - return substr(static::$defaultName, strrpos(static::$defaultName, ':') + 1); - } } diff --git a/src/N98/Magento/Command/Developer/Module/Disableenable/DisableCommand.php b/src/N98/Magento/Command/Developer/Module/Disableenable/DisableCommand.php index 281cd72f6..da549a6b7 100644 --- a/src/N98/Magento/Command/Developer/Module/Disableenable/DisableCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Disableenable/DisableCommand.php @@ -26,4 +26,9 @@ class DisableCommand extends AbstractCommand * @see AsCommand */ protected static $defaultDescription = 'Disables a module or all modules in codePool.'; + + /** + * @var string + */ + protected string $commandName = 'enable'; } diff --git a/src/N98/Magento/Command/Developer/Module/Disableenable/EnableCommand.php b/src/N98/Magento/Command/Developer/Module/Disableenable/EnableCommand.php index f5d46467c..dafcceec2 100644 --- a/src/N98/Magento/Command/Developer/Module/Disableenable/EnableCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Disableenable/EnableCommand.php @@ -26,4 +26,9 @@ class EnableCommand extends AbstractCommand * @see AsCommand */ protected static $defaultDescription = 'Enables a module or all modules in codePool.'; + + /** + * @var string + */ + protected string $commandName = 'enable'; } From fc53547a438a62d4e65bcd8890d29f713f84aeb4 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 19 Jun 2024 15:06:56 +0200 Subject: [PATCH 068/136] [skip ci] Updated dev:class:lookup command --- .../Command/Developer/ClassLookupCommand.php | 74 +++++++++++++------ 1 file changed, 50 insertions(+), 24 deletions(-) diff --git a/src/N98/Magento/Command/Developer/ClassLookupCommand.php b/src/N98/Magento/Command/Developer/ClassLookupCommand.php index 20126eb5a..6e1fc69af 100644 --- a/src/N98/Magento/Command/Developer/ClassLookupCommand.php +++ b/src/N98/Magento/Command/Developer/ClassLookupCommand.php @@ -1,58 +1,84 @@ setName('dev:class:lookup') - ->setDescription('Resolves a grouped class name') - ->addArgument('type', InputArgument::REQUIRED, 'The type of the class (helper|block|model)') - ->addArgument('name', InputArgument::REQUIRED, 'The grouped class name') - ; - } + public const COMMAND_ARGUMENT_TYPE = 'type'; + + public const COMMAND_ARGUMENT_NAME = 'name'; + + + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultName = 'dev:class:lookup'; /** - * @return \Mage_Core_Model_Config + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand */ - protected function _getConfig() + protected static $defaultDescription = 'Resolves a grouped class name.'; + + protected function configure(): void { - return Mage::getConfig(); + $this + ->addArgument( + self::COMMAND_ARGUMENT_TYPE, + InputArgument::REQUIRED, + 'The type of the class (helper|block|model)' + ) + ->addArgument( + self::COMMAND_ARGUMENT_NAME, + InputArgument::REQUIRED, + 'The grouped class name' + ) + ; } /** * @param InputInterface $input * @param OutputInterface $output - * * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + $this->detectMagento($output); + $this->initMagento(); + + /** @var string $type */ + $type = $input->getArgument(self::COMMAND_ARGUMENT_TYPE); + /** @var string $name */ + $name = $input->getArgument(self::COMMAND_ARGUMENT_NAME); + + $resolved = $this->_getMageConfig()->getGroupedClassName($type, $name); - $resolved = $this->_getConfig()->getGroupedClassName( - $input->getArgument('type'), - $input->getArgument('name') - ); $output->writeln( - ucfirst($input->getArgument('type')) . ' ' . $input->getArgument('name') . " " . + ucfirst($type) . ' ' . $name . " " . "resolves to " . $resolved . '' ); if (!class_exists('\\' . $resolved)) { $output->writeln('Note: Class ' . $resolved . ' does not exist!'); } - return 0; + + return Command::SUCCESS; } } From a4b7dba0fe11a3d6364983f11d2ff5fa7a5ff218 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 19 Jun 2024 15:31:29 +0200 Subject: [PATCH 069/136] [skip ci] Updated dev:module:rewrite:list command --- .../Developer/Module/Rewrite/ListCommand.php | 90 +++++++++---------- 1 file changed, 44 insertions(+), 46 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php b/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php index 7dbfc1268..3687bffcf 100644 --- a/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php @@ -1,66 +1,64 @@ setName('dev:module:rewrite:list') - ->setDescription('Lists all magento rewrites') - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' - ) - ; - } + protected const COMMAND_SECTION_TITLE_TEXT = 'Rewrites'; + + protected const NO_DATA_MESSAGE = 'No rewrites were found.'; + + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultName = 'dev:module:rewrite:list'; /** - * @param InputInterface $input - * @param OutputInterface $output + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultDescription = 'Lists all rewrites.'; + + /** + * {@inheritdoc} + * @return array> * - * @return int + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getData(InputInterface $input, OutputInterface $output): array { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + if (is_null($this->data)) { + $this->data = []; - $rewrites = array_merge($this->loadRewrites(), $this->loadAutoloaderRewrites()); - - $table = []; - foreach ($rewrites as $type => $data) { - if ((is_countable($data) ? count($data) : 0) > 0) { - foreach ($data as $class => $rewriteClass) { - $table[] = [$type, $class, implode(', ', $rewriteClass)]; + $rewrites = array_merge($this->loadRewrites(), $this->loadAutoloaderRewrites()); + foreach ($rewrites as $type => $data) { + if ((is_countable($data) ? count($data) : 0) > 0) { + foreach ($data as $class => $rewriteClass) { + $this->data[] = [ + 'Type' => $type, + 'Class' => $class, + 'Rewrite' => implode(', ', $rewriteClass) + ]; + } } } } - if (count($table) === 0 && $input->getOption('format') === null) { - $output->writeln('No rewrites were found.'); - } else { - if (count($table) == 0) { - $table = []; - } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); - $tableHelper - ->setHeaders(['Type', 'Class', 'Rewrite']) - ->setRows($table) - ->renderByFormat($output, $table, $input->getOption('format')); - } - return 0; + return $this->data; } } From 76fceb6bf23ab56a2ec886f6fdf7703bcbde82e6 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 19 Jun 2024 16:08:35 +0200 Subject: [PATCH 070/136] [skip ci] Removed EE MView indexer commands --- config.yaml | 2 - .../Command/Developer/ClassLookupCommand.php | 1 - .../Indexer/AbstractMviewIndexerCommand.php | 55 ------------ .../Command/Indexer/ListMviewCommand.php | 87 ------------------- .../Command/Indexer/ReindexMviewCommand.php | 62 ------------- 5 files changed, 207 deletions(-) delete mode 100644 src/N98/Magento/Command/Indexer/AbstractMviewIndexerCommand.php delete mode 100644 src/N98/Magento/Command/Indexer/ListMviewCommand.php delete mode 100644 src/N98/Magento/Command/Indexer/ReindexMviewCommand.php diff --git a/config.yaml b/config.yaml index 3966ba11f..229301153 100644 --- a/config.yaml +++ b/config.yaml @@ -132,9 +132,7 @@ commands: - N98\Magento\Command\GiftCard\RemoveCommand - N98\Magento\Command\GiftCard\Pool\GenerateCommand - N98\Magento\Command\Indexer\ListCommand - - N98\Magento\Command\Indexer\ListMviewCommand - N98\Magento\Command\Indexer\ReindexAllCommand - - N98\Magento\Command\Indexer\ReindexMviewCommand - N98\Magento\Command\Indexer\ReindexCommand - N98\Magento\Command\Installer\InstallCommand - N98\Magento\Command\Installer\UninstallCommand diff --git a/src/N98/Magento/Command/Developer/ClassLookupCommand.php b/src/N98/Magento/Command/Developer/ClassLookupCommand.php index 6e1fc69af..679120e78 100644 --- a/src/N98/Magento/Command/Developer/ClassLookupCommand.php +++ b/src/N98/Magento/Command/Developer/ClassLookupCommand.php @@ -22,7 +22,6 @@ class ClassLookupCommand extends AbstractMagentoCommand public const COMMAND_ARGUMENT_NAME = 'name'; - /** * @var string * @deprecated with symfony 6.1 diff --git a/src/N98/Magento/Command/Indexer/AbstractMviewIndexerCommand.php b/src/N98/Magento/Command/Indexer/AbstractMviewIndexerCommand.php deleted file mode 100644 index 7ef89d658..000000000 --- a/src/N98/Magento/Command/Indexer/AbstractMviewIndexerCommand.php +++ /dev/null @@ -1,55 +0,0 @@ -getApplication()->isMagentoEnterprise(); - } - - /** - * @return \Enterprise_Mview_Model_Resource_Metadata_Collection - */ - public function getMetaDataCollection() - { - $collection = $this->_getModel('enterprise_mview/metadata', '\Enterprise_Mview_Model_Resource_Metadata_Collection')->getCollection(); - return $collection; - } - - /** - * @return array[] - */ - protected function getIndexers() - { - /** @var \Enterprise_Index_Helper_Data $helper */ - $helper = $this->_getHelper('enterprise_index', '\Enterprise_Index_Helper_Data'); - - $indexers = []; - foreach ($helper->getIndexers(true) as $indexer) { - $indexers[(string) $indexer->index_table] = $indexer; - } - - foreach ($indexers as $indexerKey => $indexerData) { - if (!isset($indexerData->action_model->changelog)) { - unset($indexers[$indexerKey]); - } - } - - return $indexers; - } - - /** - * @return \Enterprise_Mview_Model_Client - */ - protected function getMviewClient() - { - return $this->_getModel('enterprise_mview/client', '\Enterprise_Mview_Model_Client'); - } -} diff --git a/src/N98/Magento/Command/Indexer/ListMviewCommand.php b/src/N98/Magento/Command/Indexer/ListMviewCommand.php deleted file mode 100644 index aec20e43d..000000000 --- a/src/N98/Magento/Command/Indexer/ListMviewCommand.php +++ /dev/null @@ -1,87 +0,0 @@ -setName('index:list:mview') - ->setDescription('Lists all magento mview indexes') - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' - ) - ; - - $help = <<setHelp($help); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } - - $table = []; - foreach ($this->getMetaDataCollection() as $index) { - $changelogName = $index->getData('changelog_name'); - $versionId = $index->getData('version_id'); - $pendingCount = $this->getPendingChangelogsCount($changelogName, $versionId); - if ($pendingCount > 0) { - $pendingString = "$pendingCount"; - } else { - $pendingString = "$pendingCount"; - } - - $table[] = [$index->getData('table_name'), $index->getData('view_name'), $changelogName, $index->getData('status'), $versionId, $pendingString]; - } - - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); - $tableHelper - ->setHeaders( - ['table_name', 'view_name', 'changelog_name', 'status', 'version_id', 'entries pending reindex'] - ) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; - } - - /** - * @param $tableName - * @param $currentVersionId - * @return int - */ - protected function getPendingChangelogsCount($tableName, $currentVersionId) - { - /** @var \Mage_Core_Model_Resource $resource */ - $resource = $this->_getSingleton('core/resource', '\Mage_Core_Model_Resource'); - $readConnection = $resource->getConnection('core_read'); - - $select = $readConnection->select() - ->from($tableName, ['count(*)']) - ->where("version_id > ?", $currentVersionId); - $todoCount = $readConnection->fetchOne($select); - - return (int) $todoCount; - } -} diff --git a/src/N98/Magento/Command/Indexer/ReindexMviewCommand.php b/src/N98/Magento/Command/Indexer/ReindexMviewCommand.php deleted file mode 100644 index bfe03b2e3..000000000 --- a/src/N98/Magento/Command/Indexer/ReindexMviewCommand.php +++ /dev/null @@ -1,62 +0,0 @@ -setName('index:reindex:mview') - ->addArgument('table_name', InputArgument::REQUIRED, 'View table name"') - ->setDescription('Reindex a magento index by code using the materialised view functionality'); - - $help = <<setHelp($help); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } - $tableName = $input->getArgument('table_name'); - - $indexers = $this->getIndexers(); - - if (!array_key_exists($tableName, $indexers)) { - throw new InvalidArgumentException("$tableName is not a view table"); - } - - $indexerData = $indexers[$tableName]; - $indexTable = (string) $indexerData->index_table; - $actionName = (string) $indexerData->action_model->changelog; - - $client = $this->getMviewClient(); - $client->init($indexTable); - if (!$client->getMetadata()->getId()) { - throw new InvalidArgumentException("Could not load metadata for $tableName"); - } - - $output->writeln("Starting mview indexer {$indexTable} with action {$actionName} "); - $client->execute($actionName); - $output->writeln("Done"); - return 0; - } -} From 56fbb46ecf16005b057e6ec48bce9456a3bb86c0 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 19 Jun 2024 16:26:16 +0200 Subject: [PATCH 071/136] [skip ci] Removed EE Cms commands --- config.yaml | 2 - .../Command/Cms/Banner/ToggleCommand.php | 77 --------------- .../Command/Cms/Page/PublishCommand.php | 97 ------------------- 3 files changed, 176 deletions(-) delete mode 100644 src/N98/Magento/Command/Cms/Banner/ToggleCommand.php delete mode 100644 src/N98/Magento/Command/Cms/Page/PublishCommand.php diff --git a/config.yaml b/config.yaml index 229301153..5acc49d84 100644 --- a/config.yaml +++ b/config.yaml @@ -64,10 +64,8 @@ commands: - N98\Magento\Command\Cache\ReportCommand - N98\Magento\Command\Cache\ViewCommand - N98\Magento\Command\Category\Create\DummyCommand - - N98\Magento\Command\Cms\Banner\ToggleCommand - N98\Magento\Command\Cms\Block\ListCommand - N98\Magento\Command\Cms\Block\ToggleCommand - - N98\Magento\Command\Cms\Page\PublishCommand - N98\Magento\Command\Config\DeleteCommand - N98\Magento\Command\Config\DumpCommand - N98\Magento\Command\Config\GetCommand diff --git a/src/N98/Magento/Command/Cms/Banner/ToggleCommand.php b/src/N98/Magento/Command/Cms/Banner/ToggleCommand.php deleted file mode 100644 index 376efd183..000000000 --- a/src/N98/Magento/Command/Cms/Banner/ToggleCommand.php +++ /dev/null @@ -1,77 +0,0 @@ -setName('cms:banner:toggle') - ->addArgument('banner_id', InputArgument::REQUIRED, 'Banner ID') - ->setDescription('Toggle a banner (Enterprise only)') - ; - } - - /** - * @return bool - */ - public function isEnabled() - { - return $this->getApplication()->isMagentoEnterprise(); - } - - /** - * @return Enterprise_Banner_Model_Banner - */ - protected function _getBannerModel() - { - return $this->_getModel('enterprise_banner/banner'); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->detectMagento($output, true); - $this->requireEnterprise($output); - $this->initMagento(); - - $this->writeSection($output, 'Banner Toggle'); - $bannerId = $input->getArgument('banner_id'); - - $banner = $this->_getBannerModel()->load($bannerId); - - if (!$banner->getId()) { - $output->writeln('Banner was not found'); - return 0; - } - - $disabled = !$banner->getIsEnabled(); - $comment = 'Banner ' - . '' . (!$disabled ? 'disabled' : 'enabled') . ''; - - $banner->setIsEnabled($disabled); - $banner->save(); - $output->writeln($comment); - return 0; - } -} diff --git a/src/N98/Magento/Command/Cms/Page/PublishCommand.php b/src/N98/Magento/Command/Cms/Page/PublishCommand.php deleted file mode 100644 index 8658ac183..000000000 --- a/src/N98/Magento/Command/Cms/Page/PublishCommand.php +++ /dev/null @@ -1,97 +0,0 @@ -setName('cms:page:publish') - ->addArgument( - 'page_id', - InputArgument::REQUIRED, - 'Even if the Revision ID is unique, we require the page id for security reasons' - ) - ->addArgument('revision_id', InputArgument::REQUIRED, 'Revision ID (the ID, not the sequential number)') - ->setDescription('Publish a CMS page revision (Enterprise only)'); - } - - /** - * @return bool - */ - public function isEnabled() - { - return $this->getApplication()->isMagentoEnterprise(); - } - - /** - * @return Mage_Cms_Model_Page - */ - protected function _getPageModel() - { - return $this->_getModel('cms/page'); - } - - /** - * @return Enterprise_Cms_Model_Page_Revision - */ - protected function _getPageRevisionModel() - { - return $this->_getModel('enterprise_cms/page_revision'); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->detectMagento($output, true); - $this->requireEnterprise($output); - if (!$this->initMagento()) { - return 0; - } - - $this->writeSection($output, 'CMS Publish'); - $pageId = $input->getArgument('page_id'); - $revisionId = $input->getArgument('revision_id'); - - $revision = $this->_getPageRevisionModel()->load($revisionId); - - if (!$revision->getId()) { - $output->writeln('Revision was not found'); - - return 0; - } - - if ($revision->getPageId() != $pageId) { - $output->writeln(sprintf( - 'Revision\'s page id (%d) does not match the given page id', - $revision->getPageId() - )); - - return 0; - } - $revision->publish(); - $output->writeln('Page published'); - return 0; - } -} From 65df7f4c12584f87cb5964397f5bcd84ca626518 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 19 Jun 2024 16:42:16 +0200 Subject: [PATCH 072/136] [skip ci] Removed EE Giftcard commands --- config.yaml | 4 - .../GiftCard/AbstractGiftCardCommand.php | 16 ---- .../Command/GiftCard/CreateCommand.php | 59 -------------- .../Magento/Command/GiftCard/InfoCommand.php | 78 ------------------- .../Command/GiftCard/Pool/GenerateCommand.php | 38 --------- .../Command/GiftCard/RemoveCommand.php | 50 ------------ 6 files changed, 245 deletions(-) delete mode 100644 src/N98/Magento/Command/GiftCard/AbstractGiftCardCommand.php delete mode 100644 src/N98/Magento/Command/GiftCard/CreateCommand.php delete mode 100644 src/N98/Magento/Command/GiftCard/InfoCommand.php delete mode 100644 src/N98/Magento/Command/GiftCard/Pool/GenerateCommand.php delete mode 100644 src/N98/Magento/Command/GiftCard/RemoveCommand.php diff --git a/config.yaml b/config.yaml index 5acc49d84..0e64ace4d 100644 --- a/config.yaml +++ b/config.yaml @@ -125,10 +125,6 @@ commands: - N98\Magento\Command\Eav\Attribute\ListCommand - N98\Magento\Command\Eav\Attribute\RemoveCommand - N98\Magento\Command\Eav\Attribute\ViewCommand - - N98\Magento\Command\GiftCard\CreateCommand - - N98\Magento\Command\GiftCard\InfoCommand - - N98\Magento\Command\GiftCard\RemoveCommand - - N98\Magento\Command\GiftCard\Pool\GenerateCommand - N98\Magento\Command\Indexer\ListCommand - N98\Magento\Command\Indexer\ReindexAllCommand - N98\Magento\Command\Indexer\ReindexCommand diff --git a/src/N98/Magento/Command/GiftCard/AbstractGiftCardCommand.php b/src/N98/Magento/Command/GiftCard/AbstractGiftCardCommand.php deleted file mode 100644 index 1deaeb51e..000000000 --- a/src/N98/Magento/Command/GiftCard/AbstractGiftCardCommand.php +++ /dev/null @@ -1,16 +0,0 @@ -getApplication()->isMagentoEnterprise(); - } -} diff --git a/src/N98/Magento/Command/GiftCard/CreateCommand.php b/src/N98/Magento/Command/GiftCard/CreateCommand.php deleted file mode 100644 index 69d36767a..000000000 --- a/src/N98/Magento/Command/GiftCard/CreateCommand.php +++ /dev/null @@ -1,59 +0,0 @@ -setName('giftcard:create') - ->addArgument( - 'amount', - InputArgument::REQUIRED, - 'Amount for new gift card' - ) - ->addOption( - 'website', - null, - InputOption::VALUE_OPTIONAL, - 'Website ID to attach gift card to' - ) - ->setDescription('Create a gift card with a specified amount'); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } - $data = ['status' => 1, 'is_redeemable' => 1, 'website_id' => $input->getOption('website') ?: Mage::app()->getStore(true)->getWebsiteId(), 'balance' => $input->getArgument('amount')]; - $id = Mage::getModel('enterprise_giftcardaccount/api')->create($data); - if (!$id) { - $output->writeln('Failed to create gift card'); - } - $code = Mage::getModel('enterprise_giftcardaccount/giftcardaccount') - ->load($id) - ->getCode(); - $output->writeln('Gift card ' . $code . ' was created'); - return 0; - } -} diff --git a/src/N98/Magento/Command/GiftCard/InfoCommand.php b/src/N98/Magento/Command/GiftCard/InfoCommand.php deleted file mode 100644 index b1bb2d783..000000000 --- a/src/N98/Magento/Command/GiftCard/InfoCommand.php +++ /dev/null @@ -1,78 +0,0 @@ -setName('giftcard:info') - ->addArgument('code', InputArgument::REQUIRED, 'Gift card code') - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' - ) - ->setDescription('Get gift card account information by code'); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->detectMagento($output, true); - $this->requireEnterprise($output); - - if (!class_exists('Enterprise_GiftCardAccount_Model_Giftcardaccount')) { - return 0; - } - - if (!$this->initMagento()) { - return 0; - } - - /** @var \Enterprise_GiftCardAccount_Model_Giftcardaccount $card */ - $card = Mage::getModel('enterprise_giftcardaccount/giftcardaccount')->loadByCode($input->getArgument('code')); - if (!$card->getId()) { - $output->writeln('No gift card found for that code'); - return 0; - } - $data = [ - ['Gift Card Account ID', $card->getId()], - ['Code', $card->getCode()], - ['Status', \Enterprise_GiftCardAccount_Model_Giftcardaccount::STATUS_ENABLED == $card->getStatus() ? 'Enabled' : 'Disabled'], - ['Date Created', $card->getDateCreated()], - ['Expiration Date', $card->getDateExpires()], - ['Website ID', $card->getWebsiteId()], - ['Remaining Balance', $card->getBalance()], - ['State', $card->getStateText()], - ['Is Redeemable', $card->getIsRedeemable()] - ]; - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); - $tableHelper - ->setHeaders(['Name', 'Value']) - ->setRows($data) - ->renderByFormat($output, $data, $input->getOption('format')); - return 0; - } -} diff --git a/src/N98/Magento/Command/GiftCard/Pool/GenerateCommand.php b/src/N98/Magento/Command/GiftCard/Pool/GenerateCommand.php deleted file mode 100644 index 93ee4e441..000000000 --- a/src/N98/Magento/Command/GiftCard/Pool/GenerateCommand.php +++ /dev/null @@ -1,38 +0,0 @@ -setName('giftcard:pool:generate') - ->setDescription('Generate giftcard pool'); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } - - Mage::getModel('enterprise_giftcardaccount/pool')->generatePool(); - $output->writeln('New pool was generated.'); - return 0; - } -} diff --git a/src/N98/Magento/Command/GiftCard/RemoveCommand.php b/src/N98/Magento/Command/GiftCard/RemoveCommand.php deleted file mode 100644 index 9b6a7c7af..000000000 --- a/src/N98/Magento/Command/GiftCard/RemoveCommand.php +++ /dev/null @@ -1,50 +0,0 @@ -setName('giftcard:remove') - ->addArgument('code', InputArgument::REQUIRED, 'Gift card code') - ->setDescription('Remove a gift card account by code'); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } - $accounts = Mage::getModel('enterprise_giftcardaccount/giftcardaccount')->getCollection() - ->addFieldToFilter('code', $input->getArgument('code')); - if (!$accounts->count()) { - $output->writeln('No gift cards with matching code found'); - } else { - foreach ($accounts as $account) { - $id = $account->getId(); - $account->delete(); - $output->writeln('Deleted gift card account id ' . $id . ''); - } - } - return 0; - } -} From 746f37b3d33346314a903f6e24c5cc794c75c739 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 19 Jun 2024 16:47:21 +0200 Subject: [PATCH 073/136] [skip ci] Removed EE Admin commands --- config.yaml | 3 - .../Command/Admin/User/LockCommand.php | 89 --------------- .../Command/Admin/User/LockdownCommand.php | 85 --------------- .../Command/Admin/User/UnlockCommand.php | 103 ------------------ 4 files changed, 280 deletions(-) delete mode 100644 src/N98/Magento/Command/Admin/User/LockCommand.php delete mode 100644 src/N98/Magento/Command/Admin/User/LockdownCommand.php delete mode 100644 src/N98/Magento/Command/Admin/User/UnlockCommand.php diff --git a/config.yaml b/config.yaml index 0e64ace4d..8aac255a7 100644 --- a/config.yaml +++ b/config.yaml @@ -52,9 +52,6 @@ commands: - N98\Magento\Command\Admin\User\ListCommand - N98\Magento\Command\Admin\User\DeleteUserCommand - N98\Magento\Command\Admin\User\ChangeStatusCommand - - N98\Magento\Command\Admin\User\LockCommand - - N98\Magento\Command\Admin\User\LockdownCommand - - N98\Magento\Command\Admin\User\UnlockCommand - N98\Magento\Command\Cache\CleanCommand - N98\Magento\Command\Cache\Dir\FlushCommand - N98\Magento\Command\Cache\DisableCommand diff --git a/src/N98/Magento/Command/Admin/User/LockCommand.php b/src/N98/Magento/Command/Admin/User/LockCommand.php deleted file mode 100644 index 251325b65..000000000 --- a/src/N98/Magento/Command/Admin/User/LockCommand.php +++ /dev/null @@ -1,89 +0,0 @@ -setName('admin:user:lock') - ->addArgument('username', InputArgument::REQUIRED, 'Admin username to lock') - ->addArgument('lifetime', InputArgument::OPTIONAL, 'Optional - lock lifetime in days (default one month)') - ->setDescription( - <<getApplication()->isMagentoEnterprise(); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return void - */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } - - $username = $input->getArgument('username'); - $lifetime = $input->getArgument('lifetime') ?: $this->daysToSeconds(self::LIFETIME_DEFAULT); - - $user = Mage::getModel('admin/user')->loadByUsername($username); - if (!$user || !$user->getId()) { - $output->writeln("Couldn't find admin username '{$username}'"); - return 0; - } - - Mage::getResourceModel('enterprise_pci/admin_user')->lock($user->getId(), 0, $lifetime); - - $lifetimeMessage = ''; - if ($input->getArgument('lifetime')) { - $lifetimeMessage = sprintf(' for %d days.', $input->getArgument('lifetime')); - } - - $output->writeln( - sprintf('%s locked%s', $username, $lifetimeMessage) - ); - return 0; - } - - /** - * Convert a number of days to seconds for the lock lifetime parameter - * - * @param int $days - * @return int Seconds - */ - public function daysToSeconds($days) - { - return $days * 24 * 60 * 60; - } -} diff --git a/src/N98/Magento/Command/Admin/User/LockdownCommand.php b/src/N98/Magento/Command/Admin/User/LockdownCommand.php deleted file mode 100644 index fc1f57f3b..000000000 --- a/src/N98/Magento/Command/Admin/User/LockdownCommand.php +++ /dev/null @@ -1,85 +0,0 @@ -setName('admin:user:lockdown') - ->addArgument('lifetime', InputArgument::OPTIONAL, 'Optional - lock lifetime in days (default one month)') - ->addOption('dry-run', null, InputOption::VALUE_NONE, 'Dry run mode') - ->setDescription( - <<detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } - - if ($dryrun = $input->getOption('dry-run')) { - $output->writeln('Dry run mode enabled.'); - } - - $lifetime = $input->getArgument('lifetime') ?: $this->daysToSeconds(self::LIFETIME_DEFAULT); - - $userIds = Mage::getModel('admin/user')->getCollection()->getAllIds(); - - if (empty($userIds)) { - $output->writeln('No admin users were found!'); - return 0; - } - - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); - $confirm = $dialog->ask( - $input, - $output, - new ConfirmationQuestion(sprintf('Really lock all %d admin users? [n]: ', is_countable($userIds) ? count($userIds) : 0), false) - ); - - if (!$confirm) { - return 0; - } - - if (!$dryrun) { - Mage::getResourceModel('enterprise_pci/admin_user')->lock($userIds, 0, $lifetime); - } - - $lifetimeMessage = ''; - if ($input->getArgument('lifetime')) { - $lifetimeMessage = sprintf(' for %d days.', $input->getArgument('lifetime')); - } - - $output->writeln( - sprintf('All %d admins locked%s', is_countable($userIds) ? count($userIds) : 0, $lifetimeMessage) - ); - return 0; - } -} diff --git a/src/N98/Magento/Command/Admin/User/UnlockCommand.php b/src/N98/Magento/Command/Admin/User/UnlockCommand.php deleted file mode 100644 index 3ae8db3da..000000000 --- a/src/N98/Magento/Command/Admin/User/UnlockCommand.php +++ /dev/null @@ -1,103 +0,0 @@ -setName('admin:user:unlock') - ->addArgument( - 'username', - InputArgument::OPTIONAL, - 'Admin Username to Unlock' - ) - ->addOption('dry-run', null, InputOption::VALUE_NONE, 'Dry run mode') - ->setDescription('Release lock on admin user for one or all users'); - } - - /** - * @return bool - */ - public function isEnabled() - { - return $this->getApplication()->isMagentoEnterprise(); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return void - */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->detectMagento($output, true); - $this->requireEnterprise($output); - if (!$this->initMagento()) { - return 0; - } - - if ($dryrun = $input->getOption('dry-run')) { - $output->writeln('Dry run mode enabled.'); - } - - // Unlock a single admin account - if ($username = $input->getArgument('username')) { - $user = Mage::getModel('admin/user')->loadByUsername($username); - if (!$user || !$user->getId()) { - $output->writeln('Couldn\'t find admin ' . $username . ''); - return 0; - } - Mage::getResourceModel('enterprise_pci/admin_user')->unlock($user->getId()); - $output->writeln('' . $username . ' unlocked'); - return 0; - } - - // Unlock all admin accounts - $userIds = Mage::getModel('admin/user')->getCollection()->getAllIds(); - - if (empty($userIds)) { - $output->writeln('No admin users found.'); - return 0; - } - - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); - $shouldUnlockAll = $dialog->ask( - $input, - $output, - new ConfirmationQuestion( - sprintf( - 'Really unlock all %d admin users? [n]: ', - is_countable($userIds) ? count($userIds) : 0 - ), - false - ) - ); - - if ($shouldUnlockAll) { - if (!$dryrun) { - Mage::getResourceModel('enterprise_pci/admin_user')->unlock($userIds); - } - $output->writeln( - sprintf('All %d admin users unlocked', is_countable($userIds) ? count($userIds) : 0) - ); - } - return 0; - } -} From e51031903b45734cc3123cdd87a2a651d1a71503 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 19 Jun 2024 16:49:31 +0200 Subject: [PATCH 074/136] [skip ci] Removed EE related code --- src/N98/Magento/Application.php | 19 ++---------------- .../Command/Cache/AbstractCacheCommand.php | 14 +------------ .../Magento/Command/Cache/FlushCommand.php | 20 ------------------- .../Magento/Command/Cache/ReportCommand.php | 8 +------- src/N98/Magento/Command/Cache/ViewCommand.php | 9 ++------- .../Command/Developer/ConsoleCommand.php | 5 ++--- .../Developer/Ide/PhpStorm/MetaCommand.php | 8 +------- src/N98/Util/Console/Helper/MagentoHelper.php | 20 ------------------- .../Command/Cache/CleanCommandTest.php | 4 +--- 9 files changed, 10 insertions(+), 97 deletions(-) diff --git a/src/N98/Magento/Application.php b/src/N98/Magento/Application.php index a215adc57..a5638aebb 100644 --- a/src/N98/Magento/Application.php +++ b/src/N98/Magento/Application.php @@ -19,7 +19,6 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Event\ConsoleEvent; use Symfony\Component\Console\Formatter\OutputFormatterStyle; -use Symfony\Component\Console\Helper\FormatterHelper; use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputInterface; @@ -81,11 +80,6 @@ class Application extends BaseApplication */ protected $_magentoRootFolder = null; - /** - * @var bool - */ - protected $_magentoEnterprise = false; - /** * @var bool */ @@ -244,7 +238,6 @@ public function detectMagento(InputInterface $input = null, OutputInterface $out $this->_magentoDetected = $magentoHelper->detect($folder, $subFolders); $this->_magentoRootFolder = $magentoHelper->getRootFolder(); - $this->_magentoEnterprise = $magentoHelper->isEnterpriseEdition(); $this->_magerunStopFileFound = $magentoHelper->isMagerunStopFileFound(); $this->_magerunStopFileFolder = $magentoHelper->getMagerunStopFileFolder(); $this->_magerunUseDeveloperMode = ($input->getParameterOption('--developer-mode')); @@ -433,7 +426,7 @@ public function checkVarDir(OutputInterface $output) * * @return bool false if magento root folder is not set, true otherwise */ - public function initMagento($soft = false) + public function initMagento(bool $soft = false): bool { if ($this->getMagentoRootFolder() === null) { return false; @@ -457,14 +450,6 @@ public function getLongVersion() return parent::getLongVersion() . ' by netz98 GmbH'; } - /** - * @return boolean - */ - public function isMagentoEnterprise() - { - return $this->_magentoEnterprise; - } - /** * @return string */ @@ -734,7 +719,7 @@ private function setRootDir($path) * * @return void */ - protected function _initMagento1($soft = false) + protected function _initMagento1(bool $soft = false) { // Load Mage class definition Initialiser::bootstrap($this->_magentoRootFolder); diff --git a/src/N98/Magento/Command/Cache/AbstractCacheCommand.php b/src/N98/Magento/Command/Cache/AbstractCacheCommand.php index bef36bed9..91aec953b 100644 --- a/src/N98/Magento/Command/Cache/AbstractCacheCommand.php +++ b/src/N98/Magento/Command/Cache/AbstractCacheCommand.php @@ -4,12 +4,10 @@ namespace N98\Magento\Command\Cache; -use Enterprise_PageCache_Model_Cache; use InvalidArgumentException; use Mage_Core_Model_Cache; use N98\Magento\Command\AbstractMagentoCommand; use RuntimeException; -use Symfony\Component\Console\Input\InputInterface; use Zend_Cache_Core; /** @@ -19,8 +17,6 @@ */ abstract class AbstractCacheCommand extends AbstractMagentoCommand { - public const COMMAND_OPTION_FPC = 'fpc'; - /** * @return Mage_Core_Model_Cache * @@ -32,18 +28,10 @@ protected function _getCacheModel(): Mage_Core_Model_Cache } /** - * @param InputInterface $input * @return Zend_Cache_Core */ - protected function getCacheInstance(InputInterface $input): Zend_Cache_Core + protected function getCacheInstance(): Zend_Cache_Core { - if ($input->hasOption(static::COMMAND_OPTION_FPC) && $input->getOption(static::COMMAND_OPTION_FPC)) { - if (!class_exists('\Enterprise_PageCache_Model_Cache')) { - throw new RuntimeException('Enterprise page cache not found'); - } - return Enterprise_PageCache_Model_Cache::getCacheInstance()->getFrontend(); - } - return $this->_getMage()->getCache(); } diff --git a/src/N98/Magento/Command/Cache/FlushCommand.php b/src/N98/Magento/Command/Cache/FlushCommand.php index 0515f1952..c3b15964e 100644 --- a/src/N98/Magento/Command/Cache/FlushCommand.php +++ b/src/N98/Magento/Command/Cache/FlushCommand.php @@ -4,7 +4,6 @@ namespace N98\Magento\Command\Cache; -use Enterprise_PageCache_Model_Cache; use Exception; use Mage; use Symfony\Component\Console\Attribute\AsCommand; @@ -83,25 +82,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->reinitCache(); } - /* Since Magento 1.10 we have an own cache handler for FPC */ - if ($this->isEnterpriseFullPageCachePresent() && class_exists('Enterprise_PageCache_Model_Cache')) { - $result = Enterprise_PageCache_Model_Cache::getCacheInstance()->flush(); - if ($result) { - $output->writeln('FPC cleared'); - } else { - $output->writeln('Failed to clear FPC'); - } - } - return Command::SUCCESS; } - - /** - * @return bool - */ - protected function isEnterpriseFullPageCachePresent(): bool - { - $isModuleEnabled = Mage::helper('core')->isModuleEnabled('Enterprise_PageCache'); - return $this->_magentoEnterprise && $isModuleEnabled && version_compare(Mage::getVersion(), '1.11.0.0', '>='); - } } diff --git a/src/N98/Magento/Command/Cache/ReportCommand.php b/src/N98/Magento/Command/Cache/ReportCommand.php index e75f2b1f5..c9f302790 100644 --- a/src/N98/Magento/Command/Cache/ReportCommand.php +++ b/src/N98/Magento/Command/Cache/ReportCommand.php @@ -68,12 +68,6 @@ protected function configure(): void InputOption::VALUE_OPTIONAL, 'Filter output by TAG (separate multiple tags by comma)' ) - ->addOption( - self::COMMAND_OPTION_FPC, - null, - InputOption::VALUE_NONE, - 'Use full page cache instead of core cache (Enterprise only!)' - ) ; parent::configure(); @@ -90,7 +84,7 @@ public function getData(InputInterface $input, OutputInterface $output): array if (is_null($this->data)) { $this->data = []; - $cacheInstance = $this->getCacheInstance($input); + $cacheInstance = $this->getCacheInstance(); $filterTag = $input->getOption(self::COMMAND_OPTION_FILTER_TAG); if ($filterTag !== null) { diff --git a/src/N98/Magento/Command/Cache/ViewCommand.php b/src/N98/Magento/Command/Cache/ViewCommand.php index 451869d84..0913e41c2 100644 --- a/src/N98/Magento/Command/Cache/ViewCommand.php +++ b/src/N98/Magento/Command/Cache/ViewCommand.php @@ -50,12 +50,7 @@ protected function configure(): void InputOption::VALUE_NONE, 'Unserialize output' ) - ->addOption( - self::COMMAND_OPTION_FPC, - null, - InputOption::VALUE_NONE, - 'Use full page cache instead of core cache (Enterprise only!)' - ); + ; } /** @@ -68,7 +63,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->detectMagento($output); $this->initMagento(); - $cacheInstance = $this->getCacheInstance($input); + $cacheInstance = $this->getCacheInstance(); /** @var string $cacheId */ $cacheId = $input->getArgument(self::COMMAND_ARGUMENT_ID); /** @var string $cacheData */ diff --git a/src/N98/Magento/Command/Developer/ConsoleCommand.php b/src/N98/Magento/Command/Developer/ConsoleCommand.php index 8ca6127df..af93790ea 100644 --- a/src/N98/Magento/Command/Developer/ConsoleCommand.php +++ b/src/N98/Magento/Command/Developer/ConsoleCommand.php @@ -14,7 +14,7 @@ class ConsoleCommand extends AbstractMagentoCommand { - protected function configure() + protected function configure(): void { $this ->setName('dev:console') @@ -46,9 +46,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($initialized) { $ok = Charset::convertInteger(Charset::UNICODE_CHECKMARK_CHAR); - $edition = $this->getApplication()->isMagentoEnterprise() ? 'EE' : 'CE'; $consoleOutput->writeln( - 'Magento ' . Mage::getVersion() . ' ' . $edition . + 'Magento ' . Mage::getVersion() . ' ' . 'CE' . ' initialized. ' . $ok ); } else { diff --git a/src/N98/Magento/Command/Developer/Ide/PhpStorm/MetaCommand.php b/src/N98/Magento/Command/Developer/Ide/PhpStorm/MetaCommand.php index d20e4e899..abfdda8ea 100644 --- a/src/N98/Magento/Command/Developer/Ide/PhpStorm/MetaCommand.php +++ b/src/N98/Magento/Command/Developer/Ide/PhpStorm/MetaCommand.php @@ -44,7 +44,7 @@ class MetaCommand extends AbstractMagentoCommand public const VERSION_2017 = '2016.2+'; public const VERSION_2019 = '2019.1+'; - protected function configure() + protected function configure(): void { $this ->setName('dev:ide:phpstorm:meta') @@ -166,12 +166,6 @@ protected function getResourceHelperMap() { $classes = []; - if (($this->_magentoEnterprise && version_compare(Mage::getVersion(), '1.11.2.0', '<=')) - || (!$this->_magentoEnterprise && version_compare(Mage::getVersion(), '1.6.2.0', '<')) - ) { - return $classes; - } - $modelAliases = array_keys((array) Mage::getConfig()->getNode('global/models')); foreach ($modelAliases as $modelAlias) { $resourceHelper = @Mage::getResourceHelper($modelAlias); diff --git a/src/N98/Util/Console/Helper/MagentoHelper.php b/src/N98/Util/Console/Helper/MagentoHelper.php index 50f707e47..c06f3f17d 100644 --- a/src/N98/Util/Console/Helper/MagentoHelper.php +++ b/src/N98/Util/Console/Helper/MagentoHelper.php @@ -23,11 +23,6 @@ class MagentoHelper extends AbstractHelper */ protected $_magentoRootFolder = null; - /** - * @var bool - */ - protected $_magentoEnterprise = false; - /** * @var bool */ @@ -119,14 +114,6 @@ public function getRootFolder() return $this->_magentoRootFolder; } - /** - * @return bool - */ - public function isEnterpriseEdition() - { - return $this->_magentoEnterprise; - } - /** * @return boolean */ @@ -302,13 +289,6 @@ protected function _search($searchFolder) $this->_magentoRootFolder = $searchFolder; - if (is_callable(['\Mage', 'getEdition'])) { - $this->_magentoEnterprise = (Mage::getEdition() == 'Enterprise'); - } else { - $this->_magentoEnterprise = is_dir($this->_magentoRootFolder . '/app/code/core/Enterprise') || - is_dir($this->_magentoRootFolder . '/app/design/frontend/enterprise/default/layout'); - } - if (OutputInterface::VERBOSITY_DEBUG <= $this->output->getVerbosity()) { $this->output->writeln( 'Found Magento in folder ' . $this->_magentoRootFolder . '' diff --git a/tests/N98/Magento/Command/Cache/CleanCommandTest.php b/tests/N98/Magento/Command/Cache/CleanCommandTest.php index 92c1945c0..3c2e9863a 100644 --- a/tests/N98/Magento/Command/Cache/CleanCommandTest.php +++ b/tests/N98/Magento/Command/Cache/CleanCommandTest.php @@ -22,9 +22,7 @@ public function getApplication() // FIXME #613 make install command work with 1.9+ and cache initialization $version = Mage::getVersion(); $against = '1.9.0.0'; - if ($application->isMagentoEnterprise()) { - $against = '1.14.0.0'; - } + if (-1 != version_compare($version, $against)) { self::markTestSkipped( sprintf( From c8f2925e02aa42679704a6ea320707582640bd59 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 19 Jun 2024 18:30:17 +0200 Subject: [PATCH 075/136] [skip ci] Updated dev:log:db command --- .../Command/Developer/Log/DbCommand.php | 68 +++++++++++++++---- 1 file changed, 53 insertions(+), 15 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Log/DbCommand.php b/src/N98/Magento/Command/Developer/Log/DbCommand.php index 08410e814..79b80b6a6 100644 --- a/src/N98/Magento/Command/Developer/Log/DbCommand.php +++ b/src/N98/Magento/Command/Developer/Log/DbCommand.php @@ -1,27 +1,63 @@ setName('dev:log:db') - ->addOption('on', null, InputOption::VALUE_NONE, 'Force logging') - ->addOption('off', null, InputOption::VALUE_NONE, 'Disable logging') - ->setDescription('Turn on/off database query logging'); + ->addOption( + self::COMMAND_OPTION_ON, + null, + InputOption::VALUE_NONE, + 'Force logging' + ) + ->addOption( + self::COMMAND_OPTION_OFF, + null, + InputOption::VALUE_NONE, + 'Disable logging' + ) + ; } /** * @return string */ - protected function _getVarienAdapterPhpFile() + protected function _getVarienAdapterPhpFile(): string { return $this->_magentoRootFolder . '/lib/Varien/Db/Adapter/Pdo/Mysql.php'; } @@ -29,7 +65,6 @@ protected function _getVarienAdapterPhpFile() /** * @param InputInterface $input * @param OutputInterface $output - * * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int @@ -43,29 +78,32 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->_replaceVariable($input, $output, '$_logAllQueries'); $output->writeln("Done. You can tail " . $this->_getDebugLogFilename() . ""); - return 0; + + return Command::SUCCESS; } /** * @return string * @todo I believe 1.5 and under put this in a different filename. */ - protected function _getDebugLogFilename() + protected function _getDebugLogFilename(): string { return 'var/debug/pdo_mysql.log'; } /** - * @param InputInterface $input + * @param InputInterface $input * @param OutputInterface $output - * @param string $variable - * + * @param string $variable * @return void */ - protected function _replaceVariable($input, $output, $variable) + protected function _replaceVariable(InputInterface $input, OutputInterface $output, string $variable): void { $varienAdapterPhpFile = $this->_getVarienAdapterPhpFile(); $contents = file_get_contents($varienAdapterPhpFile); + if (!$contents) { + $contents = ''; + } $debugLinePattern = "/protected\\s" . '\\' . $variable . "\\s*?=\\s(false|true)/m"; preg_match($debugLinePattern, $contents, $matches); @@ -74,9 +112,9 @@ protected function _replaceVariable($input, $output, $variable) } $currentValue = $matches[1]; - if ($input->getOption('off')) { + if ($input->getOption(self::COMMAND_OPTION_OFF)) { $newValue = 'false'; - } elseif ($input->getOption('on')) { + } elseif ($input->getOption(self::COMMAND_OPTION_ON)) { $newValue = 'true'; } else { $newValue = ($currentValue == 'false') ? 'true' : 'false'; From 810cda1036c4ad0afd5787b007948981f45887ba Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 19 Jun 2024 18:30:51 +0200 Subject: [PATCH 076/136] [skip ci] Updated dev:log:size command --- .../Developer/Log/AbstractLogCommand.php | 45 +++++------ .../Command/Developer/Log/SizeCommand.php | 74 ++++++++++++++----- 2 files changed, 80 insertions(+), 39 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Log/AbstractLogCommand.php b/src/N98/Magento/Command/Developer/Log/AbstractLogCommand.php index ed5a46c79..714cde4dd 100644 --- a/src/N98/Magento/Command/Developer/Log/AbstractLogCommand.php +++ b/src/N98/Magento/Command/Developer/Log/AbstractLogCommand.php @@ -1,26 +1,31 @@ ignoreUnreadableDirs(true); + $finder->ignoreUnreadableDirs(); $logDirs = [$this->getLogDir()]; @@ -34,7 +39,7 @@ protected function getLogFileIterator() /** * @return string */ - protected function getLogDir() + protected function getLogDir(): string { return Mage::getBaseDir('log'); } @@ -42,17 +47,16 @@ protected function getLogDir() /** * @return string */ - protected function getDebugDir() + protected function getDebugDir(): string { return Mage::getBaseDir('var') . '/debug'; } /** * @param string $filename - * * @return bool */ - protected function logfileExists($filename) + protected function logfileExists(string $filename): bool { $iterator = $this->getLogFileIterator(); return $iterator->name(basename($filename))->count() == 1; @@ -61,34 +65,33 @@ protected function logfileExists($filename) /** * @param InputInterface $input * @param OutputInterface $output - * - * @return string + * @return mixed */ protected function askLogFile(InputInterface $input, OutputInterface $output) { $logFiles = $this->getLogFileIterator(); + + if (!$logFiles->count()) { + $output->writeln('No logfiles found.'); + return ''; + } + $files = []; $choices = []; - $i = 0; foreach ($logFiles as $logFile) { - $files[$i++] = $logFile->getPathname(); - $choices[] = '[' . ($i) . '] ' . $logFile->getFilename() . PHP_EOL; - } - - if ($i === 0) { - return ''; + $files[] = $logFile->getPathname(); + $choices[] = $logFile->getFilename() . PHP_EOL; } - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $questionObj = new ChoiceQuestion('Please select a log file: ', $choices); $questionObj->setValidator(function ($typeInput) use ($files) { - if (!isset($files[$typeInput - 1])) { + if (!isset($files[$typeInput])) { throw new InvalidArgumentException('Invalid file'); } - return $files[$typeInput - 1]; + return $files[$typeInput]; }); return $dialog->ask($input, $output, $questionObj); diff --git a/src/N98/Magento/Command/Developer/Log/SizeCommand.php b/src/N98/Magento/Command/Developer/Log/SizeCommand.php index d8d1cafd1..132325139 100644 --- a/src/N98/Magento/Command/Developer/Log/SizeCommand.php +++ b/src/N98/Magento/Command/Developer/Log/SizeCommand.php @@ -1,61 +1,99 @@ setName('dev:log:size') - ->addArgument('log_filename', InputArgument::OPTIONAL, 'Name of log file.') - ->addOption('human', '', InputOption::VALUE_NONE, 'Human readable output') - ->setDescription('Get size of log file'); + ->addArgument( + self::COMMAND_ARGUMENT_LOG_FILENAME, + InputArgument::OPTIONAL, + 'Name of log file.' + ) + ->addOption( + self::COMMAND_OPTION_HUMAN, + null, + InputOption::VALUE_NONE, + 'Human readable output' + ) + ; } /** * @param InputInterface $input * @param OutputInterface $output - * - * @throws RuntimeException * @return int + * @throws RuntimeException */ protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output); - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); - $fileName = $input->getArgument('log_filename'); + $fileName = $input->getArgument(self::COMMAND_ARGUMENT_LOG_FILENAME); if ($fileName === null) { + /** @var string $path */ $path = $this->askLogFile($input, $output); } else { $path = $this->getLogDir() . DIRECTORY_SEPARATOR . $fileName; } - if ($this->logfileExists(basename($path))) { + $size = 0; + if ($path && $this->logfileExists(basename($path))) { $size = @filesize($path); if ($size === false) { throw new RuntimeException('Couldn\t detect filesize.'); } } else { - $size = 0; + $output->writeln('Logfile not found.'); + $path = ''; } - if ($input->getOption('human')) { - $output->writeln(Filesystem::humanFileSize($size)); - } else { - $output->writeln("$size"); + if ($path) { + if ($input->getOption(self::COMMAND_OPTION_HUMAN)) { + $output->writeln(Filesystem::humanFileSize($size)); + } else { + $output->writeln("$size"); + } } - return 0; + + return Command::SUCCESS; } } From aa926fa5504409c7ec065d6d20f151bb510d98fd Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 19 Jun 2024 18:39:39 +0200 Subject: [PATCH 077/136] [skip ci] Updated dev:report:count command --- .../Command/Developer/Report/CountCommand.php | 38 +++++++++++++------ 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Report/CountCommand.php b/src/N98/Magento/Command/Developer/Report/CountCommand.php index 0591f1ac9..9748460e0 100644 --- a/src/N98/Magento/Command/Developer/Report/CountCommand.php +++ b/src/N98/Magento/Command/Developer/Report/CountCommand.php @@ -1,26 +1,41 @@ setName('dev:report:count') - ->setDescription('Get count of report files'); - } + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultName = 'dev:report:count'; + + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultDescription = 'Get count of report files.'; /** * @param InputInterface $input * @param OutputInterface $output - * * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int @@ -29,10 +44,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->initMagento(); $dir = Mage::getBaseDir('var') . DIRECTORY_SEPARATOR . 'report' . DIRECTORY_SEPARATOR; - $count = $this->getFileCount($dir); + $count = (string) $this->getFileCount($dir); $output->writeln($count); - return 0; + + return Command::SUCCESS; } /** @@ -41,9 +57,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int * @param string $path Path to the directory * @return int */ - protected function getFileCount($path) + protected function getFileCount(string $path): int { $finder = Finder::create(); - return $finder->files()->ignoreUnreadableDirs(true)->in($path)->count(); + return $finder->files()->ignoreUnreadableDirs()->in($path)->count(); } } From 38c5a01d84e8e063beef3204a8d712b6c3cce5d7 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 19 Jun 2024 19:57:03 +0200 Subject: [PATCH 078/136] [skip ci] Updated db:info command --- .../Database/AbstractDatabaseCommand.php | 30 ++- .../Magento/Command/Database/InfoCommand.php | 201 +++++++++++------- 2 files changed, 134 insertions(+), 97 deletions(-) diff --git a/src/N98/Magento/Command/Database/AbstractDatabaseCommand.php b/src/N98/Magento/Command/Database/AbstractDatabaseCommand.php index 45ae4da1b..d67e15ba7 100644 --- a/src/N98/Magento/Command/Database/AbstractDatabaseCommand.php +++ b/src/N98/Magento/Command/Database/AbstractDatabaseCommand.php @@ -1,12 +1,14 @@ getDatabaseHelper(); + $database = $this->getDatabaseHelper(); $this->dbSettings = $database->getDbSettings($output); } /** * @param $name * - * @return \PDO|void + * @return PDO|void */ public function __get($name) { @@ -49,7 +51,7 @@ public function __get($name) * * @return string */ - protected function getCompressionHelp() + protected function getCompressionHelp(): string { $messages = []; $messages[] = ''; @@ -66,7 +68,7 @@ protected function getCompressionHelp() * @return Compressor * @deprecated Since 1.97.29; use AbstractCompressor::create() instead */ - protected function getCompressor($type) + protected function getCompressor(string $type): Compressor { return AbstractCompressor::create($type); } @@ -76,7 +78,7 @@ protected function getCompressor($type) * * @deprecated Please use database helper */ - protected function getMysqlClientToolConnectionString() + protected function getMysqlClientToolConnectionString(): string { return $this->getDatabaseHelper()->getMysqlClientToolConnectionString(); } @@ -89,19 +91,11 @@ protected function getMysqlClientToolConnectionString() * * @deprecated Please use database helper */ - protected function _dsn() + protected function _dsn(): string { return $this->getDatabaseHelper()->dsn(); } - /** - * @return DatabaseHelper - */ - protected function getDatabaseHelper() - { - return $this->getHelper('database'); - } - /** * @param array $excludes * @param array $definitions @@ -111,8 +105,8 @@ protected function getDatabaseHelper() * * @deprecated Please use database helper */ - protected function resolveTables(array $excludes, array $definitions, array $resolved = []) + protected function resolveTables(array $excludes, array $definitions, array $resolved = []): array { - return $this->getHelper('database')->resolveTables($excludes, $definitions, $resolved); + return $this->getDatabaseHelper()->resolveTables($excludes, $definitions, $resolved); } } diff --git a/src/N98/Magento/Command/Database/InfoCommand.php b/src/N98/Magento/Command/Database/InfoCommand.php index 2985f19ab..d8471c647 100644 --- a/src/N98/Magento/Command/Database/InfoCommand.php +++ b/src/N98/Magento/Command/Database/InfoCommand.php @@ -1,116 +1,159 @@ setName('db:info') - ->addArgument('setting', InputArgument::OPTIONAL, 'Only output value of named setting') - ->setDescription('Dumps database informations') - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' + ->addDeprecatedAlias( + 'database:info', + 'Please use db:info' + ) + ->addArgument( + self::COMMAND_ARGUMENT_SETTING, + InputArgument::OPTIONAL, + 'Only output value of named setting' ) ; - $this->addDeprecatedAlias('database:info', 'Please use db:info'); - $help = <<setHelp($help); } /** * @param InputInterface $input * @param OutputInterface $output - * * @throws InvalidArgumentException * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectDbSettings($output); + if (($settingArgument = $input->getArgument(self::COMMAND_ARGUMENT_SETTING)) !== null) { + $settings = $this->getData($input, $output); + if (!isset($settings[$settingArgument])) { + throw new InvalidArgumentException('Unknown setting: ' . $settingArgument); + } + $output->writeln((string) $settings[$settingArgument]['Value']); - $settings = []; - foreach ($this->dbSettings as $key => $value) { - $settings[$key] = (string) $value; + return Command::SUCCESS; } - $isSocketConnect = $this->dbSettings->isSocketConnect(); - - // note: there is no need to specify the default port neither for PDO, nor JDBC nor CLI. - $portOrDefault = $this->dbSettings['port'] ?? 3306; - - $pdoConnectionString = ''; - if ($isSocketConnect) { - $pdoConnectionString = sprintf( - 'mysql:unix_socket=%s;dbname=%s', - $this->dbSettings['unix_socket'], - $this->dbSettings['dbname'] - ); - } else { - $pdoConnectionString = sprintf( - 'mysql:host=%s;port=%s;dbname=%s', - $this->dbSettings['host'], - $portOrDefault, - $this->dbSettings['dbname'] - ); - } - $settings['PDO-Connection-String'] = $pdoConnectionString; - - $jdbcConnectionString = ''; - if ($isSocketConnect) { - // isn't supported according to this post: http://stackoverflow.com/a/18493673/145829 - $jdbcConnectionString = 'Connecting using JDBC through a unix socket isn\'t supported!'; - } else { - $jdbcConnectionString = sprintf( - 'jdbc:mysql://%s:%s/%s?username=%s&password=%s', - $this->dbSettings['host'], - $portOrDefault, - $this->dbSettings['dbname'], - $this->dbSettings['username'], - $this->dbSettings['password'] - ); - } - $settings['JDBC-Connection-String'] = $jdbcConnectionString; + return parent::execute($input, $output); + } - /* @var DatabaseHelper $database */ - $database = $this->getHelper('database'); - $mysqlCliString = 'mysql ' . $database->getMysqlClientToolConnectionString(); - $settings['MySQL-Cli-String'] = $mysqlCliString; + /** + * {@inheritdoc} + * @return array> + * + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter + */ + public function getData(InputInterface $input, OutputInterface $output): array + { + if (is_null($this->data)) { + $this->detectDbSettings($output); - $rows = []; - foreach ($settings as $settingName => $settingValue) { - $rows[] = [$settingName, $settingValue]; - } + $settings = []; + foreach ($this->dbSettings as $key => $value) { + $settings[$key] = (string) $value; + } - if (($settingArgument = $input->getArgument('setting')) !== null) { - if (!isset($settings[$settingArgument])) { - throw new InvalidArgumentException('Unknown setting: ' . $settingArgument); + if ($this->dbSettings instanceof DbSettings) { + $isSocketConnect = $this->dbSettings->isSocketConnect(); + } else { + $isSocketConnect = false; + } + + // note: there is no need to specify the default port neither for PDO, nor JDBC nor CLI. + $portOrDefault = $this->dbSettings['port'] ?? 3306; + + $pdoConnectionString = ''; + if ($isSocketConnect) { + $pdoConnectionString = sprintf( + 'mysql:unix_socket=%s;dbname=%s', + $this->dbSettings['unix_socket'], + $this->dbSettings['dbname'] + ); + } else { + $pdoConnectionString = sprintf( + 'mysql:host=%s;port=%s;dbname=%s', + $this->dbSettings['host'], + $portOrDefault, + $this->dbSettings['dbname'] + ); + } + $settings['PDO-Connection-String'] = $pdoConnectionString; + + $jdbcConnectionString = ''; + if ($isSocketConnect) { + // isn't supported according to this post: http://stackoverflow.com/a/18493673/145829 + $jdbcConnectionString = 'Connecting using JDBC through a unix socket isn\'t supported!'; + } else { + $jdbcConnectionString = sprintf( + 'jdbc:mysql://%s:%s/%s?username=%s&password=%s', + $this->dbSettings['host'], + $portOrDefault, + $this->dbSettings['dbname'], + $this->dbSettings['username'], + $this->dbSettings['password'] + ); + } + $settings['JDBC-Connection-String'] = $jdbcConnectionString; + + $database = $this->getDatabaseHelper(); + $mysqlCliString = 'mysql ' . $database->getMysqlClientToolConnectionString(); + $settings['MySQL-Cli-String'] = $mysqlCliString; + + foreach ($settings as $settingName => $settingValue) { + $this->data[$settingName] = [ + 'Name' => $settingName, + 'Value' => $settingValue + ]; } - $output->writeln((string) $settings[$settingArgument]); - } else { - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); - $tableHelper - ->setHeaders(['Name', 'Value']) - ->renderByFormat($output, $rows, $input->getOption('format')); } - return 0; + + return $this->data; } } From fb3370ee697ea076e95decac73e0312677730944 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 19 Jun 2024 20:26:47 +0200 Subject: [PATCH 079/136] [skip ci] Updated db:status command --- .../Command/Database/StatusCommand.php | 51 ++++++++++++------- .../Command/Database/VariablesCommand.php | 2 +- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/N98/Magento/Command/Database/StatusCommand.php b/src/N98/Magento/Command/Database/StatusCommand.php index af1d18497..f4bf10124 100644 --- a/src/N98/Magento/Command/Database/StatusCommand.php +++ b/src/N98/Magento/Command/Database/StatusCommand.php @@ -1,18 +1,40 @@ > */ protected array $_importantVars = [ 'Threads_connected' => [ @@ -61,27 +83,24 @@ class StatusCommand extends AbstractShowCommand ]; /** - * @var array + * @var array */ protected array $_specialFormat = ['Uptime' => 'timeElapsedString']; - protected function configure(): void + /** + * @return string + */ + public function getHelp(): string { - parent::configure(); - $this - ->setName('db:status') - ->setDescription('Shows important server status information or custom selected status values'); - - $help = <<setHelp($help); } /** - * @param array $outputVars + * @param array> $outputVars * @param bool $hasDescription - * @return array + * @return array> */ protected function generateRows(array $outputVars, bool $hasDescription): array { @@ -141,12 +160,12 @@ protected function allowRounding(string $name): bool * echo time_elapsed_string('@1367367755'); # timestamp input * echo time_elapsed_string('2013-05-01 00:22:35', true); * - * @param $datetime + * @param string $datetime * @param bool $full * @return string * @throws Exception */ - protected function timeElapsedString($datetime, bool $full = false): string + protected function timeElapsedString(string $datetime, bool $full = false): string { if (is_numeric($datetime)) { $datetime = time() - $datetime; @@ -157,13 +176,9 @@ protected function timeElapsedString($datetime, bool $full = false): string $ago = new DateTime($datetime); $diff = $now->diff($ago); - $diff->w = floor($diff->d / 7); - $diff->d -= $diff->w * 7; - $string = [ 'y' => 'year', 'm' => 'month', - 'w' => 'week', 'd' => 'day', 'h' => 'hour', 'i' => 'minute', diff --git a/src/N98/Magento/Command/Database/VariablesCommand.php b/src/N98/Magento/Command/Database/VariablesCommand.php index 7e004926b..c566c9c2f 100644 --- a/src/N98/Magento/Command/Database/VariablesCommand.php +++ b/src/N98/Magento/Command/Database/VariablesCommand.php @@ -31,7 +31,7 @@ class VariablesCommand extends AbstractShowCommand * variable name => recommended size (but this value must be calculated depending on the server size * @see https://launchpadlibrarian.net/78745738/tuning-primer.sh convert that to PHP ... ? * http://www.slideshare.net/shinguz/mysql-configuration-the-most-important-variables GERMAN - * @var array + * @var array> */ protected array $_importantVars = [ 'have_query_cache' => '', From abcd6b8e666c0b4f3f14112aff53902424c53266 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 19 Jun 2024 21:11:50 +0200 Subject: [PATCH 080/136] [skip ci] Updated db:query command --- .../Magento/Command/Database/QueryCommand.php | 84 ++++++++++++++----- 1 file changed, 64 insertions(+), 20 deletions(-) diff --git a/src/N98/Magento/Command/Database/QueryCommand.php b/src/N98/Magento/Command/Database/QueryCommand.php index 7583ba6c2..86f62020c 100644 --- a/src/N98/Magento/Command/Database/QueryCommand.php +++ b/src/N98/Magento/Command/Database/QueryCommand.php @@ -1,25 +1,65 @@ setName('db:query') - ->addArgument('query', InputArgument::OPTIONAL, 'SQL query') - ->addOption('only-command', null, InputOption::VALUE_NONE, 'Print only mysql command. Do not execute') - ->setDescription('Executes an SQL query on the database defined in local.xml') + ->addArgument( + self::COMMAND_ARGUMENT_QUERY, + InputArgument::OPTIONAL, + 'SQL query' + ) + ->addOption( + self::COMMAND_OPTION_ONLY_COMMAND, + null, + InputOption::VALUE_NONE, + 'Print only mysql command. Do not execute' + ) ; + } - $help = <<setHelp($help); } /** * @return bool */ - public function isEnabled() + public function isEnabled(): bool { return Exec::allowed(); } /** - * Returns the query string with escaped ' characters so it can be used + * Returns the query string with escaped ' characters, so it can be used * within the mysql -e argument. * * The -e argument is enclosed by single quotes. As you can't escape @@ -51,7 +90,7 @@ public function isEnabled() * @param string $query * @return string */ - protected function getEscapedSql($query) + protected function getEscapedSql(string $query): string { return str_replace("'", "'\''", $query); } @@ -59,28 +98,33 @@ protected function getEscapedSql($query) /** * @param InputInterface $input * @param OutputInterface $output - * * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectDbSettings($output); - $query = $this->getOrAskForArgument('query', $input, $output, 'SQL Query'); + $query = $this->getOrAskForArgument(self::COMMAND_ARGUMENT_QUERY, $input, $output, 'SQL Query'); - /** @var \N98\Util\Console\Helper\DatabaseHelper $helper */ - $helper = $this->getHelper('database'); - $exec = sprintf('mysql %s -e %s', $helper->getMysqlClientToolConnectionString(), escapeshellarg($query)); + $helper = $this->getDatabaseHelper(); + $exec = sprintf( + 'mysql %s -e %s', + $helper->getMysqlClientToolConnectionString(), + escapeshellarg($query) + ); - if ($input->getOption('only-command')) { + if ($input->getOption(self::COMMAND_OPTION_ONLY_COMMAND)) { $output->writeln($exec); } else { Exec::run($exec, $commandOutput, $returnValue); - $output->writeln($commandOutput); - if ($returnValue > 0) { - $output->writeln('' . $commandOutput . ''); + if ($commandOutput) { + $output->writeln($commandOutput); + if ($returnValue > 0) { + $output->writeln('' . $commandOutput . ''); + } } } - return 0; + + return Command::SUCCESS; } } From da6ae5fd3bcb8f4e1453672da3d57c057b0e0a38 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 19 Jun 2024 21:26:51 +0200 Subject: [PATCH 081/136] [skip ci] Updated db:console command --- .../Command/Database/ConsoleCommand.php | 48 +++++++++++++------ 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/src/N98/Magento/Command/Database/ConsoleCommand.php b/src/N98/Magento/Command/Database/ConsoleCommand.php index 2a8b6fa25..f9502b33a 100644 --- a/src/N98/Magento/Command/Database/ConsoleCommand.php +++ b/src/N98/Magento/Command/Database/ConsoleCommand.php @@ -1,33 +1,53 @@ setName('db:console') ->setAliases(['mysql-client']) ->addOption( - 'use-mycli-instead-of-mysql', + self::COMMAND_OPTION_USE_MYCLI_INSTEAD_OF_MYSQL, null, InputOption::VALUE_NONE, 'Use `mycli` as the MySQL client instead of `mysql`' ) ->addOption( - 'no-auto-rehash', + self::COMMAND_OPTION_NO_AUTO_REHASH, null, InputOption::VALUE_NONE, 'Same as `-A` option to MySQL client to turn off ' . 'auto-complete (avoids long initial connection time).' ) - ->setDescription('Opens mysql client by database config from local.xml'); + ; } /** @@ -40,16 +60,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectDbSettings($output); - $args = [$input->getOption('use-mycli-instead-of-mysql') ? 'mycli' : 'mysql']; + $args = [$input->getOption(self::COMMAND_OPTION_USE_MYCLI_INSTEAD_OF_MYSQL) ? 'mycli' : 'mysql']; - if ($input->getOption('no-auto-rehash')) { + if ($input->getOption(self::COMMAND_OPTION_NO_AUTO_REHASH)) { $args[] = '--no-auto-rehash'; } $args[] = $this->getMysqlClientToolConnection(); $this->processCommand(implode(' ', $args)); - return 0; + + return Command::SUCCESS; } /** @@ -57,7 +78,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int * * @param string $command */ - private function processCommand($command) + private function processCommand(string $command): void { $descriptorSpec = [0 => STDIN, 1 => STDOUT, 2 => STDERR]; @@ -72,11 +93,8 @@ private function processCommand($command) /** * @return string */ - private function getMysqlClientToolConnection() + private function getMysqlClientToolConnection(): string { - /* @var DatabaseHelper $database */ - $database = $this->getHelper('database'); - - return $database->getMysqlClientToolConnectionString(); + return $this->getDatabaseHelper()->getMysqlClientToolConnectionString(); } } From 753fd94137c553056ed76ef94f3a52ea37e9af56 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 20 Jun 2024 00:07:06 +0200 Subject: [PATCH 082/136] [skip ci] Updated sys:cron:run command --- .../Command/System/Cron/RunCommand.php | 129 +++++++++++------- 1 file changed, 81 insertions(+), 48 deletions(-) diff --git a/src/N98/Magento/Command/System/Cron/RunCommand.php b/src/N98/Magento/Command/System/Cron/RunCommand.php index 28684ca65..3342e1e6a 100644 --- a/src/N98/Magento/Command/System/Cron/RunCommand.php +++ b/src/N98/Magento/Command/System/Cron/RunCommand.php @@ -1,61 +1,98 @@ setName('sys:cron:run') - ->addArgument('job', InputArgument::OPTIONAL, 'Job code') - ->addOption('schedule', 's', InputOption::VALUE_NONE, 'Schedule cron instead of run with current user') - ->setDescription('Runs a cronjob by job code'); - $help = <<addArgument( + self::COMMAND_ARGUMENT_JOB, + InputArgument::OPTIONAL, + 'Job code' + ) + ->addOption( + self::COMMAND_OPTION_SCHEDULE, + 's', + InputOption::VALUE_NONE, + 'Schedule cron instead of run with current user' + ) + ; + } + + /** + * @return string + */ + public function getHelp(): string + { + return <<setHelp($help); } /** * @param InputInterface $input * @param OutputInterface $output - * * @return int * @throws Exception */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + $this->detectMagento($output); + $this->initMagento(); - $jobCode = $input->getArgument('job'); + /** @var string $jobCode */ + $jobCode = $input->getArgument(self::COMMAND_ARGUMENT_JOB); if (!$jobCode) { $this->writeSection($output, 'Cronjob'); + /** @var string $jobCode */ $jobCode = $this->askJobCode($input, $output, $this->getJobs()); } @@ -65,36 +102,36 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->write('Run ' . $callableName . ' '); - if ($input->hasOption('schedule') && $input->getOption('schedule')) { + if ($input->hasOption(self::COMMAND_OPTION_SCHEDULE) && $input->getOption(self::COMMAND_OPTION_SCHEDULE)) { $this->scheduleConfigModel($callback, $jobCode); } else { $this->executeConfigModel($callback, $jobCode); } $output->writeln('done'); - return 0; + + return Command::SUCCESS; } /** * @param InputInterface $input * @param OutputInterface $output - * @param array $jobs array of array containing "job" keyed string entries of job-codes + * @param array> $jobs + * array of array containing "job" keyed string entries of job-codes * - * @return string job-code + * @return mixed job-code * @throws InvalidArgumentException|Exception when user selects invalid job interactively */ protected function askJobCode(InputInterface $input, OutputInterface $output, array $jobs) { - $index = 0; $keyMap = array_keys($jobs); $choices = []; - foreach ($jobs as $key => $job) { + foreach ($jobs as $job) { $choices[] = '' . $job['Job'] . ''; } - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new ChoiceQuestion('Please select job: ', $choices); $question->setValidator(function ($typeInput) use ($keyMap, $jobs) { $key = $keyMap[$typeInput]; @@ -111,9 +148,9 @@ protected function askJobCode(InputInterface $input, OutputInterface $output, ar /** * @param string $runConfigModel * @param string $jobCode - * @return array + * @return array{array{Mage_Core_Model_Abstract, string}&callable(): mixed, callable-string} */ - private function getCallbackFromRunConfigModel($runConfigModel, $jobCode) + private function getCallbackFromRunConfigModel(string $runConfigModel, string $jobCode): array { if (!preg_match(self::REGEX_RUN_MODEL, $runConfigModel, $runMatches)) { throw new RuntimeException( @@ -141,23 +178,20 @@ private function getCallbackFromRunConfigModel($runConfigModel, $jobCode) } /** - * @param array $callback + * @param mixed $callback * @param string $jobCode - * @throws Exception + * @throws Exception|Throwable */ - private function executeConfigModel($callback, $jobCode) + private function executeConfigModel($callback, string $jobCode): void { - Mage::getConfig()->init()->loadEventObservers('crontab'); + $this->_getMageConfig()->init()->loadEventObservers('crontab'); Mage::app()->addEventArea('crontab'); /* @var Mage_Cron_Model_Schedule $schedule */ $schedule = Mage::getModel('cron/schedule'); - if (false === $schedule) { - throw new RuntimeException('Failed to create new Mage_Cron_Model_Schedule model'); - } $environment = new ServerEnvironment(); - $environment->initalize(); + $environment->initialize(); try { $timestamp = strftime('%Y-%m-%d %H:%M:%S', time()); @@ -169,7 +203,9 @@ private function executeConfigModel($callback, $jobCode) ->setScheduledAt($timestamp) ->save(); - $callback($schedule); + if (is_callable($callback)) { + $callback($schedule); + } $schedule->setStatus(Mage_Cron_Model_Schedule::STATUS_SUCCESS); } catch (Exception $cronException) { @@ -192,16 +228,14 @@ private function executeConfigModel($callback, $jobCode) } /** - * @param array $callback + * @param mixed $callback * @param string $jobCode + * @throws Mage_Core_Exception */ - private function scheduleConfigModel($callback, $jobCode) + private function scheduleConfigModel($callback, string $jobCode): void { /* @var Mage_Cron_Model_Schedule $schedule */ $schedule = Mage::getModel('cron/schedule'); - if (false === $schedule) { - throw new RuntimeException('Failed to create new Mage_Cron_Model_Schedule model'); - } if (empty($callback)) { Mage::throwException(Mage::helper('cron')->__('No callbacks found')); @@ -221,19 +255,19 @@ private function scheduleConfigModel($callback, $jobCode) 0, $cronException ); + } catch (Throwable $e) { } } /** - * @param $jobCode + * @param string $jobCode * @return string */ - private function getRunConfigModelByJobCode($jobCode) + private function getRunConfigModelByJobCode(string$jobCode): string { - $jobsRoot = Mage::getConfig()->getNode('crontab/jobs'); - $defaultJobsRoot = Mage::getConfig()->getNode('default/crontab/jobs'); + $jobsRoot = $this->_getMageConfigNode('crontab/jobs'); + $defaultJobsRoot = $this->_getMageConfigNode('default/crontab/jobs'); - /* @var Mage_Core_Model_Config_Element $jobConfig */ $jobConfig = $jobsRoot->{$jobCode}; if (!$jobConfig || !$jobConfig->run) { $jobConfig = $defaultJobsRoot->{$jobCode}; @@ -242,7 +276,6 @@ private function getRunConfigModelByJobCode($jobCode) throw new RuntimeException(sprintf('No job-config found for job "%s"!', $jobCode)); } - /* @var Mage_Core_Model_Config_Element $runConfig */ $runConfig = $jobConfig->run; if (empty($runConfig->model)) { throw new RuntimeException(sprintf('No run-config found for job "%s"!', $jobCode)); From abf7c56b68d80a23257db4edf31efa9519c21265 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 20 Jun 2024 00:08:45 +0200 Subject: [PATCH 083/136] [skip ci] Updated sys:cron:... commands --- .../System/Cron/AbstractCronCommand.php | 38 +++++++++++------- .../Command/System/Cron/ServerEnvironment.php | 40 +++++++++---------- .../System/Cron/ServerEnvironmentTest.php | 12 +++--- 3 files changed, 48 insertions(+), 42 deletions(-) diff --git a/src/N98/Magento/Command/System/Cron/AbstractCronCommand.php b/src/N98/Magento/Command/System/Cron/AbstractCronCommand.php index e18bfd735..6953eaedf 100644 --- a/src/N98/Magento/Command/System/Cron/AbstractCronCommand.php +++ b/src/N98/Magento/Command/System/Cron/AbstractCronCommand.php @@ -3,25 +3,31 @@ namespace N98\Magento\Command\System\Cron; use AppendIterator; +use Iterator; use IteratorIterator; use Mage; +use Mage_Core_Exception; use Mage_Core_Model_Config_Element; use Mage_Cron_Exception; use Mage_Cron_Model_Schedule; use N98\Magento\Command\AbstractMagentoCommand; -use Traversable; abstract class AbstractCronCommand extends AbstractMagentoCommand { /** - * @return array + * @return array> + * @throws Mage_Core_Exception */ - protected function getJobs() + protected function getJobs(): array { $table = []; $jobs = $this->getJobConfigElements(); + /** + * @var string $name + * @var Mage_Core_Model_Config_Element $job + */ foreach ($jobs as $name => $job) { $model = null; if (isset($job->run->model)) { @@ -36,8 +42,9 @@ protected function getJobs() } /** - * @param Mage_Core_Model_Config_Element $job - * @return array of five cron values,keyed by 'm', 'h', 'D', 'M' and 'WD' + * @param Mage_Core_Model_Config_Element $job + * @return array|false of five cron values,keyed by 'm', 'h', 'D', 'M' and 'WD' + * @throws Mage_Core_Exception */ protected function getSchedule(Mage_Core_Model_Config_Element $job) { @@ -50,7 +57,7 @@ protected function getSchedule(Mage_Core_Model_Config_Element $job) $expr = $job->schedule->cron_expr; } - if ($cronExpressions = $this->parseCronExpression($expr)) { + if (is_string($expr) && $cronExpressions = $this->parseCronExpression($expr)) { return array_combine($keys, $cronExpressions); } @@ -60,18 +67,18 @@ protected function getSchedule(Mage_Core_Model_Config_Element $job) /** * Get job configuration from XML and database. Expression priority is given to the database. * - * @return AppendIterator|Mage_Core_Model_Config_Element[] + * @return AppendIterator> */ - private function getJobConfigElements() + private function getJobConfigElements(): AppendIterator { $jobs = new AppendIterator(); $paths = ['crontab/jobs', 'default/crontab/jobs']; foreach ($paths as $path) { - if ($jobConfig = Mage::getConfig()->getNode($path)) { + if ($jobConfig = $this->_getMageConfig()->getNode($path)) { $jobs->append(new IteratorIterator($jobConfig->children())); - }; + } } return $jobs; @@ -82,9 +89,11 @@ private function getJobConfigElements() * * uses magento 1 internal parser of cron expressions * - * @return array with five values (zero-indexed) or FALSE in case it does not exists. + * @param string $expr + * @return array|null with five values (zero-indexed) or FALSE in case it does not exist. + * @throws Mage_Core_Exception */ - private function parseCronExpression($expr) + private function parseCronExpression(string $expr): ?array { if ((string)$expr === 'always') { return array_fill(0, 5, '*'); @@ -96,9 +105,10 @@ private function parseCronExpression($expr) try { $schedule->setCronExpr($expr); } catch (Mage_Cron_Exception $e) { - return false; + return null; } + /** @var array $array */ $array = $schedule->getData('cron_expr_arr'); $array = array_slice($array, 0, 5); // year is optional and never parsed @@ -108,7 +118,7 @@ private function parseCronExpression($expr) try { $schedule->matchCronExpression($expression, 1); } catch (Mage_Cron_Exception $e) { - return false; + return null; } } diff --git a/src/N98/Magento/Command/System/Cron/ServerEnvironment.php b/src/N98/Magento/Command/System/Cron/ServerEnvironment.php index 1d155a8b7..c60e3cd39 100644 --- a/src/N98/Magento/Command/System/Cron/ServerEnvironment.php +++ b/src/N98/Magento/Command/System/Cron/ServerEnvironment.php @@ -1,10 +1,6 @@ |null */ - private $backup; + private ?array $backup; /** - * @var array + * @var array */ - private $keys; + private array $keys; public function __construct() { $this->keys = ['SCRIPT_NAME', 'SCRIPT_FILENAME']; } - /** - * - */ - public function initalize() + public function initialize(): void { if (isset($this->backup)) { throw new BadMethodCallException('Environment already backed up, can\'t initialize any longer'); @@ -50,19 +42,23 @@ public function initalize() throw new UnexpectedValueException('Need argv to work'); } - $basename = basename($GLOBALS['argv'][0]); + $basename = $GLOBALS['argv'][0]; + if (is_string($basename)) { + $basename = basename($basename); - foreach ($this->keys as $key) { - $buffer = $_SERVER[$key]; - $this->backup[$key] = $buffer; - $_SERVER[$key] = str_replace($basename, 'index.php', $buffer); + foreach ($this->keys as $key) { + /** @var string $buffer */ + $buffer = $_SERVER[$key]; + $this->backup[$key] = $buffer; + $_SERVER[$key] = str_replace($basename, 'index.php', $buffer); + } } } - public function reset() + public function reset(): void { if (false === isset($this->backup)) { - throw new BadMethodCallException('Environment not yet backed up, initalize first, can\'t reset'); + throw new BadMethodCallException('Environment not yet backed up, initialize first, can\'t reset'); } foreach ($this->backup as $key => $value) { diff --git a/tests/N98/Magento/Command/System/Cron/ServerEnvironmentTest.php b/tests/N98/Magento/Command/System/Cron/ServerEnvironmentTest.php index ff7cb3a96..c71c4e38d 100644 --- a/tests/N98/Magento/Command/System/Cron/ServerEnvironmentTest.php +++ b/tests/N98/Magento/Command/System/Cron/ServerEnvironmentTest.php @@ -23,8 +23,8 @@ protected function setUp(): void */ public function regression() { - $store = Mage::app()->getStore(null); - $actual = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); + $store = Mage::app()->getStore(); + $actual = $store->getBaseUrl(); self::assertIsString($actual); self::assertMatchesRegularExpression('~/(ide-phpunit.php|phpunit)/$~', $actual); } @@ -34,13 +34,13 @@ public function regression() */ public function environmentFix() { - $store = Mage::app()->getStore(null); + $store = Mage::app()->getStore(); $store->resetConfig(); $environment = new ServerEnvironment(); - $environment->initalize(); + $environment->initialize(); - $actual = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); + $actual = $store->getBaseUrl(); self::assertIsString($actual); self::assertStringEndsWith('/index.php/', $actual); @@ -48,7 +48,7 @@ public function environmentFix() $environment->reset(); - $actual = Mage::app()->getStore(null)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); + $actual = Mage::app()->getStore(null)->getBaseUrl(); self::assertIsString($actual); self::assertMatchesRegularExpression('~/(ide-phpunit.php|phpunit)/$~', $actual); } From f1f3b7e13be573fc55ceb5a58866c216ea7f4d2a Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 20 Jun 2024 00:09:59 +0200 Subject: [PATCH 084/136] [skip ci] Updated sys:cron:... commands --- .../Command/System/Cron/HistoryCommand.php | 15 +++++++++++---- .../Magento/Command/System/Cron/ListCommand.php | 10 +++++++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/N98/Magento/Command/System/Cron/HistoryCommand.php b/src/N98/Magento/Command/System/Cron/HistoryCommand.php index 4ebf590ac..d1f312c9d 100644 --- a/src/N98/Magento/Command/System/Cron/HistoryCommand.php +++ b/src/N98/Magento/Command/System/Cron/HistoryCommand.php @@ -15,6 +15,11 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +/** + * Cron history command + * + * @package N98\Magento\Command\Cron + */ class HistoryCommand extends AbstractMagentoCommand implements AbstractMagentoCommandFormatInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Last executed jobs'; @@ -35,7 +40,7 @@ class HistoryCommand extends AbstractMagentoCommand implements AbstractMagentoCo */ protected static $defaultDescription = 'Last executed cronjobs with status.'; - protected function configure() + protected function configure(): void { $this->addOption( self::COMMAND_OPTION_TIMEZONE, @@ -49,7 +54,7 @@ protected function configure() /** * {@inheritdoc} - * @return array + * @return array> * * @throws Mage_Core_Model_Store_Exception * @throws Mage_Core_Exception @@ -59,10 +64,11 @@ public function getData(InputInterface $input, OutputInterface $output): array if (is_null($this->data)) { $this->data = []; + /** @var string $timezone */ $timezone = $input->getOption(self::COMMAND_OPTION_TIMEZONE) - ?: $this->_getMage()->getStore()->getConfig('general/locale/timezone'); + ?: $this->_getMageStore()->getConfig('general/locale/timezone'); - $output->writeln('Times shown in ' . $timezone . ''); + $output->writeln(sprintf('Times shown in %s', $timezone)); $date = Mage::getSingleton('core/date'); $offset = $date->calculateOffset($timezone); @@ -71,6 +77,7 @@ public function getData(InputInterface $input, OutputInterface $output): array ->addFieldToFilter('status', ['neq' => Mage_Cron_Model_Schedule::STATUS_PENDING]) ->addOrder('finished_at'); + /** @var Mage_Cron_Model_Schedule $job */ foreach ($collection as $job) { $this->data[] = [ 'Job' => $job->getJobCode(), diff --git a/src/N98/Magento/Command/System/Cron/ListCommand.php b/src/N98/Magento/Command/System/Cron/ListCommand.php index 30001dfe8..2c95cf71b 100644 --- a/src/N98/Magento/Command/System/Cron/ListCommand.php +++ b/src/N98/Magento/Command/System/Cron/ListCommand.php @@ -4,11 +4,18 @@ namespace N98\Magento\Command\System\Cron; +use Mage_Core_Exception; +use Mage_Core_Model_Config_Element; use N98\Magento\Command\AbstractMagentoCommandFormatInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +/** + * Cron list command + * + * @package N98\Magento\Command\Cron + */ class ListCommand extends AbstractCronCommand implements AbstractMagentoCommandFormatInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Cronjobs'; @@ -29,9 +36,10 @@ class ListCommand extends AbstractCronCommand implements AbstractMagentoCommandF /** * {@inheritdoc} - * @return array> + * @return array> * * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter + * @throws Mage_Core_Exception */ public function getData(InputInterface $input, OutputInterface $output): array { From a588350d9fada4d7a30b6d3c9d197fe6a8b9ab37 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 20 Jun 2024 00:11:53 +0200 Subject: [PATCH 085/136] [skip ci] Added DDEV command for PhpStan --- .ddev/commands/web/phpstan | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 .ddev/commands/web/phpstan diff --git a/.ddev/commands/web/phpstan b/.ddev/commands/web/phpstan new file mode 100755 index 000000000..b365b081c --- /dev/null +++ b/.ddev/commands/web/phpstan @@ -0,0 +1,7 @@ +#!/bin/bash + +## Description: run PHPStan +## Usage: phpstan +## Example: ddev phpstan + +XDEBUG_MODE=off php vendor/bin/phpstan analyze "$@" From 2ee2f856124c74098147ca817d6786bd80e91c26 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 20 Jun 2024 00:58:27 +0200 Subject: [PATCH 086/136] [skip ci] Updated dev:theme:duplicates command --- .../Developer/Theme/DuplicatesCommand.php | 92 ++++++++++++++----- .../Command/Developer/Theme/InfoCommand.php | 47 ++++++---- .../Command/Developer/Theme/ListCommand.php | 7 +- 3 files changed, 101 insertions(+), 45 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Theme/DuplicatesCommand.php b/src/N98/Magento/Command/Developer/Theme/DuplicatesCommand.php index ec41260e7..7def8809e 100644 --- a/src/N98/Magento/Command/Developer/Theme/DuplicatesCommand.php +++ b/src/N98/Magento/Command/Developer/Theme/DuplicatesCommand.php @@ -5,38 +5,73 @@ use DateTime; use N98\JUnitXml\Document as JUnitXmlDocument; use N98\Magento\Command\AbstractMagentoCommand; +use Symfony\Component\Console\Attribute\AsCommand; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Finder\Finder; +use Symfony\Component\Finder\SplFileInfo; +/** + * Theme duplicates command + * + * @package N98\Magento\Command\Developer\Theme + */ class DuplicatesCommand extends AbstractMagentoCommand { - protected function configure() + public const COMMAND_ARGUMENT_THEME = 'theme'; + + public const COMMAND_ARGUMENT_ORIG_THEME = 'originalTheme'; + + public const COMMAND_OPTION_LOG_JUNIT = 'log-junit'; + + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultName = 'dev:theme:duplicates'; + + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultDescription = 'Find duplicate files (templates, layout, locale, etc.) between two themes.'; + + protected function configure(): void { $this - ->setName('dev:theme:duplicates') - ->addArgument('theme', InputArgument::REQUIRED, 'Your theme') ->addArgument( - 'originalTheme', + self::COMMAND_ARGUMENT_THEME, + InputArgument::REQUIRED, + 'Your theme' + ) + ->addArgument( + self::COMMAND_ARGUMENT_ORIG_THEME, InputArgument::OPTIONAL, - 'Original theme to comapre. Default is "base/default"', + 'Original theme to compare. Default is "base/default"', 'base/default' ) ->addOption( - 'log-junit', + self::COMMAND_OPTION_LOG_JUNIT, null, InputOption::VALUE_REQUIRED, 'Log duplicates in JUnit XML format to defined file.' ) - ->setDescription('Find duplicate files (templates, layout, locale, etc.) between two themes.') ; + } - $help = <<setHelp($help); } /** @@ -51,10 +86,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->detectMagento($output); $referenceFiles = $this->getChecksums( - $this->_magentoRootFolder . '/app/design/frontend/' . $input->getArgument('originalTheme') + $this->_magentoRootFolder . '/app/design/frontend/' + . $input->getArgument(self::COMMAND_ARGUMENT_ORIG_THEME) ); - $themeFolder = $this->_magentoRootFolder . '/app/design/frontend/' . $input->getArgument('theme'); + $themeFolder = $this->_magentoRootFolder . '/app/design/frontend/' + . $input->getArgument(self::COMMAND_ARGUMENT_THEME); $themeFiles = $this->getChecksums($themeFolder); $duplicates = []; @@ -66,8 +103,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } - if ($input->getOption('log-junit')) { - $this->logJUnit($input, $duplicates, $input->getOption('log-junit'), microtime($time) - $time); + /** @var string $filename */ + $filename = $input->getOption(self::COMMAND_OPTION_LOG_JUNIT); + if ($input->getOption(self::COMMAND_OPTION_LOG_JUNIT)) { + $this->logJUnit( + $input, + $duplicates, + $filename, + microtime(true) - $time + ); } else { if (count($duplicates) === 0) { $output->writeln('No duplicates were found'); @@ -76,26 +120,26 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } - return 0; + return Command::SUCCESS; } /** * @param string $baseFolder - * @return array + * @return array */ - protected function getChecksums($baseFolder) + protected function getChecksums(string $baseFolder): array { $finder = Finder::create(); $finder ->files() - ->ignoreUnreadableDirs(true) + ->ignoreUnreadableDirs() ->ignoreDotFiles(true) ->ignoreVCS(true) ->followLinks() ->in($baseFolder); $checksums = []; foreach ($finder as $file) { - /* @var \Symfony\Component\Finder\SplFileInfo $file */ + /* @var SplFileInfo $file */ if (file_exists($file->getRealPath())) { $checksums[$file->getRelativePathname()] = md5_file($file->getRealPath()); } @@ -106,11 +150,11 @@ protected function getChecksums($baseFolder) /** * @param InputInterface $input - * @param array $duplicates - * @param string $filename - * @param float $duration + * @param array $duplicates + * @param string $filename + * @param float $duration */ - protected function logJUnit($input, array $duplicates, $filename, $duration) + protected function logJUnit(InputInterface $input, array $duplicates, string $filename, float $duration): void { $document = new JUnitXmlDocument(); $suite = $document->addTestSuite(); @@ -120,8 +164,8 @@ protected function logJUnit($input, array $duplicates, $filename, $duration) $testCase = $suite->addTestCase(); $testCase->setName( - 'Magento Duplicate Theme Files: ' . $input->getArgument('theme') . ' | ' . - $input->getArgument('originalTheme') + 'Magento Duplicate Theme Files: ' . $input->getArgument(self::COMMAND_ARGUMENT_THEME) . ' | ' . + $input->getArgument(self::COMMAND_ARGUMENT_ORIG_THEME) ); $testCase->setClassname('ConflictsCommand'); foreach ($duplicates as $duplicate) { diff --git a/src/N98/Magento/Command/Developer/Theme/InfoCommand.php b/src/N98/Magento/Command/Developer/Theme/InfoCommand.php index 9635bbf97..723f02841 100644 --- a/src/N98/Magento/Command/Developer/Theme/InfoCommand.php +++ b/src/N98/Magento/Command/Developer/Theme/InfoCommand.php @@ -4,11 +4,10 @@ namespace N98\Magento\Command\Developer\Theme; -use Mage; use Mage_Core_Model_Store; +use Mage_Core_Model_Website; use N98\Magento\Command\AbstractMagentoCommand; use N98\Magento\Command\AbstractMagentoStoreConfigCommand; -use Parameter; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; @@ -21,6 +20,8 @@ */ class InfoCommand extends AbstractMagentoCommand { + public const THEMES_EXCEPTION = '_ua_regexp'; + /** * @var string * @deprecated with symfony 6.1 @@ -35,15 +36,13 @@ class InfoCommand extends AbstractMagentoCommand */ protected static $defaultDescription = 'Displays settings of current design on particular store view.'; - public const THEMES_EXCEPTION = '_ua_regexp'; - /** - * @var array + * @var array */ protected array $_configNodes = ['Theme translations' => 'design/theme/locale']; /** - * @var array + * @var array */ protected array $_configNodesWithExceptions = [ 'Design Package Name' => 'design/package/name', @@ -63,9 +62,7 @@ class InfoCommand extends AbstractMagentoCommand protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output); - if (!$this->initMagento()) { - return Command::FAILURE; - } + $this->initMagento(); foreach ($this->_getMage()->getWebsites() as $website) { foreach ($website->getStores() as $store) { @@ -83,39 +80,48 @@ protected function execute(InputInterface $input, OutputInterface $output): int */ protected function _displayTable(OutputInterface $output, Mage_Core_Model_Store $store): InfoCommand { + /** @var Mage_Core_Model_Website $website */ + $website = $store->getWebsite(); + $this->writeSection( $output, - 'Current design setting on store: ' . $store->getWebsite()->getCode() . '/' . $store->getCode() + 'Current design setting on store: ' . $website->getCode() . '/' . $store->getCode() ); $storeInfoLines = $this->_parse($this->_configNodesWithExceptions, $store, true); $storeInfoLines = array_merge($storeInfoLines, $this->_parse($this->_configNodes, $store)); $tableHelper = $this->getTableHelper(); $tableHelper - ->setHeaders([Parameter::class, 'Value']) + ->setHeaders(['Parameter', 'Value']) ->renderByFormat($output, $storeInfoLines); return $this; } /** - * @param array $nodes + * @param array $nodes * @param Mage_Core_Model_Store $store * @param bool $withExceptions - * @return array + * @return array> */ protected function _parse(array $nodes, Mage_Core_Model_Store $store, bool $withExceptions = false): array { $result = []; foreach ($nodes as $nodeLabel => $node) { - $result[] = [$nodeLabel, (string) Mage::getConfig()->getNode( - $node, - AbstractMagentoStoreConfigCommand::SCOPE_STORE_VIEW, - $store->getCode() - )]; + $result[] = [ + $nodeLabel, + (string) $this->_getMageConfig()->getNode( + $node, + AbstractMagentoStoreConfigCommand::SCOPE_STORE_VIEW, + $store->getCode() + ) + ]; if ($withExceptions) { - $result[] = [$nodeLabel . ' exceptions', $this->_parseException($node, $store)]; + $result[] = [ + $nodeLabel . ' exceptions', + $this->_parseException($node, $store) + ]; } } @@ -129,7 +135,7 @@ protected function _parse(array $nodes, Mage_Core_Model_Store $store, bool $with */ protected function _parseException(string $node, Mage_Core_Model_Store $store): string { - $exception = (string) Mage::getConfig()->getNode( + $exception = (string) $this->_getMageConfig()->getNode( $node . self::THEMES_EXCEPTION, AbstractMagentoStoreConfigCommand::SCOPE_STORE_VIEW, $store->getCode() @@ -139,6 +145,7 @@ protected function _parseException(string $node, Mage_Core_Model_Store $store): return ''; } + /** @var array> $exceptions */ $exceptions = unserialize($exception); $result = []; foreach ($exceptions as $expression) { diff --git a/src/N98/Magento/Command/Developer/Theme/ListCommand.php b/src/N98/Magento/Command/Developer/Theme/ListCommand.php index df324dc7c..63b8297e3 100644 --- a/src/N98/Magento/Command/Developer/Theme/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Theme/ListCommand.php @@ -11,6 +11,11 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +/** + * Theme list command + * + * @package N98\Magento\Command\Developer\Theme + */ class ListCommand extends AbstractMagentoCommand implements AbstractMagentoCommandFormatInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Themes'; @@ -53,7 +58,7 @@ public function getData(InputInterface $input, OutputInterface $output): array } /** - * @return array + * @return array> */ protected function getThemes(): array { From eb498af6a48cca69f330d551157d4b9741b31e9f Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 20 Jun 2024 01:15:16 +0200 Subject: [PATCH 087/136] [skip ci] Updated dev:translate:export command --- .../Developer/Translate/ExportCommand.php | 89 ++++++++++++++----- .../Translate/InlineAdminCommand.php | 2 +- .../Developer/Translate/InlineShopCommand.php | 2 +- 3 files changed, 69 insertions(+), 24 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Translate/ExportCommand.php b/src/N98/Magento/Command/Developer/Translate/ExportCommand.php index 812c4b058..651bc4942 100644 --- a/src/N98/Magento/Command/Developer/Translate/ExportCommand.php +++ b/src/N98/Magento/Command/Developer/Translate/ExportCommand.php @@ -1,70 +1,115 @@ setName('dev:translate:export') - ->setDescription('Export inline translations') - ->addArgument('locale', InputOption::VALUE_REQUIRED, Locale::class) - ->addArgument('filename', InputArgument::OPTIONAL, 'Export filename') - ->addOption('store', null, InputOption::VALUE_OPTIONAL, 'Limit to a special store'); + ->addArgument( + self::COMMAND_ARGUMENT_LOCALE, + InputOption::VALUE_REQUIRED, + Locale::class + ) + ->addArgument( + self::COMMAND_ARGUMENT_FILENAME, + InputArgument::OPTIONAL, + 'Export filename' + ) + ->addOption( + self::COMMAND_OPTION_STORE, + null, + InputOption::VALUE_OPTIONAL, + 'Limit to a special store' + ); } /** * @param InputInterface $input * @param OutputInterface $output - * * @return int + * @throws Mage_Core_Model_Store_Exception */ protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output); - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); - /** @var DatabaseHelper $helper */ - $helper = $this->getHelper('database'); + $helper = $this->getDatabaseHelper(); $db = $helper->getConnection(); - $filename = $input->getArgument('filename'); + /** @var string $filename */ + $filename = $input->getArgument(self::COMMAND_ARGUMENT_FILENAME); if (!$filename) { $filename = 'translate.csv'; } - $locale = $input->getArgument('locale'); + $locale = $input->getArgument(self::COMMAND_ARGUMENT_LOCALE); $output->writeln('Exporting to ' . $filename . ''); + /** @var string $store */ + $store = $input->getOption(self::COMMAND_OPTION_STORE); $parameters = ['locale' => $locale]; $sql = "SELECT * FROM core_translate WHERE locale = :locale"; - if ($input->getOption('store')) { + if ($store) { $sql .= ' AND store_id = :store_id'; - $parameters['store_id'] = Mage::app()->getStore($input->getOption('store')); + $parameters['store_id'] = Mage::app()->getStore($store); } $statement = $db->prepare($sql); $statement->execute($parameters); $result = $statement->fetchAll(); - $f = fopen($filename, 'w'); - foreach ($result as $row) { - fputcsv($f, [$row['string'], $row['translate']]); + if ($result) { + $f = fopen($filename, 'w'); + if ($f) { + foreach ($result as $row) { + fputcsv($f, [$row['string'], $row['translate']]); + } + + fclose($f); + } } - fclose($f); - return 0; + return Command::SUCCESS; } } diff --git a/src/N98/Magento/Command/Developer/Translate/InlineAdminCommand.php b/src/N98/Magento/Command/Developer/Translate/InlineAdminCommand.php index c0a8a85fb..7b6ed764d 100644 --- a/src/N98/Magento/Command/Developer/Translate/InlineAdminCommand.php +++ b/src/N98/Magento/Command/Developer/Translate/InlineAdminCommand.php @@ -50,7 +50,7 @@ class InlineAdminCommand extends AbstractMagentoStoreConfigCommand * @param Mage_Core_Model_Store $store * @param bool $disabled */ - protected function _afterSave(Mage_Core_Model_Store $store, bool $disabled) + protected function _afterSave(Mage_Core_Model_Store $store, bool $disabled): void { $this->detectAskAndSetDeveloperIp($store, $disabled); } diff --git a/src/N98/Magento/Command/Developer/Translate/InlineShopCommand.php b/src/N98/Magento/Command/Developer/Translate/InlineShopCommand.php index 85f170fd1..ced7135b1 100644 --- a/src/N98/Magento/Command/Developer/Translate/InlineShopCommand.php +++ b/src/N98/Magento/Command/Developer/Translate/InlineShopCommand.php @@ -45,7 +45,7 @@ class InlineShopCommand extends AbstractMagentoStoreConfigCommand * @param Mage_Core_Model_Store $store * @param bool $disabled */ - protected function _afterSave(Mage_Core_Model_Store $store, bool $disabled) + protected function _afterSave(Mage_Core_Model_Store $store, bool $disabled): void { $this->detectAskAndSetDeveloperIp($store, $disabled); } From 386e46e7d48a4c507d3b6eb9c1a92a867f40f83d Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 20 Jun 2024 01:26:33 +0200 Subject: [PATCH 088/136] [skip ci] Updated dev:translate:set command --- .../Developer/Translate/SetCommand.php | 81 ++++++++++++++----- 1 file changed, 61 insertions(+), 20 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Translate/SetCommand.php b/src/N98/Magento/Command/Developer/Translate/SetCommand.php index 68421dc4d..18682f97f 100644 --- a/src/N98/Magento/Command/Developer/Translate/SetCommand.php +++ b/src/N98/Magento/Command/Developer/Translate/SetCommand.php @@ -1,55 +1,95 @@ Globally for locale'; + + protected function configure(): void { $this - ->setName('dev:translate:set') - ->addArgument('string', InputArgument::REQUIRED, 'String to translate') - ->addArgument('translate', InputArgument::REQUIRED, 'Translated string') - ->addArgument('store', InputArgument::OPTIONAL) - ->setDescription('Adds a translation to core_translate table. Globally for locale') + ->addArgument( + self::COMMAND_ARGUMENT_STRING, + InputArgument::REQUIRED, + 'String to translate') + ->addArgument( + self::COMMAND_ARGUMENT_TRANSLATE, + InputArgument::REQUIRED, + 'Translated string') + ->addArgument( + self::COMMAND_ARGUMENT_STORE, + InputArgument::OPTIONAL + ) ; } /** * @param InputInterface $input * @param OutputInterface $output - * * @return int - * @throws \Exception + * @throws Exception */ protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output); - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); - /** @var ParameterHelper $parameterHelper */ - $parameterHelper = $this->getHelper('parameter'); + $parameterHelper = $this->getParameterHelper(); + /** @var Mage_Core_Model_Store $store */ $store = $parameterHelper->askStore($input, $output); + /** @var string $locale */ $locale = Mage::getStoreConfig('general/locale/code', $store->getId()); - /* @var \Mage_Core_Model_Store $store */ + /** @var string $string */ + $string = $input->getArgument(self::COMMAND_ARGUMENT_STRING); + + /** @var string $translate */ + $translate = $input->getArgument(self::COMMAND_ARGUMENT_TRANSLATE); + $resource = Mage::getResourceModel('core/translate_string'); $resource->saveTranslate( - $input->getArgument('string'), - $input->getArgument('translate'), + $string, + $translate, $locale, $store->getId() ); @@ -58,13 +98,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int sprintf( 'Translated (%s): %s => %s', $locale, - $input->getArgument('string'), - $input->getArgument('translate') + $string, + $translate ) ); $input = new StringInput('cache:flush'); $this->getApplication()->run($input, new NullOutput()); - return 0; + + return Command::SUCCESS; } } From 4caacb3e2df3d474752efb02057d3538a41dab6e Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 20 Jun 2024 01:28:17 +0200 Subject: [PATCH 089/136] [skip ci] Fixes signatures --- .../Magento/Command/Developer/TemplateHintsBlocksCommand.php | 2 +- src/N98/Magento/Command/Developer/TemplateHintsCommand.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/N98/Magento/Command/Developer/TemplateHintsBlocksCommand.php b/src/N98/Magento/Command/Developer/TemplateHintsBlocksCommand.php index c1dff3910..d81071fa3 100644 --- a/src/N98/Magento/Command/Developer/TemplateHintsBlocksCommand.php +++ b/src/N98/Magento/Command/Developer/TemplateHintsBlocksCommand.php @@ -57,7 +57,7 @@ class TemplateHintsBlocksCommand extends AbstractMagentoStoreConfigCommand * @param Mage_Core_Model_Store $store * @param bool $disabled */ - protected function _afterSave(Mage_Core_Model_Store $store, bool $disabled) + protected function _afterSave(Mage_Core_Model_Store $store, bool $disabled): void { $this->detectAskAndSetDeveloperIp($store, $disabled); } diff --git a/src/N98/Magento/Command/Developer/TemplateHintsCommand.php b/src/N98/Magento/Command/Developer/TemplateHintsCommand.php index 91a321399..6eb9a2694 100644 --- a/src/N98/Magento/Command/Developer/TemplateHintsCommand.php +++ b/src/N98/Magento/Command/Developer/TemplateHintsCommand.php @@ -57,7 +57,7 @@ class TemplateHintsCommand extends AbstractMagentoStoreConfigCommand * @param Mage_Core_Model_Store $store * @param bool $disabled */ - protected function _afterSave(Mage_Core_Model_Store $store, bool $disabled) + protected function _afterSave(Mage_Core_Model_Store $store, bool $disabled): void { $this->detectAskAndSetDeveloperIp($store, $disabled); } From 20d43dc167c2aaf597f85cfaf28e1bfd84f386b0 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 20 Jun 2024 01:29:47 +0200 Subject: [PATCH 090/136] [skip ci] Updated AbstractMagentoStoreConfigCommand --- .../AbstractMagentoStoreConfigCommand.php | 128 +++++++++--------- 1 file changed, 67 insertions(+), 61 deletions(-) diff --git a/src/N98/Magento/Command/AbstractMagentoStoreConfigCommand.php b/src/N98/Magento/Command/AbstractMagentoStoreConfigCommand.php index e760d13f0..cf7ba3594 100644 --- a/src/N98/Magento/Command/AbstractMagentoStoreConfigCommand.php +++ b/src/N98/Magento/Command/AbstractMagentoStoreConfigCommand.php @@ -1,13 +1,16 @@ setName($this->commandName) - ->addOption('on', null, InputOption::VALUE_NONE, 'Switch on') - ->addOption('off', null, InputOption::VALUE_NONE, 'Switch off') - ->setDescription($this->commandDescription) + ->addOption( + self::COMMAND_OPTION_ON, + null, + InputOption::VALUE_NONE, + 'Switch on' + ) + ->addOption( + self::COMMAND_OPTION_OFF, + null, + InputOption::VALUE_NONE, + 'Switch off' + ) ; if ($this->scope == self::SCOPE_STORE_VIEW_GLOBAL) { @@ -101,32 +106,31 @@ protected function configure() /** * @param InputInterface $input * @param OutputInterface $output - * * @return int + * @throws Mage_Core_Model_Store_Exception + * @throws Exception */ protected function execute(InputInterface $input, OutputInterface $output): int { - $store = null; - $runOnStoreView = null; $this->detectMagento($output); - if ($this->initMagento()) { - $runOnStoreView = false; - if ($this->scope == self::SCOPE_STORE_VIEW - || ($this->scope == self::SCOPE_STORE_VIEW_GLOBAL && !$input->getOption('global')) - ) { - $runOnStoreView = true; - } - - if ($runOnStoreView) { - $store = $this->_initStore($input, $output); - } else { - $store = Mage::app()->getStore(Mage_Core_Model_App::ADMIN_STORE_ID); - } + $this->initMagento(); + + $runOnStoreView = false; + if ($this->scope == self::SCOPE_STORE_VIEW + || ($this->scope == self::SCOPE_STORE_VIEW_GLOBAL && !$input->getOption('global')) + ) { + $runOnStoreView = true; + } + + if ($runOnStoreView) { + $store = $this->_initStore($input, $output); + } else { + $store = Mage::app()->getStore(Mage_Core_Model_App::ADMIN_STORE_ID); } - if ($input->getOption('on')) { + if ($input->getOption(self::COMMAND_OPTION_ON)) { $isFalse = true; - } elseif ($input->getOption('off')) { + } elseif ($input->getOption(self::COMMAND_OPTION_OFF)) { $isFalse = false; } else { $isFalse = !Mage::getStoreConfigFlag($this->configPath, $store->getId()); @@ -152,18 +156,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int $input = new StringInput('cache:flush'); $this->getApplication()->run($input, new NullOutput()); - return 0; + + return Command::SUCCESS; } /** * Determine if a developer restriction is in place, and if we're enabling something that will use it * then notify and ask if it needs to be changed from its current value. * - * @param \Mage_Core_Model_Store $store - * @param bool $enabled + * @param Mage_Core_Model_Store $store + * @param bool $enabled * @return void */ - protected function detectAskAndSetDeveloperIp(Mage_Core_Model_Store $store, $enabled) + protected function detectAskAndSetDeveloperIp(Mage_Core_Model_Store $store, bool $enabled): void { if (!$enabled) { // No need to notify about developer IP restrictions if we're disabling template hints etc @@ -182,14 +187,18 @@ protected function detectAskAndSetDeveloperIp(Mage_Core_Model_Store $store, $ena /** * Ask if the developer IP should be changed, and change it if required * - * @param InputInterface $input + * @param InputInterface $input * @param OutputInterface $output - * @param \Mage_Core_Model_Store $store + * @param Mage_Core_Model_Store $store * @param string|null $devRestriction * @return void */ - protected function askAndSetDeveloperIp(InputInterface $input, OutputInterface $output, Mage_Core_Model_Store $store, $devRestriction) - { + protected function askAndSetDeveloperIp( + InputInterface $input, + OutputInterface $output, + Mage_Core_Model_Store $store, + ?string $devRestriction + ): void { $output->writeln( sprintf( 'Please note: developer IP restriction is enabled for %s.', @@ -197,8 +206,7 @@ protected function askAndSetDeveloperIp(InputInterface $input, OutputInterface $ ) ); - /** @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new Question('Change developer IP? Enter a new IP to change or leave blank: '); $newDeveloperIp = $dialog->ask($input, $output, $question); @@ -213,10 +221,10 @@ protected function askAndSetDeveloperIp(InputInterface $input, OutputInterface $ /** * Set the restricted IP for developer access * - * @param \Mage_Core_Model_Store $store - * @param string $newDeveloperIp + * @param Mage_Core_Model_Store $store + * @param string $newDeveloperIp */ - protected function setDeveloperIp(Mage_Core_Model_Store $store, $newDeveloperIp) + protected function setDeveloperIp(Mage_Core_Model_Store $store, string $newDeveloperIp): void { Mage::getModel('core/config') ->saveConfig('dev/restrict/allow_ips', $newDeveloperIp, 'stores', $store->getId()); @@ -225,30 +233,28 @@ protected function setDeveloperIp(Mage_Core_Model_Store $store, $newDeveloperIp) /** * @param InputInterface $input * @param OutputInterface $output - * * @return mixed */ protected function _initStore(InputInterface $input, OutputInterface $output) { - /** @var ParameterHelper $parameterHelper */ - $parameterHelper = $this->getHelper('parameter'); + $parameterHelper = $this->getParameterHelper(); return $parameterHelper->askStore($input, $output, 'store', $this->withAdminStore); } /** - * @param \Mage_Core_Model_Store $store + * @param Mage_Core_Model_Store $store * @param bool $disabled */ - protected function _beforeSave(Mage_Core_Model_Store $store, $disabled) + protected function _beforeSave(Mage_Core_Model_Store $store, bool $disabled): void { } /** - * @param \Mage_Core_Model_Store $store + * @param Mage_Core_Model_Store $store * @param bool $disabled */ - protected function _afterSave(Mage_Core_Model_Store $store, $disabled) + protected function _afterSave(Mage_Core_Model_Store $store, bool $disabled): void { } } From 353c98aa5cedefcd6f396960c1cf366d3d695290 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 20 Jun 2024 02:01:29 +0200 Subject: [PATCH 091/136] [skip ci] Updated admin:user:delete command --- .../Command/Admin/User/DeleteUserCommand.php | 63 +++++++++++++------ 1 file changed, 44 insertions(+), 19 deletions(-) diff --git a/src/N98/Magento/Command/Admin/User/DeleteUserCommand.php b/src/N98/Magento/Command/Admin/User/DeleteUserCommand.php index a161800f6..9f63217c2 100644 --- a/src/N98/Magento/Command/Admin/User/DeleteUserCommand.php +++ b/src/N98/Magento/Command/Admin/User/DeleteUserCommand.php @@ -1,51 +1,74 @@ setName('admin:user:delete') - ->addArgument('id', InputArgument::OPTIONAL, 'Username or Email') - ->addOption('force', 'f', InputOption::VALUE_NONE, 'Force') - ->setDescription('Delete the account of a adminhtml user.') + ->addArgument( + self::COMMAND_ARGUMENT_ID, + InputArgument::OPTIONAL, + 'Username or Email' + ) + ->addOption( + self::COMMAND_OPTION_FORCE, + 'f', + InputOption::VALUE_NONE, + 'Force' + ) ; } /** * @param InputInterface $input * @param OutputInterface $output - * * @return int + * @throws Throwable */ protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output); - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); - // Username - $id = $this->getOrAskForArgument('id', $input, $output, 'Username or Email'); + $id = $this->getOrAskForArgument(self::COMMAND_ARGUMENT_ID, $input, $output, 'Username or Email'); $user = $this->getUserModel()->loadByUsername($id); if (!$user->getId()) { @@ -54,10 +77,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (!$user->getId()) { $output->writeln('User was not found'); - return 0; + + return Command::SUCCESS; } - $shouldRemove = $input->getOption('force'); + $shouldRemove = $input->getOption(self::COMMAND_OPTION_FORCE); if (!$shouldRemove) { $shouldRemove = $dialog->ask( $input, @@ -76,6 +100,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } else { $output->writeln('Aborting delete'); } - return 0; + + return Command::SUCCESS; } } From 0f478bd3e1932c58257e00bf1dc085856dd005fe Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 20 Jun 2024 02:03:34 +0200 Subject: [PATCH 092/136] [skip ci] Updated AbstractAdminUserCommand --- .../Admin/User/AbstractAdminUserCommand.php | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php b/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php index 4e8c64eb1..13bd2e3b2 100644 --- a/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php +++ b/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php @@ -1,32 +1,43 @@ _getModel('admin/user', 'Mage_User_Model_User'); + return Mage::getModel('admin/user'); } /** - * @return \Mage_Core_Model_Abstract + * @return Mage_Admin_Model_Roles */ - protected function getRoleModel() + protected function getRoleModel(): Mage_Admin_Model_Roles { - return $this->_getModel('admin/roles', 'Mage_User_Model_Role'); + return Mage::getModel('admin/roles'); } /** - * @return \Mage_Core_Model_Abstract + * @return Mage_Admin_Model_Rules */ - protected function getRulesModel() + protected function getRulesModel(): Mage_Admin_Model_Rules { - return $this->_getModel('admin/rules', 'Mage_User_Model_Rules'); + return Mage::getModel('admin/rules'); } } From a11a60fd659221c0c61a3bb0f7acc4eed63b00c0 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 20 Jun 2024 02:04:18 +0200 Subject: [PATCH 093/136] [skip ci] Updated admin:user:change-password command --- .../Command/Admin/User/ChangePasswordCommand.php | 11 ++++++----- src/N98/Magento/Command/Admin/User/ListCommand.php | 7 ++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/N98/Magento/Command/Admin/User/ChangePasswordCommand.php b/src/N98/Magento/Command/Admin/User/ChangePasswordCommand.php index 30b79e3ea..52a66d439 100644 --- a/src/N98/Magento/Command/Admin/User/ChangePasswordCommand.php +++ b/src/N98/Magento/Command/Admin/User/ChangePasswordCommand.php @@ -6,8 +6,8 @@ use Exception; use RuntimeException; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Attribute\AsCommand; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -39,7 +39,7 @@ class ChangePasswordCommand extends AbstractAdminUserCommand */ protected static $defaultDescription = 'Changes the password of a adminhtml user.'; - protected function configure() + protected function configure(): void { $this ->addArgument( @@ -58,7 +58,6 @@ protected function configure() /** * @param InputInterface $input * @param OutputInterface $output - * * @return int * @throws Throwable */ @@ -69,8 +68,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int $dialog = $this->getQuestionHelper(); - // Username - if (($username = $input->getArgument(self::COMMAND_ARGUMENT_USERNAME)) == null) { + /** @var string|null $username */ + $username = $input->getArgument(self::COMMAND_ARGUMENT_USERNAME); + if ($username === null) { + /** @var string $username */ $username = $dialog->ask($input, $output, new Question('Username: ')); } diff --git a/src/N98/Magento/Command/Admin/User/ListCommand.php b/src/N98/Magento/Command/Admin/User/ListCommand.php index 4b6b6bdf0..1f5ea7d05 100644 --- a/src/N98/Magento/Command/Admin/User/ListCommand.php +++ b/src/N98/Magento/Command/Admin/User/ListCommand.php @@ -10,6 +10,11 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +/** + * List admin command + * + * @package N98\Magento\Command\Admin\User + */ class ListCommand extends AbstractAdminUserCommand implements AbstractMagentoCommandFormatInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Admin users'; @@ -39,9 +44,9 @@ public function getData(InputInterface $input, OutputInterface $output): array if (is_null($this->data)) { $this->data = []; - /** @var Mage_Admin_Model_User $userModel */ $userModel = $this->getUserModel(); $userList = $userModel->getCollection(); + /** @var Mage_Admin_Model_User $user */ foreach ($userList as $user) { $this->data[] = [ 'id' => $user->getId(), From 5131d431be82ea0775a4abe12887d095646653c4 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 20 Jun 2024 03:38:08 +0200 Subject: [PATCH 094/136] [skip ci] Updated admin:user:... commands --- .../Admin/User/AbstractAdminUserCommand.php | 34 ++++ .../Admin/User/ChangeStatusCommand.php | 140 ++++++++------ .../Command/Admin/User/CreateUserCommand.php | 179 ++++++++++++------ .../Command/Admin/User/DeleteUserCommand.php | 20 +- 4 files changed, 250 insertions(+), 123 deletions(-) diff --git a/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php b/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php index 13bd2e3b2..80402b8d6 100644 --- a/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php +++ b/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php @@ -9,6 +9,9 @@ use Mage_Admin_Model_Rules; use Mage_Admin_Model_User; use N98\Magento\Command\AbstractMagentoCommand; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; /** * Class AbstractAdminUserCommand @@ -17,6 +20,19 @@ */ abstract class AbstractAdminUserCommand extends AbstractMagentoCommand { + public const COMMAND_ARGUMENT_ID = 'id'; + + protected function configure(): void + { + $this + ->addArgument( + self::COMMAND_ARGUMENT_ID, + InputArgument::OPTIONAL, + 'Username or Email' + ) + ; + } + /** * @return Mage_Admin_Model_User */ @@ -40,4 +56,22 @@ protected function getRulesModel(): Mage_Admin_Model_Rules { return Mage::getModel('admin/rules'); } + + /** + * Get User by ID or Email + * + * @param InputInterface $input + * @param OutputInterface $output + * @return Mage_Admin_Model_User + */ + protected function getUserByIdOrEmail(InputInterface $input, OutputInterface $output): Mage_Admin_Model_User + { + $id = $this->getOrAskForArgument(self::COMMAND_ARGUMENT_ID, $input, $output, 'Username or Email'); + $user = $this->getUserModel()->loadByUsername($id); + if (!$user->getId()) { + $user = $this->getUserModel()->load($id, 'email'); + } + + return $user; + } } diff --git a/src/N98/Magento/Command/Admin/User/ChangeStatusCommand.php b/src/N98/Magento/Command/Admin/User/ChangeStatusCommand.php index e113d9df5..8c017ac19 100644 --- a/src/N98/Magento/Command/Admin/User/ChangeStatusCommand.php +++ b/src/N98/Magento/Command/Admin/User/ChangeStatusCommand.php @@ -1,87 +1,121 @@ setName('admin:user:change-status') - ->addArgument('id', InputArgument::OPTIONAL, 'Username or Email') - ->addOption('activate', null, InputOption::VALUE_NONE, 'Activate user') - ->addOption('deactivate', null, InputOption::VALUE_NONE, 'Deactivate user') - ->setDescription('Set active status of an adminhtml user. If no option is set the status will be toggled.') + ->addOption( + self::COMMAND_OPTION_ACTIVATE, + null, + InputOption::VALUE_NONE, + 'Activate user' + ) + ->addOption( + self::COMMAND_OPTION_DEACTIVATE, + null, + InputOption::VALUE_NONE, + 'Deactivate user' + ) ; } /** * @param InputInterface $input * @param OutputInterface $output - * * @return int + * @throws Throwable */ protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output); - if ($this->initMagento()) { - // Username + $this->initMagento(); - $id = $this->getOrAskForArgument('id', $input, $output, 'Username or Email'); - $user = $this->getUserModel()->loadByUsername($id); - if (!$user->getId()) { - $user = $this->getUserModel()->load($id, 'email'); + $user = $this->getUserByIdOrEmail($input, $output); + if (!$user->getId()) { + $output->writeln('User was not found'); + + return Command::INVALID; + } + + try { + $result = $user->validate(); + + if (is_array($result)) { + throw new RuntimeException(implode(PHP_EOL, $result)); + } + + if ($input->getOption(self::COMMAND_OPTION_ACTIVATE)) { + $user->setIsActive(1); } - if (!$user->getId()) { - $output->writeln('User was not found'); - return 0; + if ($input->getOption(self::COMMAND_OPTION_DEACTIVATE)) { + $user->setIsActive(0); } - try { - $result = $user->validate(); - - if (is_array($result)) { - throw new RuntimeException(implode(PHP_EOL, $result)); - } - - if ($input->getOption('activate')) { - $user->setIsActive(1); - } - - if ($input->getOption('deactivate')) { - $user->setIsActive(0); - } - - // toggle is_active - if (!$input->getOption('activate') && !$input->getOption('deactivate')) { - $user->setIsActive(!$user->getIsActive()); // toggle - } - - $user->save(); - - if ($user->getIsActive() == 1) { - $output->writeln( - 'User ' . $user->getUsername() . '' . - ' is now active' - ); - } else { - $output->writeln( - 'User ' . $user->getUsername() . '' . - ' is now inactive' - ); - } - } catch (Exception $e) { - $output->writeln('' . $e->getMessage() . ''); + // toggle is_active + if (!$input->getOption(self::COMMAND_OPTION_ACTIVATE) + && !$input->getOption(self::COMMAND_OPTION_DEACTIVATE) + ) { + $user->setIsActive((int)!$user->getIsActive()); } + + $user->save(); + + if ($user->getIsActive() == 1) { + $output->writeln(sprintf( + 'User %s is now active', + $user->getUsername() + )); + } else { + $output->writeln(sprintf( + 'User %s is now inactive', + $user->getUsername() + )); + } + } catch (Exception $e) { + $output->writeln(sprintf('%s', $e->getMessage())); } - return 0; + + return Command::SUCCESS; } } diff --git a/src/N98/Magento/Command/Admin/User/CreateUserCommand.php b/src/N98/Magento/Command/Admin/User/CreateUserCommand.php index a43bf6dbc..222fb1b8a 100644 --- a/src/N98/Magento/Command/Admin/User/CreateUserCommand.php +++ b/src/N98/Magento/Command/Admin/User/CreateUserCommand.php @@ -1,27 +1,83 @@ setName('admin:user:create') - ->addArgument('username', InputArgument::OPTIONAL, 'Username') - ->addArgument('email', InputArgument::OPTIONAL, 'Email, empty string = generate') - ->addArgument('password', InputArgument::OPTIONAL, 'Password') - ->addArgument('firstname', InputArgument::OPTIONAL, 'Firstname') - ->addArgument('lastname', InputArgument::OPTIONAL, 'Lastname') - ->addArgument('role', InputArgument::OPTIONAL, 'Role') - ->setDescription('Create admin user.') + ->addArgument( + self::COMMAND_ARGUMENT_USERNAME, + InputArgument::OPTIONAL, + 'Username' + ) + ->addArgument( + self::COMMAND_ARGUMENT_EMAIL, + InputArgument::OPTIONAL, + 'Email, empty string = generate' + ) + ->addArgument( + self::COMMAND_ARGUMENT_PASSWORD, + InputArgument::OPTIONAL, + 'Password' + ) + ->addArgument( + self::COMMAND_ARGUMENT_FIRSTNAME, + InputArgument::OPTIONAL, + 'Firstname' + ) + ->addArgument( + self::COMMAND_ARGUMENT_LASTNAME, + InputArgument::OPTIONAL, + 'Lastname' + ) + ->addArgument( + self::COMMAND_ARGUMENT_ROLE, + InputArgument::OPTIONAL, + 'Role' + ) ; } @@ -29,57 +85,72 @@ protected function configure() * @param InputInterface $input * @param OutputInterface $output * @return int + * @throws Mage_Core_Exception + * @throws Throwable */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output, true); - if ($this->initMagento()) { - $username = $this->getOrAskForArgument('username', $input, $output); - $email = $this->getOrAskForArgument('email', $input, $output); - if (($password = $input->getArgument('password')) === null) { - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); - $question = new Question('Password: '); - $question->setHidden(true); - $password = $dialog->ask($input, $output, $question); + $this->detectMagento($output); + $this->initMagento(); + + $username = $this->getOrAskForArgument(self::COMMAND_ARGUMENT_USERNAME, $input, $output); + $email = $this->getOrAskForArgument(self::COMMAND_ARGUMENT_EMAIL, $input, $output); + if (($password = $input->getArgument(self::COMMAND_ARGUMENT_PASSWORD)) === null) { + $dialog = $this->getQuestionHelper(); + $question = new Question('Password: '); + $question->setHidden(true); + $password = $dialog->ask($input, $output, $question); + } + + $firstname = $this->getOrAskForArgument(self::COMMAND_ARGUMENT_FIRSTNAME, $input, $output); + $lastname = $this->getOrAskForArgument(self::COMMAND_ARGUMENT_LASTNAME, $input, $output); + /** @var string|null $roleName */ + $roleName = $input->getArgument(self::COMMAND_ARGUMENT_ROLE); + if ($roleName !== null) { + $role = $this->getRoleModel()->load($roleName, 'role_name'); + if (!$role->getId()) { + $output->writeln('Role was not found'); + + return Command::INVALID; } + } else { + // create new role if not yet existing + $role = $this->getRoleModel()->load('Development', 'role_name'); + if (!$role->getId()) { + $role + ->setName('Development') + ->setRoleType('G') + ->save(); + + // give "all" privileges to role + $this + ->getRulesModel() + ->setRoleId($role->getId()) + ->setResources(['all']) + ->saveRel(); - $firstname = $this->getOrAskForArgument('firstname', $input, $output); - $lastname = $this->getOrAskForArgument('lastname', $input, $output); - if (($roleName = $input->getArgument('role')) != null) { - $role = $this->getRoleModel()->load($roleName, 'role_name'); - if (!$role->getId()) { - $output->writeln('Role was not found'); - return 0; - } - } else { - // create new role if not yet existing - $role = $this->getRoleModel()->load('Development', 'role_name'); - if (!$role->getId()) { - $role->setName('Development') - ->setRoleType('G') - ->save(); - - // give "all" privileges to role - $this->getRulesModel() - ->setRoleId($role->getId()) - ->setResources(['all']) - ->saveRel(); - - $output->writeln('The role Development was automatically created.'); - } + $output->writeln('The role Development was automatically created.'); } + } - // create new user - $user = $this->getUserModel() - ->setData(['username' => $username, 'firstname' => $firstname, 'lastname' => $lastname, 'email' => $email, 'password' => $password, 'is_active' => 1])->save(); + // create new user + $user = $this->getUserModel() + ->setData([ + 'username' => $username, + 'firstname' => $firstname, + 'lastname' => $lastname, + 'email' => $email, + 'password' => $password, + 'is_active' => 1 + ]) + ->save(); - $user->setRoleIds([$role->getId()]) - ->setRoleUserId($user->getUserId()) - ->saveRelations(); + $user->setRoleIds([$role->getId()]) + ->setRoleUserId($user->getUserId()) + ->saveRelations(); - $output->writeln('User ' . $username . ' successfully created'); - } - return 0; + $output->writeln('User ' . $username . ' successfully created'); + + return Command::SUCCESS; } } diff --git a/src/N98/Magento/Command/Admin/User/DeleteUserCommand.php b/src/N98/Magento/Command/Admin/User/DeleteUserCommand.php index 9f63217c2..560e0710d 100644 --- a/src/N98/Magento/Command/Admin/User/DeleteUserCommand.php +++ b/src/N98/Magento/Command/Admin/User/DeleteUserCommand.php @@ -6,7 +6,6 @@ use Exception; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -20,8 +19,6 @@ */ class DeleteUserCommand extends AbstractAdminUserCommand { - public const COMMAND_ARGUMENT_ID = 'id'; - public const COMMAND_OPTION_FORCE = 'force'; /** @@ -40,12 +37,9 @@ class DeleteUserCommand extends AbstractAdminUserCommand protected function configure(): void { + parent::configure(); + $this - ->addArgument( - self::COMMAND_ARGUMENT_ID, - InputArgument::OPTIONAL, - 'Username or Email' - ) ->addOption( self::COMMAND_OPTION_FORCE, 'f', @@ -68,17 +62,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $dialog = $this->getQuestionHelper(); - $id = $this->getOrAskForArgument(self::COMMAND_ARGUMENT_ID, $input, $output, 'Username or Email'); - - $user = $this->getUserModel()->loadByUsername($id); - if (!$user->getId()) { - $user = $this->getUserModel()->load($id, 'email'); - } - + $user = $this->getUserByIdOrEmail($input, $output); if (!$user->getId()) { $output->writeln('User was not found'); - return Command::SUCCESS; + return Command::INVALID; } $shouldRemove = $input->getOption(self::COMMAND_OPTION_FORCE); From 7473f2dad3a5e5de1941b849cebf6f2a113b92fe Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 20 Jun 2024 03:46:58 +0200 Subject: [PATCH 095/136] [skip ci] Updated media:dump commands --- src/N98/Magento/Command/Media/DumpCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/N98/Magento/Command/Media/DumpCommand.php b/src/N98/Magento/Command/Media/DumpCommand.php index 060e4ad95..feeaa318b 100644 --- a/src/N98/Magento/Command/Media/DumpCommand.php +++ b/src/N98/Magento/Command/Media/DumpCommand.php @@ -7,8 +7,8 @@ use N98\Magento\Application; use N98\Magento\Command\AbstractMagentoCommand; use RuntimeException; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Attribute\AsCommand; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; From f1a7311b87cd0f92c720717b9646a94db54ae4c9 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 20 Jun 2024 04:15:46 +0200 Subject: [PATCH 096/136] [skip ci] Updated index:... commands --- .../Indexer/AbstractIndexerCommand.php | 85 +++++++++++-------- .../Magento/Command/Indexer/ListCommand.php | 9 +- .../Command/Indexer/ReindexAllCommand.php | 52 ++++++++---- .../Command/Indexer/ReindexCommand.php | 79 +++++++++++------ 4 files changed, 146 insertions(+), 79 deletions(-) diff --git a/src/N98/Magento/Command/Indexer/AbstractIndexerCommand.php b/src/N98/Magento/Command/Indexer/AbstractIndexerCommand.php index 4020d2063..7eb70bcd2 100644 --- a/src/N98/Magento/Command/Indexer/AbstractIndexerCommand.php +++ b/src/N98/Magento/Command/Indexer/AbstractIndexerCommand.php @@ -1,8 +1,11 @@ getIndexerModel() instead', E_USER_DEPRECATED); return $this->getIndexerModel(); } /** - * @return array + * @return array> + * @throws Exception */ - protected function getIndexerList() + protected function getIndexerList(): array { $list = []; $indexCollection = $this->getIndexerModel()->getProcessesCollection(); + /** @var Mage_Index_Model_Process $indexer */ foreach ($indexCollection as $indexer) { - $lastReadbleRuntime = $this->getRuntime($indexer); + $lastReadableRuntime = $this->getRuntime($indexer); $runtimeInSeconds = $this->getRuntimeInSeconds($indexer); - $list[] = ['code' => $indexer->getIndexerCode(), 'status' => $indexer->getStatus(), 'last_runtime' => $lastReadbleRuntime, 'runtime_seconds' => $runtimeInSeconds]; + $list[] = [ + 'code' => $indexer->getIndexerCode(), + 'status' => $indexer->getStatus(), + 'last_runtime' => $lastReadableRuntime, + 'runtime_seconds' => $runtimeInSeconds + ]; } return $list; @@ -66,25 +75,25 @@ protected function getIndexerList() * * @param Mage_Index_Model_Process $indexer * @return string + * @throws Exception */ - protected function getRuntime(Mage_Index_Model_Process $indexer) + protected function getRuntime(Mage_Index_Model_Process $indexer): string { $dateTimeUtils = new DateTimeUtils(); - $startTime = new \DateTime($indexer->getStartedAt()); - $endTime = new \DateTime($indexer->getEndedAt()); + $startTime = new DateTime($indexer->getStartedAt()); + $endTime = new DateTime($indexer->getEndedAt()); if ($startTime > $endTime) { return 'index not finished'; } - $lastRuntime = $dateTimeUtils->getDifferenceAsString($startTime, $endTime); - return $lastRuntime; + return $dateTimeUtils->getDifferenceAsString($startTime, $endTime); } /** * Disable observer which try to create adminhtml session on CLI */ - protected function disableObservers() + protected function disableObservers(): void { - $node = Mage::app()->getConfig()->getNode('adminhtml/events/core_locale_set_locale/observers/bind_locale'); + $node = $this->_getMageConfig()->getNode('adminhtml/events/core_locale_set_locale/observers/bind_locale'); if ($node) { $node->appendChild(new Varien_Simplexml_Element('disabled')); } @@ -96,7 +105,7 @@ protected function disableObservers() * @param Mage_Index_Model_Process $indexer * @return int */ - protected function getRuntimeInSeconds(Mage_Index_Model_Process $indexer) + protected function getRuntimeInSeconds(Mage_Index_Model_Process $indexer): int { $startTimestamp = strtotime($indexer->getStartedAt()); $endTimestamp = strtotime($indexer->getEndedAt()); @@ -107,8 +116,9 @@ protected function getRuntimeInSeconds(Mage_Index_Model_Process $indexer) /** * @param OutputInterface $output * @param Mage_Index_Model_Process $process + * @throws Exception */ - protected function writeEstimatedEnd(OutputInterface $output, Mage_Index_Model_Process $process) + protected function writeEstimatedEnd(OutputInterface $output, Mage_Index_Model_Process $process): void { $runtimeInSeconds = $this->getRuntimeInSeconds($process); @@ -119,7 +129,7 @@ protected function writeEstimatedEnd(OutputInterface $output, Mage_Index_Model_P return; } - $estimatedEnd = new \DateTime('now', new DateTimeZone('UTC')); + $estimatedEnd = new DateTime('now', new DateTimeZone('UTC')); $estimatedEnd->add(new DateInterval('PT' . $runtimeInSeconds . 'S')); $output->writeln( sprintf('Estimated end: %s', $estimatedEnd->format('Y-m-d H:i:s T')) @@ -129,15 +139,15 @@ protected function writeEstimatedEnd(OutputInterface $output, Mage_Index_Model_P /** * @param OutputInterface $output * @param Mage_Index_Model_Process $process - * @param \DateTime $startTime - * @param \DateTime $endTime + * @param DateTime $startTime + * @param DateTime $endTime */ protected function writeSuccessResult( OutputInterface $output, Mage_Index_Model_Process $process, - \DateTime $startTime, - \DateTime $endTime - ) { + DateTime $startTime, + DateTime $endTime + ): void { $output->writeln( sprintf( 'Successfully reindexed %s (Runtime: %s)', @@ -150,17 +160,17 @@ protected function writeSuccessResult( /** * @param OutputInterface $output * @param Mage_Index_Model_Process $process - * @param \DateTime $startTime - * @param \DateTime $endTime + * @param DateTime $startTime + * @param DateTime $endTime * @param string $errorMessage */ protected function writeFailedResult( OutputInterface $output, Mage_Index_Model_Process $process, - \DateTime $startTime, - \DateTime $endTime, - $errorMessage - ) { + DateTime $startTime, + DateTime $endTime, + string $errorMessage + ): void { $output->writeln( sprintf( 'Reindex finished with error message "%s". %s (Runtime: %s)', @@ -173,24 +183,24 @@ protected function writeFailedResult( /** * @param OutputInterface $output - * @param array $processes + * @param Mage_Index_Model_Process[] $processes * @return bool */ - protected function executeProcesses(OutputInterface $output, array $processes) + protected function executeProcesses(OutputInterface $output, array $processes): bool { $isSuccessful = true; try { - \Mage::dispatchEvent('shell_reindex_init_process'); + Mage::dispatchEvent('shell_reindex_init_process'); foreach ($processes as $process) { if (!$this->executeProcess($output, $process)) { $isSuccessful = false; } } - \Mage::dispatchEvent('shell_reindex_finalize_process'); + Mage::dispatchEvent('shell_reindex_finalize_process'); } catch (Exception $e) { $isSuccessful = false; - \Mage::dispatchEvent('shell_reindex_finalize_process'); + Mage::dispatchEvent('shell_reindex_finalize_process'); } return $isSuccessful; @@ -200,28 +210,29 @@ protected function executeProcesses(OutputInterface $output, array $processes) * @param OutputInterface $output * @param Mage_Index_Model_Process $process * @return bool + * @throws Exception */ - private function executeProcess(OutputInterface $output, Mage_Index_Model_Process $process) + private function executeProcess(OutputInterface $output, Mage_Index_Model_Process $process): bool { $output->writeln( sprintf('Started reindex of: %s', $process->getIndexerCode()) ); $this->writeEstimatedEnd($output, $process); - $startTime = new \DateTime('now'); + $startTime = new DateTime('now'); $isSuccessful = true; $errorMessage = ''; try { $process->reindexEverything(); - \Mage::dispatchEvent($process->getIndexerCode() . '_shell_reindex_after'); + Mage::dispatchEvent($process->getIndexerCode() . '_shell_reindex_after'); } catch (Exception $e) { $errorMessage = $e->getMessage(); $isSuccessful = false; } - $endTime = new \DateTime('now'); + $endTime = new DateTime('now'); if ($isSuccessful) { $this->writeSuccessResult($output, $process, $startTime, $endTime); diff --git a/src/N98/Magento/Command/Indexer/ListCommand.php b/src/N98/Magento/Command/Indexer/ListCommand.php index f8dc38069..10b4a481f 100644 --- a/src/N98/Magento/Command/Indexer/ListCommand.php +++ b/src/N98/Magento/Command/Indexer/ListCommand.php @@ -4,11 +4,17 @@ namespace N98\Magento\Command\Indexer; +use Exception; use N98\Magento\Command\AbstractMagentoCommandFormatInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +/** + * List indexer command + * + * @package N98\Magento\Command\Indexer + */ class ListCommand extends AbstractIndexerCommand implements AbstractMagentoCommandFormatInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Indexes'; @@ -27,7 +33,7 @@ class ListCommand extends AbstractIndexerCommand implements AbstractMagentoComma */ protected static $defaultDescription = 'Lists all magento indexes.'; - public function getHelp() + public function getHelp(): string { return <<> + * @throws Exception * * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ diff --git a/src/N98/Magento/Command/Indexer/ReindexAllCommand.php b/src/N98/Magento/Command/Indexer/ReindexAllCommand.php index 238450b4e..dcd5fba79 100644 --- a/src/N98/Magento/Command/Indexer/ReindexAllCommand.php +++ b/src/N98/Magento/Command/Indexer/ReindexAllCommand.php @@ -1,46 +1,66 @@ setName('index:reindex:all') - ->setDescription('Reindex all magento indexes') - ; + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultName = 'index:reindex:all'; - $this->setHelp('Loops all magento indexes and triggers reindex.'); + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultDescription = 'Reindex all indexes.'; + + /** + * @return string + */ + public function getHelp(): string + { + return <<detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + $this->detectMagento($output); + $this->initMagento(); $this->disableObservers(); - /* @var Mage_Index_Model_Resource_Process_Collection|Mage_Index_Model_Process[] $processes */ + /* @var Mage_Index_Model_Resource_Process_Collection $processes */ $processes = $this->getIndexerModel()->getProcessesCollection(); + /** @phpstan-ignore argument.type (@TODO(sr)) */ if (!$this->executeProcesses($output, iterator_to_array($processes, false))) { - return 1; + return Command::FAILURE; } - return 0; + return Command::SUCCESS; } } diff --git a/src/N98/Magento/Command/Indexer/ReindexCommand.php b/src/N98/Magento/Command/Indexer/ReindexCommand.php index 207df03fe..721ea1bc7 100644 --- a/src/N98/Magento/Command/Indexer/ReindexCommand.php +++ b/src/N98/Magento/Command/Indexer/ReindexCommand.php @@ -1,27 +1,60 @@ setName('index:reindex') - ->addArgument('index_code', InputArgument::OPTIONAL, 'Code of indexer.') - ->setDescription('Reindex a magento index by code'); + ->addArgument( + self::COMMAND_ARGUMENT_INDEX_CODE, + InputArgument::OPTIONAL, + 'Code of indexer.' + ) + ; + } - $help = <<setHelp($help); } /** * @param InputInterface $input * @param OutputInterface $output - * * @return int + * @throws Exception */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + $this->detectMagento($output); + $this->initMagento(); $this->writeSection($output, 'Reindex'); $this->disableObservers(); - $indexCode = $input->getArgument('index_code'); + $indexCode = $input->getArgument(self::COMMAND_ARGUMENT_INDEX_CODE); if ($indexCode === null) { + /** @var array $indexCodes */ $indexCodes = $this->askForIndexCodes($input, $output); } else { // take cli argument @@ -64,18 +95,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int $processes = $this->getProcessesByIndexCodes($indexCodes); if (!$this->executeProcesses($output, $processes)) { - return 1; // end with error + return Command::FAILURE; } - return 0; + return Command::SUCCESS; } /** - * @param $indexCodes - * - * @return array + * @param array $indexCodes + * @return array */ - private function getProcessesByIndexCodes($indexCodes) + private function getProcessesByIndexCodes(array $indexCodes): array { $processes = []; foreach ($indexCodes as $indexCode) { @@ -92,14 +122,14 @@ private function getProcessesByIndexCodes($indexCodes) /** * @param InputInterface $input * @param OutputInterface $output - * - * @return array + * @return mixed + * @throws Exception */ private function askForIndexCodes(InputInterface $input, OutputInterface $output) { $indexerList = $this->getIndexerList(); $choices = []; - foreach ($indexerList as $key => $indexer) { + foreach ($indexerList as $indexer) { $choices[] = sprintf( '%-40s (last runtime: %s)', $indexer['code'], @@ -126,8 +156,7 @@ private function askForIndexCodes(InputInterface $input, OutputInterface $output return $returnCodes; }; - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new ChoiceQuestion( 'Please select a indexer: ', $choices From e1cc768c48202a27d46a5cf8f86add7b7e7d32b2 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 20 Jun 2024 04:45:25 +0200 Subject: [PATCH 097/136] [skip ci] Updated config:dump command --- .../Command/Admin/User/CreateUserCommand.php | 1 + .../Magento/Command/Config/DumpCommand.php | 64 ++++++++++++++----- 2 files changed, 49 insertions(+), 16 deletions(-) diff --git a/src/N98/Magento/Command/Admin/User/CreateUserCommand.php b/src/N98/Magento/Command/Admin/User/CreateUserCommand.php index 222fb1b8a..740cd2d8c 100644 --- a/src/N98/Magento/Command/Admin/User/CreateUserCommand.php +++ b/src/N98/Magento/Command/Admin/User/CreateUserCommand.php @@ -5,6 +5,7 @@ namespace N98\Magento\Command\Admin\User; use Mage_Core_Exception; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; diff --git a/src/N98/Magento/Command/Config/DumpCommand.php b/src/N98/Magento/Command/Config/DumpCommand.php index d58cb80c2..7e494f0c0 100644 --- a/src/N98/Magento/Command/Config/DumpCommand.php +++ b/src/N98/Magento/Command/Config/DumpCommand.php @@ -1,25 +1,57 @@ setName('config:dump') - ->addArgument('xpath', InputArgument::OPTIONAL, 'XPath to filter XML output', null) - ->setDescription('Dump merged xml config') + ->addArgument( + self::COMMAND_ARGUMENT_XPATH, + InputArgument::OPTIONAL, + 'XPath to filter XML output' + ) ; + } - $help = << extern_file.xml HELP; - $this->setHelp($help); } /** * @param InputInterface $input * @param OutputInterface $output - * * @return int * @throws InvalidArgumentException */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + $this->detectMagento($output); + $this->initMagento(); - $config = Mage::app()->getConfig()->getNode($input->getArgument('xpath')); + /** @var string $xpath */ + $xpath = $input->getArgument(self::COMMAND_ARGUMENT_XPATH); + $config = $this->_getMageConfig()->getNode($xpath); if (!$config) { throw new InvalidArgumentException('xpath was not found'); } + $dom = new DOMDocument(); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; - $dom->loadXML($config->asXml()); - $output->writeln($dom->saveXML(), OutputInterface::OUTPUT_RAW); - return 0; + $dom->loadXML((string)$config->asXML()); + $output->writeln((string)$dom->saveXML(), OutputInterface::OUTPUT_RAW); + + return Command::SUCCESS; } } From 8ecb96e52c558bdd34f10809805bd470a597f39c Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 20 Jun 2024 05:39:12 +0200 Subject: [PATCH 098/136] [skip ci] Updated customer:change-password command --- .../Customer/AbstractCustomerCommand.php | 32 +++----- .../Customer/ChangePasswordCommand.php | 79 ++++++++++++++----- 2 files changed, 73 insertions(+), 38 deletions(-) diff --git a/src/N98/Magento/Command/Customer/AbstractCustomerCommand.php b/src/N98/Magento/Command/Customer/AbstractCustomerCommand.php index 0b1a3d2cd..9eed3dda7 100644 --- a/src/N98/Magento/Command/Customer/AbstractCustomerCommand.php +++ b/src/N98/Magento/Command/Customer/AbstractCustomerCommand.php @@ -1,7 +1,10 @@ _getModel('customer/customer', 'Mage_Customer_Model_Customer'); + return Mage::getModel('customer/customer'); } /** * @return Mage_Customer_Model_Resource_Customer_Collection */ - protected function getCustomerCollection() + protected function getCustomerCollection(): Mage_Customer_Model_Resource_Customer_Collection { - return $this->_getResourceModel( - 'customer/customer_collection', - 'Mage_Customer_Model_Resource_Customer_Collection' - ); + return Mage::getResourceModel('customer/customer_collection'); } /** * @return Mage_Customer_Model_Address */ - protected function getAddressModel() + protected function getAddressModel(): Mage_Customer_Model_Address { - return $this->_getModel('customer/address', 'Mage_Customer_Model_Address'); + return Mage::getModel('customer/address'); } /** * @return Mage_Directory_Model_Resource_Region_Collection */ - protected function getRegionCollection() + protected function getRegionCollection(): Mage_Directory_Model_Resource_Region_Collection { - return $this->_getResourceModel( - 'directory/region_collection', - 'Mage_Directory_Model_Resource_Region_Collection' - ); + return Mage::getResourceModel('directory/region_collection'); } /** * @return Mage_Directory_Model_Resource_Country_Collection */ - protected function getCountryCollection() + protected function getCountryCollection(): Mage_Directory_Model_Resource_Country_Collection { - return $this->_getResourceModel( - 'directory/country_collection', - 'Mage_Directory_Model_Resource_Country_Collection' - ); + return Mage::getResourceModel('directory/country_collection'); } } diff --git a/src/N98/Magento/Command/Customer/ChangePasswordCommand.php b/src/N98/Magento/Command/Customer/ChangePasswordCommand.php index 9095772f2..60e01ef20 100644 --- a/src/N98/Magento/Command/Customer/ChangePasswordCommand.php +++ b/src/N98/Magento/Command/Customer/ChangePasswordCommand.php @@ -1,15 +1,20 @@ setName('customer:change-password') - ->addArgument('email', InputArgument::OPTIONAL, 'Email') - ->addArgument('password', InputArgument::OPTIONAL, 'Password') - ->addArgument('website', InputArgument::OPTIONAL, 'Website of the customer') - ->setDescription('Changes the password of a customer.') + ->addArgument( + self::COMMAND_ARGUMENT_EMAIL, + InputArgument::OPTIONAL, + 'Email' + ) + ->addArgument( + self::COMMAND_ARGUMENT_PASSWORD, + InputArgument::OPTIONAL, + 'Password' + ) + ->addArgument( + self::COMMAND_ARGUMENT_WEBSITE, + InputArgument::OPTIONAL, + 'Website of the customer' + ) ; + } - $help = <<setHelp($help); } /** * @param InputInterface $input * @param OutputInterface $output - * * @return int + * @throws Mage_Core_Exception + * @throws Throwable */ protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output); $this->initMagento(); - // Password - if (($password = $input->getArgument('password')) == null) { - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + if (($password = $input->getArgument(self::COMMAND_ARGUMENT_PASSWORD)) == null) { + $dialog = $this->getQuestionHelper(); $question = new Question('Password: '); $question->setHidden(true); $password = $dialog->ask($input, $output, $question); } - /** @var ParameterHelper $parameterHelper */ - $parameterHelper = $this->getHelper('parameter'); + $parameterHelper = $this->getParameterHelper(); $email = $parameterHelper->askEmail($input, $output); + /** @var Mage_Core_Model_Website $website */ $website = $parameterHelper->askWebsite($input, $output); $customer = $this->getCustomerModel() @@ -65,7 +104,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int ->loadByEmail($email); if ($customer->getId() <= 0) { $output->writeln('Customer was not found'); - return 0; + + return Command::SUCCESS; } try { @@ -79,6 +119,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } catch (Exception $e) { $output->writeln('' . $e->getMessage() . ''); } - return 0; + + return Command::SUCCESS; } } From 8eecf0f310dcb3782840c1a42a4e72248e2b65fb Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 20 Jun 2024 05:42:52 +0200 Subject: [PATCH 099/136] [skip ci] Updated customer:list command --- src/N98/Magento/Command/Customer/ListCommand.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/N98/Magento/Command/Customer/ListCommand.php b/src/N98/Magento/Command/Customer/ListCommand.php index b107fd7ef..46793049e 100644 --- a/src/N98/Magento/Command/Customer/ListCommand.php +++ b/src/N98/Magento/Command/Customer/ListCommand.php @@ -5,6 +5,7 @@ namespace N98\Magento\Command\Customer; use Mage_Core_Exception; +use Mage_Customer_Model_Customer; use N98\Magento\Command\AbstractMagentoCommandFormatInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; @@ -18,7 +19,7 @@ */ class ListCommand extends AbstractCustomerCommand implements AbstractMagentoCommandFormatInterface { - protected const COMMAND_SECTION_TITLE_TEXT = 'Customers'; + protected const COMMAND_SECTION_TITLE_TEXT = 'Customer list'; public const COMMAND_ARGUMENT_SEARCH = 'search'; @@ -38,7 +39,7 @@ class ListCommand extends AbstractCustomerCommand implements AbstractMagentoComm */ protected static $defaultDescription = 'Lists customers.'; - protected function configure() + protected function configure(): void { $this->addArgument( self::COMMAND_ARGUMENT_SEARCH, @@ -49,7 +50,10 @@ protected function configure() parent::configure(); } - public function getHelp() + /** + * @return string + */ + public function getHelp(): string { return <<setPageSize($config['limit']); + /** @var Mage_Customer_Model_Customer $customer */ foreach ($collection as $customer) { $this->data[] = [ 'id' => $customer->getId(), From 274d4b74990e6f549086d82c75d9af642b589315 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 20 Jun 2024 07:38:24 +0200 Subject: [PATCH 100/136] [skip ci] Updated script:... commands --- .../Repository/AbstractRepositoryCommand.php | 15 ++- .../Command/Script/Repository/ListCommand.php | 20 ++-- .../Command/Script/Repository/RunCommand.php | 112 ++++++++++++++---- .../Script/Repository/ScriptLoader.php | 60 ++++++---- 4 files changed, 150 insertions(+), 57 deletions(-) diff --git a/src/N98/Magento/Command/Script/Repository/AbstractRepositoryCommand.php b/src/N98/Magento/Command/Script/Repository/AbstractRepositoryCommand.php index 250cd62fc..ca9f4fe33 100644 --- a/src/N98/Magento/Command/Script/Repository/AbstractRepositoryCommand.php +++ b/src/N98/Magento/Command/Script/Repository/AbstractRepositoryCommand.php @@ -1,9 +1,17 @@ */ - protected function getScripts() + protected function getScripts(): array { $folders = (array) $this->getApplication()->getConfig('script', 'folders'); $magentoRootFolder = $this->getApplication()->getMagentoRootFolder(); $loader = new ScriptLoader($folders, $magentoRootFolder); - $files = $loader->getFiles(); - return $files; + return $loader->getFiles(); } } diff --git a/src/N98/Magento/Command/Script/Repository/ListCommand.php b/src/N98/Magento/Command/Script/Repository/ListCommand.php index 9b02dd208..2253dbd63 100644 --- a/src/N98/Magento/Command/Script/Repository/ListCommand.php +++ b/src/N98/Magento/Command/Script/Repository/ListCommand.php @@ -4,13 +4,16 @@ namespace N98\Magento\Command\Script\Repository; -use Description; -use Location; use N98\Magento\Command\AbstractMagentoCommandFormatInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +/** + * List scripts command + * + * @package N98\Magento\Command\Script\Repository + */ class ListCommand extends AbstractRepositoryCommand implements AbstractMagentoCommandFormatInterface { protected const NO_DATA_MESSAGE = 'No script file found'; @@ -29,7 +32,10 @@ class ListCommand extends AbstractRepositoryCommand implements AbstractMagentoCo */ protected static $defaultDescription = 'Lists all scripts in repository.'; - public function getHelp() + /** + * @return string + */ + public function getHelp(): string { return << $file['location'], - Description::class => $file['description'] + 'Location' => $file['location'], + 'Description' => $file['description'] ]; } } @@ -76,10 +82,8 @@ public function getData(InputInterface $input, OutputInterface $output): array * Skip initialisation * * @param bool $soft - * @return true */ - public function initMagento(bool $soft = false) + public function initMagento(bool $soft = false): void { - return true; } } diff --git a/src/N98/Magento/Command/Script/Repository/RunCommand.php b/src/N98/Magento/Command/Script/Repository/RunCommand.php index 85f812a87..7dd448c08 100644 --- a/src/N98/Magento/Command/Script/Repository/RunCommand.php +++ b/src/N98/Magento/Command/Script/Repository/RunCommand.php @@ -1,9 +1,12 @@ addArgument( + self::COMMAND_ARGUMENT_SCRIPT, + InputArgument::OPTIONAL, + 'Name of script in repository' + ) + ->addOption( + self::COMMAND_OPTION_DEFINE, + 'd', + InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, + 'Defines a variable' + ) + ->addOption( + self::COMMAND_OPTION_STOP_ON_ERROR, + null, + InputOption::VALUE_NONE, + 'Stops execution of script on error' + ) + ; + } + + /** + * @return string + */ + public function getHelp(): string + { + return << HELP; - - $this - ->setName('script:repo:run') - ->addArgument('script', InputArgument::OPTIONAL, 'Name of script in repository') - ->addOption('define', 'd', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Defines a variable') - ->addOption('stop-on-error', null, InputOption::VALUE_NONE, 'Stops execution of script on error') - ->setDescription('Run script from repository') - ->setHelp($help) - ; } + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return int + * @throws Exception + */ protected function execute(InputInterface $input, OutputInterface $output): int { $files = $this->getScripts(); - if ($input->getArgument('script') == null && $input->isInteractive()) { + if ($input->getArgument(self::COMMAND_ARGUMENT_SCRIPT) == null && $input->isInteractive()) { $choices = []; foreach ($files as $file) { $files[] = $file; @@ -67,8 +118,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int return $files[$typeInput]['fileinfo']->getPathname(); }; - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new ChoiceQuestion( 'Please select a script file: ', $choices @@ -77,8 +127,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $selectedFile = $dialog->ask($input, $output, $question); } else { - $script = $input->getArgument('script'); - if (substr($script, -strlen(self::MAGERUN_EXTENSION)) !== self::MAGERUN_EXTENSION) { + $script = $input->getArgument(self::COMMAND_ARGUMENT_SCRIPT); + if (is_string($script) && !str_ends_with($script, self::MAGERUN_EXTENSION)) { $script .= self::MAGERUN_EXTENSION; } @@ -88,15 +138,31 @@ protected function execute(InputInterface $input, OutputInterface $output): int $selectedFile = $files[$script]['fileinfo']->getPathname(); } - $scriptArray = ['command' => 'script', 'filename' => $selectedFile]; - foreach ($input->getOption('define') as $define) { + $scriptArray = [ + 'command' => 'script', + 'filename' => $selectedFile + ]; + + /** @var array $defined */ + $defined = $input->getOption(self::COMMAND_OPTION_DEFINE); + foreach ($defined as $define) { $scriptArray['--define'][] = $define; } - if ($input->getOption('stop-on-error')) { + if ($input->getOption(self::COMMAND_OPTION_STOP_ON_ERROR)) { $scriptArray['--stop-on-error'] = true; } $input = new ArrayInput($scriptArray); $this->getApplication()->run($input, $output); - return 0; + + return Command::SUCCESS; + } + + /** + * Skip initialisation + * + * @param bool $soft + */ + public function initMagento(bool $soft = false): void + { } } diff --git a/src/N98/Magento/Command/Script/Repository/ScriptLoader.php b/src/N98/Magento/Command/Script/Repository/ScriptLoader.php index c8ddfe91f..183840793 100644 --- a/src/N98/Magento/Command/Script/Repository/ScriptLoader.php +++ b/src/N98/Magento/Command/Script/Repository/ScriptLoader.php @@ -1,44 +1,51 @@ */ - protected $_scriptFiles = []; + protected array $_scriptFiles = []; /** * @var string * @deprecated since 1.97.29 */ - protected $_homeScriptFolder = ''; + protected string $_homeScriptFolder = ''; /** - * @var string + * @var string|null */ - protected $_magentoRootFolder = ''; + protected ?string $_magentoRootFolder = ''; /** - * @var array + * @var array */ - protected $_scriptFolders = []; + protected array $_scriptFolders = []; /** - * @param array $scriptFolders - * @param string $magentoRootFolder + * @param array $scriptFolders + * @param string|null $magentoRootFolder */ - public function __construct(array $scriptFolders, $magentoRootFolder = null) + public function __construct(array $scriptFolders, ?string $magentoRootFolder = null) { $this->homeDir = OperatingSystem::getHomeDir(); @@ -53,19 +60,24 @@ public function __construct(array $scriptFolders, $magentoRootFolder = null) } /** - * @return array + * @return array */ - public function getFiles() + public function getFiles(): array { return $this->_scriptFiles; } - protected function findScripts(array $scriptFolders = null) + /** + * @param array|null $scriptFolders + * @return void + */ + protected function findScripts(?array $scriptFolders = null): void { if (null === $scriptFolders) { $scriptFolders = $this->_scriptFolders; } + /** @phpstan-ignore argument.type (@TODO(sr)) */ $scriptFolders = array_filter(array_filter($scriptFolders, 'strlen'), 'is_dir'); $this->_scriptFolders = $scriptFolders; @@ -76,13 +88,18 @@ protected function findScripts(array $scriptFolders = null) $finder = Finder::create() ->files()->followLinks() - ->ignoreUnreadableDirs(true) + ->ignoreUnreadableDirs() ->name('*.magerun') ->in($scriptFolders); $scriptFiles = []; - foreach ($finder as $file) { /* @var SplFileInfo $file */ - $scriptFiles[$file->getFilename()] = ['fileinfo' => $file, 'description' => $this->_readFirstLineOfFile($file->getPathname()), 'location' => $this->_getLocation($file->getPathname())]; + foreach ($finder as $file) { + /* @var SplFileInfo $file */ + $scriptFiles[$file->getFilename()] = [ + 'fileinfo' => $file, + 'description' => $this->_readFirstLineOfFile($file->getPathname()), + 'location' => $this->_getLocation($file->getPathname()) + ]; } ksort($scriptFiles); @@ -93,16 +110,16 @@ protected function findScripts(array $scriptFolders = null) * Reads the first line. If it's a comment return it. * * @param string $file - * * @return string */ - protected function _readFirstLineOfFile($file) + protected function _readFirstLineOfFile(string $file): string { $f = @fopen($file, 'r'); if (!$f) { return ''; } - $line = trim(fgets($f)); + + $line = trim((string)fgets($f)); fclose($f); if (isset($line[0]) && $line[0] != '#') { @@ -114,10 +131,9 @@ protected function _readFirstLineOfFile($file) /** * @param string $pathname - * * @return string */ - protected function _getLocation($pathname) + protected function _getLocation(string $pathname): string { if (strstr($pathname, $this->_magentoRootFolder)) { return 'project'; From ba4d6f3b8f68dff334b996dca1096d75686665ad Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 20 Jun 2024 15:17:59 +0200 Subject: [PATCH 101/136] [skip ci] Updated config:search command --- .../Magento/Command/Config/SearchCommand.php | 155 ++++++++++++------ 1 file changed, 102 insertions(+), 53 deletions(-) diff --git a/src/N98/Magento/Command/Config/SearchCommand.php b/src/N98/Magento/Command/Config/SearchCommand.php index 760f165a0..c266b5fc4 100644 --- a/src/N98/Magento/Command/Config/SearchCommand.php +++ b/src/N98/Magento/Command/Config/SearchCommand.php @@ -1,46 +1,79 @@ setName('config:search') - ->setDescription('Search system configuration descriptions.') - ->setHelp( - << and for the indicated text. -EOT + ->addArgument( + self::COMMAND_ARGUMENT_TEXT, + InputArgument::REQUIRED, + 'The text to search for' ) - ->addArgument('text', InputArgument::REQUIRED, 'The text to search for'); + ; + } + + /** + * @return string + */ + public function getHelp(): string + { + return << and for the indicated text. +EOT; } /** * @param InputInterface $input * @param OutputInterface $output - * * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); $this->writeSection($output, 'Config Search'); - $searchString = $input->getArgument('text'); - $system = Mage::getConfig()->loadModulesConfiguration('system.xml'); + /** @var string $searchString */ + $searchString = $input->getArgument(self::COMMAND_ARGUMENT_TEXT); + $system = $this->_getMageConfig()->loadModulesConfiguration('system.xml'); $matches = $this->_searchConfiguration($searchString, $system); if (count($matches) > 0) { @@ -64,25 +97,31 @@ protected function execute(InputInterface $input, OutputInterface $output): int } else { $output->writeln('No matches for ' . $searchString . ''); } + return 0; } /** * @param string $searchString - * @param string $system - * - * @return array + * @param Varien_Simplexml_Config $system + * @return array */ - protected function _searchConfiguration($searchString, $system) + protected function _searchConfiguration(string $searchString, Varien_Simplexml_Config $system): array { $xpathSections = ['sections/*', 'sections/*/groups/*', 'sections/*/groups/*/fields/*']; $matches = []; foreach ($xpathSections as $xpath) { + /** @var Varien_Simplexml_Element $node */ + $node = $system->getNode(); + /** @var array $elem */ + $elem = $node->xpath($xpath); $tmp = $this->_searchConfigurationNodes( $searchString, - $system->getNode()->xpath($xpath) + $elem ); + + /** @var array $matches */ $matches = array_merge($matches, $tmp); } @@ -91,11 +130,10 @@ protected function _searchConfiguration($searchString, $system) /** * @param string $searchString - * @param array $nodes - * - * @return array + * @param object{type: string, node: Mage_Core_Model_Config_Element, label: string, comment: string, match_type: string}[] $nodes + * @return object[] */ - protected function _searchConfigurationNodes($searchString, $nodes) + protected function _searchConfigurationNodes(string $searchString, array $nodes): array { $matches = []; foreach ($nodes as $node) { @@ -110,11 +148,10 @@ protected function _searchConfigurationNodes($searchString, $nodes) /** * @param string $searchString - * @param object $node - * - * @return bool|stdClass + * @param object{type: string, node: Mage_Core_Model_Config_Element, label: string, comment: string} $node + * @return null|object */ - protected function _searchNode($searchString, $node) + protected function _searchNode(string $searchString, object $node): ?object { $match = new stdClass(); $match->type = $this->_getNodeType($node); @@ -132,18 +169,20 @@ protected function _searchNode($searchString, $node) return $match; } - return false; + return null; } /** - * @param object $node - * + * @param object{type: string, node: Mage_Core_Model_Config_Element, label: string, comment: string} $node * @return string */ - protected function _getNodeType($node) + protected function _getNodeType(object $node) { - $parent = current($node->xpath('parent::*')); - $grandParent = current($parent->xpath('parent::*')); + /** @var Mage_Core_Model_Config_Element $node */ + $parent = current($node->xpath(self::XPATH_EXPR_PARENT)); + /** @var Mage_Core_Model_Config_Element $parent */ + $grandParent = current($parent->xpath(self::XPATH_EXPR_PARENT)); + /** @var Mage_Core_Model_Config_Element $grandParent */ if ($grandParent->getName() == 'config') { return 'section'; } @@ -161,12 +200,11 @@ protected function _getNodeType($node) } /** - * @param object $match - * + * @param object{type: string, node: Mage_Core_Model_Config_Element, label: string, comment: string} $match * @return string * @throws RuntimeException */ - protected function _getPhpMageStoreConfigPathFromMatch($match) + protected function _getPhpMageStoreConfigPathFromMatch(object $match): string { switch ($match->type) { case 'section': @@ -174,18 +212,24 @@ protected function _getPhpMageStoreConfigPathFromMatch($match) break; case 'field': - $parent = current($match->node->xpath('parent::*')); - $parent = current($parent->xpath('parent::*')); + /** @var Mage_Core_Model_Config_Element $parent */ + $parent = current($match->node->xpath(self::XPATH_EXPR_PARENT)); + /** @var Mage_Core_Model_Config_Element $parent */ + $parent = current($parent->xpath(self::XPATH_EXPR_PARENT)); - $grand = current($parent->xpath('parent::*')); - $grand = current($grand->xpath('parent::*')); + /** @var Mage_Core_Model_Config_Element $grand */ + $grand = current($parent->xpath(self::XPATH_EXPR_PARENT)); + /** @var Mage_Core_Model_Config_Element $grand */ + $grand = current($grand->xpath(self::XPATH_EXPR_PARENT)); $path = $grand->getName() . '/' . $parent->getName() . '/' . $match->node->getName(); break; case 'group': - $parent = current($match->node->xpath('parent::*')); - $parent = current($parent->xpath('parent::*')); + /** @var Mage_Core_Model_Config_Element $parent */ + $parent = current($match->node->xpath(self::XPATH_EXPR_PARENT)); + /** @var Mage_Core_Model_Config_Element $parent */ + $parent = current($parent->xpath(self::XPATH_EXPR_PARENT)); $path = $parent->getName() . '/' . $match->node->getName(); break; @@ -198,29 +242,34 @@ protected function _getPhpMageStoreConfigPathFromMatch($match) } /** - * @param object $match - * + * @param object{type: string, node: Mage_Core_Model_Config_Element, label: string, comment: string} $match * @return string * @throws RuntimeException */ - protected function _getPathFromMatch($match) + protected function _getPathFromMatch(object $match): string { switch ($match->type) { case 'section': return (string) $match->node->label . ' -> ... -> ...'; case 'field': - $parent = current($match->node->xpath('parent::*')); - $parent = current($parent->xpath('parent::*')); + /** @var Mage_Core_Model_Config_Element $parent */ + $parent = current($match->node->xpath(self::XPATH_EXPR_PARENT)); + /** @var Mage_Core_Model_Config_Element $parent */ + $parent = current($parent->xpath(self::XPATH_EXPR_PARENT)); - $grand = current($parent->xpath('parent::*')); - $grand = current($grand->xpath('parent::*')); + /** @var Mage_Core_Model_Config_Element $grand */ + $grand = current($parent->xpath(self::XPATH_EXPR_PARENT)); + /** @var Mage_Core_Model_Config_Element $grand */ + $grand = current($grand->xpath(self::XPATH_EXPR_PARENT)); return $grand->label . ' -> ' . $parent->label . ' -> ' . $match->node->label . ''; case 'group': - $parent = current($match->node->xpath('parent::*')); - $parent = current($parent->xpath('parent::*')); + /** @var Mage_Core_Model_Config_Element $parent */ + $parent = current($match->node->xpath(self::XPATH_EXPR_PARENT)); + /** @var Mage_Core_Model_Config_Element $parent */ + $parent = current($parent->xpath(self::XPATH_EXPR_PARENT)); return $parent->label . ' -> ' . $match->node->label . ' -> ...'; default: From 613bc0cc6573cf418869a170a3e78244bf907f17 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 20 Jun 2024 16:10:08 +0200 Subject: [PATCH 102/136] [skip ci] Updated config:set command --- .../Magento/Command/Config/SearchCommand.php | 4 +- src/N98/Magento/Command/Config/SetCommand.php | 135 +++++++++++++----- 2 files changed, 100 insertions(+), 39 deletions(-) diff --git a/src/N98/Magento/Command/Config/SearchCommand.php b/src/N98/Magento/Command/Config/SearchCommand.php index c266b5fc4..d0040eea5 100644 --- a/src/N98/Magento/Command/Config/SearchCommand.php +++ b/src/N98/Magento/Command/Config/SearchCommand.php @@ -7,6 +7,8 @@ use Mage_Core_Model_Config_Element; use RuntimeException; use stdClass; +use Symfony\Component\Console\Attribute\AsCommand; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -98,7 +100,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('No matches for ' . $searchString . ''); } - return 0; + return Command::SUCCESS; } /** diff --git a/src/N98/Magento/Command/Config/SetCommand.php b/src/N98/Magento/Command/Config/SetCommand.php index 9dac9db47..15121b6e1 100644 --- a/src/N98/Magento/Command/Config/SetCommand.php +++ b/src/N98/Magento/Command/Config/SetCommand.php @@ -1,107 +1,166 @@ setName('config:set') - ->setDescription('Set a core config item') - ->addArgument('path', InputArgument::REQUIRED, 'The config path') - ->addArgument('value', InputArgument::REQUIRED, 'The config value') + ->addArgument( + self::COMMAND_ARGUMENT_PATH, + InputArgument::REQUIRED, + 'The config path' + ) + ->addArgument( + self::COMMAND_ARGUMENT_VALUE, + InputArgument::REQUIRED, + 'The config value' + ) ->addOption( - 'scope', + self::COMMAND_OPTION_SCOPE, null, InputOption::VALUE_OPTIONAL, 'The config value\'s scope (default, websites, stores)', 'default' ) - ->addOption('scope-id', null, InputOption::VALUE_OPTIONAL, 'The config value\'s scope ID', '0') ->addOption( - 'encrypt', + self::COMMAND_OPTION_SCOPE_ID, + null, + InputOption::VALUE_OPTIONAL, + 'The config value\'s scope ID', + '0' + ) + ->addOption( + self::COMMAND_OPTION_ENCRYPT, null, InputOption::VALUE_NONE, 'The config value should be encrypted using local.xml\'s crypt key' ) ->addOption( - 'force', + self::COMMAND_OPTION_FORCE, null, InputOption::VALUE_NONE, 'Allow creation of non-standard scope-id\'s for websites and stores' ) ->addOption( - "no-null", + self::COMMAND_OPTION_NO_NULL, null, InputOption::VALUE_NONE, "Do not treat value NULL as " . self::DISPLAY_NULL_UNKNOWN_VALUE . " value" ) ; + } - $help = <<setHelp($help); } /** * @param InputInterface $input * @param OutputInterface $output - * * @return int + * @throws Mage_Core_Exception */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + $this->detectMagento($output); + $this->initMagento(); $config = $this->_getConfigModel(); if (!$config->getResourceModel()) { // without a resource model, a config option can't be saved. - return 0; + return Command::FAILURE; } - $allowZeroScope = $input->getOption('force'); + /** @var bool $allowZeroScope */ + $allowZeroScope = $input->getOption(self::COMMAND_OPTION_FORCE); + /** @var string $scope */ + $scope = $input->getOption(self::COMMAND_OPTION_SCOPE); + /** @var string $scopeId */ + $scopeId = $input->getOption(self::COMMAND_OPTION_SCOPE_ID); - $scope = $input->getOption('scope'); $this->_validateScopeParam($scope); - $scopeId = $this->_convertScopeIdParam($scope, $input->getOption('scope-id'), $allowZeroScope); + $scopeId = (int) $this->_convertScopeIdParam($scope, $scopeId, $allowZeroScope); - $valueDisplay = $value = $input->getArgument('value'); + /** @var string $value */ + $value = $input->getArgument(self::COMMAND_ARGUMENT_VALUE); + $valueDisplay = $value; - if ($value === "NULL" && !$input->getOption('no-null')) { - if ($input->getOption('encrypt')) { - throw new InvalidArgumentException("Encryption is not possbile for NULL values"); + if ($value === "NULL" && !$input->getOption(self::COMMAND_OPTION_NO_NULL)) { + if ($input->getOption(self::COMMAND_OPTION_ENCRYPT)) { + throw new InvalidArgumentException("Encryption is not possible for NULL values"); } $value = null; $valueDisplay = self::DISPLAY_NULL_UNKNOWN_VALUE; } else { $value = str_replace(['\n', '\r'], ["\n", "\r"], $value); - $value = $this->_formatValue($value, ($input->getOption('encrypt') ? 'encrypt' : false)); + $value = $this->_formatValue($value, ($input->getOption(self::COMMAND_OPTION_ENCRYPT) ? 'encrypt' : false)); } - $config->saveConfig( - $input->getArgument('path'), - $value, - $scope, - $scopeId - ); - - $output->writeln( - '' . $input->getArgument('path') . " => " . $valueDisplay . - '' - ); - return 0; + /** @var string $path */ + $path = $input->getArgument(self::COMMAND_ARGUMENT_PATH); + /** @phpstan-ignore argument.type (Parameter #2 $value of method Mage_Core_Model_Config::saveConfig() expects string, string|null given @TODO(sr)) */ + $config->saveConfig($path, $value, $scope, $scopeId); + + $output->writeln(sprintf( + '%s => %s', + $path, + $valueDisplay + )); + + return Command::SUCCESS; } } From a60dc342c161e2b18ac14679bc30b263b255eae5 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 20 Jun 2024 18:47:34 +0200 Subject: [PATCH 103/136] [skip ci] Updated admin:... commands --- .../Admin/User/AbstractAdminUserCommand.php | 12 ------------ .../Command/Admin/User/ChangeStatusCommand.php | 6 ++++++ .../Command/Admin/User/DeleteUserCommand.php | 7 +++++++ src/N98/Magento/Command/Cache/CleanCommand.php | 15 +++++++++------ .../Magento/Command/System/Cron/RunCommand.php | 4 ++-- 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php b/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php index 80402b8d6..3689e51f2 100644 --- a/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php +++ b/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php @@ -9,7 +9,6 @@ use Mage_Admin_Model_Rules; use Mage_Admin_Model_User; use N98\Magento\Command\AbstractMagentoCommand; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -22,17 +21,6 @@ abstract class AbstractAdminUserCommand extends AbstractMagentoCommand { public const COMMAND_ARGUMENT_ID = 'id'; - protected function configure(): void - { - $this - ->addArgument( - self::COMMAND_ARGUMENT_ID, - InputArgument::OPTIONAL, - 'Username or Email' - ) - ; - } - /** * @return Mage_Admin_Model_User */ diff --git a/src/N98/Magento/Command/Admin/User/ChangeStatusCommand.php b/src/N98/Magento/Command/Admin/User/ChangeStatusCommand.php index 8c017ac19..510629c59 100644 --- a/src/N98/Magento/Command/Admin/User/ChangeStatusCommand.php +++ b/src/N98/Magento/Command/Admin/User/ChangeStatusCommand.php @@ -8,6 +8,7 @@ use RuntimeException; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -44,6 +45,11 @@ protected function configure(): void parent::configure(); $this + ->addArgument( + self::COMMAND_ARGUMENT_ID, + InputArgument::OPTIONAL, + 'Username or Email' + ) ->addOption( self::COMMAND_OPTION_ACTIVATE, null, diff --git a/src/N98/Magento/Command/Admin/User/DeleteUserCommand.php b/src/N98/Magento/Command/Admin/User/DeleteUserCommand.php index 560e0710d..21925912b 100644 --- a/src/N98/Magento/Command/Admin/User/DeleteUserCommand.php +++ b/src/N98/Magento/Command/Admin/User/DeleteUserCommand.php @@ -5,7 +5,9 @@ namespace N98\Magento\Command\Admin\User; use Exception; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -40,6 +42,11 @@ protected function configure(): void parent::configure(); $this + ->addArgument( + self::COMMAND_ARGUMENT_ID, + InputArgument::OPTIONAL, + 'Username or Email' + ) ->addOption( self::COMMAND_OPTION_FORCE, 'f', diff --git a/src/N98/Magento/Command/Cache/CleanCommand.php b/src/N98/Magento/Command/Cache/CleanCommand.php index 9ff3f9fb0..1e89847d4 100644 --- a/src/N98/Magento/Command/Cache/CleanCommand.php +++ b/src/N98/Magento/Command/Cache/CleanCommand.php @@ -44,6 +44,8 @@ protected function configure(): void 'Cache type code like "config"' ) ; + + parent::configure(); } /** @@ -56,17 +58,18 @@ public function getHelp(): string If you would like to clean only one cache type use like: - $ n98-magerun.phar cache:clean full_page + $ n98-magerun.phar cache:clean block_html If you would like to clean multiple cache types at once use like: - $ n98-magerun.phar cache:clean full_page block_html + $ n98-magerun.phar cache:clean block_html eav + +If you would like to remove all cache entries use cache:flush -If you would like to remove all cache entries use `cache:flush` +Options: + --reinit Reinitialise the config cache after cleaning (Default) + --no-reinit Don't reinitialise the config cache after cleaning -Options: - --reinit Reinitialise the config cache after cleaning (Default) - --no-reinit Don't reinitialise the config cache after cleaning HELP; } diff --git a/src/N98/Magento/Command/System/Cron/RunCommand.php b/src/N98/Magento/Command/System/Cron/RunCommand.php index 3342e1e6a..f8614e396 100644 --- a/src/N98/Magento/Command/System/Cron/RunCommand.php +++ b/src/N98/Magento/Command/System/Cron/RunCommand.php @@ -265,8 +265,8 @@ private function scheduleConfigModel($callback, string $jobCode): void */ private function getRunConfigModelByJobCode(string$jobCode): string { - $jobsRoot = $this->_getMageConfigNode('crontab/jobs'); - $defaultJobsRoot = $this->_getMageConfigNode('default/crontab/jobs'); + $jobsRoot = $this->_getMageConfig()->getNode('crontab/jobs'); + $defaultJobsRoot = $this->_getMageConfig()->getNode('default/crontab/jobs'); $jobConfig = $jobsRoot->{$jobCode}; if (!$jobConfig || !$jobConfig->run) { From 90cbd2aa32edc606755a3618150769c5d6b87427 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 20 Jun 2024 19:48:38 +0200 Subject: [PATCH 104/136] [skip ci] Updated config:get command --- src/N98/Magento/Command/Config/GetCommand.php | 194 ++++++++++++------ 1 file changed, 129 insertions(+), 65 deletions(-) diff --git a/src/N98/Magento/Command/Config/GetCommand.php b/src/N98/Magento/Command/Config/GetCommand.php index 72416d8ec..9a1504012 100644 --- a/src/N98/Magento/Command/Config/GetCommand.php +++ b/src/N98/Magento/Command/Config/GetCommand.php @@ -1,153 +1,217 @@ setName('config:get') - ->setDescription('Get a core config item') - ->setHelp( - <<path is not set, all available config items will be listed. -The path may contain wildcards (*). -If path ends with a trailing slash, all child items will be listed. E.g. - - config:get web/ -is the same as - config:get web/* -EOT + ->addArgument( + self::COMMAND_ARGUMENT_PATH, + InputArgument::REQUIRED, + 'The config path' ) - ->addArgument('path', InputArgument::OPTIONAL, 'The config path') ->addOption( - 'scope', + self::COMMAND_OPTION_SCOPE, null, InputOption::VALUE_REQUIRED, 'The config value\'s scope (default, websites, stores)' ) - ->addOption('scope-id', null, InputOption::VALUE_REQUIRED, 'The config value\'s scope ID') ->addOption( - 'decrypt', + self::COMMAND_OPTION_SCOPE_ID, + null, InputOption::VALUE_REQUIRED, + 'The config value\'s scope ID' + ) + ->addOption( + self::COMMAND_OPTION_DECRYPT, null, InputOption::VALUE_NONE, 'Decrypt the config value using local.xml\'s crypt key' ) - ->addOption('update-script', null, InputOption::VALUE_NONE, 'Output as update script lines') - ->addOption('magerun-script', null, InputOption::VALUE_NONE, 'Output for usage with config:set') ->addOption( - 'format', + self::COMMAND_OPTION_UPDATE_SCRIPT, + null, + InputOption::VALUE_NONE, + 'Output as update script lines' + ) + ->addOption( + self::COMMAND_OPTION_MAGERUN_SCRIPT, + null, + InputOption::VALUE_NONE, + 'Output for usage with config:set' + ) + ->addOption( + self::COMMAND_OPTION_FORMAT, null, InputOption::VALUE_OPTIONAL, 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' ); + } + + /** + * @return string + */ + public function getHelp(): string + { + return <<path is not set, all available config items will be listed. +The path may contain wildcards (*). +If path ends with a trailing slash, all child items will be listed. E.g. - $help = <<setHelp($help); + config:get web/ +is the same as + config:get web/* +EOT; } /** * @param InputInterface $input * @param OutputInterface $output - * * @return int + * @throws Mage_Core_Exception */ protected function execute(InputInterface $input, OutputInterface $output): int { $table = []; - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + $this->detectMagento($output); + $this->initMagento(); - /* @var \Mage_Core_Model_Resource_Db_Collection_Abstract $collection */ $collection = $this->_getConfigDataModel()->getCollection(); - $searchPath = $input->getArgument('path'); + /** @var string $searchPath */ + $searchPath = $input->getArgument(self::COMMAND_ARGUMENT_PATH); - if (substr($input->getArgument('path'), -1, 1) === '/') { + if (substr($searchPath, -1, 1) === '/') { $searchPath .= '*'; } $collection->addFieldToFilter('path', ['like' => str_replace('*', '%', $searchPath)]); - if ($scope = $input->getOption('scope')) { + if ($scope = $input->getOption(self::COMMAND_OPTION_SCOPE)) { $collection->addFieldToFilter('scope', ['eq' => $scope]); } - if ($scopeId = $input->getOption('scope-id')) { - $collection->addFieldToFilter( - 'scope_id', - ['eq' => $scopeId] - ); + if ($scopeId = $input->getOption(self::COMMAND_OPTION_SCOPE_ID)) { + $collection->addFieldToFilter('scope_id', ['eq' => $scopeId]); } $collection->addOrder('path', 'ASC'); - // sort according to the config overwrite order // trick to force order default -> (f)website -> store , because f comes after d and before s $collection->addOrder('REPLACE(scope, "website", "fwebsite")', 'ASC'); - $collection->addOrder('scope_id', 'ASC'); - if ($collection->count() == 0) { - $output->writeln(sprintf("Couldn't find a config value for \"%s\"", $input->getArgument('path'))); + if (!$collection->getSize()) { + /** @var string $path */ + $path = $input->getArgument(self::COMMAND_ARGUMENT_PATH); + $output->writeln(sprintf("Couldn't find a config value for \"%s\"", $path)); - return 0; + return Command::SUCCESS; } + /** @var Mage_Core_Model_Config_Data $item */ foreach ($collection as $item) { - $table[] = ['path' => $item->getPath(), 'scope' => $item->getScope(), 'scope_id' => $item->getScopeId(), 'value' => $this->_formatValue( - $item->getValue(), - $input->getOption('decrypt') ? 'decrypt' : false - )]; + $table[] = [ + 'path' => $item->getPath(), + 'scope' => $item->getScope(), + 'scope_id' => $item->getScopeId(), + 'value' => $this->_formatValue( + $item->getValue(), + $input->getOption(self::COMMAND_OPTION_DECRYPT) ? 'decrypt' : false + ) + ]; } ksort($table); - if ($input->getOption('update-script')) { + if ($input->getOption(self::COMMAND_OPTION_UPDATE_SCRIPT)) { $this->renderAsUpdateScript($output, $table); - } elseif ($input->getOption('magerun-script')) { + } elseif ($input->getOption(self::COMMAND_OPTION_MAGERUN_SCRIPT)) { $this->renderAsMagerunScript($output, $table); } else { - $this->renderAsTable($output, $table, $input->getOption('format')); + /** @var string|null $format */ + $format = $input->getOption(self::COMMAND_OPTION_FORMAT); + $this->renderAsTable($output, $table, $format); } - return 0; + + return Command::SUCCESS; } /** * @param OutputInterface $output - * @param array $table - * @param string $format + * @param array $table + * @param string|null $format */ - protected function renderAsTable(OutputInterface $output, $table, $format) + protected function renderAsTable(OutputInterface $output, array $table, ?string $format): void { $formattedTable = []; foreach ($table as $row) { - $formattedTable[] = [$row['path'], $row['scope'], $row['scope_id'], $this->renderTableValue($row['value'], $format)]; + $formattedTable[] = [ + $row['path'], + $row['scope'], + $row['scope_id'], + $this->renderTableValue($row['value'], $format) + ]; } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper - ->setHeaders([Path::class, 'Scope', 'Scope-ID', 'Value']) + ->setHeaders(['Path', 'Scope', 'Scope-ID', 'Value']) ->setRows($formattedTable) ->renderByFormat($output, $formattedTable, $format); } - private function renderTableValue($value, $format) + /** + * @param string|null $value + * @param string|null $format + * @return string|null + */ + private function renderTableValue(?string $value, ?string$format): ?string { if ($value === null) { switch ($format) { @@ -172,9 +236,9 @@ private function renderTableValue($value, $format) /** * @param OutputInterface $output - * @param array $table + * @param array $table */ - protected function renderAsUpdateScript(OutputInterface $output, $table) + protected function renderAsUpdateScript(OutputInterface $output, array $table): void { $output->writeln('writeln('$installer = $this;'); @@ -205,9 +269,9 @@ protected function renderAsUpdateScript(OutputInterface $output, $table) /** * @param OutputInterface $output - * @param array $table + * @param array $table */ - protected function renderAsMagerunScript(OutputInterface $output, $table) + protected function renderAsMagerunScript(OutputInterface $output, array $table): void { foreach ($table as $row) { $value = $row['value']; From 271cb9b33bd23c50e0724ffda1732cf67b93d21b Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 20 Jun 2024 20:47:51 +0200 Subject: [PATCH 105/136] [skip ci] Updated config:delete command --- .../Command/Config/AbstractConfigCommand.php | 63 ++++---- .../Magento/Command/Config/DeleteCommand.php | 143 ++++++++++++------ src/N98/Magento/Command/Config/GetCommand.php | 8 +- src/N98/Magento/Command/Config/SetCommand.php | 8 +- 4 files changed, 136 insertions(+), 86 deletions(-) diff --git a/src/N98/Magento/Command/Config/AbstractConfigCommand.php b/src/N98/Magento/Command/Config/AbstractConfigCommand.php index ebcfe5114..533506c0b 100644 --- a/src/N98/Magento/Command/Config/AbstractConfigCommand.php +++ b/src/N98/Magento/Command/Config/AbstractConfigCommand.php @@ -1,22 +1,34 @@ strings of configuration scopes */ - protected $_scopes = ['default', 'websites', 'stores']; + protected array $_scopes = ['default', 'websites', 'stores']; /** - * @return \Mage_Core_Model_Encryption + * @return Mage_Core_Model_Encryption */ protected function getEncryptionModel() { @@ -24,19 +36,27 @@ protected function getEncryptionModel() } /** - * @return \Mage_Core_Model_Abstract + * @return Mage_Core_Model_Config */ - protected function _getConfigDataModel() + protected function _getConfigModel(): Mage_Core_Model_Config { - return $this->_getModel('core/config_data', 'Mage_Core_Model_Config_Data'); + return Mage::getModel('core/config'); } /** - * @param string $value - * @param string $encryptionType - * @return string + * @return Mage_Core_Model_Config_Data */ - protected function _formatValue($value, $encryptionType) + protected function _getConfigDataModel(): Mage_Core_Model_Config_Data + { + return Mage::getModel('core/config_data'); + } + + /** + * @param string|null $value + * @param string|null $encryptionType + * @return string|null + */ + protected function _formatValue(?string $value, ?string $encryptionType): ?string { if ($value === null) { $formatted = $value; @@ -53,10 +73,9 @@ protected function _formatValue($value, $encryptionType) /** * @param string $scope - * * @return string */ - protected function _validateScopeParam($scope) + protected function _validateScopeParam(string $scope): string { if (!in_array($scope, $this->_scopes)) { throw new InvalidArgumentException( @@ -70,11 +89,11 @@ protected function _validateScopeParam($scope) /** * @param string $scope * @param string $scopeId - * @param boolean $allowZeroScope - * - * @return string non-negative integer number + * @param bool $allowZeroScope + * @return string|int|null non-negative integer number + * @throws Mage_Core_Exception */ - protected function _convertScopeIdParam($scope, $scopeId, $allowZeroScope = false) + protected function _convertScopeIdParam(string $scope, string $scopeId, bool $allowZeroScope = false) { if ($scope === 'default') { if ("$scopeId" !== "0") { @@ -124,11 +143,11 @@ protected function _convertScopeIdParam($scope, $scopeId, $allowZeroScope = fals } /** - * @param boolean $condition + * @param bool $condition * @param string $mask * @param string $scopeId */ - private function invalidScopeId($condition, $mask, $scopeId) + private function invalidScopeId(bool $condition, string $mask, string $scopeId): void { if (!$condition) { return; @@ -138,12 +157,4 @@ private function invalidScopeId($condition, $mask, $scopeId) sprintf($mask, var_export($scopeId, true)) ); } - - /** - * @return \Mage_Core_Model_Config - */ - protected function _getConfigModel() - { - return $this->_getModel('core/config', 'Mage_Core_Model_Config'); - } } diff --git a/src/N98/Magento/Command/Config/DeleteCommand.php b/src/N98/Magento/Command/Config/DeleteCommand.php index 360eb0efc..c79e2b107 100644 --- a/src/N98/Magento/Command/Config/DeleteCommand.php +++ b/src/N98/Magento/Command/Config/DeleteCommand.php @@ -1,67 +1,116 @@ setName('config:delete') - ->setDescription('Deletes a store config item') - ->addArgument('path', InputArgument::REQUIRED, 'The config path') + ->addArgument( + self::COMMAND_ARGUMENT_PATH, + InputArgument::REQUIRED, + 'The config path' + ) ->addOption( - 'scope', + self::COMMAND_OPTION_SCOPE, null, InputOption::VALUE_OPTIONAL, 'The config value\'s scope (default, websites, stores)', 'default' ) - ->addOption('scope-id', null, InputOption::VALUE_OPTIONAL, 'The config value\'s scope ID', '0') ->addOption( - 'force', + self::COMMAND_OPTION_SCOPE_ID, + null, + InputOption::VALUE_OPTIONAL, + 'The config value\'s scope ID', '0' + ) + ->addOption( + self::COMMAND_OPTION_FORCE, null, InputOption::VALUE_NONE, 'Allow deletion of non-standard scope-id\'s for websites and stores' ) - ->addOption('all', null, InputOption::VALUE_NONE, 'Delete all entries by path') + ->addOption( + self::COMMAND_OPTION_ALL, + null, + InputOption::VALUE_NONE, + 'Delete all entries by path' + ) ; + } - $help = <<setHelp($help); } /** * @param InputInterface $input * @param OutputInterface $output - * * @return int + * @throws Mage_Core_Exception */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output, true); - - if (!$this->initMagento()) { - return 0; - } + $this->detectMagento($output); + $this->initMagento(); $deleted = []; - $allowZeroScope = $input->getOption('force'); + /** @var bool $allowZeroScope */ + $allowZeroScope = $input->getOption(self::COMMAND_OPTION_FORCE); + + /** @var string $scope */ + $scope = $input->getOption(self::COMMAND_OPTION_SCOPE); + $scope = $this->_validateScopeParam($scope); - $scope = $this->_validateScopeParam($input->getOption('scope')); - $scopeId = $this->_convertScopeIdParam($scope, $input->getOption('scope-id'), $allowZeroScope); + /** @var string $scopeId */ + $scopeId = $input->getOption(self::COMMAND_OPTION_SCOPE_ID); + $scopeId = (int)$this->_convertScopeIdParam($scope, $scopeId, $allowZeroScope); - $path = $input->getArgument('path'); + /** @var string $path */ + $path = $input->getArgument(self::COMMAND_ARGUMENT_PATH); if (false !== strstr($path, '*')) { $paths = $this->expandPathPattern($input, $path); @@ -74,34 +123,34 @@ protected function execute(InputInterface $input, OutputInterface $output): int } if (count($deleted) > 0) { - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['Deleted Path', 'Scope', 'Scope-ID']) ->setRows($deleted) ->render($output); } - return 0; + + return Command::SUCCESS; } /** * @param InputInterface $input * @param string $path - * @param string $scopeId - * - * @return array + * @param int $scopeId + * @return array> */ - protected function _deletePath(InputInterface $input, $path, $scopeId) + protected function _deletePath(InputInterface $input, string $path, int $scopeId): array { $deleted = []; - $force = $input->getOption('force'); - if ($input->getOption('all')) { + /** @var bool $force */ + $force = $input->getOption(self::COMMAND_OPTION_FORCE); + if ($input->getOption(self::COMMAND_OPTION_ALL)) { // Default $deleted[] = $this->deleteConfigEntry($path, 'default', 0); // Delete websites foreach (Mage::app()->getWebsites($force) as $website) { - $deleted[] = $this->deleteConfigEntry($path, 'websites', $website->getId()); + $deleted[] = $this->deleteConfigEntry($path, 'websites', (int)$website->getId()); } // Delete stores @@ -109,31 +158,35 @@ protected function _deletePath(InputInterface $input, $path, $scopeId) $deleted[] = $this->deleteConfigEntry($path, 'stores', $store->getId()); } } else { - $deleted[] = $this->deleteConfigEntry($path, $input->getOption('scope'), $scopeId); + /** @var string $scope */ + $scope = $input->getOption(self::COMMAND_OPTION_SCOPE); + $deleted[] = $this->deleteConfigEntry($path, $scope, $scopeId); } return $deleted; } /** + * @param InputInterface $input * @param string $pattern - * @return array + * @return array + * @throws Mage_Core_Exception */ - private function expandPathPattern($input, $pattern) + private function expandPathPattern(InputInterface $input, string $pattern): array { $paths = []; - /* @var \Mage_Core_Model_Resource_Db_Collection_Abstract $collection */ $collection = $this->_getConfigDataModel()->getCollection(); $likePattern = str_replace('*', '%', $pattern); $collection->addFieldToFilter('path', ['like' => $likePattern]); - if ($scope = $input->getOption('scope')) { + if ($scope = $input->getOption(self::COMMAND_OPTION_SCOPE)) { $collection->addFieldToFilter('scope', ['eq' => $scope]); } $collection->addOrder('path', 'ASC'); + /** @var Mage_Core_Model_Config_Data $item */ foreach ($collection as $item) { $paths[] = $item->getPath(); } @@ -147,19 +200,17 @@ private function expandPathPattern($input, $pattern) * @param string $path * @param string $scope * @param int $scopeId - * - * @return array + * @return array */ - private function deleteConfigEntry($path, $scope, $scopeId) + private function deleteConfigEntry(string $path, string $scope, int $scopeId): array { $config = $this->_getConfigModel(); + $config->deleteConfig($path, $scope, $scopeId); - $config->deleteConfig( - $path, - $scope, - $scopeId - ); - - return ['path' => $path, 'scope' => $scope, 'scopeId' => $scopeId]; + return [ + 'path' => $path, + 'scope' => $scope, + 'scopeId' => $scopeId + ]; } } diff --git a/src/N98/Magento/Command/Config/GetCommand.php b/src/N98/Magento/Command/Config/GetCommand.php index 9a1504012..9f3b440b3 100644 --- a/src/N98/Magento/Command/Config/GetCommand.php +++ b/src/N98/Magento/Command/Config/GetCommand.php @@ -22,12 +22,6 @@ */ class GetCommand extends AbstractConfigCommand { - public const COMMAND_ARGUMENT_PATH = 'path'; - - public const COMMAND_OPTION_SCOPE = 'scope'; - - public const COMMAND_OPTION_SCOPE_ID = 'scope-id'; - public const COMMAND_OPTION_DECRYPT = 'decrypt'; public const COMMAND_OPTION_UPDATE_SCRIPT = 'update-script'; @@ -162,7 +156,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int 'scope_id' => $item->getScopeId(), 'value' => $this->_formatValue( $item->getValue(), - $input->getOption(self::COMMAND_OPTION_DECRYPT) ? 'decrypt' : false + $input->getOption(self::COMMAND_OPTION_DECRYPT) ? 'decrypt' : null ) ]; } diff --git a/src/N98/Magento/Command/Config/SetCommand.php b/src/N98/Magento/Command/Config/SetCommand.php index 15121b6e1..eb88b03d0 100644 --- a/src/N98/Magento/Command/Config/SetCommand.php +++ b/src/N98/Magento/Command/Config/SetCommand.php @@ -20,14 +20,8 @@ */ class SetCommand extends AbstractConfigCommand { - public const COMMAND_ARGUMENT_PATH = 'path'; - public const COMMAND_ARGUMENT_VALUE = 'value'; - public const COMMAND_OPTION_SCOPE = 'scope'; - - public const COMMAND_OPTION_SCOPE_ID = 'scope-id'; - public const COMMAND_OPTION_ENCRYPT = 'encrypt'; public const COMMAND_OPTION_FORCE = 'force'; @@ -147,7 +141,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $valueDisplay = self::DISPLAY_NULL_UNKNOWN_VALUE; } else { $value = str_replace(['\n', '\r'], ["\n", "\r"], $value); - $value = $this->_formatValue($value, ($input->getOption(self::COMMAND_OPTION_ENCRYPT) ? 'encrypt' : false)); + $value = $this->_formatValue($value, ($input->getOption(self::COMMAND_OPTION_ENCRYPT) ? 'encrypt' : null)); } /** @var string $path */ From 00223b32b19b3eb242e792efec91479c5031344e Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 21 Jun 2024 00:32:20 +0200 Subject: [PATCH 106/136] [skip ci] Updated db:maintain:check-tables command --- .../Database/Maintain/CheckTablesCommand.php | 287 +++++++++++------- 1 file changed, 170 insertions(+), 117 deletions(-) diff --git a/src/N98/Magento/Command/Database/Maintain/CheckTablesCommand.php b/src/N98/Magento/Command/Database/Maintain/CheckTablesCommand.php index a554f1450..0616f904a 100644 --- a/src/N98/Magento/Command/Database/Maintain/CheckTablesCommand.php +++ b/src/N98/Magento/Command/Database/Maintain/CheckTablesCommand.php @@ -1,51 +1,93 @@ */ - protected $showProgress = false; + protected array $allowedTypes = ['QUICK', 'FAST', 'CHANGED', 'MEDIUM', 'EXTENDED']; + + protected function configure(): void + { + $this + ->addOption( + self::COMMAND_OPTION_TYPE, + null, + InputOption::VALUE_OPTIONAL, + 'Check type (one of QUICK, FAST, MEDIUM, EXTENDED, CHANGED)', + 'MEDIUM' + ) + ->addOption( + self::COMMAND_OPTION_REPAIR, + null, + InputOption::VALUE_NONE, + 'Repair tables (only MyISAM)' + ) + ->addOption( + self::COMMAND_OPTION_TABLE, + null, + InputOption::VALUE_OPTIONAL, + 'Process only given table (wildcards are supported)' + ); + + parent::configure(); + } /** - * @var array + * @return string */ - protected $allowedTypes = ['QUICK', 'FAST', 'CHANGED', 'MEDIUM', 'EXTENDED']; - - protected function configure() + public function getHelp(): string { - $help = <<<'HELP' + return <<TYPE OPTIONS QUICK @@ -72,40 +114,15 @@ protected function configure() InnoDB tables will be optimized with the ALTER TABLE ... ENGINE=InnoDB statement. The options above do not apply to them. HELP; - - $this - ->setName('db:maintain:check-tables') - ->setDescription('Check database tables') - ->addOption( - 'type', - null, - InputOption::VALUE_OPTIONAL, - 'Check type (one of QUICK, FAST, MEDIUM, EXTENDED, CHANGED)', - 'MEDIUM' - ) - ->addOption('repair', null, InputOption::VALUE_NONE, 'Repair tables (only MyISAM)') - ->addOption( - 'table', - null, - InputOption::VALUE_OPTIONAL, - 'Process only given table (wildcards are supported)' - ) - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' - ) - ->setHelp($help); } /** * @throws InvalidArgumentException - * */ - protected function isTypeAllowed() + protected function isTypeAllowed(InputInterface $input): void { - $type = $this->input->getOption('type'); + /** @var string $type */ + $type = $input->getOption(self::COMMAND_OPTION_TYPE); $type = strtoupper($type); if ($type && !in_array($type, $this->allowedTypes)) { throw new InvalidArgumentException('Invalid type was given'); @@ -115,7 +132,7 @@ protected function isTypeAllowed() /** * @param ProgressBar $progress */ - protected function progressAdvance(ProgressBar $progress) + protected function progressAdvance(ProgressBar $progress): void { if ($this->showProgress) { $progress->advance(); @@ -123,121 +140,150 @@ protected function progressAdvance(ProgressBar $progress) } /** - * @param InputInterface $input - * @param OutputInterface $output + * {@inheritdoc} + * @return array> * - * @return int + * @uses self::_checkInnoDB() + * @uses self::_checkMEMORY() + * @uses self::_checkMyISAM() */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getData(InputInterface $input, OutputInterface $output): array { - $this->input = $input; - $this->output = $output; - $this->isTypeAllowed(); - $this->detectMagento($output); - $this->dbHelper = $this->getHelper('database'); - $this->showProgress = $input->getOption('format') == null; - - if ($input->getOption('table')) { - $resolvedTables = [$this->dbHelper->resolveTables( - ['@check'], - ['check' => ['tables' => explode(' ', $input->getOption('table'))]] - )]; - $tables = $resolvedTables[0]; - } else { - $tables = $this->dbHelper->getTables(); - } - - $allTableStatus = $this->dbHelper->getTablesStatus(); + if (is_null($this->data)) { + $data = []; + $this->isTypeAllowed($input); + $database = $this->getDatabaseHelper(); + $this->showProgress = $input->getOption(self::COMMAND_OPTION_FORMAT) === null; + + /** @var string $table */ + $table = $input->getOption(self::COMMAND_OPTION_TABLE); + if ($table) { + $resolvedTables = [$database->resolveTables( + ['@check'], + ['check' => ['tables' => explode(' ', $table)]] + )]; + $tables = $resolvedTables[0]; + } else { + $tables = $database->getTables(); + } - $tableOutput = []; + $allTableStatus = $database->getTablesStatus(); - $progress = new ProgressBar($output, 50); + $progress = new ProgressBar($output, 50); - if ($this->showProgress) { - $progress->start(count($tables)); - } + if ($this->showProgress) { + $progress->start(count($tables)); + } - $methods = ['InnoDB' => 1, 'MEMORY' => 1, 'MyISAM' => 1]; + $methods = ['InnoDB' => 1, 'MEMORY' => 1, 'MyISAM' => 1]; + + foreach ($tables as $tableName) { + if (isset($allTableStatus[$tableName]) && isset($methods[$allTableStatus[$tableName]['Engine']])) { + $m = '_check' . $allTableStatus[$tableName]['Engine']; + $data = array_merge($data, $this->$m($input, $output, $tableName)); + } else { + $data[] = [ + 'table' => $tableName, + 'operation' => 'not supported', + 'type' => '', + 'status' => '' + ]; + } + $this->progressAdvance($progress); + } - foreach ($tables as $tableName) { - if (isset($allTableStatus[$tableName]) && isset($methods[$allTableStatus[$tableName]['Engine']])) { - $m = '_check' . $allTableStatus[$tableName]['Engine']; - $tableOutput = array_merge($tableOutput, $this->$m($tableName)); - } else { - $tableOutput[] = ['table' => $tableName, 'operation' => 'not supported', 'type' => '', 'status' => '']; + if ($this->showProgress) { + $progress->finish(); } - $this->progressAdvance($progress); - } - if ($this->showProgress) { - $progress->finish(); + $this->data = $data; } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); - $tableHelper - ->setHeaders(['Table', 'Operation', 'Type', 'Status']) - ->renderByFormat($this->output, $tableOutput, $this->input->getOption('format')); - return 0; + return $this->data; } /** + * @param OutputInterface $output * @param string $tableName * @param string $engine - * - * @return array + * @return array> */ - protected function _queryAlterTable($tableName, $engine) + protected function _queryAlterTable(OutputInterface $output, string $tableName, string $engine): array { - $connection = $this->dbHelper->getConnection($this->output); + $connection = $this->getDatabaseHelper()->getConnection($output); $start = microtime(true); $affectedRows = $connection->exec(sprintf('ALTER TABLE %s ENGINE=%s', $tableName, $engine)); - return [['table' => $tableName, 'operation' => 'ENGINE ' . $engine, 'type' => sprintf('%15s rows', (string) $affectedRows), 'status' => sprintf('%.3f secs', microtime(true) - $start)]]; + return [[ + 'table' => $tableName, + 'operation' => 'ENGINE ' . $engine, + 'type' => sprintf('%15s rows', (string) $affectedRows), + 'status' => sprintf('%.3f secs', microtime(true) - $start) + ]]; } /** + * @param InputInterface $input + * @param OutputInterface $output * @param string $tableName + * @return array> * - * @return array + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - protected function _checkInnoDB($tableName) + protected function _checkInnoDB(InputInterface $input, OutputInterface $output, string $tableName): array { - return $this->_queryAlterTable($tableName, 'InnoDB'); + return $this->_queryAlterTable($output, $tableName, 'InnoDB'); } /** + * @param InputInterface $input + * @param OutputInterface $output * @param string $tableName + * @return array> * - * @return array + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - protected function _checkMEMORY($tableName) + protected function _checkMEMORY(InputInterface $input, OutputInterface $output, string $tableName): array { - return $this->_queryAlterTable($tableName, 'MEMORY'); + return $this->_queryAlterTable($output, $tableName, 'MEMORY'); } /** + * @param InputInterface $input + * @param OutputInterface $output * @param string $tableName - * - * @return array + * @return array> */ - protected function _checkMyISAM($tableName) + protected function _checkMyISAM(InputInterface $input, OutputInterface $output, string $tableName): array { $table = []; - $type = $this->input->getOption('type'); - $result = $this->_query(sprintf('CHECK TABLE %s %s', $tableName, $type)); + + /** @var string $type */ + $type = $input->getOption(self::COMMAND_OPTION_TYPE); + + /** @var array $result */ + $result = $this->_query($output, sprintf('CHECK TABLE %s %s', $tableName, $type)); if ($result['Msg_text'] == self::MESSAGE_CHECK_NOT_SUPPORTED) { return []; } - $table[] = ['table' => $tableName, 'operation' => $result['Op'], 'type' => $type, 'status' => $result['Msg_text']]; + $table[] = [ + 'table' => $tableName, + 'operation' => $result['Op'], + 'type' => $type, + 'status' => $result['Msg_text'] + ]; - if ($result['Msg_text'] != 'OK' - && $this->input->getOption('repair') - ) { - $result = $this->_query(sprintf('REPAIR TABLE %s %s', $tableName, $type)); + if ($result['Msg_text'] != 'OK' && $input->getOption(self::COMMAND_OPTION_REPAIR)) { + /** @var array $result */ + $result = $this->_query($output, sprintf('REPAIR TABLE %s %s', $tableName, $type)); if ($result['Msg_text'] != self::MESSAGE_REPAIR_NOT_SUPPORTED) { - $table[] = ['table' => $tableName, 'operation' => $result['Op'], 'type' => $type, 'status' => $result['Msg_text']]; + $table[] = [ + 'table' => $tableName, + 'operation' => $result['Op'], + 'type' => $type, + 'status' => $result['Msg_text'] + ]; } } @@ -245,17 +291,24 @@ protected function _checkMyISAM($tableName) } /** + * @param OutputInterface $output * @param string $sql - * - * @return array|bool + * @return mixed */ - protected function _query($sql) + protected function _query(OutputInterface $output, string $sql) { - $connection = $this->dbHelper->getConnection($this->output); + $connection = $this->getDatabaseHelper()->getConnection($output); $query = $connection->prepare($sql); $query->execute(); - $result = $query->fetch(PDO::FETCH_ASSOC); + return $query->fetch(PDO::FETCH_ASSOC); + } - return $result; + /** + * Skip initialisation + * + * @param bool $soft + */ + public function initMagento(bool $soft = false): void + { } } From 6008ba409bd01bfe97dcb675c3c7c8f1e6fd06c0 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 21 Jun 2024 01:18:59 +0200 Subject: [PATCH 107/136] [skip ci] Updated eav:attribute:view command --- .../Command/Eav/Attribute/ViewCommand.php | 165 +++++++++++------- 1 file changed, 103 insertions(+), 62 deletions(-) diff --git a/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php b/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php index 476eb8804..863c5996d 100644 --- a/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php +++ b/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php @@ -1,96 +1,137 @@ setName('eav:attribute:view') - ->addArgument('entityType', InputArgument::REQUIRED, 'Entity Type Code like catalog_product') - ->addArgument('attributeCode', InputArgument::REQUIRED, 'Attribute Code') - ->setDescription('View informations about an EAV attribute') - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' - ); + ->addArgument( + self::COMMAND_ARGUMENT_ENTITY, + InputArgument::REQUIRED, + 'Entity Type Code like catalog_product' + ) + ->addArgument( + self::COMMAND_ARGUMENT_ATTRIBUTE, + InputArgument::REQUIRED, + 'Attribute Code' + ) + ; + + parent::configure(); } /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int + * {@inheritdoc} + * @return array> + * @throws Mage_Core_Exception */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function getData(InputInterface $input, OutputInterface $output): array { - $this->detectMagento($output); - $this->initMagento(); + if (is_null($this->data)) { + /** @var string $entityType */ + $entityType = $input->getArgument(self::COMMAND_ARGUMENT_ENTITY); + /** @var string $attributeCode */ + $attributeCode = $input->getArgument(self::COMMAND_ARGUMENT_ATTRIBUTE); - $entityType = $input->getArgument('entityType'); - $attributeCode = $input->getArgument('attributeCode'); + $attribute = $this->getAttribute($entityType, $attributeCode); + if (!$attribute) { + throw new InvalidArgumentException('Attribute was not found.'); + } - $attribute = $this->getAttribute($entityType, $attributeCode); - if (!$attribute) { - throw new InvalidArgumentException('Attribute was not found.'); - } + $cacheIdTags = $attribute->getCacheIdTags(); + $cacheTags = $attribute->getCacheTags(); + $flatColumns = $attribute->getFlatColumns(); - $table = [ - ['ID', $attribute->getId()], - ['Code', $attribute->getName()], - ['Attribute-Set-ID', $attribute->getAttributeSetId()], - ['Visible-On-Front', $attribute->getIsVisibleOnFront() ? 'yes' : 'no'], - ['Attribute-Model', $attribute->getAttributeModel() ?: ''], - ['Backend-Model', $attribute->getBackendModel() ?: ''], - ['Backend-Table', $attribute->getBackendTable() ?: ''], - ['Backend-Type', $attribute->getBackendType() ?: ''], - ['Source-Model', $attribute->getSourceModel() ?: ''], - ['Cache-ID-Tags', $attribute->getCacheIdTags() ? implode(',', $attribute->getCacheIdTags()) : ''], - ['Cache-Tags', $attribute->getCacheTags() ? implode(',', $attribute->getCacheTags()) : ''], - ['Default-Value', $attribute->getDefaultValue() ?: ''], - ['Flat-Columns', $attribute->getFlatColumns() ? implode(',', array_keys($attribute->getFlatColumns())) : ''] - ]; - - $flatIndexes = $attribute->getFlatIndexes() ? $attribute->getFlatIndexes() : ''; - if ($flatIndexes) { - $key = array_key_first($flatIndexes); - $flatIndexes = implode(',', $flatIndexes[$key]['fields']); - } - $table[] = ['Flat-Indexes', $flatIndexes ? $key . ' - ' . $flatIndexes : '']; + $this->data = [ + ['ID', $attribute->getId()], + ['Code', $attribute->getName()], + ['Attribute-Set-ID', $attribute->getAttributeSetId()], + ['Visible-On-Front', $attribute->getIsVisibleOnFront() ? 'yes' : 'no'], + ['Attribute-Model', $attribute->getAttributeModel() ?: ''], + ['Backend-Model', $attribute->getBackendModel() ?: ''], + ['Backend-Table', $attribute->getBackendTable() ?: ''], + ['Backend-Type', $attribute->getBackendType() ?: ''], + ['Source-Model', $attribute->getSourceModel() ?: ''], + ['Cache-ID-Tags', is_array($cacheIdTags) ? implode(',', $cacheIdTags) : ''], + ['Cache-Tags', is_array($cacheTags) ? implode(',', $cacheTags) : ''], + ['Default-Value', $attribute->getDefaultValue() ?: ''], + ['Flat-Columns', is_array($flatColumns) ? implode(',', array_keys($flatColumns)) : ''] + ]; + + $key = ''; + $flatIndexes = $attribute->getFlatIndexes() ? $attribute->getFlatIndexes() : ''; + if ($flatIndexes) { + $key = array_key_first($flatIndexes); + $flatIndexes = implode(',', $flatIndexes[$key]['fields']); + } + $this->data[] = ['Flat-Indexes', $flatIndexes ? $key . ' - ' . $flatIndexes : '']; - if ($attribute->getFrontend()) { - $table[] = ['Frontend-Label', $attribute->getFrontend()->getLabel()]; - $table[] = ['Frontend-Class', trim($attribute->getFrontend()->getClass())]; - $table[] = ['Frontend-Input', trim($attribute->getFrontend()->getInputType())]; - $table[] = ['Frontend-Input-Renderer-Class', trim($attribute->getFrontend()->getInputRendererClass())]; + if ($attribute->getFrontend()) { + $this->data[] = ['Frontend-Label', $attribute->getFrontend()->getLabel()]; + $this->data[] = ['Frontend-Class', trim($attribute->getFrontend()->getClass())]; + $this->data[] = ['Frontend-Input', trim($attribute->getFrontend()->getInputType())]; + $this->data[] = ['Frontend-Input-Renderer-Class', trim((string)$attribute->getFrontend()->getInputRendererClass())]; + } } +// ) + return $this->data; + } - $this - ->getHelper('table') - ->setHeaders(['Type', 'Value']) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; + /** + * @return array + * + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter + */ + protected function getTableHeaders(InputInterface $input, OutputInterface $output): array + { + return ['Type', 'Value']; } /** * @param string $entityType * @param string $attributeCode - * - * @return \Mage_Eav_Model_Entity_Attribute_Abstract|false + * @return Mage_Eav_Model_Entity_Attribute_Abstract|false + * @throws Mage_Core_Exception */ - protected function getAttribute($entityType, $attributeCode) + protected function getAttribute(string $entityType, string $attributeCode) { return Mage::getModel('eav/config')->getAttribute($entityType, $attributeCode); } From 12a36e6c8303f4b91788ce2a4dff19321e096a10 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 21 Jun 2024 01:31:30 +0200 Subject: [PATCH 108/136] [skip ci] Updated eav:attribute:list command --- .../Command/Eav/Attribute/ListCommand.php | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/N98/Magento/Command/Eav/Attribute/ListCommand.php b/src/N98/Magento/Command/Eav/Attribute/ListCommand.php index 77c5ab92a..dcde6b3d9 100644 --- a/src/N98/Magento/Command/Eav/Attribute/ListCommand.php +++ b/src/N98/Magento/Command/Eav/Attribute/ListCommand.php @@ -6,6 +6,7 @@ use Exception; use Mage; +use Mage_Eav_Model_Entity_Attribute; use Mage_Eav_Model_Entity_Type; use N98\Magento\Command\AbstractMagentoCommand; use N98\Magento\Command\AbstractMagentoCommandFormatInterface; @@ -14,6 +15,11 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +/** + * EAV attribute list command + * + * @package N98\Magento\Command\Eav\Attribute + */ class ListCommand extends AbstractMagentoCommand implements AbstractMagentoCommandFormatInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'EAV attributes'; @@ -38,7 +44,7 @@ class ListCommand extends AbstractMagentoCommand implements AbstractMagentoComma */ protected static $defaultDescription = 'Lists all EAV attributes.'; - protected function configure() + protected function configure(): void { $this ->addOption( @@ -76,6 +82,7 @@ public function getData(InputInterface $input, OutputInterface $output): array $attributesCollection = Mage::getResourceModel('eav/entity_attribute_collection'); $attributesCollection->setOrder('attribute_code', 'asc'); + /** @var Mage_Eav_Model_Entity_Attribute $attribute */ foreach ($attributesCollection as $attribute) { $entityType = $this->_getEntityType($attribute); @@ -89,16 +96,16 @@ public function getData(InputInterface $input, OutputInterface $output): array } $row = []; - $row['code'] = $attribute->getAttributeCode(); - $row['id'] = $attribute->getId(); - $row['entity_type'] = $entityType; - $row['label'] = $attribute->getFrontendLabel(); + $row['Code'] = $attribute->getAttributeCode(); + $row['ID'] = $attribute->getId(); + $row['Entity type'] = $entityType; + $row['Label'] = $attribute->getFrontendLabel(); if ($input->getOption(self::COMMAND_OPTION_ADD_SOURCE)) { - $row['source'] = $attribute->getSourceModel() ?: ''; + $row['Source'] = $attribute->getSourceModel() ?: ''; } if ($input->getOption(self::COMMAND_OPTION_ADD_BACKEND)) { - $row['backend_type'] = $attribute->getBackendType(); + $row['Backend type'] = $attribute->getBackendType(); } $this->data[] = $row; @@ -109,10 +116,10 @@ public function getData(InputInterface $input, OutputInterface $output): array } /** - * @param $attribute + * @param Mage_Eav_Model_Entity_Attribute $attribute * @return null|string */ - protected function _getEntityType($attribute): ?string + protected function _getEntityType(Mage_Eav_Model_Entity_Attribute $attribute): ?string { $entityTypeCode = ''; try { From 62bcfd371a7b5f4f923b26429ec5d6b019d83fdb Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 21 Jun 2024 01:51:03 +0200 Subject: [PATCH 109/136] [skip ci] Updated eav:attribute:remove command --- .../Command/Eav/Attribute/RemoveCommand.php | 60 +++++++++++++++---- 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/src/N98/Magento/Command/Eav/Attribute/RemoveCommand.php b/src/N98/Magento/Command/Eav/Attribute/RemoveCommand.php index 68e71dcbd..5b52505e3 100644 --- a/src/N98/Magento/Command/Eav/Attribute/RemoveCommand.php +++ b/src/N98/Magento/Command/Eav/Attribute/RemoveCommand.php @@ -1,44 +1,76 @@ */ class RemoveCommand extends AbstractMagentoCommand { - protected function configure() + public const COMMAND_ARGUMENT_ENTITY = 'entityType'; + + public const COMMAND_ARGUMENT_ATTRIBUTE = 'attributeCode'; + + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultName = 'eav:attribute:remove'; + + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultDescription = 'Removes attribute for a given attribute code.'; + + protected function configure(): void { $this - ->setName('eav:attribute:remove') - ->addArgument('entityType', InputArgument::REQUIRED, 'Entity Type Code like catalog_product') - ->addArgument('attributeCode', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'Attribute Code') - ->setDescription('Removes attribute for a given attribute code'); + ->addArgument( + self::COMMAND_ARGUMENT_ENTITY, + InputArgument::REQUIRED, + 'Entity Type Code like catalog_product' + ) + ->addArgument( + self::COMMAND_ARGUMENT_ATTRIBUTE, + InputArgument::REQUIRED | InputArgument::IS_ARRAY, + 'Attribute Code' + ) + ; } /** - * @param InputInterface $input + * @param InputInterface $input * @param OutputInterface $output - * * @return int + * @throws Exception */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output, true); + $this->detectMagento($output); $this->initMagento(); - $entityType = $input->getArgument('entityType'); + /** @var string $entityType */ + $entityType = $input->getArgument(self::COMMAND_ARGUMENT_ENTITY); try { $attributes = Mage::getModel('eav/config')->getEntityAttributeCodes($entityType); @@ -47,7 +79,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); - foreach ($input->getArgument('attributeCode') as $attributeCode) { + + /** @var array $attributeCodes */ + $attributeCodes = $input->getArgument(self::COMMAND_ARGUMENT_ATTRIBUTE); + foreach ($attributeCodes as $attributeCode) { if (!in_array($attributeCode, $attributes)) { $message = sprintf( 'Attribute: "%s" does not exist for entity type: "%s"', @@ -67,6 +102,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int ); } } - return 0; + + return Command::SUCCESS; } } From 9f08e8b9072b312045e5dd2ae99dd8ea3736b127 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 21 Jun 2024 02:42:26 +0200 Subject: [PATCH 110/136] [skip ci] Updated eav:attribute:create-dummy-values command --- .../Eav/Attribute/Create/DummyCommand.php | 184 +++++++++++++----- .../Eav/Attribute/Create/DummyValues.php | 39 +++- 2 files changed, 166 insertions(+), 57 deletions(-) diff --git a/src/N98/Magento/Command/Eav/Attribute/Create/DummyCommand.php b/src/N98/Magento/Command/Eav/Attribute/Create/DummyCommand.php index 469db9fa9..2e7ed740a 100644 --- a/src/N98/Magento/Command/Eav/Attribute/Create/DummyCommand.php +++ b/src/N98/Magento/Command/Eav/Attribute/Create/DummyCommand.php @@ -1,53 +1,109 @@ addArgument( + self::COMMAND_ARGUMENT_LOCALE, + InputArgument::OPTIONAL, + Locale::class + ) + ->addArgument( + self::COMMAND_ARGUMENT_ATTRIBUTE_ID, + InputArgument::OPTIONAL, + 'Attribute ID to add values' + ) + ->addArgument( + self::COMMAND_ARGUMENT_VALUES_TYPE, + InputArgument::OPTIONAL, + 'Types of Values to create (default int)' + ) + ->addArgument( + self::COMMAND_ARGUMENT_VALUES_NUMBER, + InputArgument::OPTIONAL, + 'Number of Values to create (default 1)' + ) + ; + } + + /** + * @return string + */ + public function getHelp(): string + { + return <<setName('eav:attribute:create-dummy-values')->addArgument('locale', InputArgument::OPTIONAL, Locale::class) - ->addArgument('attribute-id', InputArgument::OPTIONAL, 'Attribute ID to add values') - ->addArgument('values-type', InputArgument::OPTIONAL, 'Types of Values to create (default int)') - ->addArgument('values-number', InputArgument::OPTIONAL, 'Number of Values to create (default 1)') - ->setDescription('Create a dummy values for dropdown attributes')->setHelp($help) - ; } /** * @param InputInterface $input * @param OutputInterface $output - * * @return int + * @throws Throwable */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + $this->detectMagento($output); + $this->initMagento(); $output->writeln( "This only create sample attribute values, do not use on production environment" @@ -55,23 +111,30 @@ protected function execute(InputInterface $input, OutputInterface $output): int // Ask for Arguments $argument = $this->askForArguments($input, $output); - if (!in_array($input->getArgument('locale'), $this->supportedLocales)) { + + /** @var string $locale */ + $locale = $input->getArgument(self::COMMAND_ARGUMENT_LOCALE); + if (!in_array($locale, $this->supportedLocales)) { $output->writeln( sprintf( "Locale '%s' not supported, switch to default locale 'us_US'.", - $input->getArgument('locale') + $locale ) ); - $argument['locale'] = "en_US"; + $argument[self::COMMAND_ARGUMENT_LOCALE] = 'en_US'; } else { - $argument['locale'] = $input->getArgument('locale'); + $argument[self::COMMAND_ARGUMENT_LOCALE] = $locale; } /** @var Mage_Eav_Model_Entity_Attribute $attribute */ $attribute = Mage::getModel('eav/entity_attribute')->load($argument['attribute-id']); $dummyValues = new DummyValues(); - for ($i = 0; $i < $argument['values-number']; $i++) { - $value = $dummyValues->createValue($argument['values-type'], $argument['locale']); + for ($i = 0; $i < $argument[self::COMMAND_ARGUMENT_VALUES_NUMBER]; $i++) { + $value = $dummyValues->createValue( + $argument[self::COMMAND_ARGUMENT_VALUES_TYPE], + $argument[self::COMMAND_ARGUMENT_LOCALE] + ); + if (!$this->attributeValueExists($attribute, $value)) { try { $attribute->setData('option', ['value' => ['option' => [$value, $value]]]); @@ -82,70 +145,94 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln("ATTRIBUTE VALUE: '" . $value . "' ADDED!\r"); } } - return 0; + + return Command::SUCCESS; } /** * Ask for command arguments * - * @param InputInterface $input + * @param InputInterface $input * @param OutputInterface $output - * - * @return array + * @return array + * @throws Mage_Core_Exception */ - private function askForArguments(InputInterface $input, OutputInterface $output) + private function askForArguments(InputInterface $input, OutputInterface $output): array { - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $argument = []; // Attribute ID - if (is_null($input->getArgument('attribute-id'))) { - $attribute_code = Mage::getModel('eav/entity_attribute') - ->getCollection()->addFieldToSelect('*') + if (is_null($input->getArgument(self::COMMAND_ARGUMENT_ATTRIBUTE_ID))) { + /** @var Mage_Eav_Model_Resource_Entity_Attribute_Collection $attributeCodeCollection */ + $attributeCodeCollection = Mage::getModel('eav/entity_attribute')->getCollection(); + $attributeCodeCollection + ->addFieldToSelect('*') ->addFieldToFilter('entity_type_id', ['eq' => 4]) ->addFieldToFilter('backend_type', ['in' => ['int']]) ->setOrder('attribute_id', 'ASC') ; $attribute_codes = []; - foreach ($attribute_code as $item) { + /** @var Mage_Eav_Model_Entity_Attribute $item */ + foreach ($attributeCodeCollection as $item) { $attribute_codes[$item['attribute_id']] = $item['attribute_id'] . "|" . $item['attribute_code']; } $question = new ChoiceQuestion('Please select Attribute ID', $attribute_codes); $question->setErrorMessage('Attribute ID "%s" is invalid.'); - $response = explode("|", $dialog->ask($input, $output, $question)); - $input->setArgument('attribute-id', $response[0]); + + /** @var string $answer */ + $answer = $dialog->ask($input, $output, $question); + $response = explode('|', $answer); + $input->setArgument(self::COMMAND_ARGUMENT_ATTRIBUTE_ID, $response[0]); } - $output->writeln('Attribute code selected: ' . $input->getArgument('attribute-id') . ""); - $argument['attribute-id'] = (int) $input->getArgument('attribute-id'); + + /** @var string $attributeId */ + $attributeId = $input->getArgument(self::COMMAND_ARGUMENT_ATTRIBUTE_ID); + $output->writeln(sprintf( + 'Attribute code selected: %s', + $attributeId + )); + $argument[self::COMMAND_ARGUMENT_ATTRIBUTE_ID] = $attributeId; // Type of Values - if (is_null($input->getArgument('values-type'))) { + if (is_null($input->getArgument(self::COMMAND_ARGUMENT_VALUES_TYPE))) { $valueTypes = DummyValues::getValueTypeList(); $question = new ChoiceQuestion('Please select Attribute Value Type', $valueTypes, 'int'); $question->setErrorMessage('Attribute Value Type "%s" is invalid.'); - $input->setArgument('values-type', $dialog->ask($input, $output, $question)); + $input->setArgument(self::COMMAND_ARGUMENT_VALUES_TYPE, $dialog->ask($input, $output, $question)); } - $output->writeln('Attribute Value Type selected: ' . $input->getArgument('values-type') . ""); - $argument['values-type'] = $input->getArgument('values-type'); + + /** @var string $valueType */ + $valueType = $input->getArgument(self::COMMAND_ARGUMENT_VALUES_TYPE); + $output->writeln(sprintf( + 'Attribute Value Type selected: %s', + $valueType + )); + $argument[self::COMMAND_ARGUMENT_VALUES_TYPE] = $valueType; // Number of Values - if (is_null($input->getArgument('values-number'))) { + if (is_null($input->getArgument(self::COMMAND_ARGUMENT_VALUES_NUMBER))) { $question = new Question("Please enter the number of values to create (default 1): ", 1); $question->setValidator(function ($answer) { $answer = (int) ($answer); - if (!is_int($answer) || $answer <= 0) { + if ($answer <= 0) { throw new RuntimeException('Please enter an integer value or > 0'); } return $answer; }); - $input->setArgument('values-number', $dialog->ask($input, $output, $question)); + $input->setArgument(self::COMMAND_ARGUMENT_VALUES_NUMBER, $dialog->ask($input, $output, $question)); } - $output->writeln('Number of values to create: ' . $input->getArgument('values-number') . ""); - $argument['values-number'] = $input->getArgument('values-number'); + + /** @var string $valueNumber */ + $valueNumber = $input->getArgument(self::COMMAND_ARGUMENT_VALUES_NUMBER); + $output->writeln(sprintf( + 'Number of values to create: %s', + $valueNumber + )); + $argument[self::COMMAND_ARGUMENT_VALUES_NUMBER] = $valueNumber; return $argument; } @@ -154,11 +241,10 @@ private function askForArguments(InputInterface $input, OutputInterface $output) * Check if an option exist * * @param Mage_Eav_Model_Entity_Attribute $attribute - * @param string $arg_value - * + * @param string|int $arg_value * @return bool */ - private function attributeValueExists(Mage_Eav_Model_Entity_Attribute $attribute, $arg_value) + private function attributeValueExists(Mage_Eav_Model_Entity_Attribute $attribute, $arg_value): bool { $options = Mage::getModel('eav/entity_attribute_source_table'); $options->setAttribute($attribute); diff --git a/src/N98/Magento/Command/Eav/Attribute/Create/DummyValues.php b/src/N98/Magento/Command/Eav/Attribute/Create/DummyValues.php index 64641fdd0..20cd0a04c 100644 --- a/src/N98/Magento/Command/Eav/Attribute/Create/DummyValues.php +++ b/src/N98/Magento/Command/Eav/Attribute/Create/DummyValues.php @@ -1,35 +1,58 @@ */ - public static function getValueTypeList() + public static function getValueTypeList(): array { - return ['int' => 'int', 'string' => 'string', 'color' => 'color', 'size' => 'size', 'designer' => 'designer']; + return [ + 'int' => 'int', + 'string' => 'string', + 'color' => 'color', + 'size' => 'size', + 'designer' => 'designer' + ]; } /** * Create random value * * @param string $type - * + * @param string $locale * @return int|string */ - public function createValue($type, $locale) + public function createValue(string $type, string $locale) { if (!isset($this->faker)) { $this->faker = Factory::create($locale); From e41f3378b7d3205caae1199aca7531482bd47fa0 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 21 Jun 2024 03:57:21 +0200 Subject: [PATCH 111/136] [skip ci] Updated customer:delete command --- .../Command/Customer/DeleteCommand.php | 231 ++++++++++-------- .../Magento/Command/Customer/ListCommand.php | 10 +- 2 files changed, 140 insertions(+), 101 deletions(-) diff --git a/src/N98/Magento/Command/Customer/DeleteCommand.php b/src/N98/Magento/Command/Customer/DeleteCommand.php index e38d09b81..e52c6d81b 100644 --- a/src/N98/Magento/Command/Customer/DeleteCommand.php +++ b/src/N98/Magento/Command/Customer/DeleteCommand.php @@ -1,20 +1,24 @@ addArgument( + self::COMMAND_ARGUMENT_ID, + InputArgument::OPTIONAL, + 'Customer Id or email', + false + ) + ->addOption( + self::COMMAND_OPTION_ALL, + 'a', InputOption::VALUE_NONE, + 'Delete all customers' + ) + ->addOption( + self::COMMAND_OPTION_FORCE, + 'f', InputOption::VALUE_NONE, + 'Force delete' + ) + ->addOption( + self::COMMAND_OPTION_RANGE, + '-r', InputOption::VALUE_NONE, + 'Delete a range of customers by Id' + ) + ; + } /** - * Set up options + * @return string */ - protected function configure() + public function getHelp(): string { - $this - ->setName('customer:delete') - ->addArgument('id', InputArgument::OPTIONAL, 'Customer Id or email', false) - ->addOption('all', 'a', InputOption::VALUE_NONE, 'Delete all customers') - ->addOption('force', 'f', InputOption::VALUE_NONE, 'Force delete') - ->addOption('range', '-r', InputOption::VALUE_NONE, 'Delete a range of customers by Id') - ->setDescription('Delete Customer/s'); - - $help = <<Example Usage: @@ -62,59 +92,55 @@ protected function configure() n98-magerun customer:delete --range # Will prompt for start and end Ids for batch deletion HELP; - - $this->setHelp($help); } /** - * @param InputInterface $input + * @param InputInterface $input * @param OutputInterface $output - * * @return int + * @throws Mage_Core_Exception + * @throws Throwable */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output, true); + $this->detectMagento($output); $this->initMagento(); - $this->input = $input; - $this->output = $output; - $this->questionHelper = $this->getHelperSet()->get('question'); + $dialog = $this->getQuestionHelper(); - // Defaults - $range = $all = false; + /** @var string $id */ + $id = $input->getArgument(self::COMMAND_ARGUMENT_ID); + $range = $input->getOption(self::COMMAND_OPTION_RANGE); + $all = $input->getOption(self::COMMAND_OPTION_ALL); - $id = $this->input->getArgument('id'); - $range = $this->input->getOption('range'); - $all = $this->input->getOption('all'); // Get args required if (!($id) && !($range) && !($all)) { // Delete more than one customer ? - $batchDelete = $this->questionHelper->ask( - $this->input, - $this->output, + $batchDelete = $dialog->ask( + $input, + $output, $this->getQuestion('Delete more than 1 customer?', 'n'), ); if ($batchDelete) { // Batch deletion - $all = $this->questionHelper->ask( - $this->input, - $this->output, - new ConfirmationQuestion('Delete all customers?', 'n'), + $all = $dialog->ask( + $input, + $output, + new ConfirmationQuestion('Delete all customers?', false, 'n'), ); if (!$all) { - $range = $this->questionHelper->ask( - $this->input, - $this->output, - new ConfirmationQuestion('Delete a range of customers?', 'n'), + $range = $dialog->ask( + $input, + $output, + new ConfirmationQuestion('Delete a range of customers?', false, 'n'), ); if (!$range) { // Nothing to do - $this->output->writeln('Finished nothing to do'); - return (int) false; + $output->writeln('Finished nothing to do'); + return Command::SUCCESS; } } } @@ -123,20 +149,21 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (!$range && !$all) { // Single customer deletion if (!$id) { - $id = $this->questionHelper->ask($this->input, $this->output, $this->getQuestion('Customer Id'), null); + /** @var string $id */ + $id = $dialog->ask($input, $output, $this->getQuestion('Customer Id')); } try { - $customer = $this->getCustomer($id); + $customer = $this->getCustomer($input, $output, $id); } catch (Exception $e) { - $this->output->writeln('No customer found!'); - return (int) false; + $output->writeln('No customer found!'); + return Command::SUCCESS; } - if ($this->shouldRemove()) { - $this->deleteCustomer($customer); + if ($this->shouldRemove($input, $output)) { + $this->deleteCustomer($output, $customer); } else { - $this->output->writeln('Aborting delete'); + $output->writeln('Aborting delete'); } } else { $customers = $this->getCustomerCollection(); @@ -148,14 +175,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($range) { // Get Range $ranges = []; - $ranges[0] = $this->questionHelper->ask( - $this->input, - $this->output, + $ranges[0] = $dialog->ask( + $input, + $output, $this->getQuestion('Range start Id', '1')->setValidator([$this, 'validateInt']), ); - $ranges[1] = $this->questionHelper->ask( - $this->input, - $this->output, + $ranges[1] = $dialog->ask( + $input, + $output, $this->getQuestion('Range end Id', '1')->setValidator([$this, 'validateInt']), ); @@ -166,26 +193,31 @@ protected function execute(InputInterface $input, OutputInterface $output): int $customers->addAttributeToFilter('entity_id', ['from' => $ranges[0], 'to' => $ranges[1]]); } - if ($this->shouldRemove()) { - $count = $this->batchDelete($customers); - $this->output->writeln('Successfully deleted ' . $count . ' customer/s'); + if ($this->shouldRemove($input, $output)) { + $count = $this->batchDelete($output, $customers); + $output->writeln('Successfully deleted ' . $count . ' customer/s'); } else { - $this->output->writeln('Aborting delete'); + $output->writeln('Aborting delete'); } } - return 0; + + return Command::SUCCESS; } /** + * @param InputInterface $input + * @param OutputInterface $output * @return bool */ - protected function shouldRemove() + protected function shouldRemove(InputInterface $input, OutputInterface $output): bool { - $shouldRemove = $this->input->getOption('force'); + /** @var bool $shouldRemove */ + $shouldRemove = $input->getOption(self::COMMAND_OPTION_FORCE); if (!$shouldRemove) { - $shouldRemove = $this->questionHelper->ask( - $this->input, - $this->output, + /** @var bool $shouldRemove */ + $shouldRemove = $this->getQuestionHelper()->ask( + $input, + $output, $this->getQuestion('Are you sure?', 'n'), ); } @@ -194,19 +226,19 @@ protected function shouldRemove() } /** + * @param InputInterface $input + * @param OutputInterface $output * @param int|string $id - * - * @return \Mage_Customer_Model_Customer - * @throws RuntimeException + * @return Mage_Customer_Model_Customer + * @throws Mage_Core_Exception */ - protected function getCustomer($id) + protected function getCustomer(InputInterface $input, OutputInterface $output, $id): Mage_Customer_Model_Customer { - /** @var \Mage_Customer_Model_Customer $customer */ $customer = $this->getCustomerModel()->load($id); if (!$customer->getId()) { - /** @var ParameterHelper $parameterHelper */ - $parameterHelper = $this->getHelper('parameter'); - $website = $parameterHelper->askWebsite($this->input, $this->output); + $parameterHelper = $this->getParameterHelper(); + /** @var Mage_Core_Model_Website $website */ + $website = $parameterHelper->askWebsite($input, $output); $customer = $this->getCustomerModel() ->setWebsiteId($website->getId()) ->loadByEmail($id); @@ -220,34 +252,42 @@ protected function getCustomer($id) } /** - * @param \Mage_Customer_Model_Customer $customer - * + * @param OutputInterface $output + * @param Mage_Customer_Model_Customer $customer * @return true|Exception + * @throws Throwable */ - protected function deleteCustomer(Mage_Customer_Model_Customer $customer) + protected function deleteCustomer(OutputInterface $output, Mage_Customer_Model_Customer $customer) { try { $customer->delete(); - $this->output->writeln( - sprintf('%s (%s) was successfully deleted', $customer->getName(), $customer->getEmail()) - ); + $output->writeln(sprintf( + '%s (%s) was successfully deleted', + $customer->getName(), + $customer->getEmail() + )); return true; } catch (Exception $e) { - $this->output->writeln('' . $e->getMessage() . ''); + $output->writeln('' . $e->getMessage() . ''); return $e; } } /** - * @param Mage_Customer_Model_Entity_Customer_Collection|Mage_Customer_Model_Resource_Customer_Collection $customers - * + * @param OutputInterface $output + * @param Mage_Customer_Model_Resource_Customer_Collection $customers * @return int + * @throws Throwable */ - protected function batchDelete($customers) - { + protected function batchDelete( + OutputInterface $output, + Mage_Customer_Model_Resource_Customer_Collection $customers + ): int { $count = 0; + + /** @var Mage_Customer_Model_Customer $customer */ foreach ($customers as $customer) { - if ($this->deleteCustomer($customer) === true) { + if ($this->deleteCustomer($output, $customer) === true) { $count++; } } @@ -259,7 +299,7 @@ protected function batchDelete($customers) * @param string $answer * @return string */ - public function validateInt($answer) + public function validateInt(string $answer): string { if ((int)$answer === 0) { throw new RuntimeException( @@ -272,11 +312,10 @@ public function validateInt($answer) /** * @param string $message - * @param string $default [optional] - * - * @return \Symfony\Component\Console\Question\Question + * @param string|null $default [optional] + * @return Question */ - private function getQuestion($message, $default = null) + private function getQuestion(string $message, ?string $default = null): Question { $params = [$message]; $pattern = '%s: '; diff --git a/src/N98/Magento/Command/Customer/ListCommand.php b/src/N98/Magento/Command/Customer/ListCommand.php index 46793049e..041887f8f 100644 --- a/src/N98/Magento/Command/Customer/ListCommand.php +++ b/src/N98/Magento/Command/Customer/ListCommand.php @@ -94,11 +94,11 @@ public function getData(InputInterface $input, OutputInterface $output): array /** @var Mage_Customer_Model_Customer $customer */ foreach ($collection as $customer) { $this->data[] = [ - 'id' => $customer->getId(), - 'email' => $customer->getEmail(), - 'firstname' => $customer->getFirstname(), - 'lastname' => $customer->getLastname(), - 'website' => $this->_getWebsiteCodeById($customer->getwebsiteId()) + 'ID' => $customer->getId(), + 'Email' => $customer->getEmail(), + 'Firstname' => $customer->getFirstname(), + 'Lastname' => $customer->getLastname(), + 'Website' => $this->_getWebsiteCodeById($customer->getwebsiteId()) ]; } } From c1cc6cdde6abd77fac47feb3e9b486aa4a130e4e Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 21 Jun 2024 04:04:14 +0200 Subject: [PATCH 112/136] [skip ci] Updated customer:info command --- .../Magento/Command/Customer/InfoCommand.php | 70 ++++++++++++++----- 1 file changed, 51 insertions(+), 19 deletions(-) diff --git a/src/N98/Magento/Command/Customer/InfoCommand.php b/src/N98/Magento/Command/Customer/InfoCommand.php index 59fba2fdc..593940419 100644 --- a/src/N98/Magento/Command/Customer/InfoCommand.php +++ b/src/N98/Magento/Command/Customer/InfoCommand.php @@ -1,11 +1,15 @@ + */ + protected array $blacklist = ['password_hash', 'increment_id']; + + protected function configure(): void { $this - ->setName('customer:info') - ->addArgument('email', InputArgument::OPTIONAL, 'Email') - ->addArgument('website', InputArgument::OPTIONAL, 'Website of the customer') - ->setDescription('Loads basic customer info by email address.'); + ->addArgument( + self::COMMAND_ARGUMENT_EMAIL, + InputArgument::OPTIONAL, + 'Customers email' + ) + ->addArgument( + self::COMMAND_ARGUMENT_WEBSITE, + InputArgument::OPTIONAL, + 'Website of the customer' + ) + ; } /** * @param InputInterface $input * @param OutputInterface $output - * * @return int + * @throws Mage_Core_Exception */ protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output); $this->initMagento(); - /** @var ParameterHelper $parameterHelper */ - $parameterHelper = $this->getHelper('parameter'); + $parameterHelper = $this->getParameterHelper(); $email = $parameterHelper->askEmail($input, $output); + /** @var Mage_Core_Model_Website $website */ $website = $parameterHelper->askWebsite($input, $output); $customer = $this->getCustomerModel() @@ -53,7 +82,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int ->loadByEmail($email); if ($customer->getId() <= 0) { $output->writeln('Customer was not found'); - return 0; + + return Command::SUCCESS; } $table = []; @@ -63,8 +93,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int } try { $attribute = $customer->getResource()->getAttribute($key); - $key = $attribute instanceof Mage_Customer_Model_Attribute ? $attribute->getFrontend()->getLabel() : $key; - $value = $attribute instanceof Mage_Customer_Model_Attribute ? $attribute->getFrontend()->getValue($customer) : $value; + $key = $attribute instanceof Mage_Customer_Model_Attribute + ? $attribute->getFrontend()->getLabel() : $key; + $value = $attribute instanceof Mage_Customer_Model_Attribute + ? $attribute->getFrontend()->getValue($customer) : $value; if (is_array($value)) { $value = implode(' - ', $value); @@ -76,12 +108,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper - ->setHeaders([Attribute::class, 'Value']) + ->setHeaders(['Attribute', 'Value']) ->setRows($table) ->render($output); - return 0; + + return Command::SUCCESS; } } From 186e118f781e595ea42d67d242eb877b5c3506af Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 21 Jun 2024 07:03:58 +0200 Subject: [PATCH 113/136] [skip ci] Use symfony/filesystem --- .../Command/System/MaintenanceCommand.php | 42 +++++++++++++------ 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/src/N98/Magento/Command/System/MaintenanceCommand.php b/src/N98/Magento/Command/System/MaintenanceCommand.php index e8feb89bc..43feaa200 100644 --- a/src/N98/Magento/Command/System/MaintenanceCommand.php +++ b/src/N98/Magento/Command/System/MaintenanceCommand.php @@ -11,14 +11,17 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Filesystem\Exception\IOExceptionInterface; +use Symfony\Component\Filesystem\Filesystem; /** * @package N98\Magento\Command\System */ class MaintenanceCommand extends AbstractMagentoCommand { - private const COMMAND_OPTION_ON = 'on'; - private const COMMAND_OPTION_OFF = 'off'; + public const COMMAND_OPTION_OFF = 'off'; + + public const COMMAND_OPTION_ON = 'on'; /** * @var string @@ -34,10 +37,22 @@ class MaintenanceCommand extends AbstractMagentoCommand */ protected static $defaultDescription = 'Toggles maintenance mode'; + /** + * @var Filesystem + */ + private Filesystem $filessystem; + + public function __construct() + { + parent:: __construct(); + + $this->filessystem = new Filesystem(); + } + /** * @return void */ - protected function configure() + protected function configure(): void { $this ->addOption( @@ -58,7 +73,6 @@ protected function configure() /** * @param InputInterface $input * @param OutputInterface $output - * * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int @@ -71,7 +85,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } elseif ($input->getOption(self::COMMAND_OPTION_ON)) { $this->switchOn($output, $flagFile); } else { - if (file_exists($flagFile)) { + if ($this->filessystem->exists($flagFile)) { $this->switchOff($output, $flagFile); } else { $this->switchOn($output, $flagFile); @@ -87,11 +101,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int */ private function switchOn(OutputInterface $output, string $flagFile): void { - if (!file_exists($flagFile)) { - if (!touch($flagFile)) { - throw new RuntimeException('maintenance.flag file is not writable.'); - } + try { + $this->filessystem->touch($flagFile); + } catch (IOExceptionInterface $exception) { + throw new RuntimeException($exception->getMessage()); } + $output->writeln('Maintenance mode on'); } @@ -101,11 +116,12 @@ private function switchOn(OutputInterface $output, string $flagFile): void */ private function switchOff(OutputInterface $output, string $flagFile): void { - if (file_exists($flagFile)) { - if (!unlink($flagFile)) { - throw new RuntimeException('maintenance.flag file is not removable.'); - } + try { + $this->filessystem->remove($flagFile); + } catch (IOExceptionInterface $exception) { + throw new RuntimeException($exception->getMessage()); } + $output->writeln('Maintenance mode off'); } } From 1bedc5ca4c4a091abb2256cf9b675b95a12233ab Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 21 Jun 2024 08:22:18 +0200 Subject: [PATCH 114/136] [skip ci] Updated class names/minor fixes --- .../Admin/DisableNotificationsCommand.php | 4 +- .../Admin/User/AbstractAdminUserCommand.php | 4 +- .../Admin/User/ChangePasswordCommand.php | 2 +- .../Admin/User/ChangeStatusCommand.php | 13 ++++++- .../Command/Admin/User/ListCommand.php | 4 +- .../Command/Cache/AbstractCacheCommand.php | 4 +- .../Command/Cache/Dir/FlushCommand.php | 4 +- src/N98/Magento/Command/Cache/ListCommand.php | 4 +- .../Magento/Command/Cache/ReportCommand.php | 4 +- .../Cms/Block/AbstractCmsBlockCommand.php | 4 +- .../Magento/Command/Cms/Block/ListCommand.php | 4 +- .../Command/Config/AbstractConfigCommand.php | 4 +- .../Customer/AbstractCustomerCommand.php | 4 +- .../Magento/Command/Customer/ListCommand.php | 4 +- .../Database/AbstractDatabaseCommand.php | 9 ++++- .../Command/Database/CreateCommand.php | 2 +- .../Magento/Command/Database/DropCommand.php | 10 ++--- .../Command/Database/ImportCommand.php | 2 +- .../Magento/Command/Database/InfoCommand.php | 4 +- .../Database/Maintain/CheckTablesCommand.php | 39 ++++++++++--------- .../Command/Design/DemoNoticeCommand.php | 4 +- .../Command/Developer/ClassLookupCommand.php | 4 +- .../Developer/Code/Model/MethodCommand.php | 6 +-- .../Developer/Log/AbstractLogCommand.php | 4 +- .../Command/Developer/Log/LogCommand.php | 4 +- .../Command/Developer/MergeCssCommand.php | 4 +- .../Command/Developer/MergeJsCommand.php | 4 +- ...nd.php => AbstractDependenciesCommand.php} | 14 +++---- .../Module/Dependencies/FromCommand.php | 7 +++- .../Module/Dependencies/OnCommand.php | 20 +++++----- ...d.php => AbstractDisableenableCommand.php} | 12 ++++-- .../Module/Disableenable/DisableCommand.php | 2 +- .../Module/Disableenable/EnableCommand.php | 2 +- .../Command/Developer/Module/ListCommand.php | 16 +++++--- .../Developer/Module/Observer/ListCommand.php | 9 ++--- .../Module/Rewrite/AbstractRewriteCommand.php | 12 ++++-- .../Module/Rewrite/ConflictsCommand.php | 16 ++++---- .../Developer/Module/Rewrite/ListCommand.php | 4 +- .../Command/Developer/ProfilerCommand.php | 4 +- .../Command/Developer/Report/CountCommand.php | 4 +- .../Command/Developer/SymlinksCommand.php | 4 +- .../Developer/TemplateHintsBlocksCommand.php | 4 +- .../Developer/TemplateHintsCommand.php | 4 +- .../Developer/Theme/DuplicatesCommand.php | 4 +- .../Command/Developer/Theme/InfoCommand.php | 4 +- .../Command/Developer/Theme/ListCommand.php | 6 +-- .../Developer/Translate/ExportCommand.php | 4 +- .../Translate/InlineAdminCommand.php | 4 +- .../Developer/Translate/InlineShopCommand.php | 4 +- .../Developer/Translate/SetCommand.php | 10 +++-- .../Eav/Attribute/Create/DummyCommand.php | 4 +- .../Command/Eav/Attribute/ListCommand.php | 6 +-- .../Command/Eav/Attribute/RemoveCommand.php | 4 +- .../Command/Eav/Attribute/ViewCommand.php | 6 +-- .../Indexer/AbstractIndexerCommand.php | 4 +- .../Magento/Command/Indexer/ListCommand.php | 4 +- .../Command/Installer/InstallCommand.php | 8 ++-- .../Command/Installer/UninstallCommand.php | 10 ++--- .../Media/Cache/Image/ClearCommand.php | 4 +- .../Media/Cache/JsCss/ClearCommand.php | 4 +- src/N98/Magento/Command/Media/DumpCommand.php | 4 +- .../Repository/AbstractRepositoryCommand.php | 4 +- .../Command/Script/Repository/ListCommand.php | 4 +- .../Command/System/Check/WebsiteCheck.php | 4 +- .../Magento/Command/System/CheckCommand.php | 21 +++++----- .../System/Cron/AbstractCronCommand.php | 4 +- .../Command/System/Cron/HistoryCommand.php | 6 +-- .../Command/System/Cron/ListCommand.php | 4 +- .../Magento/Command/System/InfoCommand.php | 37 ++++++++---------- .../Command/System/MaintenanceCommand.php | 4 +- .../System/Setup/AbstractSetupCommand.php | 4 +- .../System/Setup/ChangeVersionCommand.php | 17 ++++---- .../System/Setup/CompareVersionsCommand.php | 14 +++---- .../System/Setup/IncrementalCommand.php | 20 ++++------ .../Command/System/Setup/RemoveCommand.php | 11 ++---- .../Command/System/Setup/RunCommand.php | 17 +++----- .../Store/Config/BaseUrlListCommand.php | 6 +-- .../Command/System/Store/ListCommand.php | 6 +-- .../Command/System/Website/ListCommand.php | 6 +-- 79 files changed, 289 insertions(+), 287 deletions(-) rename src/N98/Magento/Command/Developer/Module/Dependencies/{AbstractCommand.php => AbstractDependenciesCommand.php} (88%) rename src/N98/Magento/Command/Developer/Module/Disableenable/{AbstractCommand.php => AbstractDisableenableCommand.php} (95%) diff --git a/src/N98/Magento/Command/Admin/DisableNotificationsCommand.php b/src/N98/Magento/Command/Admin/DisableNotificationsCommand.php index 108a7b456..4016d9e1f 100644 --- a/src/N98/Magento/Command/Admin/DisableNotificationsCommand.php +++ b/src/N98/Magento/Command/Admin/DisableNotificationsCommand.php @@ -4,7 +4,7 @@ namespace N98\Magento\Command\Admin; -use N98\Magento\Command\AbstractMagentoStoreConfigCommand; +use N98\Magento\Command\AbstractStoreConfigCommand; use Symfony\Component\Console\Attribute\AsCommand; /** @@ -12,7 +12,7 @@ * * @package N98\Magento\Command\Admin */ -class DisableNotificationsCommand extends AbstractMagentoStoreConfigCommand +class DisableNotificationsCommand extends AbstractStoreConfigCommand { /** * @var string diff --git a/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php b/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php index 3689e51f2..179e871e7 100644 --- a/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php +++ b/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php @@ -8,7 +8,7 @@ use Mage_Admin_Model_Roles; use Mage_Admin_Model_Rules; use Mage_Admin_Model_User; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -17,7 +17,7 @@ * * @package N98\Magento\Command\Admin\User */ -abstract class AbstractAdminUserCommand extends AbstractMagentoCommand +abstract class AbstractAdminUserCommand extends AbstractCommand { public const COMMAND_ARGUMENT_ID = 'id'; diff --git a/src/N98/Magento/Command/Admin/User/ChangePasswordCommand.php b/src/N98/Magento/Command/Admin/User/ChangePasswordCommand.php index 52a66d439..8b4fa6006 100644 --- a/src/N98/Magento/Command/Admin/User/ChangePasswordCommand.php +++ b/src/N98/Magento/Command/Admin/User/ChangePasswordCommand.php @@ -99,7 +99,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $user->save(); $output->writeln('Password successfully changed'); } catch (Exception $e) { - $output->writeln('' . $e->getMessage() . ''); + $output->writeln(sprintf('%s', $e->getMessage())); } return Command::SUCCESS; diff --git a/src/N98/Magento/Command/Admin/User/ChangeStatusCommand.php b/src/N98/Magento/Command/Admin/User/ChangeStatusCommand.php index 510629c59..d8c72dac4 100644 --- a/src/N98/Magento/Command/Admin/User/ChangeStatusCommand.php +++ b/src/N98/Magento/Command/Admin/User/ChangeStatusCommand.php @@ -38,7 +38,7 @@ class ChangeStatusCommand extends AbstractAdminUserCommand * @deprecated with symfony 6.1 * @see AsCommand */ - protected static $defaultDescription = 'Set active status of an adminhtml user. If no option is set the status will be toggled.'; + protected static $defaultDescription = 'Set active status of an adminhtml user.'; protected function configure(): void { @@ -65,6 +65,17 @@ protected function configure(): void ; } + /** + * @return string + */ + public function getHelp(): string + { + return <<setName('db:create') diff --git a/src/N98/Magento/Command/Database/DropCommand.php b/src/N98/Magento/Command/Database/DropCommand.php index 469f80bd7..f9c86f6a9 100644 --- a/src/N98/Magento/Command/Database/DropCommand.php +++ b/src/N98/Magento/Command/Database/DropCommand.php @@ -2,8 +2,6 @@ namespace N98\Magento\Command\Database; -use N98\Util\Console\Helper\DatabaseHelper; -use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -11,7 +9,7 @@ class DropCommand extends AbstractDatabaseCommand { - protected function configure() + protected function configure(): void { $this ->setName('db:drop') @@ -38,10 +36,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectDbSettings($output); - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); - /** @var DatabaseHelper $dbHelper */ - $dbHelper = $this->getHelper('database'); + $dialog = $this->getQuestionHelper(); + $dbHelper = $this->getDatabaseHelper(); if ($input->getOption('force')) { $shouldDrop = true; diff --git a/src/N98/Magento/Command/Database/ImportCommand.php b/src/N98/Magento/Command/Database/ImportCommand.php index 6efc22e40..7508d8959 100644 --- a/src/N98/Magento/Command/Database/ImportCommand.php +++ b/src/N98/Magento/Command/Database/ImportCommand.php @@ -11,7 +11,7 @@ class ImportCommand extends AbstractDatabaseCommand { - protected function configure() + protected function configure(): void { $this ->setName('db:import') diff --git a/src/N98/Magento/Command/Database/InfoCommand.php b/src/N98/Magento/Command/Database/InfoCommand.php index d8471c647..dbb67d088 100644 --- a/src/N98/Magento/Command/Database/InfoCommand.php +++ b/src/N98/Magento/Command/Database/InfoCommand.php @@ -5,7 +5,7 @@ namespace N98\Magento\Command\Database; use InvalidArgumentException; -use N98\Magento\Command\AbstractMagentoCommandFormatInterface; +use N98\Magento\Command\CommandFormatInterface; use N98\Magento\DbSettings; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; @@ -18,7 +18,7 @@ * * @package N98\Magento\Command\Database */ -class InfoCommand extends AbstractDatabaseCommand implements AbstractMagentoCommandFormatInterface +class InfoCommand extends AbstractDatabaseCommand implements CommandFormatInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Database information'; diff --git a/src/N98/Magento/Command/Database/Maintain/CheckTablesCommand.php b/src/N98/Magento/Command/Database/Maintain/CheckTablesCommand.php index 0616f904a..52fad6a1f 100644 --- a/src/N98/Magento/Command/Database/Maintain/CheckTablesCommand.php +++ b/src/N98/Magento/Command/Database/Maintain/CheckTablesCommand.php @@ -5,8 +5,8 @@ namespace N98\Magento\Command\Database\Maintain; use InvalidArgumentException; -use N98\Magento\Command\AbstractMagentoCommand; -use N98\Magento\Command\AbstractMagentoCommandFormatInterface; +use N98\Magento\Command\AbstractCommand; +use N98\Magento\Command\CommandFormatInterface; use N98\Util\Console\Helper\Table\Renderer\RendererFactory; use PDO; use Symfony\Component\Console\Attribute\AsCommand; @@ -20,7 +20,7 @@ * * @package N98\Magento\Command\Database\Maintain */ -class CheckTablesCommand extends AbstractMagentoCommand implements AbstractMagentoCommandFormatInterface +class CheckTablesCommand extends AbstractCommand implements CommandFormatInterface { public const COMMAND_OPTION_TYPE = 'type'; @@ -183,10 +183,10 @@ public function getData(InputInterface $input, OutputInterface $output): array $data = array_merge($data, $this->$m($input, $output, $tableName)); } else { $data[] = [ - 'table' => $tableName, - 'operation' => 'not supported', - 'type' => '', - 'status' => '' + 'Table' => $tableName, + 'Operation' => 'not supported', + 'Type' => '', + 'Status' => '' ]; } $this->progressAdvance($progress); @@ -194,6 +194,7 @@ public function getData(InputInterface $input, OutputInterface $output): array if ($this->showProgress) { $progress->finish(); + $output->writeln(''); } $this->data = $data; @@ -215,10 +216,10 @@ protected function _queryAlterTable(OutputInterface $output, string $tableName, $affectedRows = $connection->exec(sprintf('ALTER TABLE %s ENGINE=%s', $tableName, $engine)); return [[ - 'table' => $tableName, - 'operation' => 'ENGINE ' . $engine, - 'type' => sprintf('%15s rows', (string) $affectedRows), - 'status' => sprintf('%.3f secs', microtime(true) - $start) + 'Table' => $tableName, + 'Operation' => 'ENGINE ' . $engine, + 'Type' => sprintf('%15s rows', (string) $affectedRows), + 'Status' => sprintf('%.3f secs', microtime(true) - $start) ]]; } @@ -268,10 +269,10 @@ protected function _checkMyISAM(InputInterface $input, OutputInterface $output, } $table[] = [ - 'table' => $tableName, - 'operation' => $result['Op'], - 'type' => $type, - 'status' => $result['Msg_text'] + 'Table' => $tableName, + 'Operation' => $result['Op'], + 'Type' => $type, + 'Status' => $result['Msg_text'] ]; if ($result['Msg_text'] != 'OK' && $input->getOption(self::COMMAND_OPTION_REPAIR)) { @@ -279,10 +280,10 @@ protected function _checkMyISAM(InputInterface $input, OutputInterface $output, $result = $this->_query($output, sprintf('REPAIR TABLE %s %s', $tableName, $type)); if ($result['Msg_text'] != self::MESSAGE_REPAIR_NOT_SUPPORTED) { $table[] = [ - 'table' => $tableName, - 'operation' => $result['Op'], - 'type' => $type, - 'status' => $result['Msg_text'] + 'Table' => $tableName, + 'Operation' => $result['Op'], + 'Type' => $type, + 'Status' => $result['Msg_text'] ]; } } diff --git a/src/N98/Magento/Command/Design/DemoNoticeCommand.php b/src/N98/Magento/Command/Design/DemoNoticeCommand.php index fcbfa4037..884cec41b 100644 --- a/src/N98/Magento/Command/Design/DemoNoticeCommand.php +++ b/src/N98/Magento/Command/Design/DemoNoticeCommand.php @@ -4,7 +4,7 @@ namespace N98\Magento\Command\Design; -use N98\Magento\Command\AbstractMagentoStoreConfigCommand; +use N98\Magento\Command\AbstractStoreConfigCommand; use Symfony\Component\Console\Attribute\AsCommand; /** @@ -12,7 +12,7 @@ * * @package N98\Magento\Command\Design */ -class DemoNoticeCommand extends AbstractMagentoStoreConfigCommand +class DemoNoticeCommand extends AbstractStoreConfigCommand { /** * @var string diff --git a/src/N98/Magento/Command/Developer/ClassLookupCommand.php b/src/N98/Magento/Command/Developer/ClassLookupCommand.php index 679120e78..c88695090 100644 --- a/src/N98/Magento/Command/Developer/ClassLookupCommand.php +++ b/src/N98/Magento/Command/Developer/ClassLookupCommand.php @@ -4,7 +4,7 @@ namespace N98\Magento\Command\Developer; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; @@ -16,7 +16,7 @@ * * @package N98\Magento\Command\Developer */ -class ClassLookupCommand extends AbstractMagentoCommand +class ClassLookupCommand extends AbstractCommand { public const COMMAND_ARGUMENT_TYPE = 'type'; diff --git a/src/N98/Magento/Command/Developer/Code/Model/MethodCommand.php b/src/N98/Magento/Command/Developer/Code/Model/MethodCommand.php index 3213e2439..ac09c762b 100644 --- a/src/N98/Magento/Command/Developer/Code/Model/MethodCommand.php +++ b/src/N98/Magento/Command/Developer/Code/Model/MethodCommand.php @@ -4,14 +4,14 @@ use InvalidArgumentException; use Mage; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use PDO; use RuntimeException; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -class MethodCommand extends AbstractMagentoCommand +class MethodCommand extends AbstractCommand { /** * @var InputInterface @@ -44,7 +44,7 @@ class MethodCommand extends AbstractMagentoCommand */ protected $_tableColumns = []; - protected function configure() + protected function configure(): void { $this ->setName('dev:code:model:method') diff --git a/src/N98/Magento/Command/Developer/Log/AbstractLogCommand.php b/src/N98/Magento/Command/Developer/Log/AbstractLogCommand.php index 714cde4dd..9df71e5a9 100644 --- a/src/N98/Magento/Command/Developer/Log/AbstractLogCommand.php +++ b/src/N98/Magento/Command/Developer/Log/AbstractLogCommand.php @@ -6,7 +6,7 @@ use InvalidArgumentException; use Mage; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ChoiceQuestion; @@ -17,7 +17,7 @@ * * @package N98\Magento\Command\Developer\Log */ -class AbstractLogCommand extends AbstractMagentoCommand +class AbstractLogCommand extends AbstractCommand { /** * @return Finder diff --git a/src/N98/Magento/Command/Developer/Log/LogCommand.php b/src/N98/Magento/Command/Developer/Log/LogCommand.php index 232df91fa..ae573facf 100644 --- a/src/N98/Magento/Command/Developer/Log/LogCommand.php +++ b/src/N98/Magento/Command/Developer/Log/LogCommand.php @@ -4,7 +4,7 @@ namespace N98\Magento\Command\Developer\Log; -use N98\Magento\Command\AbstractMagentoStoreConfigCommand; +use N98\Magento\Command\AbstractStoreConfigCommand; use Symfony\Component\Console\Attribute\AsCommand; /** @@ -12,7 +12,7 @@ * * @package N98\Magento\Command\Developer\Log */ -class LogCommand extends AbstractMagentoStoreConfigCommand +class LogCommand extends AbstractStoreConfigCommand { /** * @var string diff --git a/src/N98/Magento/Command/Developer/MergeCssCommand.php b/src/N98/Magento/Command/Developer/MergeCssCommand.php index f35ca1ff2..bd63a1f03 100644 --- a/src/N98/Magento/Command/Developer/MergeCssCommand.php +++ b/src/N98/Magento/Command/Developer/MergeCssCommand.php @@ -4,7 +4,7 @@ namespace N98\Magento\Command\Developer; -use N98\Magento\Command\AbstractMagentoStoreConfigCommand; +use N98\Magento\Command\AbstractStoreConfigCommand; use Symfony\Component\Console\Attribute\AsCommand; /** @@ -12,7 +12,7 @@ * * @package N98\Magento\Command\Developer */ -class MergeCssCommand extends AbstractMagentoStoreConfigCommand +class MergeCssCommand extends AbstractStoreConfigCommand { /** * @var string diff --git a/src/N98/Magento/Command/Developer/MergeJsCommand.php b/src/N98/Magento/Command/Developer/MergeJsCommand.php index 0548073fc..6d25a023c 100644 --- a/src/N98/Magento/Command/Developer/MergeJsCommand.php +++ b/src/N98/Magento/Command/Developer/MergeJsCommand.php @@ -4,7 +4,7 @@ namespace N98\Magento\Command\Developer; -use N98\Magento\Command\AbstractMagentoStoreConfigCommand; +use N98\Magento\Command\AbstractStoreConfigCommand; use Symfony\Component\Console\Attribute\AsCommand; /** @@ -12,7 +12,7 @@ * * @package N98\Magento\Command\Developer */ -class MergeJsCommand extends AbstractMagentoStoreConfigCommand +class MergeJsCommand extends AbstractStoreConfigCommand { /** * @var string diff --git a/src/N98/Magento/Command/Developer/Module/Dependencies/AbstractCommand.php b/src/N98/Magento/Command/Developer/Module/Dependencies/AbstractDependenciesCommand.php similarity index 88% rename from src/N98/Magento/Command/Developer/Module/Dependencies/AbstractCommand.php rename to src/N98/Magento/Command/Developer/Module/Dependencies/AbstractDependenciesCommand.php index 9eb3b5b5d..7b234b19f 100644 --- a/src/N98/Magento/Command/Developer/Module/Dependencies/AbstractCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Dependencies/AbstractDependenciesCommand.php @@ -4,15 +4,14 @@ use Exception; use InvalidArgumentException; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use N98\Util\Console\Helper\Table\Renderer\RendererFactory; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -abstract class AbstractCommand extends AbstractMagentoCommand +abstract class AbstractDependenciesCommand extends AbstractCommand { /**#@+ * Command texts to output @@ -30,12 +29,12 @@ abstract class AbstractCommand extends AbstractMagentoCommand * * @var array */ - protected $modules; + protected array $modules; /** * Configure command */ - protected function configure() + protected function configure(): void { $this->setName(static::COMMAND_NAME) ->addArgument('moduleName', InputArgument::REQUIRED, 'Module to show dependencies') @@ -70,8 +69,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $dependencies = $this->findModuleDependencies($moduleName, $recursive); if (!empty($dependencies)) { usort($dependencies, [$this, 'sortDependencies']); - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['Name', 'Status', 'Current installed version', 'Code pool']) ->renderByFormat($output, $dependencies, $input->getOption('format')); @@ -95,7 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int * @return array * @throws InvalidArgumentException of module-name is not found */ - abstract protected function findModuleDependencies($moduleName, $recursive = false); + abstract protected function findModuleDependencies(string $moduleName, bool $recursive = false): array; /** * Sort dependencies list by module name ascending diff --git a/src/N98/Magento/Command/Developer/Module/Dependencies/FromCommand.php b/src/N98/Magento/Command/Developer/Module/Dependencies/FromCommand.php index 8ada911a6..1a0d6c182 100644 --- a/src/N98/Magento/Command/Developer/Module/Dependencies/FromCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Dependencies/FromCommand.php @@ -5,7 +5,7 @@ use InvalidArgumentException; use Mage; -class FromCommand extends AbstractCommand +class FromCommand extends AbstractDependenciesCommand { /**#@+ * Command texts to output @@ -13,15 +13,18 @@ class FromCommand extends AbstractCommand * @var string */ public const COMMAND_NAME = 'dev:module:dependencies:from'; + public const COMMAND_DESCRIPTION = 'Show list of modules which depend on %s module'; + public const COMMAND_SECTION_TITLE_TEXT = "List of modules which depend on %s module"; + public const COMMAND_NO_RESULTS_TEXT = "No modules depend on %s module"; /**#@-*/ /** * @inheritdoc */ - protected function findModuleDependencies($moduleName, $recursive = false) + protected function findModuleDependencies($moduleName, $recursive = false): array { if ($this->modules === null) { $this->modules = Mage::app()->getConfig()->getNode('modules')->asArray(); diff --git a/src/N98/Magento/Command/Developer/Module/Dependencies/OnCommand.php b/src/N98/Magento/Command/Developer/Module/Dependencies/OnCommand.php index 5082f3a66..016d77f7f 100644 --- a/src/N98/Magento/Command/Developer/Module/Dependencies/OnCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Dependencies/OnCommand.php @@ -5,19 +5,15 @@ use Exception; use InvalidArgumentException; use Mage; -use N98\Magento\Command\AbstractMagentoCommand; use N98\Util\Console\Helper\Table\Renderer\RendererFactory; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -class OnCommand extends AbstractMagentoCommand +class OnCommand extends AbstractDependenciesCommand { - private $modules; - - protected function configure() + protected function configure(): void { $this ->setName('dev:module:dependencies:on') @@ -61,8 +57,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($input->getOption('format') === null && count($dependencies) === 0) { $output->writeln(sprintf("Module %s doesn't have dependencies", $moduleName)); } else { - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['Name', 'Status', 'Current installed version', 'Code pool']) ->renderByFormat($output, $dependencies, $input->getOption('format')); @@ -82,7 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int * @return array * @throws InvalidArgumentException */ - protected function findModuleDependencies($moduleName, $recursive = false) + protected function findModuleDependencies(string $moduleName, bool $recursive = false): array { if ($this->modules === null) { $this->modules = Mage::app()->getConfig()->getNode('modules')->asArray(); @@ -96,7 +91,10 @@ protected function findModuleDependencies($moduleName, $recursive = false) if (isset($this->modules[$dependencyName])) { $dependencies[] = [$dependencyName, isset($this->modules[$dependencyName]['active']) ? $this->formatActive($this->modules[$dependencyName]['active']) - : '-', $this->modules[$dependencyName]['version'] ?? '-', $this->modules[$dependencyName]['codePool'] ?? '-']; + : '-', $this->modules[$dependencyName]['version'] + ?? '-', $this->modules[$dependencyName]['codePool'] + ?? '-' + ]; if ($recursive) { $dependencies = array_merge( $dependencies, @@ -122,7 +120,7 @@ protected function findModuleDependencies($moduleName, $recursive = false) * @param array $b * @return int */ - private function sortDependencies(array $a, array $b) + private function sortDependencies(array $a, array $b): int { return strcmp($a[0], $b[0]); } diff --git a/src/N98/Magento/Command/Developer/Module/Disableenable/AbstractCommand.php b/src/N98/Magento/Command/Developer/Module/Disableenable/AbstractDisableenableCommand.php similarity index 95% rename from src/N98/Magento/Command/Developer/Module/Disableenable/AbstractCommand.php rename to src/N98/Magento/Command/Developer/Module/Disableenable/AbstractDisableenableCommand.php index 528719c5c..898c64a70 100644 --- a/src/N98/Magento/Command/Developer/Module/Disableenable/AbstractCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Disableenable/AbstractDisableenableCommand.php @@ -7,7 +7,7 @@ use Exception; use InvalidArgumentException; use Mage_Core_Model_Config; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -16,11 +16,11 @@ use Varien_Simplexml_Element; /** - * Abstract enable/disable Magento module(s) + * Class AbstractDisableenableCommand * * @package N98\Magento\Command\Developer\Module\Disableenable */ -class AbstractCommand extends AbstractMagentoCommand +abstract class AbstractDisableenableCommand extends AbstractCommand { public const COMMAND_ARGUMENT_MODULE = 'moduleName'; @@ -173,7 +173,11 @@ protected function enableModule(string $module, OutputInterface $output): void ); } } else { - $msg = sprintf('%s: already %sd', $module, $this->commandName); + $msg = sprintf( + '%s: already %sd', + $module, + $this->commandName + ); } } diff --git a/src/N98/Magento/Command/Developer/Module/Disableenable/DisableCommand.php b/src/N98/Magento/Command/Developer/Module/Disableenable/DisableCommand.php index da549a6b7..47969e3b3 100644 --- a/src/N98/Magento/Command/Developer/Module/Disableenable/DisableCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Disableenable/DisableCommand.php @@ -11,7 +11,7 @@ * * @package N98\Magento\Command\Developer\Module\Disableenable */ -class DisableCommand extends AbstractCommand +class DisableCommand extends AbstractDisableenableCommand { /** * @var string diff --git a/src/N98/Magento/Command/Developer/Module/Disableenable/EnableCommand.php b/src/N98/Magento/Command/Developer/Module/Disableenable/EnableCommand.php index dafcceec2..21cb3c3d4 100644 --- a/src/N98/Magento/Command/Developer/Module/Disableenable/EnableCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Disableenable/EnableCommand.php @@ -11,7 +11,7 @@ * * @package N98\Magento\Command\Developer\Module\Disableenable */ -class EnableCommand extends AbstractCommand +class EnableCommand extends AbstractDisableenableCommand { /** * @var string diff --git a/src/N98/Magento/Command/Developer/Module/ListCommand.php b/src/N98/Magento/Command/Developer/Module/ListCommand.php index 0cfe1cc7f..060880214 100644 --- a/src/N98/Magento/Command/Developer/Module/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Module/ListCommand.php @@ -4,15 +4,20 @@ namespace N98\Magento\Command\Developer\Module; -use N98\Magento\Command\AbstractMagentoCommand; -use N98\Magento\Command\AbstractMagentoCommandFormatInterface; +use N98\Magento\Command\AbstractCommand; +use N98\Magento\Command\CommandFormatInterface; use N98\Magento\Modules; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -class ListCommand extends AbstractMagentoCommand implements AbstractMagentoCommandFormatInterface +/** + * List module(s) command + * + * @package N98\Magento\Command\Developer\Module + */ +class ListCommand extends AbstractCommand implements CommandFormatInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Installed Modules'; @@ -38,7 +43,7 @@ class ListCommand extends AbstractMagentoCommand implements AbstractMagentoComma */ protected static $defaultDescription = 'List all installed modules.'; - protected function configure() + protected function configure(): void { $this ->addOption( @@ -77,10 +82,9 @@ public function getData(InputInterface $input, OutputInterface $output): array /** * @param InputInterface $input - * * @return Modules */ - private function filterModules(InputInterface $input) + private function filterModules(InputInterface $input): Modules { $modules = new Modules(); return $modules diff --git a/src/N98/Magento/Command/Developer/Module/Observer/ListCommand.php b/src/N98/Magento/Command/Developer/Module/Observer/ListCommand.php index cfd8a4086..279a5ddab 100644 --- a/src/N98/Magento/Command/Developer/Module/Observer/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Observer/ListCommand.php @@ -5,9 +5,8 @@ namespace N98\Magento\Command\Developer\Module\Observer; use InvalidArgumentException; -use Mage; -use N98\Magento\Command\AbstractMagentoCommand; -use N98\Magento\Command\AbstractMagentoCommandFormatInterface; +use N98\Magento\Command\AbstractCommand; +use N98\Magento\Command\CommandFormatInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -19,7 +18,7 @@ * * @package N98\Magento\Command\Developer\Module\Observer */ -class ListCommand extends AbstractMagentoCommand implements AbstractMagentoCommandFormatInterface +class ListCommand extends AbstractCommand implements CommandFormatInterface { public const COMMAND_ARGUMENT_TYPE = 'type'; @@ -84,7 +83,7 @@ public function getData(InputInterface $input, OutputInterface $output): array $this->writeSection($output, 'Observers: ' . $type); } - $frontendEvents = $this->_getMageConfigNode($type . '/events')->asArray(); + $frontendEvents = $this->_getMageConfig()->getNode($type . '/events')->asArray(); if (true === $input->getOption(self::COMMAND_OPTION_SORT)) { // sorting for Observers is a bad idea because the order in which observers will be called is important. ksort($frontendEvents); diff --git a/src/N98/Magento/Command/Developer/Module/Rewrite/AbstractRewriteCommand.php b/src/N98/Magento/Command/Developer/Module/Rewrite/AbstractRewriteCommand.php index a0f4f9555..a867535e0 100644 --- a/src/N98/Magento/Command/Developer/Module/Rewrite/AbstractRewriteCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Rewrite/AbstractRewriteCommand.php @@ -3,10 +3,10 @@ namespace N98\Magento\Command\Developer\Module\Rewrite; use Mage; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use Symfony\Component\Finder\Finder; -abstract class AbstractRewriteCommand extends AbstractMagentoCommand +abstract class AbstractRewriteCommand extends AbstractCommand { protected $_rewriteTypes = ['blocks', 'helpers', 'models']; @@ -72,7 +72,7 @@ protected function loadAutoloaderRewrites() /** * Searches for all rewrites over autoloader in "app/code/" of - * Mage, Enterprise Zend, Varien namespaces. + * Mage, Zend, Varien namespaces. * * @param string $codePool * @return array @@ -82,7 +82,11 @@ protected function loadAutoloaderRewritesByCodepool($codePool) $return = []; $localCodeFolder = Mage::getBaseDir('code') . '/' . $codePool; - $folders = ['Mage' => $localCodeFolder . '/Mage', 'Enterprise' => $localCodeFolder . '/Enterprise', 'Varien' => $localCodeFolder . '/Varien', 'Zend' => $localCodeFolder . '/Zend']; + $folders = [ + 'Mage' => $localCodeFolder . '/Mage', + 'Varien' => $localCodeFolder . '/Varien', + 'Zend' => $localCodeFolder . '/Zend' + ]; foreach ($folders as $vendorPrefix => $folder) { if (is_dir($folder)) { diff --git a/src/N98/Magento/Command/Developer/Module/Rewrite/ConflictsCommand.php b/src/N98/Magento/Command/Developer/Module/Rewrite/ConflictsCommand.php index 15f2260d1..b482f3888 100644 --- a/src/N98/Magento/Command/Developer/Module/Rewrite/ConflictsCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Rewrite/ConflictsCommand.php @@ -10,10 +10,11 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Zend_Text_Table; +use Zend_Text_Table_Exception; class ConflictsCommand extends AbstractRewriteCommand { - protected function configure() + protected function configure(): void { $this ->setName('dev:module:rewrite:conflicts') @@ -46,9 +47,7 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 2; - } + $this->initMagento(); $conflicts = []; $time = microtime(true); @@ -84,7 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int * @param string $class * @return string */ - protected function _getLoadedClass($type, $class) + protected function _getLoadedClass(string $type, string $class): string { switch ($type) { case 'blocks': @@ -138,7 +137,7 @@ protected function logJUnit(array $conflicts, $filename, $duration) * @param array $classes * @return bool */ - protected function _isInheritanceConflict(array $classes) + protected function _isInheritanceConflict(array $classes): bool { $later = null; foreach (array_reverse($classes) as $class) { @@ -162,9 +161,10 @@ protected function _isInheritanceConflict(array $classes) /** * @param OutputInterface $output - * @param array $conflicts + * @param array $conflicts + * @throws Zend_Text_Table_Exception */ - private function writeOutput(OutputInterface $output, array $conflicts) + private function writeOutput(OutputInterface $output, array $conflicts): void { if (!$conflicts) { $output->writeln('No rewrite conflicts were found.'); diff --git a/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php b/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php index 3687bffcf..f99dc8ac2 100644 --- a/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php @@ -4,7 +4,7 @@ namespace N98\Magento\Command\Developer\Module\Rewrite; -use N98\Magento\Command\AbstractMagentoCommandFormatInterface; +use N98\Magento\Command\CommandFormatInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -14,7 +14,7 @@ * * @package N98\Magento\Command\Developer\Module */ -class ListCommand extends AbstractRewriteCommand implements AbstractMagentoCommandFormatInterface +class ListCommand extends AbstractRewriteCommand implements CommandFormatInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Rewrites'; diff --git a/src/N98/Magento/Command/Developer/ProfilerCommand.php b/src/N98/Magento/Command/Developer/ProfilerCommand.php index 1342af86e..c8140e995 100644 --- a/src/N98/Magento/Command/Developer/ProfilerCommand.php +++ b/src/N98/Magento/Command/Developer/ProfilerCommand.php @@ -4,7 +4,7 @@ namespace N98\Magento\Command\Developer; -use N98\Magento\Command\AbstractMagentoStoreConfigCommand; +use N98\Magento\Command\AbstractStoreConfigCommand; use Symfony\Component\Console\Attribute\AsCommand; /** @@ -12,7 +12,7 @@ * * @package N98\Magento\Command\Developer */ -class ProfilerCommand extends AbstractMagentoStoreConfigCommand +class ProfilerCommand extends AbstractStoreConfigCommand { /** * @var string diff --git a/src/N98/Magento/Command/Developer/Report/CountCommand.php b/src/N98/Magento/Command/Developer/Report/CountCommand.php index 9748460e0..2a5ef244f 100644 --- a/src/N98/Magento/Command/Developer/Report/CountCommand.php +++ b/src/N98/Magento/Command/Developer/Report/CountCommand.php @@ -5,7 +5,7 @@ namespace N98\Magento\Command\Developer\Report; use Mage; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; @@ -17,7 +17,7 @@ * * @package N98\Magento\Command\Developer\Report */ -class CountCommand extends AbstractMagentoCommand +class CountCommand extends AbstractCommand { /** * @var string diff --git a/src/N98/Magento/Command/Developer/SymlinksCommand.php b/src/N98/Magento/Command/Developer/SymlinksCommand.php index 48fb22a3f..cad9c52f1 100644 --- a/src/N98/Magento/Command/Developer/SymlinksCommand.php +++ b/src/N98/Magento/Command/Developer/SymlinksCommand.php @@ -4,7 +4,7 @@ namespace N98\Magento\Command\Developer; -use N98\Magento\Command\AbstractMagentoStoreConfigCommand; +use N98\Magento\Command\AbstractStoreConfigCommand; use Symfony\Component\Console\Attribute\AsCommand; /** @@ -12,7 +12,7 @@ * * @package N98\Magento\Command\Developer */ -class SymlinksCommand extends AbstractMagentoStoreConfigCommand +class SymlinksCommand extends AbstractStoreConfigCommand { /** * @var string diff --git a/src/N98/Magento/Command/Developer/TemplateHintsBlocksCommand.php b/src/N98/Magento/Command/Developer/TemplateHintsBlocksCommand.php index d81071fa3..816061f7b 100644 --- a/src/N98/Magento/Command/Developer/TemplateHintsBlocksCommand.php +++ b/src/N98/Magento/Command/Developer/TemplateHintsBlocksCommand.php @@ -5,7 +5,7 @@ namespace N98\Magento\Command\Developer; use Mage_Core_Model_Store; -use N98\Magento\Command\AbstractMagentoStoreConfigCommand; +use N98\Magento\Command\AbstractStoreConfigCommand; use Symfony\Component\Console\Attribute\AsCommand; /** @@ -13,7 +13,7 @@ * * @package N98\Magento\Command\Developer */ -class TemplateHintsBlocksCommand extends AbstractMagentoStoreConfigCommand +class TemplateHintsBlocksCommand extends AbstractStoreConfigCommand { /** * @var string diff --git a/src/N98/Magento/Command/Developer/TemplateHintsCommand.php b/src/N98/Magento/Command/Developer/TemplateHintsCommand.php index 6eb9a2694..a944aa1f6 100644 --- a/src/N98/Magento/Command/Developer/TemplateHintsCommand.php +++ b/src/N98/Magento/Command/Developer/TemplateHintsCommand.php @@ -5,7 +5,7 @@ namespace N98\Magento\Command\Developer; use Mage_Core_Model_Store; -use N98\Magento\Command\AbstractMagentoStoreConfigCommand; +use N98\Magento\Command\AbstractStoreConfigCommand; use Symfony\Component\Console\Attribute\AsCommand; /** @@ -13,7 +13,7 @@ * * @package N98\Magento\Command\Developer */ -class TemplateHintsCommand extends AbstractMagentoStoreConfigCommand +class TemplateHintsCommand extends AbstractStoreConfigCommand { /** * @var string diff --git a/src/N98/Magento/Command/Developer/Theme/DuplicatesCommand.php b/src/N98/Magento/Command/Developer/Theme/DuplicatesCommand.php index 7def8809e..4b5df6d96 100644 --- a/src/N98/Magento/Command/Developer/Theme/DuplicatesCommand.php +++ b/src/N98/Magento/Command/Developer/Theme/DuplicatesCommand.php @@ -4,7 +4,7 @@ use DateTime; use N98\JUnitXml\Document as JUnitXmlDocument; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; @@ -19,7 +19,7 @@ * * @package N98\Magento\Command\Developer\Theme */ -class DuplicatesCommand extends AbstractMagentoCommand +class DuplicatesCommand extends AbstractCommand { public const COMMAND_ARGUMENT_THEME = 'theme'; diff --git a/src/N98/Magento/Command/Developer/Theme/InfoCommand.php b/src/N98/Magento/Command/Developer/Theme/InfoCommand.php index 723f02841..2bdd73540 100644 --- a/src/N98/Magento/Command/Developer/Theme/InfoCommand.php +++ b/src/N98/Magento/Command/Developer/Theme/InfoCommand.php @@ -6,7 +6,7 @@ use Mage_Core_Model_Store; use Mage_Core_Model_Website; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use N98\Magento\Command\AbstractMagentoStoreConfigCommand; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; @@ -18,7 +18,7 @@ * * @package N98\Magento\Command\Developer\Theme */ -class InfoCommand extends AbstractMagentoCommand +class InfoCommand extends AbstractCommand { public const THEMES_EXCEPTION = '_ua_regexp'; diff --git a/src/N98/Magento/Command/Developer/Theme/ListCommand.php b/src/N98/Magento/Command/Developer/Theme/ListCommand.php index 63b8297e3..082fdf78b 100644 --- a/src/N98/Magento/Command/Developer/Theme/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Theme/ListCommand.php @@ -5,8 +5,8 @@ namespace N98\Magento\Command\Developer\Theme; use Mage; -use N98\Magento\Command\AbstractMagentoCommand; -use N98\Magento\Command\AbstractMagentoCommandFormatInterface; +use N98\Magento\Command\AbstractCommand; +use N98\Magento\Command\CommandFormatInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -16,7 +16,7 @@ * * @package N98\Magento\Command\Developer\Theme */ -class ListCommand extends AbstractMagentoCommand implements AbstractMagentoCommandFormatInterface +class ListCommand extends AbstractCommand implements CommandFormatInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Themes'; diff --git a/src/N98/Magento/Command/Developer/Translate/ExportCommand.php b/src/N98/Magento/Command/Developer/Translate/ExportCommand.php index 651bc4942..afef6057b 100644 --- a/src/N98/Magento/Command/Developer/Translate/ExportCommand.php +++ b/src/N98/Magento/Command/Developer/Translate/ExportCommand.php @@ -7,7 +7,7 @@ use Locale; use Mage; use Mage_Core_Model_Store_Exception; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; @@ -20,7 +20,7 @@ * * @package NN98\Magento\Command\Developer\Translate */ -class ExportCommand extends AbstractMagentoCommand +class ExportCommand extends AbstractCommand { public const COMMAND_ARGUMENT_LOCALE = 'locale'; diff --git a/src/N98/Magento/Command/Developer/Translate/InlineAdminCommand.php b/src/N98/Magento/Command/Developer/Translate/InlineAdminCommand.php index 7b6ed764d..99ff1f198 100644 --- a/src/N98/Magento/Command/Developer/Translate/InlineAdminCommand.php +++ b/src/N98/Magento/Command/Developer/Translate/InlineAdminCommand.php @@ -5,7 +5,7 @@ namespace N98\Magento\Command\Developer\Translate; use Mage_Core_Model_Store; -use N98\Magento\Command\AbstractMagentoStoreConfigCommand; +use N98\Magento\Command\AbstractStoreConfigCommand; use Symfony\Component\Console\Attribute\AsCommand; /** @@ -13,7 +13,7 @@ * * @package N98\Magento\Command\Developer\Translate */ -class InlineAdminCommand extends AbstractMagentoStoreConfigCommand +class InlineAdminCommand extends AbstractStoreConfigCommand { /** * @var string diff --git a/src/N98/Magento/Command/Developer/Translate/InlineShopCommand.php b/src/N98/Magento/Command/Developer/Translate/InlineShopCommand.php index ced7135b1..5b2747193 100644 --- a/src/N98/Magento/Command/Developer/Translate/InlineShopCommand.php +++ b/src/N98/Magento/Command/Developer/Translate/InlineShopCommand.php @@ -5,7 +5,7 @@ namespace N98\Magento\Command\Developer\Translate; use Mage_Core_Model_Store; -use N98\Magento\Command\AbstractMagentoStoreConfigCommand; +use N98\Magento\Command\AbstractStoreConfigCommand; use Symfony\Component\Console\Attribute\AsCommand; /** @@ -13,7 +13,7 @@ * * @package N98\Magento\Command\Developer\Translate */ -class InlineShopCommand extends AbstractMagentoStoreConfigCommand +class InlineShopCommand extends AbstractStoreConfigCommand { /** * @var string diff --git a/src/N98/Magento/Command/Developer/Translate/SetCommand.php b/src/N98/Magento/Command/Developer/Translate/SetCommand.php index 18682f97f..57e22b811 100644 --- a/src/N98/Magento/Command/Developer/Translate/SetCommand.php +++ b/src/N98/Magento/Command/Developer/Translate/SetCommand.php @@ -7,7 +7,7 @@ use Exception; use Mage; use Mage_Core_Model_Store; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; @@ -21,7 +21,7 @@ * * @package NN98\Magento\Command\Developer\Translate */ -class SetCommand extends AbstractMagentoCommand +class SetCommand extends AbstractCommand { public const COMMAND_ARGUMENT_STRING = 'string'; @@ -49,11 +49,13 @@ protected function configure(): void ->addArgument( self::COMMAND_ARGUMENT_STRING, InputArgument::REQUIRED, - 'String to translate') + 'String to translate' + ) ->addArgument( self::COMMAND_ARGUMENT_TRANSLATE, InputArgument::REQUIRED, - 'Translated string') + 'Translated string' + ) ->addArgument( self::COMMAND_ARGUMENT_STORE, InputArgument::OPTIONAL diff --git a/src/N98/Magento/Command/Eav/Attribute/Create/DummyCommand.php b/src/N98/Magento/Command/Eav/Attribute/Create/DummyCommand.php index 2e7ed740a..803d5ed99 100644 --- a/src/N98/Magento/Command/Eav/Attribute/Create/DummyCommand.php +++ b/src/N98/Magento/Command/Eav/Attribute/Create/DummyCommand.php @@ -10,7 +10,7 @@ use Mage_Core_Exception; use Mage_Eav_Model_Entity_Attribute; use Mage_Eav_Model_Resource_Entity_Attribute_Collection; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use RuntimeException; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; @@ -26,7 +26,7 @@ * * @package N98\Magento\Command\Eav\Attribute */ -class DummyCommand extends AbstractMagentoCommand +class DummyCommand extends AbstractCommand { public const COMMAND_ARGUMENT_LOCALE = 'locale'; diff --git a/src/N98/Magento/Command/Eav/Attribute/ListCommand.php b/src/N98/Magento/Command/Eav/Attribute/ListCommand.php index dcde6b3d9..b6de7527c 100644 --- a/src/N98/Magento/Command/Eav/Attribute/ListCommand.php +++ b/src/N98/Magento/Command/Eav/Attribute/ListCommand.php @@ -8,8 +8,8 @@ use Mage; use Mage_Eav_Model_Entity_Attribute; use Mage_Eav_Model_Entity_Type; -use N98\Magento\Command\AbstractMagentoCommand; -use N98\Magento\Command\AbstractMagentoCommandFormatInterface; +use N98\Magento\Command\AbstractCommand; +use N98\Magento\Command\CommandFormatInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -20,7 +20,7 @@ * * @package N98\Magento\Command\Eav\Attribute */ -class ListCommand extends AbstractMagentoCommand implements AbstractMagentoCommandFormatInterface +class ListCommand extends AbstractCommand implements CommandFormatInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'EAV attributes'; diff --git a/src/N98/Magento/Command/Eav/Attribute/RemoveCommand.php b/src/N98/Magento/Command/Eav/Attribute/RemoveCommand.php index 5b52505e3..36d80ad9d 100644 --- a/src/N98/Magento/Command/Eav/Attribute/RemoveCommand.php +++ b/src/N98/Magento/Command/Eav/Attribute/RemoveCommand.php @@ -9,7 +9,7 @@ use Mage; use Mage_Core_Exception; use Mage_Eav_Model_Entity_Setup; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; @@ -22,7 +22,7 @@ * @package N98\Magento\Command\Eav\Attribute * @author Aydin Hassan */ -class RemoveCommand extends AbstractMagentoCommand +class RemoveCommand extends AbstractCommand { public const COMMAND_ARGUMENT_ENTITY = 'entityType'; diff --git a/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php b/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php index 863c5996d..614722a85 100644 --- a/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php +++ b/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php @@ -8,8 +8,8 @@ use Mage; use Mage_Core_Exception; use Mage_Eav_Model_Entity_Attribute_Abstract; -use N98\Magento\Command\AbstractMagentoCommand; -use N98\Magento\Command\AbstractMagentoCommandFormatInterface; +use N98\Magento\Command\AbstractCommand; +use N98\Magento\Command\CommandFormatInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -20,7 +20,7 @@ * * @package N98\Magento\Command\Eav\Attribute */ -class ViewCommand extends AbstractMagentoCommand implements AbstractMagentoCommandFormatInterface +class ViewCommand extends AbstractCommand implements CommandFormatInterface { public const COMMAND_ARGUMENT_ENTITY = 'entityType'; diff --git a/src/N98/Magento/Command/Indexer/AbstractIndexerCommand.php b/src/N98/Magento/Command/Indexer/AbstractIndexerCommand.php index 7eb70bcd2..892ed7bb1 100644 --- a/src/N98/Magento/Command/Indexer/AbstractIndexerCommand.php +++ b/src/N98/Magento/Command/Indexer/AbstractIndexerCommand.php @@ -11,7 +11,7 @@ use Mage; use Mage_Index_Model_Indexer; use Mage_Index_Model_Process; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use N98\Util\DateTime as DateTimeUtils; use Symfony\Component\Console\Output\OutputInterface; use UnexpectedValueException; @@ -22,7 +22,7 @@ * * @package N98\Magento\Command\Indexer */ -class AbstractIndexerCommand extends AbstractMagentoCommand +class AbstractIndexerCommand extends AbstractCommand { /** * @return Mage_Index_Model_Indexer diff --git a/src/N98/Magento/Command/Indexer/ListCommand.php b/src/N98/Magento/Command/Indexer/ListCommand.php index 10b4a481f..1ff832fc7 100644 --- a/src/N98/Magento/Command/Indexer/ListCommand.php +++ b/src/N98/Magento/Command/Indexer/ListCommand.php @@ -5,7 +5,7 @@ namespace N98\Magento\Command\Indexer; use Exception; -use N98\Magento\Command\AbstractMagentoCommandFormatInterface; +use N98\Magento\Command\CommandFormatInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -15,7 +15,7 @@ * * @package N98\Magento\Command\Indexer */ -class ListCommand extends AbstractIndexerCommand implements AbstractMagentoCommandFormatInterface +class ListCommand extends AbstractIndexerCommand implements CommandFormatInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Indexes'; diff --git a/src/N98/Magento/Command/Installer/InstallCommand.php b/src/N98/Magento/Command/Installer/InstallCommand.php index 3b772140c..a1218f28a 100644 --- a/src/N98/Magento/Command/Installer/InstallCommand.php +++ b/src/N98/Magento/Command/Installer/InstallCommand.php @@ -2,7 +2,7 @@ namespace N98\Magento\Command\Installer; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use N98\Magento\Command\SubCommand\SubCommandFactory; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -14,7 +14,7 @@ * @codeCoverageIgnore - Travis server uses installer to create a new shop. If it not works complete build fails. * @package N98\Magento\Command\Installer */ -class InstallCommand extends AbstractMagentoCommand +class InstallCommand extends AbstractCommand { /** * @var array @@ -26,7 +26,7 @@ class InstallCommand extends AbstractMagentoCommand */ protected $subCommandFactory; - protected function configure() + protected function configure(): void { $this ->setName('install') @@ -123,7 +123,7 @@ public function isEnabled() * @throws \RuntimeException * @return int */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $this->commandConfig = $this->getCommandConfig(); $this->writeSection($output, 'Magento Installation'); diff --git a/src/N98/Magento/Command/Installer/UninstallCommand.php b/src/N98/Magento/Command/Installer/UninstallCommand.php index b5ee14a8b..3b8a95290 100644 --- a/src/N98/Magento/Command/Installer/UninstallCommand.php +++ b/src/N98/Magento/Command/Installer/UninstallCommand.php @@ -3,9 +3,8 @@ namespace N98\Magento\Command\Installer; use Exception; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use N98\Util\Filesystem; -use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\StringInput; @@ -18,9 +17,9 @@ * @codeCoverageIgnore * @package N98\Magento\Command\Installer */ -class UninstallCommand extends AbstractMagentoCommand +class UninstallCommand extends AbstractCommand { - protected function configure() + protected function configure(): void { $this ->setName('uninstall') @@ -55,8 +54,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->detectMagento($output); $this->getApplication()->setAutoExit(false); - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $shouldUninstall = $input->getOption('force'); if (!$shouldUninstall) { diff --git a/src/N98/Magento/Command/Media/Cache/Image/ClearCommand.php b/src/N98/Magento/Command/Media/Cache/Image/ClearCommand.php index a66d1a085..6e8b7f09a 100644 --- a/src/N98/Magento/Command/Media/Cache/Image/ClearCommand.php +++ b/src/N98/Magento/Command/Media/Cache/Image/ClearCommand.php @@ -5,7 +5,7 @@ namespace N98\Magento\Command\Media\Cache\Image; use Mage; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; @@ -16,7 +16,7 @@ * * @package N98\Magento\Command\Media\Cache\Image */ -class ClearCommand extends AbstractMagentoCommand +class ClearCommand extends AbstractCommand { /** * @var string diff --git a/src/N98/Magento/Command/Media/Cache/JsCss/ClearCommand.php b/src/N98/Magento/Command/Media/Cache/JsCss/ClearCommand.php index 571efc257..7814ebc31 100644 --- a/src/N98/Magento/Command/Media/Cache/JsCss/ClearCommand.php +++ b/src/N98/Magento/Command/Media/Cache/JsCss/ClearCommand.php @@ -5,7 +5,7 @@ namespace N98\Magento\Command\Media\Cache\JsCss; use Mage; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; @@ -16,7 +16,7 @@ * * @package N98\Magento\Command\Media\Cache\JsCss */ -class ClearCommand extends AbstractMagentoCommand +class ClearCommand extends AbstractCommand { /** * @var string diff --git a/src/N98/Magento/Command/Media/DumpCommand.php b/src/N98/Magento/Command/Media/DumpCommand.php index feeaa318b..26eb651ac 100644 --- a/src/N98/Magento/Command/Media/DumpCommand.php +++ b/src/N98/Magento/Command/Media/DumpCommand.php @@ -5,7 +5,7 @@ namespace N98\Magento\Command\Media; use N98\Magento\Application; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use RuntimeException; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; @@ -22,7 +22,7 @@ * * @package N98\Magento\Command\Media */ -class DumpCommand extends AbstractMagentoCommand +class DumpCommand extends AbstractCommand { public const COMMAND_ARGUMENT_FILENAME = 'filename'; diff --git a/src/N98/Magento/Command/Script/Repository/AbstractRepositoryCommand.php b/src/N98/Magento/Command/Script/Repository/AbstractRepositoryCommand.php index ca9f4fe33..a663dd8af 100644 --- a/src/N98/Magento/Command/Script/Repository/AbstractRepositoryCommand.php +++ b/src/N98/Magento/Command/Script/Repository/AbstractRepositoryCommand.php @@ -4,7 +4,7 @@ namespace N98\Magento\Command\Script\Repository; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use Symfony\Component\Finder\SplFileInfo; /** @@ -12,7 +12,7 @@ * * @package N98\Magento\Command\Script\Repository */ -class AbstractRepositoryCommand extends AbstractMagentoCommand +class AbstractRepositoryCommand extends AbstractCommand { /** * Extension of n98-magerun scripts diff --git a/src/N98/Magento/Command/Script/Repository/ListCommand.php b/src/N98/Magento/Command/Script/Repository/ListCommand.php index 2253dbd63..e252cceb6 100644 --- a/src/N98/Magento/Command/Script/Repository/ListCommand.php +++ b/src/N98/Magento/Command/Script/Repository/ListCommand.php @@ -4,7 +4,7 @@ namespace N98\Magento\Command\Script\Repository; -use N98\Magento\Command\AbstractMagentoCommandFormatInterface; +use N98\Magento\Command\CommandFormatInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -14,7 +14,7 @@ * * @package N98\Magento\Command\Script\Repository */ -class ListCommand extends AbstractRepositoryCommand implements AbstractMagentoCommandFormatInterface +class ListCommand extends AbstractRepositoryCommand implements CommandFormatInterface { protected const NO_DATA_MESSAGE = 'No script file found'; diff --git a/src/N98/Magento/Command/System/Check/WebsiteCheck.php b/src/N98/Magento/Command/System/Check/WebsiteCheck.php index 8fc4901ba..c204623a8 100644 --- a/src/N98/Magento/Command/System/Check/WebsiteCheck.php +++ b/src/N98/Magento/Command/System/Check/WebsiteCheck.php @@ -12,8 +12,8 @@ interface WebsiteCheck { /** - * @param ResultCollection $results - * @param \Mage_Core_Model_Website $website + * @param ResultCollection $results + * @param Mage_Core_Model_Website $website */ public function check(ResultCollection $results, Mage_Core_Model_Website $website); } diff --git a/src/N98/Magento/Command/System/CheckCommand.php b/src/N98/Magento/Command/System/CheckCommand.php index dd9e58b16..243de7175 100644 --- a/src/N98/Magento/Command/System/CheckCommand.php +++ b/src/N98/Magento/Command/System/CheckCommand.php @@ -4,7 +4,7 @@ use LogicException; use Mage; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use N98\Magento\Command\CommandAware; use N98\Magento\Command\CommandConfigAware; use N98\Magento\Command\System\Check\Result; @@ -13,7 +13,6 @@ use N98\Magento\Command\System\Check\StoreCheck; use N98\Magento\Command\System\Check\WebsiteCheck; use N98\Util\Console\Helper\Table\Renderer\RendererFactory; -use N98\Util\Console\Helper\TableHelper; use N98\Util\Unicode\Charset; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -24,16 +23,16 @@ * * @package N98\Magento\Command\System */ -class CheckCommand extends AbstractMagentoCommand +class CheckCommand extends AbstractCommand { /** * Command config * * @var array */ - protected $config; + protected array $config; - protected function configure() + protected function configure(): void { $this ->setName('sys:check') @@ -63,9 +62,7 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output); - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); $this->config = $this->getCommandConfig(); @@ -159,8 +156,7 @@ protected function _printTable(InputInterface $input, OutputInterface $output, R $table[] = [$result->getResultGroup(), strip_tags($result->getMessage()), $result->getStatus()]; } - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['Group', 'Message', 'Result']) ->renderByFormat($output, $table, $input->getOption('format')); @@ -232,4 +228,9 @@ private function checkWebsites(ResultCollection $results, $checkGroupClass, Webs $check->check($results, $website); } } + + protected function getChecks() + { + return new ResultCollection(); + } } diff --git a/src/N98/Magento/Command/System/Cron/AbstractCronCommand.php b/src/N98/Magento/Command/System/Cron/AbstractCronCommand.php index 6953eaedf..4ca5f8d74 100644 --- a/src/N98/Magento/Command/System/Cron/AbstractCronCommand.php +++ b/src/N98/Magento/Command/System/Cron/AbstractCronCommand.php @@ -10,9 +10,9 @@ use Mage_Core_Model_Config_Element; use Mage_Cron_Exception; use Mage_Cron_Model_Schedule; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; -abstract class AbstractCronCommand extends AbstractMagentoCommand +abstract class AbstractCronCommand extends AbstractCommand { /** * @return array> diff --git a/src/N98/Magento/Command/System/Cron/HistoryCommand.php b/src/N98/Magento/Command/System/Cron/HistoryCommand.php index d1f312c9d..a1f50beaf 100644 --- a/src/N98/Magento/Command/System/Cron/HistoryCommand.php +++ b/src/N98/Magento/Command/System/Cron/HistoryCommand.php @@ -8,8 +8,8 @@ use Mage_Core_Exception; use Mage_Core_Model_Store_Exception; use Mage_Cron_Model_Schedule; -use N98\Magento\Command\AbstractMagentoCommand; -use N98\Magento\Command\AbstractMagentoCommandFormatInterface; +use N98\Magento\Command\AbstractCommand; +use N98\Magento\Command\CommandFormatInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -20,7 +20,7 @@ * * @package N98\Magento\Command\Cron */ -class HistoryCommand extends AbstractMagentoCommand implements AbstractMagentoCommandFormatInterface +class HistoryCommand extends AbstractCommand implements CommandFormatInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Last executed jobs'; diff --git a/src/N98/Magento/Command/System/Cron/ListCommand.php b/src/N98/Magento/Command/System/Cron/ListCommand.php index 2c95cf71b..5d3c9fdfb 100644 --- a/src/N98/Magento/Command/System/Cron/ListCommand.php +++ b/src/N98/Magento/Command/System/Cron/ListCommand.php @@ -6,7 +6,7 @@ use Mage_Core_Exception; use Mage_Core_Model_Config_Element; -use N98\Magento\Command\AbstractMagentoCommandFormatInterface; +use N98\Magento\Command\CommandFormatInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -16,7 +16,7 @@ * * @package N98\Magento\Command\Cron */ -class ListCommand extends AbstractCronCommand implements AbstractMagentoCommandFormatInterface +class ListCommand extends AbstractCronCommand implements CommandFormatInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Cronjobs'; diff --git a/src/N98/Magento/Command/System/InfoCommand.php b/src/N98/Magento/Command/System/InfoCommand.php index 808abc48a..1f9e6a312 100644 --- a/src/N98/Magento/Command/System/InfoCommand.php +++ b/src/N98/Magento/Command/System/InfoCommand.php @@ -1,27 +1,28 @@ setName('sys:info') @@ -52,13 +53,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int $softInitMode = in_array($input->getArgument('key'), ['version', 'edition']); if ($input->getOption('format') == null && $input->getArgument('key') == null) { - $this->writeSection($output, 'Magento System Information'); + $this->writeSection($output, 'System Information'); } $this->initMagento($softInitMode); - $this->infos['Version'] = $this->magentoVersion(); - $this->infos['Edition'] = ($this->_magentoEnterprise ? 'Enterprise' : 'Community'); + $this->infos['Version'] = $this->getInstalledVersion(); $this->infos['Root'] = $this->_magentoRootFolder; if ($softInitMode === false) { @@ -88,14 +88,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (($settingArgument = $input->getArgument('key')) !== null) { $settingArgument = strtolower($settingArgument); - $this->infos = array_change_key_case($this->infos, CASE_LOWER); + $this->infos = array_change_key_case($this->infos); if (!isset($this->infos[$settingArgument])) { throw new InvalidArgumentException('Unknown key: ' . $settingArgument); } $output->writeln((string) $this->infos[$settingArgument]); } else { - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['name', 'value']) ->renderByFormat($output, $table, $input->getOption('format')); @@ -103,15 +102,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int return 0; } - protected function magentoVersion() - { - if (method_exists('Mage', 'getOpenMageVersion')) { - return 'OpenMage LTS ' . Mage::getOpenMageVersion(); - } - - return Mage::getVersion(); - } - protected function addCacheInfos() { $this->infos['Cache Backend'] = get_class(Mage::app()->getCache()->getBackend()); @@ -128,7 +118,10 @@ protected function addCacheInfos() protected function findCoreOverwrites() { - $folders = [$this->_magentoRootFolder . '/app/code/local/Mage', $this->_magentoRootFolder . '/app/code/local/Enterprise', $this->_magentoRootFolder . '/app/code/community/Mage', $this->_magentoRootFolder . '/app/code/community/Enterprise']; + $folders = [ + $this->_magentoRootFolder . '/app/code/local/Mage', + $this->_magentoRootFolder . '/app/code/community/Mage' + ]; foreach ($folders as $key => $folder) { if (!is_dir($folder)) { unset($folders[$key]); @@ -147,7 +140,9 @@ protected function findCoreOverwrites() protected function findVendors() { - $codePools = ['core' => $this->_magentoRootFolder . '/app/code/core/', 'community' => $this->_magentoRootFolder . '/app/code/community/']; + $codePools = [ + 'core' => $this->_magentoRootFolder . '/app/code/core/', + 'community' => $this->_magentoRootFolder . '/app/code/community/']; if (is_dir($this->_magentoRootFolder . '/app/code/local/')) { $codePools['local'] = $this->_magentoRootFolder . '/app/code/local/'; diff --git a/src/N98/Magento/Command/System/MaintenanceCommand.php b/src/N98/Magento/Command/System/MaintenanceCommand.php index 43feaa200..8ad399e3b 100644 --- a/src/N98/Magento/Command/System/MaintenanceCommand.php +++ b/src/N98/Magento/Command/System/MaintenanceCommand.php @@ -4,7 +4,7 @@ namespace N98\Magento\Command\System; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use RuntimeException; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; @@ -17,7 +17,7 @@ /** * @package N98\Magento\Command\System */ -class MaintenanceCommand extends AbstractMagentoCommand +class MaintenanceCommand extends AbstractCommand { public const COMMAND_OPTION_OFF = 'off'; diff --git a/src/N98/Magento/Command/System/Setup/AbstractSetupCommand.php b/src/N98/Magento/Command/System/Setup/AbstractSetupCommand.php index c7419b119..d31591bd3 100644 --- a/src/N98/Magento/Command/System/Setup/AbstractSetupCommand.php +++ b/src/N98/Magento/Command/System/Setup/AbstractSetupCommand.php @@ -4,14 +4,14 @@ use InvalidArgumentException; use Mage; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use Symfony\Component\Console\Input\InputInterface; /** * Class AbstractSetupCommand * @package N98\Magento\Command\System\Setup */ -class AbstractSetupCommand extends AbstractMagentoCommand +class AbstractSetupCommand extends AbstractCommand { /** * @param string $moduleName diff --git a/src/N98/Magento/Command/System/Setup/ChangeVersionCommand.php b/src/N98/Magento/Command/System/Setup/ChangeVersionCommand.php index 95862a12d..c34c39ff9 100644 --- a/src/N98/Magento/Command/System/Setup/ChangeVersionCommand.php +++ b/src/N98/Magento/Command/System/Setup/ChangeVersionCommand.php @@ -16,7 +16,7 @@ class ChangeVersionCommand extends AbstractSetupCommand /** * Set up CLI options */ - protected function configure() + protected function configure(): void { $this ->setName('sys:setup:change-version') @@ -36,9 +36,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); $moduleVersion = $input->getArgument('version'); $moduleName = $this->getModule($input); @@ -65,12 +63,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int /** * @param string $moduleName * @param string $setupResource - * @param $version + * @param string $version * @param OutputInterface $output */ - public function updateSetupResource($moduleName, $setupResource, $version, OutputInterface $output) - { - $resourceModel = $this->_getResourceSingleton('core/resource', 'Mage_Core_Model_Resource_Resource'); + public function updateSetupResource( + string $moduleName, + string $setupResource, + string $version, OutputInterface $output + ): void { + $resourceModel = $this->_getResourceSingleton('core/resource'); $resourceModel->setDbVersion($setupResource, $version); $resourceModel->setDataVersion($setupResource, $version); diff --git a/src/N98/Magento/Command/System/Setup/CompareVersionsCommand.php b/src/N98/Magento/Command/System/Setup/CompareVersionsCommand.php index 2cc3a8df9..e5e187832 100644 --- a/src/N98/Magento/Command/System/Setup/CompareVersionsCommand.php +++ b/src/N98/Magento/Command/System/Setup/CompareVersionsCommand.php @@ -6,16 +6,15 @@ use Error; use Mage; use N98\JUnitXml\Document as JUnitXmlDocument; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use N98\Util\Console\Helper\Table\Renderer\RendererFactory; -use N98\Util\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -class CompareVersionsCommand extends AbstractMagentoCommand +class CompareVersionsCommand extends AbstractCommand { - protected function configure() + protected function configure(): void { $this ->setName('sys:setup:compare-versions') @@ -49,9 +48,7 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output); - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); $time = microtime(true); $modules = Mage::getConfig()->getNode('modules'); @@ -134,8 +131,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($input->getOption('log-junit')) { $this->logJUnit($table, $input->getOption('log-junit'), microtime($time) - $time); } else { - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders($headers) ->renderByFormat($output, $table, $input->getOption('format')); diff --git a/src/N98/Magento/Command/System/Setup/IncrementalCommand.php b/src/N98/Magento/Command/System/Setup/IncrementalCommand.php index 5c36195c2..c929c5cc8 100644 --- a/src/N98/Magento/Command/System/Setup/IncrementalCommand.php +++ b/src/N98/Magento/Command/System/Setup/IncrementalCommand.php @@ -6,10 +6,9 @@ use Mage; use Mage_Core_Model_Config; use Mage_Core_Model_Resource_Setup; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use ReflectionClass; use RuntimeException; -use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -21,7 +20,7 @@ * @package N98\Magento\Command\System\Setup * @codeCoverageIgnore */ -class IncrementalCommand extends AbstractMagentoCommand +class IncrementalCommand extends AbstractCommand { public const TYPE_MIGRATION_STRUCTURE = 'structure'; public const TYPE_MIGRATION_DATA = 'data'; @@ -54,7 +53,7 @@ class IncrementalCommand extends AbstractMagentoCommand */ protected $_config; - protected function configure() + protected function configure(): void { $this ->setName('sys:setup:incremental') @@ -457,8 +456,7 @@ protected function _processExceptionDuringUpdate( $output->writeln(["Magento encountered an error while running the following setup resource.", "", " $name ", "", "The Good News: You know the error happened, and the database", "information below will help you fix this error!", "", "The Bad News: Because Magento/MySQL can't run setup resources", "transactionally your database is now in an half upgraded, invalid", "state. Even if you fix the error, new errors may occur due to", "this half upgraded, invalid state.", '', "What to Do: ", "1. Figure out why the error happened, and manually fix your", " database and/or system so it won't happen again.", "2. Restore your database from backup.", "3. Re-run the scripts.", "", "Exception Message:", $e->getMessage(), ""]); if ($magentoExceptionOutput) { - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new Question('Press Enter to view raw Magento error text: '); $dialog->ask($input, $output, $question); @@ -497,8 +495,7 @@ protected function _runStructureOrDataScripts($toUpdate, array $needsUpdate, $ty $output = $this->_output; $output->writeln('The next ' . $type . ' update to run is ' . $toUpdate . ''); - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new Question('Press Enter to Run this update: '); $dialog->ask($input, $output, $question); @@ -539,9 +536,7 @@ protected function _init() { //bootstrap magento $this->detectMagento($this->_output); - if (!$this->initMagento()) { - return false; - } + $this->initMagento(); //don't run if cache is off. If cache is off that means //setup resource will run automagically @@ -583,8 +578,7 @@ protected function _listDetailedUpdateInformation(array $needsUpdate) $input = $this->_input; $output = $this->_output; - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new Question('Press Enter to View Update Information: '); $dialog->ask($input, $output, $question); diff --git a/src/N98/Magento/Command/System/Setup/RemoveCommand.php b/src/N98/Magento/Command/System/Setup/RemoveCommand.php index 611cadf2a..7fb56410d 100644 --- a/src/N98/Magento/Command/System/Setup/RemoveCommand.php +++ b/src/N98/Magento/Command/System/Setup/RemoveCommand.php @@ -20,7 +20,7 @@ class RemoveCommand extends AbstractSetupCommand /** * Set up CLI options */ - protected function configure() + protected function configure(): void { $this ->setName('sys:setup:remove') @@ -32,15 +32,12 @@ protected function configure() /** * @param InputInterface $input * @param OutputInterface $output - * * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); $moduleName = $this->getModule($input); $setupName = $input->getArgument('setup'); @@ -69,10 +66,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int * @param string $setupResource * @param OutputInterface $output */ - public function removeSetupResource($moduleName, $setupResource, OutputInterface $output) + public function removeSetupResource(string $moduleName, string $setupResource, OutputInterface $output): void { /** @var Mage_Core_Model_Resource $model */ - $model = $this->_getModel('core/resource', 'Mage_Core_Model_Resource'); + $model = $this->_getModel('core/resource'); $writeAdapter = $model->getConnection('core_write'); if (!$writeAdapter) { throw new RuntimeException('Database not configured'); diff --git a/src/N98/Magento/Command/System/Setup/RunCommand.php b/src/N98/Magento/Command/System/Setup/RunCommand.php index 9ae7ca4f3..8a8fd39e7 100644 --- a/src/N98/Magento/Command/System/Setup/RunCommand.php +++ b/src/N98/Magento/Command/System/Setup/RunCommand.php @@ -5,8 +5,7 @@ use Exception; use Mage; use Mage_Core_Model_Resource_Setup; -use N98\Magento\Command\AbstractMagentoCommand; -use N98\Util\Console\Helper\TableHelper; +use N98\Magento\Command\AbstractCommand; use ReflectionObject; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -14,9 +13,9 @@ use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\Console\Output\OutputInterface; -class RunCommand extends AbstractMagentoCommand +class RunCommand extends AbstractCommand { - protected function configure() + protected function configure(): void { $this ->setName('sys:setup:run') @@ -42,9 +41,7 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output); - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); try { if (false === $input->getOption('no-implicit-cache-flush')) { @@ -92,8 +89,7 @@ protected function printStackTrace(OutputInterface $output, Exception $e) return $row; }); - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $rows = []; $i = 1; foreach ($trace as $row) { @@ -111,8 +107,7 @@ protected function printStackTrace(OutputInterface $output, Exception $e) protected function printFile(OutputInterface $output, Exception $e) { if (preg_match('/Error\sin\sfile\:\s"(.+)\"\s-/', $e->getMessage(), $matches)) { - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $lines = \file($matches[1]); $rows = []; $i = 0; diff --git a/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php b/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php index 70f2fa95d..651382bbb 100644 --- a/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php +++ b/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php @@ -6,8 +6,8 @@ use Mage; use Mage_Core_Model_Store as Store; -use N98\Magento\Command\AbstractMagentoCommand; -use N98\Magento\Command\AbstractMagentoCommandFormatInterface; +use N98\Magento\Command\AbstractCommand; +use N98\Magento\Command\CommandFormatInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -17,7 +17,7 @@ * * @package N98\Magento\Command\System\Store\Config */ -class BaseUrlListCommand extends AbstractMagentoCommand implements AbstractMagentoCommandFormatInterface +class BaseUrlListCommand extends AbstractCommand implements CommandFormatInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Stores - Base URLs'; diff --git a/src/N98/Magento/Command/System/Store/ListCommand.php b/src/N98/Magento/Command/System/Store/ListCommand.php index 465d78a3d..009c28b26 100644 --- a/src/N98/Magento/Command/System/Store/ListCommand.php +++ b/src/N98/Magento/Command/System/Store/ListCommand.php @@ -4,8 +4,8 @@ namespace N98\Magento\Command\System\Store; -use N98\Magento\Command\AbstractMagentoCommand; -use N98\Magento\Command\AbstractMagentoCommandFormatInterface; +use N98\Magento\Command\AbstractCommand; +use N98\Magento\Command\CommandFormatInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -15,7 +15,7 @@ * * @package N98\Magento\Command\System\Store */ -class ListCommand extends AbstractMagentoCommand implements AbstractMagentoCommandFormatInterface +class ListCommand extends AbstractCommand implements CommandFormatInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Stores'; diff --git a/src/N98/Magento/Command/System/Website/ListCommand.php b/src/N98/Magento/Command/System/Website/ListCommand.php index 94ae59bd0..1fc05a014 100644 --- a/src/N98/Magento/Command/System/Website/ListCommand.php +++ b/src/N98/Magento/Command/System/Website/ListCommand.php @@ -4,8 +4,8 @@ namespace N98\Magento\Command\System\Website; -use N98\Magento\Command\AbstractMagentoCommand; -use N98\Magento\Command\AbstractMagentoCommandFormatInterface; +use N98\Magento\Command\AbstractCommand; +use N98\Magento\Command\CommandFormatInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -15,7 +15,7 @@ * * @package 98\Magento\Command\System\Website */ -class ListCommand extends AbstractMagentoCommand implements AbstractMagentoCommandFormatInterface +class ListCommand extends AbstractCommand implements CommandFormatInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Websites'; From 86f174ca5c1bbc0483127a0a11328132b6eb6a2a Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 21 Jun 2024 10:27:45 +0200 Subject: [PATCH 115/136] [skip ci] Updated dev:console command --- .../Command/Developer/Console/Psy/Shell.php | 7 ++ .../Command/Developer/ConsoleCommand.php | 68 ++++++++++--------- 2 files changed, 42 insertions(+), 33 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Console/Psy/Shell.php b/src/N98/Magento/Command/Developer/Console/Psy/Shell.php index 6c7dad18f..fb0fdb55f 100644 --- a/src/N98/Magento/Command/Developer/Console/Psy/Shell.php +++ b/src/N98/Magento/Command/Developer/Console/Psy/Shell.php @@ -1,10 +1,17 @@ setName('dev:console') - ->setDescription( - 'Opens PHP interactive shell with initialized Mage::app() (Experimental)' - ) - ; - } + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultName = 'dev:console'; + + /** + * @var string + * @deprecated with symfony 6.1 + * @see AsCommand + */ + protected static $defaultDescription = 'Opens PHP interactive shell with initialized Mage::app() (Experimental).'; /** * @param InputInterface $input * @param OutputInterface $output - * * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int { - $initialized = false; - try { - $this->detectMagento($output); - $initialized = $this->initMagento(); - } catch (Exception $e) { - // do nothing - } + $this->detectMagento($output); + $this->initMagento(); $consoleOutput = new ShellOutput(); $config = new Configuration(); $shell = new Shell($config); - if ($initialized) { - $ok = Charset::convertInteger(Charset::UNICODE_CHECKMARK_CHAR); - $consoleOutput->writeln( - 'Magento ' . Mage::getVersion() . ' ' . 'CE' . - ' initialized. ' . $ok - ); - } else { - $consoleOutput->writeln('Magento is not initialized.'); - } + $consoleOutput->writeln(sprintf( + '%s initialized. %s', + $this->getInstalledVersion(), + Charset::convertInteger(Charset::UNICODE_CHECKMARK_CHAR) + )); - $help = <<<'help_WRAP' + $help = <<help for some help. To exit the shell, type ^D. -help_WRAP; +HELP; $consoleOutput->writeln($help); $shell->run($input, $consoleOutput); - return 0; + + return Command::SUCCESS; } } From 7ae0b0afa3ee1f44613ca84d7a8fa92817b6e989 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 21 Jun 2024 10:34:32 +0200 Subject: [PATCH 116/136] [skip ci] Updated class names/minor fixes --- src/N98/Magento/Command/AbstractCommand.php | 632 ++++++++++++++++ .../Magento/Command/AbstractCommandHelper.php | 166 +++++ .../Command/AbstractMagentoCommand.php | 681 +----------------- .../AbstractMagentoStoreConfigCommand.php | 260 +------ .../Command/AbstractStoreConfigCommand.php | 265 +++++++ ...terface.php => CommandFormatInterface.php} | 7 +- .../Magento/Command/OpenBrowserCommand.php | 21 +- src/N98/Magento/Command/ScriptCommand.php | 25 +- src/N98/Magento/Command/SelfUpdateCommand.php | 22 +- .../Util/Console/Helper/ParameterHelper.php | 58 +- .../Helper/Table/Renderer/RendererFactory.php | 7 +- src/N98/Util/Console/Helper/TableHelper.php | 2 +- src/N98/Util/Filesystem.php | 4 +- .../_ApplicationTestComposer/FooCommand.php | 6 +- .../src/TestModule/FooCommand.php | 6 +- .../N98MagerunTest/TestDummyCommand.php | 6 +- 16 files changed, 1165 insertions(+), 1003 deletions(-) create mode 100644 src/N98/Magento/Command/AbstractCommand.php create mode 100644 src/N98/Magento/Command/AbstractCommandHelper.php create mode 100644 src/N98/Magento/Command/AbstractStoreConfigCommand.php rename src/N98/Magento/Command/{AbstractMagentoCommandFormatInterface.php => CommandFormatInterface.php} (77%) diff --git a/src/N98/Magento/Command/AbstractCommand.php b/src/N98/Magento/Command/AbstractCommand.php new file mode 100644 index 000000000..76076fc83 --- /dev/null +++ b/src/N98/Magento/Command/AbstractCommand.php @@ -0,0 +1,632 @@ +|string, array> + */ + protected ?array $data = null; + + /** + * Initializes the command just after the input has been validated. + * + * This is mainly useful when a lot of commands extends one main command + * where some things need to be initialized based on the input arguments and options. + * + * @param InputInterface $input An InputInterface instance + * @param OutputInterface $output An OutputInterface instance + */ + protected function initialize(InputInterface $input, OutputInterface $output) + { + $this->checkDeprecatedAliases($input, $output); + } + + private function _initWebsites() + { + $this->_websiteCodeMap = []; + /** @var \Mage_Core_Model_Website[] $websites */ + $websites = Mage::app()->getWebsites(); + foreach ($websites as $website) { + $this->_websiteCodeMap[$website->getId()] = $website->getCode(); + } + } + + /** + * @param int $websiteId + * @return string + */ + protected function _getWebsiteCodeById(int $websiteId): string + { + if (empty($this->_websiteCodeMap)) { + $this->_initWebsites(); + } + + if (isset($this->_websiteCodeMap[$websiteId])) { + return $this->_websiteCodeMap[$websiteId]; + } + + return ''; + } + + /** + * @param string $websiteCode + * @return int + */ + protected function _getWebsiteIdByCode(string $websiteCode): int + { + if (empty($this->_websiteCodeMap)) { + $this->_initWebsites(); + } + $websiteMap = array_flip($this->_websiteCodeMap); + + return $websiteMap[$websiteCode]; + } + + /** + * @param string|null $commandClass + * @return array + */ + protected function getCommandConfig(?string $commandClass = null): array + { + if (null === $commandClass) { + $commandClass = get_class($this); + } + + $application = $this->getApplication(); + return (array) $application->getConfig('commands', $commandClass); + } + + /** + * @param OutputInterface $output + * @param string $text + * @param string $style + */ + protected function writeSection(OutputInterface $output, string $text, string $style = 'bg=blue;fg=white') + { + $output->writeln(['', $this->getHelper('formatter')->formatBlock($text, $style, true), '']); + } + + /** + * Bootstrap magento shop + * + * @param bool $soft + * @return void + */ + protected function initMagento(bool $soft = false): void + { + $application = $this->getApplication(); + $init = $application->initMagento($soft); + if (!$init) { + throw new RuntimeException('Application could not be loaded'); + } + + $this->_magentoRootFolder = $application->getMagentoRootFolder(); + } + + /** + * Search for magento root folder + * + * @param OutputInterface $output + * @param bool $silent print debug messages + * @throws RuntimeException + */ + public function detectMagento(OutputInterface $output, bool $silent = true) + { + $this->getApplication()->detectMagento(); + + $this->_magentoRootFolder = $this->getApplication()->getMagentoRootFolder(); + + if (!$silent) { + $output->writeln( + 'Found Magento in folder "' . $this->_magentoRootFolder . '"' + ); + } + + if (!empty($this->_magentoRootFolder)) { + return; + } + + throw new RuntimeException('Magento folder could not be detected'); + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return DownloadManager + */ + protected function getComposerDownloadManager($input, $output) + { + return $this->getComposer($input, $output)->getDownloadManager(); + } + + /** + * @param array|PackageInterface $config + * @return CompletePackage + */ + protected function createComposerPackageByConfig($config) + { + $packageLoader = new PackageLoader(); + return $packageLoader->load($config); + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + * @param array|PackageInterface $config + * @param string $targetFolder + * @param bool $preferSource + * @return CompletePackage + */ + protected function downloadByComposerConfig( + InputInterface $input, + OutputInterface $output, + $config, + $targetFolder, + $preferSource = true + ) { + $dm = $this->getComposerDownloadManager($input, $output); + if (!$config instanceof PackageInterface) { + $package = $this->createComposerPackageByConfig($config); + } else { + $package = $config; + } + + $helper = new MagentoHelper(); + $helper->detect($targetFolder); + if ($this->isSourceTypeRepository($package->getSourceType()) && $helper->getRootFolder() == $targetFolder) { + $package->setInstallationSource('source'); + $this->checkRepository($package, $targetFolder); + $dm->update($package, $package, $targetFolder); + } else { + // @todo check cmuench + $dm->setPreferSource($preferSource); + $dm->download($package, $targetFolder); + } + + return $package; + } + + /** + * brings locally cached repository up to date if it is missing the requested tag + * + * @param PackageInterface $package + * @param string $targetFolder + */ + protected function checkRepository($package, $targetFolder) + { + if ($package->getSourceType() == 'git') { + $command = sprintf( + 'cd %s && git rev-parse refs/tags/%s', + escapeshellarg($this->normalizePath($targetFolder)), + escapeshellarg($package->getSourceReference()) + ); + $existingTags = shell_exec($command); + if (!$existingTags) { + $command = sprintf('cd %s && git fetch', escapeshellarg($this->normalizePath($targetFolder))); + shell_exec($command); + } + } elseif ($package->getSourceType() == 'hg') { + $command = sprintf( + 'cd %s && hg log --template "{tags}" -r %s', + escapeshellarg($targetFolder), + escapeshellarg($package->getSourceReference()) + ); + $existingTag = shell_exec($command); + if ($existingTag === $package->getSourceReference()) { + $command = sprintf('cd %s && hg pull', escapeshellarg($targetFolder)); + shell_exec($command); + } + } + } + + /** + * normalize paths on windows / cygwin / msysgit + * + * when using a path value that has been created in a cygwin shell but then PHP uses it inside a cmd shell it needs + * to be filtered. + * + * @param string $path + * @return string + */ + protected function normalizePath(string $path): string + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $path = strtr($path, '/', '\\'); + } + return $path; + } + + /** + * obtain composer + * + * @param InputInterface $input + * @param OutputInterface $output + * + * @return \Composer + */ + protected function getComposer(InputInterface $input, OutputInterface $output) + { + $io = new ConsoleIO($input, $output, $this->getHelperSet()); + $config = ['config' => ['secure-http' => false]]; + + return \ComposerFactory::create($io, $config); + } + + /** + * @param string $alias + * @param string $message + * @return AbstractCommand + */ + protected function addDeprecatedAlias(string $alias, string $message) + { + $this->_deprecatedAlias[$alias] = $message; + + return $this; + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + */ + protected function checkDeprecatedAliases(InputInterface $input, OutputInterface $output) + { + if (isset($this->_deprecatedAlias[$input->getArgument('command')])) { + $output->writeln( + 'Deprecated: ' . $this->_deprecatedAlias[$input->getArgument('command')] . + '' + ); + } + } + + /** + * @param string $value + * @return bool + */ + protected function _parseBoolOption(string $value): bool + { + return StringTyped::parseBoolOption($value); + } + + /** + * @param string $value + * @return bool + */ + public function parseBoolOption(string $value): bool + { + return $this->_parseBoolOption($value); + } + + /** + * @param string $value + * @return string + */ + protected function formatActive(string $value): string + { + return StringTyped::formatActive($value); + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return int + * @throws ExceptionInterface + */ + public function run(InputInterface $input, OutputInterface $output) + { + $this->getHelperSet()->setCommand($this); + + return parent::run($input, $output); + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + */ + protected function chooseInstallationFolder(InputInterface $input, OutputInterface $output) + { + /** + * @param string $folderName + * @return string + */ + $validateInstallationFolder = function (string $folderName) use ($input) { + $folderName = rtrim(trim($folderName, ' '), '/'); + // resolve folder-name to current working directory if relative + if (substr($folderName, 0, 1) == '.') { + $cwd = OperatingSystem::getCwd(); + $folderName = $cwd . substr($folderName, 1); + } + + if (empty($folderName)) { + throw new InvalidArgumentException('Installation folder cannot be empty'); + } + + if (!is_dir($folderName)) { + if (!@mkdir($folderName, 0777, true)) { + throw new InvalidArgumentException('Cannot create folder.'); + } + + return $folderName; + } + + if ($input->hasOption('noDownload') && $input->getOption('noDownload')) { + $magentoHelper = new MagentoHelper(); + $magentoHelper->detect($folderName); + if ($magentoHelper->getRootFolder() !== $folderName) { + throw new InvalidArgumentException( + sprintf( + 'Folder "%s" is not a Magento working copy (%s)', + $folderName, + var_export($magentoHelper->getRootFolder(), true) + ) + ); + } + + $localXml = $folderName . '/app/etc/local.xml'; + if (file_exists($localXml)) { + throw new InvalidArgumentException( + sprintf( + 'Magento working copy in %s seems already installed. Please remove %s and retry.', + $folderName, + $localXml + ) + ); + } + } + + return $folderName; + }; + + if (($installationFolder = $input->getOption('installationFolder')) == null) { + $defaultFolder = './magento'; + + $dialog = $this->getQuestionHelper(); + $questionObj = new Question( + 'Enter installation folder: [' . $defaultFolder . ']', + $defaultFolder + ); + $questionObj->setValidator($validateInstallationFolder); + + $installationFolder = $dialog->ask($input, $output, $questionObj); + } else { + // @Todo improve validation and bring it to 1 single function + $installationFolder = $validateInstallationFolder($installationFolder); + } + + $this->config['installationFolder'] = realpath($installationFolder); + \chdir($this->config['installationFolder']); + } + + /** + * @param string $type + * @return bool + */ + protected function isSourceTypeRepository(string $type): bool + { + return in_array($type, ['git', 'hg']); + } + + /** + * @param string $argument + * @param InputInterface $input + * @param OutputInterface $output + * @param string|null $message + * @return string + */ + protected function getOrAskForArgument( + string $argument, + InputInterface $input, + OutputInterface $output, + ?string $message = null + ): string { + $inputArgument = $input->getArgument($argument); + if ($inputArgument === null) { + $message = $this->getArgumentMessage($argument, $message); + + $dialog = $this->getQuestionHelper(); + return $dialog->ask($input, $output, new Question($message)); + } + + return $inputArgument; + } + + /** + * @param array $entries zero-indexed array of entries (represented by strings) to select from + * @param InputInterface $input + * @param OutputInterface $output + * @param string $question + * @return mixed + */ + protected function askForArrayEntry( + array $entries, + InputInterface $input, + OutputInterface $output, + string $question + ) { + $validator = function ($typeInput) use ($entries) { + if (!in_array($typeInput, range(0, count($entries)))) { + throw new InvalidArgumentException('Invalid type'); + } + + return $typeInput; + }; + + $dialog = $this->getQuestionHelper(); + $question = new ChoiceQuestion( + "{$question}", + $entries + ); + $question->setValidator($validator); + + $selected = $dialog->ask($input, $output, $question); + + return $entries[$selected]; + } + + /** + * @param string $argument + * @param string|null $message [optional] + * @return string + */ + protected function getArgumentMessage(string $argument, string $message = null) + { + if (null === $message) { + $message = ucfirst($argument); + } + + return sprintf('%s: ', $message); + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + * @param string $baseNamespace If this is set we can use relative class names. + * + * @return SubCommandFactory + */ + protected function createSubCommandFactory( + InputInterface $input, + OutputInterface $output, + string $baseNamespace = '' + ) { + $configBag = new ConfigBag(); + + $commandConfig = $this->getCommandConfig(); + if (empty($commandConfig)) { + $commandConfig = []; + } + + return new SubCommandFactory( + $this, + $baseNamespace, + $input, + $output, + $commandConfig, + $configBag + ); + } + + protected function configure(): void + { + if ($this instanceof CommandFormatInterface) { + $this->addOption( + self::COMMAND_OPTION_FORMAT, + null, + InputOption::VALUE_OPTIONAL, + 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']', + static::COMMAND_OPTION_FORMAT_DEFAULT + ); + } + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return int + */ + protected function execute(InputInterface $input, OutputInterface $output): int + { + if (static::COMMAND_SECTION_TITLE_TEXT && $input->getOption(self::COMMAND_OPTION_FORMAT) === null) { + $this->writeSection($output, static::COMMAND_SECTION_TITLE_TEXT); + } + + $this->detectMagento($output); + $this->initMagento(); + + $data = $this->getData($input, $output); + + if (count($data) > 0) { + $tableHelper = $this->getTableHelper(); + $tableHelper + ->setHeaders($this->getTableHeaders($input, $output)) + ->renderByFormat($output, $data, $input->getOption(self::COMMAND_OPTION_FORMAT)); + } else { + $output->writeln(sprintf('%s', static::NO_DATA_MESSAGE)); + } + + return Command::SUCCESS; + } + + /** + * @return array + */ + protected function getTableHeaders(InputInterface $input, OutputInterface $output): array + { + $data = $this->getData($input, $output); + return array_keys(reset($data)); + } + + /** + * @return Application + */ + public function getApplication(): Application + { + $application = parent::getApplication(); + if ($application instanceof Application) { + return $application; + } + + throw new RuntimeException('Application not loaded'); + } +} diff --git a/src/N98/Magento/Command/AbstractCommandHelper.php b/src/N98/Magento/Command/AbstractCommandHelper.php new file mode 100644 index 000000000..6f53637f1 --- /dev/null +++ b/src/N98/Magento/Command/AbstractCommandHelper.php @@ -0,0 +1,166 @@ +getHelper('database'); + } + + /** + * @return ParameterHelper + */ + public function getParameterHelper(): ParameterHelper + { + return $this->getHelper('parameter'); + } + + /** + * @return QuestionHelper + */ + public function getQuestionHelper(): QuestionHelper + { + return $this->getHelper('question'); + } + + /** + * @return TableHelper + */ + public function getTableHelper(): TableHelper + { + return $this->getHelper('table'); + } + + /** + * @return TwigHelper + */ + public function getTwigHelper(): TwigHelper + { + return $this->getHelper('twig'); + } + + /** + * @return Mage_Core_Model_App + */ + protected function _getMage(): Mage_Core_Model_App + { + return Mage::app(); + } + + /** + * Helper for PhpStan to avoid + * "Cannot call method loadModulesConfiguration() on Mage_Core_Model_Config|null" + * + * @return Mage_Core_Model_Config + */ + protected function _getMageConfig(): Mage_Core_Model_Config + { + return Mage::getConfig(); + } + + /** + * @return Mage_Core_Model_Store + * @throws Mage_Core_Model_Store_Exception + */ + protected function _getMageStore(): Mage_Core_Model_Store + { + return $this->_getMage()->getStore(); + } + + /** + * @return Mage_Core_Helper_Data + */ + protected function getCoreHelper(): Mage_Core_Helper_Data + { + return Mage::helper('core'); + } + + /** + * @param string $class class code + * @return Mage_Core_Model_Abstract + * @deprecated since v3.0.0 + */ + protected function _getModel(string $class) + { + return Mage::getModel($class); + } + + /** + * @param string $class class code + * @return Mage_Core_Helper_Abstract + * @deprecated since v3.0.0 + */ + protected function _getHelper(string $class) + { + return Mage::helper($class); + } + + /** + * @param string $class class code + * @return Mage_Core_Model_Abstract + * @deprecated since v3.0.0 + */ + protected function _getSingleton(string $class) + { + return Mage::getModel($class); + } + + /** + * @param string $class class code + * @return Mage_Core_Model_Abstract + * @deprecated since v3.0.0 + */ + protected function _getResourceModel(string $class) + { + return Mage::getResourceModel($class); + } + + /** + * @param string $class class code + * @return Mage_Core_Model_Abstract + * @deprecated since v3.0.0 + */ + protected function _getResourceSingleton(string $class) + { + return Mage::getResourceSingleton($class); + } +} diff --git a/src/N98/Magento/Command/AbstractMagentoCommand.php b/src/N98/Magento/Command/AbstractMagentoCommand.php index 9de52a9fd..eb44174f0 100644 --- a/src/N98/Magento/Command/AbstractMagentoCommand.php +++ b/src/N98/Magento/Command/AbstractMagentoCommand.php @@ -1,687 +1,16 @@ >|null - */ - protected ?array $data = null; - - /** - * Initializes the command just after the input has been validated. - * - * This is mainly useful when a lot of commands extends one main command - * where some things need to be initialized based on the input arguments and options. - * - * @param InputInterface $input An InputInterface instance - * @param OutputInterface $output An OutputInterface instance - */ - protected function initialize(InputInterface $input, OutputInterface $output) - { - $this->checkDeprecatedAliases($input, $output); - } - - private function _initWebsites() - { - $this->_websiteCodeMap = []; - /** @var \Mage_Core_Model_Website[] $websites */ - $websites = Mage::app()->getWebsites(false); - foreach ($websites as $website) { - $this->_websiteCodeMap[$website->getId()] = $website->getCode(); - } - } - - /** - * @param int $websiteId - * @return string - */ - protected function _getWebsiteCodeById($websiteId) - { - if (empty($this->_websiteCodeMap)) { - $this->_initWebsites(); - } - - if (isset($this->_websiteCodeMap[$websiteId])) { - return $this->_websiteCodeMap[$websiteId]; - } - - return ''; - } - - /** - * @param string $websiteCode - * @return int - */ - protected function _getWebsiteIdByCode($websiteCode) - { - if (empty($this->_websiteCodeMap)) { - $this->_initWebsites(); - } - $websiteMap = array_flip($this->_websiteCodeMap); - - return $websiteMap[$websiteCode]; - } - - /** - * @param string|null $commandClass - * @return array - */ - protected function getCommandConfig($commandClass = null) - { - if (null === $commandClass) { - $commandClass = get_class($this); - } - - $application = $this->getApplication(); - return (array) $application->getConfig('commands', $commandClass); - } - - /** - * @param OutputInterface $output - * @param string $text - * @param string $style - */ - protected function writeSection(OutputInterface $output, $text, $style = 'bg=blue;fg=white') - { - $output->writeln(['', $this->getHelper('formatter')->formatBlock($text, $style, true), '']); - } - - /** - * Bootstrap magento shop - * - * @param bool $soft - * @return bool - */ - protected function initMagento($soft = false) - { - $application = $this->getApplication(); - $init = $application->initMagento($soft); - if ($init) { - $this->_magentoRootFolder = $application->getMagentoRootFolder(); - } - - return $init; - } - - /** - * Search for magento root folder - * - * @param OutputInterface $output - * @param bool $silent print debug messages - * @throws RuntimeException - */ - public function detectMagento(OutputInterface $output, $silent = true) - { - $this->getApplication()->detectMagento(); - - $this->_magentoEnterprise = $this->getApplication()->isMagentoEnterprise(); - $this->_magentoRootFolder = $this->getApplication()->getMagentoRootFolder(); - - if (!$silent) { - $editionString = ($this->_magentoEnterprise ? ' (Enterprise Edition) ' : ''); - $output->writeln( - 'Found Magento ' . $editionString . 'in folder "' . $this->_magentoRootFolder . '"' - ); - } - - if (!empty($this->_magentoRootFolder)) { - return; - } - - throw new RuntimeException('Magento folder could not be detected'); - } - - /** - * Die if not Enterprise - */ - protected function requireEnterprise(OutputInterface $output) - { - if (!$this->_magentoEnterprise) { - $output->writeln('Enterprise Edition is required but was not detected'); - exit; - } - } - - /** - * @return \Mage_Core_Helper_Data - */ - protected function getCoreHelper() - { - return Mage::helper('core'); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * @return DownloadManager - */ - protected function getComposerDownloadManager($input, $output) - { - return $this->getComposer($input, $output)->getDownloadManager(); - } - - /** - * @param array|PackageInterface $config - * @return CompletePackage - */ - protected function createComposerPackageByConfig($config) - { - $packageLoader = new PackageLoader(); - return $packageLoader->load($config); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * @param array|PackageInterface $config - * @param string $targetFolder - * @param bool $preferSource - * @return CompletePackage - */ - protected function downloadByComposerConfig( - InputInterface $input, - OutputInterface $output, - $config, - $targetFolder, - $preferSource = true - ) { - $dm = $this->getComposerDownloadManager($input, $output); - if (!$config instanceof PackageInterface) { - $package = $this->createComposerPackageByConfig($config); - } else { - $package = $config; - } - - $helper = new MagentoHelper(); - $helper->detect($targetFolder); - if ($this->isSourceTypeRepository($package->getSourceType()) && $helper->getRootFolder() == $targetFolder) { - $package->setInstallationSource('source'); - $this->checkRepository($package, $targetFolder); - $dm->update($package, $package, $targetFolder); - } else { - // @todo check cmuench - $dm->setPreferSource($preferSource); - $dm->download($package, $targetFolder); - } - - return $package; - } - - /** - * brings locally cached repository up to date if it is missing the requested tag - * - * @param PackageInterface $package - * @param string $targetFolder - */ - protected function checkRepository($package, $targetFolder) - { - if ($package->getSourceType() == 'git') { - $command = sprintf( - 'cd %s && git rev-parse refs/tags/%s', - escapeshellarg($this->normalizePath($targetFolder)), - escapeshellarg($package->getSourceReference()) - ); - $existingTags = shell_exec($command); - if (!$existingTags) { - $command = sprintf('cd %s && git fetch', escapeshellarg($this->normalizePath($targetFolder))); - shell_exec($command); - } - } elseif ($package->getSourceType() == 'hg') { - $command = sprintf( - 'cd %s && hg log --template "{tags}" -r %s', - escapeshellarg($targetFolder), - escapeshellarg($package->getSourceReference()) - ); - $existingTag = shell_exec($command); - if ($existingTag === $package->getSourceReference()) { - $command = sprintf('cd %s && hg pull', escapeshellarg($targetFolder)); - shell_exec($command); - } - } - } - - /** - * normalize paths on windows / cygwin / msysgit - * - * when using a path value that has been created in a cygwin shell but then PHP uses it inside a cmd shell it needs - * to be filtered. - * - * @param string $path - * @return string - */ - protected function normalizePath($path) - { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { - $path = strtr($path, '/', '\\'); - } - return $path; - } - - /** - * obtain composer - * - * @param InputInterface $input - * @param OutputInterface $output - * - * @return Composer - */ - protected function getComposer(InputInterface $input, OutputInterface $output) - { - $io = new ConsoleIO($input, $output, $this->getHelperSet()); - $config = ['config' => ['secure-http' => false]]; - - return ComposerFactory::create($io, $config); - } - - /** - * @param string $alias - * @param string $message - * @return AbstractMagentoCommand - */ - protected function addDeprecatedAlias($alias, $message) - { - $this->_deprecatedAlias[$alias] = $message; - - return $this; - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - */ - protected function checkDeprecatedAliases(InputInterface $input, OutputInterface $output) - { - if (isset($this->_deprecatedAlias[$input->getArgument('command')])) { - $output->writeln( - 'Deprecated: ' . $this->_deprecatedAlias[$input->getArgument('command')] . - '' - ); - } - } - - /** - * @param string $class class code - * @return \Mage_Core_Model_Abstract - */ - protected function _getModel($class) - { - return Mage::getModel($class); - } - - /** - * @param string $class class code - * @return \Mage_Core_Helper_Abstract - */ - protected function _getHelper($class) - { - return Mage::helper($class); - } - - /** - * @param string $class class code - * @return \Mage_Core_Model_Abstract - */ - protected function _getSingleton($class) - { - return Mage::getModel($class); - } - - /** - * @param string $class class code - * @return \Mage_Core_Model_Abstract - */ - protected function _getResourceModel($class) - { - return Mage::getResourceModel($class); - } - - /** - * @param string $class class code - * @return \Mage_Core_Model_Abstract - */ - protected function _getResourceSingleton($class) - { - return Mage::getResourceSingleton($class); - } - - /** - * @param string $value - * @return bool - */ - protected function _parseBoolOption($value) - { - return StringTyped::parseBoolOption($value); - } - - /** - * @param string $value - * @return bool - */ - public function parseBoolOption($value) - { - return $this->_parseBoolOption($value); - } - - /** - * @param string $value - * @return string - */ - protected function formatActive($value) - { - return StringTyped::formatActive($value); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int - */ - public function run(InputInterface $input, OutputInterface $output) - { - $this->getHelperSet()->setCommand($this); - - return parent::run($input, $output); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - */ - protected function chooseInstallationFolder(InputInterface $input, OutputInterface $output) - { - /** - * @param string $folderName - * - * @return string - */ - $validateInstallationFolder = function ($folderName) use ($input) { - $folderName = rtrim(trim($folderName, ' '), '/'); - // resolve folder-name to current working directory if relative - if (substr($folderName, 0, 1) == '.') { - $cwd = OperatingSystem::getCwd(); - $folderName = $cwd . substr($folderName, 1); - } - - if (empty($folderName)) { - throw new InvalidArgumentException('Installation folder cannot be empty'); - } - - if (!is_dir($folderName)) { - if (!@mkdir($folderName, 0777, true)) { - throw new InvalidArgumentException('Cannot create folder.'); - } - - return $folderName; - } - - if ($input->hasOption('noDownload') && $input->getOption('noDownload')) { - $magentoHelper = new MagentoHelper(); - $magentoHelper->detect($folderName); - if ($magentoHelper->getRootFolder() !== $folderName) { - throw new InvalidArgumentException( - sprintf( - 'Folder "%s" is not a Magento working copy (%s)', - $folderName, - var_export($magentoHelper->getRootFolder(), true) - ) - ); - } - - $localXml = $folderName . '/app/etc/local.xml'; - if (file_exists($localXml)) { - throw new InvalidArgumentException( - sprintf( - 'Magento working copy in %s seems already installed. Please remove %s and retry.', - $folderName, - $localXml - ) - ); - } - } - - return $folderName; - }; - - if (($installationFolder = $input->getOption('installationFolder')) == null) { - $defaultFolder = './magento'; - - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); - $questionObj = new Question( - 'Enter installation folder: [' . $defaultFolder . ']', - $defaultFolder - ); - $questionObj->setValidator($validateInstallationFolder); - - $installationFolder = $dialog->ask($input, $output, $questionObj); - } else { - // @Todo improve validation and bring it to 1 single function - $installationFolder = $validateInstallationFolder($installationFolder); - } - - $this->config['installationFolder'] = realpath($installationFolder); - \chdir($this->config['installationFolder']); - } - - /** - * @param string $type - * - * @return bool - */ - protected function isSourceTypeRepository($type) - { - return in_array($type, ['git', 'hg']); - } - - /** - * @param string $argument - * @param InputInterface $input - * @param OutputInterface $output - * @param string $message - * @return string - */ - protected function getOrAskForArgument($argument, InputInterface $input, OutputInterface $output, $message = null) - { - $inputArgument = $input->getArgument($argument); - if ($inputArgument === null) { - $message = $this->getArgumentMessage($argument, $message); - - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); - return $dialog->ask($input, $output, new Question($message)); - } - - return $inputArgument; - } - - /** - * @param array $entries zero-indexed array of entries (represented by strings) to select from - * @param InputInterface $input - * @param OutputInterface $output - * @param string $question - * @return mixed - */ - protected function askForArrayEntry(array $entries, InputInterface $input, OutputInterface $output, $question) - { - $validator = function ($typeInput) use ($entries) { - if (!in_array($typeInput, range(0, count($entries)))) { - throw new InvalidArgumentException('Invalid type'); - } - - return $typeInput; - }; - - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); - $question = new ChoiceQuestion( - "{$question}", - $entries - ); - $question->setValidator($validator); - - $selected = $dialog->ask($input, $output, $question); - - return $entries[$selected]; - } - - /** - * @param string $argument - * @param string $message [optional] - * @return string - */ - protected function getArgumentMessage($argument, $message = null) - { - if (null === $message) { - $message = ucfirst($argument); - } - - return sprintf('%s: ', $message); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * @param string $baseNamespace If this is set we can use relative class names. - * - * @return SubCommandFactory - */ - protected function createSubCommandFactory( - InputInterface $input, - OutputInterface $output, - $baseNamespace = '' - ) { - $configBag = new ConfigBag(); - - $commandConfig = $this->getCommandConfig(); - if (empty($commandConfig)) { - $commandConfig = []; - } - - return new SubCommandFactory( - $this, - $baseNamespace, - $input, - $output, - $commandConfig, - $configBag - ); - } - - public function getTableHelper(): TableHelper - { - return $this->getHelper('table'); - } - - protected function configure() - { - if ($this instanceof AbstractMagentoCommandFormatInterface) { - $this->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' - ); - } - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $this->detectMagento($output); - if (!$this->initMagento()) { - return Command::FAILURE; - } - - if (static::COMMAND_SECTION_TITLE_TEXT && $input->getOption('format') === null) { - $this->writeSection($output, static::COMMAND_SECTION_TITLE_TEXT); - } - - $data = $this->getData($input, $output); - - if (count($data) > 0) { - $header = array_keys(reset($data)); - $tableHelper = $this->getTableHelper(); - $tableHelper - ->setHeaders($header) - ->renderByFormat($output, $data, $input->getOption('format')); - } else { - $output->writeln(sprintf('%s', static::NO_DATA_MESSAGE)); - } - - return Command::SUCCESS; - } - - protected function _getMage(): Mage_Core_Model_App - { - return Mage::app(); - } } diff --git a/src/N98/Magento/Command/AbstractMagentoStoreConfigCommand.php b/src/N98/Magento/Command/AbstractMagentoStoreConfigCommand.php index cf7ba3594..3fd055798 100644 --- a/src/N98/Magento/Command/AbstractMagentoStoreConfigCommand.php +++ b/src/N98/Magento/Command/AbstractMagentoStoreConfigCommand.php @@ -4,257 +4,13 @@ namespace N98\Magento\Command; -use Exception; -use Mage; -use Mage_Core_Model_App; -use Mage_Core_Model_Store; -use Mage_Core_Model_Store_Exception; -use N98\Util\Console\Helper\IoHelper; -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\StringInput; -use Symfony\Component\Console\Output\NullOutput; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Question\Question; - -abstract class AbstractMagentoStoreConfigCommand extends AbstractMagentoCommand +/** + * Class AbstractMagentoCommand + * + * @package N98\Magento\Command + * @deprecated v3.0.0 + * @see AbstractStoreConfigCommand + */ +abstract class AbstractMagentoStoreConfigCommand extends AbstractStoreConfigCommand { - public const COMMAND_OPTION_OFF = 'off'; - - public const COMMAND_OPTION_ON = 'on'; - - /** - * @var string - */ - public const SCOPE_STORE_VIEW = 'store'; - - /** - * @var string - */ - public const SCOPE_WEBSITE = 'website'; - - /** - * @var string - */ - public const SCOPE_GLOBAL = 'global'; - - /** - * Store view or global by additional option - */ - public const SCOPE_STORE_VIEW_GLOBAL = 'store_view_global'; - - /** - * @var string - */ - protected string $configPath = ''; - - /** - * @var string - */ - protected string $toggleComment = ''; - - /** - * @var string - */ - protected string $falseName = 'disabled'; - - /** - * @var string - */ - protected string $trueName = 'enabled'; - - /** - * Add admin store to interactive prompt - * - * @var bool - */ - protected bool $withAdminStore = false; - - /** - * @var string - */ - protected string $scope = self::SCOPE_STORE_VIEW; - - protected function configure(): void - { - $this - ->addOption( - self::COMMAND_OPTION_ON, - null, - InputOption::VALUE_NONE, - 'Switch on' - ) - ->addOption( - self::COMMAND_OPTION_OFF, - null, - InputOption::VALUE_NONE, - 'Switch off' - ) - ; - - if ($this->scope == self::SCOPE_STORE_VIEW_GLOBAL) { - $this->addOption('global', null, InputOption::VALUE_NONE, 'Set value on default scope'); - } - - if ($this->scope == self::SCOPE_STORE_VIEW || $this->scope == self::SCOPE_STORE_VIEW_GLOBAL) { - $this->addArgument('store', InputArgument::OPTIONAL, 'Store code or ID'); - } - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * @return int - * @throws Mage_Core_Model_Store_Exception - * @throws Exception - */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->detectMagento($output); - $this->initMagento(); - - $runOnStoreView = false; - if ($this->scope == self::SCOPE_STORE_VIEW - || ($this->scope == self::SCOPE_STORE_VIEW_GLOBAL && !$input->getOption('global')) - ) { - $runOnStoreView = true; - } - - if ($runOnStoreView) { - $store = $this->_initStore($input, $output); - } else { - $store = Mage::app()->getStore(Mage_Core_Model_App::ADMIN_STORE_ID); - } - - if ($input->getOption(self::COMMAND_OPTION_ON)) { - $isFalse = true; - } elseif ($input->getOption(self::COMMAND_OPTION_OFF)) { - $isFalse = false; - } else { - $isFalse = !Mage::getStoreConfigFlag($this->configPath, $store->getId()); - } - - $this->_beforeSave($store, $isFalse); - - Mage::app()->getConfig()->saveConfig( - $this->configPath, - $isFalse ? 1 : 0, - $store->getId() == Mage_Core_Model_App::ADMIN_STORE_ID ? 'default' : 'stores', - $store->getId() - ); - - $comment = - '' . $this->toggleComment . ' ' - . '' . (!$isFalse ? $this->falseName : $this->trueName) . '' - . ($runOnStoreView ? ' for store ' . $store->getCode() . '' : ''); - - $output->writeln($comment); - - $this->_afterSave($store, $isFalse); - - $input = new StringInput('cache:flush'); - $this->getApplication()->run($input, new NullOutput()); - - return Command::SUCCESS; - } - - /** - * Determine if a developer restriction is in place, and if we're enabling something that will use it - * then notify and ask if it needs to be changed from its current value. - * - * @param Mage_Core_Model_Store $store - * @param bool $enabled - * @return void - */ - protected function detectAskAndSetDeveloperIp(Mage_Core_Model_Store $store, bool $enabled): void - { - if (!$enabled) { - // No need to notify about developer IP restrictions if we're disabling template hints etc - return; - } - - if (!$devRestriction = $store->getConfig('dev/restrict/allow_ips')) { - return; - } - - /** @var IoHelper $helper */ - $helper = $this->getHelper('io'); - $this->askAndSetDeveloperIp($helper->getInput(), $helper->getOutput(), $store, $devRestriction); - } - - /** - * Ask if the developer IP should be changed, and change it if required - * - * @param InputInterface $input - * @param OutputInterface $output - * @param Mage_Core_Model_Store $store - * @param string|null $devRestriction - * @return void - */ - protected function askAndSetDeveloperIp( - InputInterface $input, - OutputInterface $output, - Mage_Core_Model_Store $store, - ?string $devRestriction - ): void { - $output->writeln( - sprintf( - 'Please note: developer IP restriction is enabled for %s.', - $devRestriction - ) - ); - - $dialog = $this->getQuestionHelper(); - $question = new Question('Change developer IP? Enter a new IP to change or leave blank: '); - $newDeveloperIp = $dialog->ask($input, $output, $question); - - if (empty($newDeveloperIp)) { - return; - } - - $this->setDeveloperIp($store, $newDeveloperIp); - $output->writeln(sprintf('New developer IP restriction set to %s', $newDeveloperIp)); - } - - /** - * Set the restricted IP for developer access - * - * @param Mage_Core_Model_Store $store - * @param string $newDeveloperIp - */ - protected function setDeveloperIp(Mage_Core_Model_Store $store, string $newDeveloperIp): void - { - Mage::getModel('core/config') - ->saveConfig('dev/restrict/allow_ips', $newDeveloperIp, 'stores', $store->getId()); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * @return mixed - */ - protected function _initStore(InputInterface $input, OutputInterface $output) - { - $parameterHelper = $this->getParameterHelper(); - - return $parameterHelper->askStore($input, $output, 'store', $this->withAdminStore); - } - - /** - * @param Mage_Core_Model_Store $store - * @param bool $disabled - */ - protected function _beforeSave(Mage_Core_Model_Store $store, bool $disabled): void - { - } - - /** - * @param Mage_Core_Model_Store $store - * @param bool $disabled - */ - protected function _afterSave(Mage_Core_Model_Store $store, bool $disabled): void - { - } } diff --git a/src/N98/Magento/Command/AbstractStoreConfigCommand.php b/src/N98/Magento/Command/AbstractStoreConfigCommand.php new file mode 100644 index 000000000..8973f747d --- /dev/null +++ b/src/N98/Magento/Command/AbstractStoreConfigCommand.php @@ -0,0 +1,265 @@ +addOption( + self::COMMAND_OPTION_ON, + null, + InputOption::VALUE_NONE, + 'Switch on' + ) + ->addOption( + self::COMMAND_OPTION_OFF, + null, + InputOption::VALUE_NONE, + 'Switch off' + ) + ; + + if ($this->scope == self::SCOPE_STORE_VIEW_GLOBAL) { + $this->addOption('global', null, InputOption::VALUE_NONE, 'Set value on default scope'); + } + + if ($this->scope == self::SCOPE_STORE_VIEW || $this->scope == self::SCOPE_STORE_VIEW_GLOBAL) { + $this->addArgument('store', InputArgument::OPTIONAL, 'Store code or ID'); + } + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return int + * @throws Mage_Core_Model_Store_Exception + * @throws Exception + */ + protected function execute(InputInterface $input, OutputInterface $output): int + { + $this->detectMagento($output); + $this->initMagento(); + + $runOnStoreView = false; + if ($this->scope == self::SCOPE_STORE_VIEW + || ($this->scope == self::SCOPE_STORE_VIEW_GLOBAL && !$input->getOption('global')) + ) { + $runOnStoreView = true; + } + + if ($runOnStoreView) { + $store = $this->_initStore($input, $output); + } else { + $store = Mage::app()->getStore(Mage_Core_Model_App::ADMIN_STORE_ID); + } + + if ($input->getOption(self::COMMAND_OPTION_ON)) { + $isFalse = true; + } elseif ($input->getOption(self::COMMAND_OPTION_OFF)) { + $isFalse = false; + } else { + $isFalse = !Mage::getStoreConfigFlag($this->configPath, $store->getId()); + } + + $this->_beforeSave($store, $isFalse); + + Mage::app()->getConfig()->saveConfig( + $this->configPath, + $isFalse ? 1 : 0, + $store->getId() == Mage_Core_Model_App::ADMIN_STORE_ID ? 'default' : 'stores', + $store->getId() + ); + + $comment = + '' . $this->toggleComment . ' ' + . '' . (!$isFalse ? $this->falseName : $this->trueName) . '' + . ($runOnStoreView ? ' for store ' . $store->getCode() . '' : ''); + + $output->writeln($comment); + + $this->_afterSave($store, $isFalse); + + $input = new StringInput('cache:flush'); + $this->getApplication()->run($input, new NullOutput()); + + return Command::SUCCESS; + } + + /** + * Determine if a developer restriction is in place, and if we're enabling something that will use it + * then notify and ask if it needs to be changed from its current value. + * + * @param Mage_Core_Model_Store $store + * @param bool $enabled + * @return void + */ + protected function detectAskAndSetDeveloperIp(Mage_Core_Model_Store $store, bool $enabled): void + { + if (!$enabled) { + // No need to notify about developer IP restrictions if we're disabling template hints etc + return; + } + + if (!$devRestriction = $store->getConfig('dev/restrict/allow_ips')) { + return; + } + + /** @var IoHelper $helper */ + $helper = $this->getHelper('io'); + $this->askAndSetDeveloperIp($helper->getInput(), $helper->getOutput(), $store, $devRestriction); + } + + /** + * Ask if the developer IP should be changed, and change it if required + * + * @param InputInterface $input + * @param OutputInterface $output + * @param Mage_Core_Model_Store $store + * @param string|null $devRestriction + * @return void + */ + protected function askAndSetDeveloperIp( + InputInterface $input, + OutputInterface $output, + Mage_Core_Model_Store $store, + ?string $devRestriction + ): void { + $output->writeln( + sprintf( + 'Please note: developer IP restriction is enabled for %s.', + $devRestriction + ) + ); + + $dialog = $this->getQuestionHelper(); + $question = new Question('Change developer IP? Enter a new IP to change or leave blank: '); + $newDeveloperIp = $dialog->ask($input, $output, $question); + + if (empty($newDeveloperIp)) { + return; + } + + $this->setDeveloperIp($store, $newDeveloperIp); + $output->writeln(sprintf('New developer IP restriction set to %s', $newDeveloperIp)); + } + + /** + * Set the restricted IP for developer access + * + * @param Mage_Core_Model_Store $store + * @param string $newDeveloperIp + */ + protected function setDeveloperIp(Mage_Core_Model_Store $store, string $newDeveloperIp): void + { + Mage::getModel('core/config') + ->saveConfig('dev/restrict/allow_ips', $newDeveloperIp, 'stores', $store->getId()); + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return mixed + */ + protected function _initStore(InputInterface $input, OutputInterface $output) + { + $parameterHelper = $this->getParameterHelper(); + + return $parameterHelper->askStore($input, $output, 'store', $this->withAdminStore); + } + + /** + * @param Mage_Core_Model_Store $store + * @param bool $disabled + */ + protected function _beforeSave(Mage_Core_Model_Store $store, bool $disabled): void + { + } + + /** + * @param Mage_Core_Model_Store $store + * @param bool $disabled + */ + protected function _afterSave(Mage_Core_Model_Store $store, bool $disabled): void + { + } +} diff --git a/src/N98/Magento/Command/AbstractMagentoCommandFormatInterface.php b/src/N98/Magento/Command/CommandFormatInterface.php similarity index 77% rename from src/N98/Magento/Command/AbstractMagentoCommandFormatInterface.php rename to src/N98/Magento/Command/CommandFormatInterface.php index 15f4939df..d03132001 100644 --- a/src/N98/Magento/Command/AbstractMagentoCommandFormatInterface.php +++ b/src/N98/Magento/Command/CommandFormatInterface.php @@ -7,7 +7,12 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -interface AbstractMagentoCommandFormatInterface +/** + * Interface AbstractCommandFormatInterface + * + * @package N98\Magento\Command + */ +interface CommandFormatInterface { /** * @param InputInterface $input diff --git a/src/N98/Magento/Command/OpenBrowserCommand.php b/src/N98/Magento/Command/OpenBrowserCommand.php index 741242fed..09c94cb21 100644 --- a/src/N98/Magento/Command/OpenBrowserCommand.php +++ b/src/N98/Magento/Command/OpenBrowserCommand.php @@ -2,10 +2,9 @@ namespace N98\Magento\Command; -use Mage; +use Mage_Core_Exception; use Mage_Core_Model_App; use Mage_Core_Model_Store; -use N98\Util\Console\Helper\ParameterHelper; use N98\Util\Exec; use N98\Util\OperatingSystem; use RuntimeException; @@ -13,9 +12,9 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class OpenBrowserCommand extends AbstractMagentoCommand +class OpenBrowserCommand extends AbstractCommand { - protected function configure() + protected function configure(): void { $this ->setName('open-browser') @@ -27,7 +26,7 @@ protected function configure() /** * @return bool */ - public function isEnabled() + public function isEnabled(): bool { return Exec::allowed(); } @@ -36,23 +35,21 @@ public function isEnabled() * @param InputInterface $input * @param OutputInterface $output * @return int + * @throws Mage_Core_Exception */ protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output); - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); - /** @var ParameterHelper $parameterHelper */ - $parameterHelper = $this->getHelper('parameter'); + $parameterHelper = $this->getParameterHelper(); $store = $parameterHelper->askStore($input, $output, 'store', true); if ($store->getId() == Mage_Core_Model_App::ADMIN_STORE_ID) { - $adminFrontName = (string) Mage::getConfig()->getNode('admin/routers/adminhtml/args/frontName'); + $adminFrontName = (string) $this->_getMageConfig()->getNode('admin/routers/adminhtml/args/frontName'); $url = rtrim($store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB), '/') . '/' . $adminFrontName; } else { - $url = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK) . '?___store=' . $store->getCode(); + $url = $store->getBaseUrl() . '?___store=' . $store->getCode(); } $output->writeln('Opening URL ' . $url . ' in browser'); diff --git a/src/N98/Magento/Command/ScriptCommand.php b/src/N98/Magento/Command/ScriptCommand.php index ce4aca091..2808799bf 100644 --- a/src/N98/Magento/Command/ScriptCommand.php +++ b/src/N98/Magento/Command/ScriptCommand.php @@ -7,7 +7,6 @@ use N98\Util\BinaryString; use N98\Util\Exec; use RuntimeException; -use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -16,7 +15,7 @@ use Symfony\Component\Console\Question\ChoiceQuestion; use Symfony\Component\Console\Question\Question; -class ScriptCommand extends AbstractMagentoCommand +class ScriptCommand extends AbstractCommand { /** * @var array @@ -33,7 +32,7 @@ class ScriptCommand extends AbstractMagentoCommand */ protected $_stopOnError = false; - protected function configure() + protected function configure(): void { $this ->setName('script') @@ -89,7 +88,7 @@ protected function configure() * \${magento.root} -> Magento Root-Folder * \${magento.version} -> Magento Version i.e. 1.7.0.2 -* \${magento.edition} -> Magento Edition -> Community or Enterprise +* \${magento.edition} -> Magento Edition -> Community * \${magerun.version} -> Magerun version i.e. 1.66.0 * \${php.version} -> PHP Version * \${script.file} -> Current script file path @@ -218,8 +217,7 @@ protected function registerVariable(InputInterface $input, OutputInterface $outp return $this->scriptVars[$matches[1]]; } - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); /** * Check for select "?[" @@ -262,7 +260,7 @@ protected function registerVariable(InputInterface $input, OutputInterface $outp * @param string $commandString * @throws RuntimeException */ - protected function runMagerunCommand(InputInterface $input, OutputInterface $output, $commandString) + protected function runMagerunCommand(InputInterface $input, OutputInterface $output, string $commandString) { $this->getApplication()->setAutoExit(false); $commandString = $this->_replaceScriptVars($commandString); @@ -278,7 +276,7 @@ protected function runMagerunCommand(InputInterface $input, OutputInterface $out * @param string $commandString * @return string */ - protected function _prepareShellCommand($commandString) + protected function _prepareShellCommand(string $commandString) { $commandString = ltrim($commandString, '!'); @@ -312,10 +310,10 @@ protected function initScriptVars() /** * @param OutputInterface $output - * @param string $commandString + * @param string $commandString * @internal param $returnValue */ - protected function runShellCommand(OutputInterface $output, $commandString) + protected function runShellCommand(OutputInterface $output, string $commandString) { $commandString = $this->_prepareShellCommand($commandString); $returnValue = shell_exec($commandString); @@ -326,13 +324,10 @@ protected function runShellCommand(OutputInterface $output, $commandString) /** * @param string $commandString - * * @return string */ - protected function _replaceScriptVars($commandString) + protected function _replaceScriptVars(string $commandString): string { - $commandString = str_replace(array_keys($this->scriptVars), $this->scriptVars, $commandString); - - return $commandString; + return str_replace(array_keys($this->scriptVars), $this->scriptVars, $commandString); } } diff --git a/src/N98/Magento/Command/SelfUpdateCommand.php b/src/N98/Magento/Command/SelfUpdateCommand.php index c9d6f2487..710aa5ae6 100644 --- a/src/N98/Magento/Command/SelfUpdateCommand.php +++ b/src/N98/Magento/Command/SelfUpdateCommand.php @@ -1,5 +1,7 @@ * @author Christian Münch */ -class SelfUpdateCommand extends AbstractMagentoCommand +class SelfUpdateCommand extends AbstractCommand { public const VERSION_TXT_URL_UNSTABLE = 'https://raw.githubusercontent.com/netz98/n98-magerun/develop/version.txt'; public const MAGERUN_DOWNLOAD_URL_UNSTABLE = 'https://files.magerun.net/n98-magerun-dev.phar'; @@ -30,7 +32,7 @@ class SelfUpdateCommand extends AbstractMagentoCommand public const CHANGELOG_DOWNLOAD_URL_UNSTABLE = 'https://raw.github.com/netz98/n98-magerun/develop/CHANGELOG.md'; public const CHANGELOG_DOWNLOAD_URL_STABLE = 'https://raw.github.com/netz98/n98-magerun/master/CHANGELOG.md'; - protected function configure() + protected function configure(): void { $this ->setName('self-update') @@ -52,18 +54,18 @@ protected function configure() /** * @return bool */ - public function isEnabled() + public function isEnabled(): bool { return $this->getApplication()->isPharMode(); } /** - * @param \Symfony\Component\Console\Input\InputInterface $input - * @param \Symfony\Component\Console\Output\OutputInterface $output + * @param InputInterface $input + * @param OutputInterface $output * @return int - * @throws \Exception + * @throws Exception */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $isDryRun = $input->getOption('dry-run'); $localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0]; @@ -145,13 +147,13 @@ protected function execute(InputInterface $input, OutputInterface $output) * @param int $statusCode * @return void */ - protected function _exit($statusCode = 0) + protected function _exit(int $statusCode = 0) { exit($statusCode); } /** - * @param \Symfony\Component\Console\Output\OutputInterface $output + * @param OutputInterface $output * @param string $remoteUrl * @param string $tempFilename */ @@ -227,7 +229,7 @@ private function replaceExistingPharFile($tempFilename, $localFilename) /** * Download changelog * - * @param \Symfony\Component\Console\Output\OutputInterface $output + * @param OutputInterface $output * @param bool $loadUnstable * @return string */ diff --git a/src/N98/Util/Console/Helper/ParameterHelper.php b/src/N98/Util/Console/Helper/ParameterHelper.php index 33ab3a0eb..57178ec80 100644 --- a/src/N98/Util/Console/Helper/ParameterHelper.php +++ b/src/N98/Util/Console/Helper/ParameterHelper.php @@ -6,6 +6,7 @@ use InvalidArgumentException; use JsonSchema\Validator; use Mage; +use Mage_Core_Model_App; use Mage_Core_Model_Website; use N98\Util\Validator\FakeMetadataFactory; use RuntimeException; @@ -25,6 +26,7 @@ use Symfony\Component\Validator\ConstraintValidatorFactory; use Symfony\Component\Validator\ConstraintViolationInterface; use Symfony\Component\Validator\ConstraintViolationListInterface; +use Symfony\Component\Validator\Validation; /** * Helper to init some parameters @@ -64,7 +66,7 @@ public function askStore( $argumentName = 'store', $withDefaultStore = false ) { - /* @var \Mage_Core_Model_App $storeManager */ + /* @var Mage_Core_Model_App $storeManager */ $storeManager = Mage::app(); try { @@ -99,7 +101,6 @@ public function askStore( return $stores[$typeInput]; }; - /* @var QuestionHelper $dialog */ $dialog = new QuestionHelper(); $question = new ChoiceQuestion('Please select a store: ', $choices); $question->setValidator($validator); @@ -120,24 +121,22 @@ public function askStore( * @param InputInterface $input * @param OutputInterface $output * @param string $argumentName - * - * @return mixed + * @return Mage_Core_Model_Website|null * @throws InvalidArgumentException + * @throws \Mage_Core_Exception */ - public function askWebsite(InputInterface $input, OutputInterface $output, $argumentName = 'website') + public function askWebsite(InputInterface $input, OutputInterface $output, string $argumentName = 'website') { - /* @var \Mage_Core_Model_App $storeManager */ + /* @var Mage_Core_Model_App $storeManager */ $storeManager = Mage::app(); - $website = null; $argumentValue = $input->getArgument($argumentName); $hasArgument = $argumentValue !== null; if ($hasArgument) { try { /* @var Mage_Core_Model_Website $website */ - $website = $storeManager->getWebsite($argumentValue); - return $website; + return $storeManager->getWebsite($argumentValue); } catch (Exception $e) { // catch all exceptions } @@ -156,26 +155,23 @@ public function askWebsite(InputInterface $input, OutputInterface $output, $argu return $websites[$typeInput]; }; - /* @var QuestionHelper $dialog */ $dialog = new QuestionHelper(); $question = new ChoiceQuestion('Please select a website: ', $choices); $question->setValidator($validator); $websiteId = $dialog->ask($input, $output, $question); - $website = $storeManager->getWebsite($websiteId); - - return $website; + return $storeManager->getWebsite($websiteId); } /** * @see askWebsite + * @param Mage_Core_Model_App $storeManager * @return array websites (integers with website IDs, 0-indexed) and question array (strings) */ - private function websitesQuestion($storeManager) + private function websitesQuestion(Mage_Core_Model_App $storeManager) { $websites = []; $question = []; - /* @var Mage_Core_Model_Website $website */ foreach ($storeManager->getWebsites() as $website) { $websites[] = $website->getId(); $question[] = sprintf('%s - %s', $website->getCode(), $website->getName()); @@ -188,16 +184,21 @@ private function websitesQuestion($storeManager) * @param InputInterface $input * @param OutputInterface $output * @param string $argumentName - * * @return string */ - public function askEmail(InputInterface $input, OutputInterface $output, $argumentName = 'email') + public function askEmail(InputInterface $input, OutputInterface $output, string $argumentName = 'email') { $constraints = new Collection( ['email' => [new NotBlank(), new Email()]] ); - return $this->validateArgument($input, $output, $argumentName, $input->getArgument($argumentName), $constraints); + return $this->validateArgument( + $input, + $output, + $argumentName, + $input->getArgument($argumentName), + $constraints + ); } /** @@ -211,13 +212,16 @@ public function askEmail(InputInterface $input, OutputInterface $output, $argume public function askPassword( InputInterface $input, OutputInterface $output, - $argumentName = 'password', - $needDigits = true + string $argumentName = 'password', + bool $needDigits = true ) { $validators = []; if ($needDigits) { - $regex = ['pattern' => '/^(?=.*\d)(?=.*[a-zA-Z])/', 'message' => 'Password must contain letters and at least one digit']; + $regex = [ + 'pattern' => '/^(?=.*\d)(?=.*[a-zA-Z])/', + 'message' => 'Password must contain letters and at least one digit' + ]; $validators[] = new Regex($regex); } @@ -227,11 +231,17 @@ public function askPassword( ['password' => $validators] ); - return $this->validateArgument($input, $output, $argumentName, $input->getArgument($argumentName), $constraints); + return $this->validateArgument( + $input, + $output, + $argumentName, + $input->getArgument($argumentName), + $constraints + ); } /** - * @param \Symfony\Component\Console\Input\InputInterface $input + * @param InputInterface $input * @param OutputInterface $output * @param string|array $question * @param callable $callback @@ -318,7 +328,7 @@ private function getValidator() protected function initValidator() { if (null === $this->validator) { - $this->validator = \Symfony\Component\Validator\Validation::createValidatorBuilder() + $this->validator = Validation::createValidatorBuilder() ->setConstraintValidatorFactory(new ConstraintValidatorFactory()) ->setMetadataFactory(new FakeMetadataFactory()) ->getValidator(); diff --git a/src/N98/Util/Console/Helper/Table/Renderer/RendererFactory.php b/src/N98/Util/Console/Helper/Table/Renderer/RendererFactory.php index 8aaefd6c1..442be8789 100644 --- a/src/N98/Util/Console/Helper/Table/Renderer/RendererFactory.php +++ b/src/N98/Util/Console/Helper/Table/Renderer/RendererFactory.php @@ -7,7 +7,12 @@ class RendererFactory { - protected static $formats = ['csv' => CsvRenderer::class, 'json' => JsonRenderer::class, 'text' => TextRenderer::class, 'xml' => XmlRenderer::class]; + protected static array $formats = [ + 'csv' => CsvRenderer::class, + 'json' => JsonRenderer::class, + 'text' => TextRenderer::class, + 'xml' => XmlRenderer::class + ]; /** * @param string $format diff --git a/src/N98/Util/Console/Helper/TableHelper.php b/src/N98/Util/Console/Helper/TableHelper.php index 2353b1dbf..88e36e68c 100644 --- a/src/N98/Util/Console/Helper/TableHelper.php +++ b/src/N98/Util/Console/Helper/TableHelper.php @@ -61,7 +61,7 @@ public function renderByFormat(OutputInterface $outputInterface, array $rows, $f $rendererFactory = new RendererFactory(); $renderer = $rendererFactory->create($format); - if ($renderer && $renderer instanceof RendererInterface) { + if ($renderer instanceof RendererInterface) { foreach ($rows as &$row) { if (!empty($this->headers)) { $row = array_combine($this->headers, $row); diff --git a/src/N98/Util/Filesystem.php b/src/N98/Util/Filesystem.php index 5b1346409..7e9674f37 100644 --- a/src/N98/Util/Filesystem.php +++ b/src/N98/Util/Filesystem.php @@ -130,11 +130,11 @@ public function recursiveRemoveDirectory($directory, $empty = false) * @param int $bytes * @param int $decimals * + * @return string * @see http://www.php.net/manual/en/function.filesize.php#106569 * - * @return string */ - public static function humanFileSize($bytes, $decimals = 2) + public static function humanFileSize(int $bytes, int $decimals = 2): string { $units = ['B', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']; $factor = floor((strlen($bytes) - 1) / 3); diff --git a/tests/N98/Magento/_ApplicationTestComposer/FooCommand.php b/tests/N98/Magento/_ApplicationTestComposer/FooCommand.php index d75e794ba..7038c2eec 100644 --- a/tests/N98/Magento/_ApplicationTestComposer/FooCommand.php +++ b/tests/N98/Magento/_ApplicationTestComposer/FooCommand.php @@ -2,13 +2,13 @@ namespace Acme; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class FooCommand extends AbstractMagentoCommand +class FooCommand extends AbstractCommand { - protected function configure() + protected function configure(): void { $this->setName('acme:foo'); } diff --git a/tests/N98/Magento/_ApplicationTestModules/test_dummy_module/src/TestModule/FooCommand.php b/tests/N98/Magento/_ApplicationTestModules/test_dummy_module/src/TestModule/FooCommand.php index 46b7d5b47..16f6c37ab 100644 --- a/tests/N98/Magento/_ApplicationTestModules/test_dummy_module/src/TestModule/FooCommand.php +++ b/tests/N98/Magento/_ApplicationTestModules/test_dummy_module/src/TestModule/FooCommand.php @@ -2,13 +2,13 @@ namespace TestModule; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class FooCommand extends AbstractMagentoCommand +class FooCommand extends AbstractCommand { - protected function configure() + protected function configure(): void { $this ->setName('testmodule:foo') diff --git a/tests/N98/Magento/_ApplicationTestSrc/N98MagerunTest/TestDummyCommand.php b/tests/N98/Magento/_ApplicationTestSrc/N98MagerunTest/TestDummyCommand.php index 2c63eb50a..2305b9fe2 100644 --- a/tests/N98/Magento/_ApplicationTestSrc/N98MagerunTest/TestDummyCommand.php +++ b/tests/N98/Magento/_ApplicationTestSrc/N98MagerunTest/TestDummyCommand.php @@ -2,13 +2,13 @@ namespace N98MagerunTest; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class TestDummyCommand extends AbstractMagentoCommand +class TestDummyCommand extends AbstractCommand { - protected function configure() + protected function configure(): void { $this ->setName('n98mageruntest:test:dummy') From f985edbffa70b367d3fcefe7e890ab036dde306a Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 21 Jun 2024 10:46:49 +0200 Subject: [PATCH 117/136] [skip ci] Updated open-browser command --- .../Magento/Command/OpenBrowserCommand.php | 40 ++++++++++++++++--- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/src/N98/Magento/Command/OpenBrowserCommand.php b/src/N98/Magento/Command/OpenBrowserCommand.php index 09c94cb21..5d5d2b56d 100644 --- a/src/N98/Magento/Command/OpenBrowserCommand.php +++ b/src/N98/Magento/Command/OpenBrowserCommand.php @@ -1,5 +1,7 @@ (experimental).'; + protected function configure(): void { $this - ->setName('open-browser') - ->addArgument('store', InputArgument::OPTIONAL, 'Store code or ID') - ->setDescription('Open current project in browser (experimental)') + ->addArgument( + self::COMMAND_ARGUMENT_STORE, + InputArgument::OPTIONAL, + 'Store code or ID' + ) ; } @@ -44,18 +70,20 @@ protected function execute(InputInterface $input, OutputInterface $output): int $parameterHelper = $this->getParameterHelper(); - $store = $parameterHelper->askStore($input, $output, 'store', true); + /** @var Mage_Core_Model_Store $store */ + $store = $parameterHelper->askStore($input, $output, self::COMMAND_ARGUMENT_STORE, true); if ($store->getId() == Mage_Core_Model_App::ADMIN_STORE_ID) { $adminFrontName = (string) $this->_getMageConfig()->getNode('admin/routers/adminhtml/args/frontName'); $url = rtrim($store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB), '/') . '/' . $adminFrontName; } else { $url = $store->getBaseUrl() . '?___store=' . $store->getCode(); } - $output->writeln('Opening URL ' . $url . ' in browser'); + $output->writeln(sprintf('Opening URL %s in browser', $url)); $opener = $this->resolveOpenerCommand($output); Exec::run(escapeshellcmd($opener . ' ' . $url)); - return 0; + + return Command::SUCCESS; } /** From 1da37d7a9986bc5dda37e7a63390a29018d4d2b1 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 21 Jun 2024 13:36:23 +0200 Subject: [PATCH 118/136] [skip ci] Added symfony/filesystem + patch for readFile() --- composer.json | 13 ++++++++++++- composer.lock | 6 +++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index de8b4ea43..4ea9a76ac 100644 --- a/composer.json +++ b/composer.json @@ -13,13 +13,14 @@ "magerun" ], "require": { - "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0", + "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", "fakerphp/faker": "^1.20", "n98/junit-xml": "~1.0", "psy/psysh": "~0.4", "rmccue/requests": "^2.0", "symfony/console": "~5.4", "symfony/event-dispatcher": "~5.4", + "symfony/filesystem": "^5.4", "symfony/finder": "~5.4", "symfony/process": "~5.4", "symfony/validator": "~5.4", @@ -62,7 +63,17 @@ "bin": [ "bin/n98-magerun" ], + "extra": { + "patches": { + "symfony/filesystem": { + "Add readFile() to symfony/filesystem (v7.1)": "https://raw.githubusercontent.com/sreichel/openmage-patches/main/symfony/filesystem.patch" + } + } + }, "config": { + "allow-plugins": { + "cweagans/composer-patches": true + }, "platform": { "php": "7.4.0" }, diff --git a/composer.lock b/composer.lock index 9310d3bcc..744ac02d6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "351863d5709b14b83e3f8638985c6359", + "content-hash": "9ca21ed212dafb705c8a94924a7f6714", "packages": [ { "name": "fakerphp/faker", @@ -4655,7 +4655,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0", + "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", "ext-pdo": "*", "ext-libxml": "*", "ext-json": "*" @@ -4666,5 +4666,5 @@ "platform-overrides": { "php": "7.4.0" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } From 24bd062e5a4ccb3ec71de4de6c556a2b02ae7527 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 21 Jun 2024 13:38:44 +0200 Subject: [PATCH 119/136] [skip ci] Updated composer.json --- composer.json | 8 +-- composer.lock | 137 ++++++++++++++++++++++++++------------------------ 2 files changed, 74 insertions(+), 71 deletions(-) diff --git a/composer.json b/composer.json index 4ea9a76ac..d55cb34a7 100644 --- a/composer.json +++ b/composer.json @@ -14,6 +14,9 @@ ], "require": { "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", + "ext-json": "*", + "ext-libxml": "*", + "ext-pdo": "*", "fakerphp/faker": "^1.20", "n98/junit-xml": "~1.0", "psy/psysh": "~0.4", @@ -25,10 +28,7 @@ "symfony/process": "~5.4", "symfony/validator": "~5.4", "symfony/yaml": "~5.4", - "twig/twig": "^3.7.1", - "ext-pdo": "*", - "ext-libxml": "*", - "ext-json": "*" + "twig/twig": "^3.7.1" }, "require-dev": { "ext-simplexml": "*", diff --git a/composer.lock b/composer.lock index 744ac02d6..96b1010e7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9ca21ed212dafb705c8a94924a7f6714", + "content-hash": "ab8065053994350841e8aec111da3a6f", "packages": [ { "name": "fakerphp/faker", @@ -760,6 +760,73 @@ ], "time": "2022-01-02T09:53:40+00:00" }, + { + "name": "symfony/filesystem", + "version": "v5.4.40", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "26dd9912df6940810ea00f8f53ad48d6a3424995" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/26dd9912df6940810ea00f8f53ad48d6a3424995", + "reference": "26dd9912df6940810ea00f8f53ad48d6a3424995", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.8", + "symfony/polyfill-php80": "^1.16" + }, + "require-dev": { + "symfony/process": "^5.4|^6.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides basic utilities for the filesystem", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/filesystem/tree/v5.4.40" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-05-31T14:33:22+00:00" + }, { "name": "symfony/finder", "version": "v5.4.27", @@ -4403,70 +4470,6 @@ }, "time": "2022-08-31T10:31:18+00:00" }, - { - "name": "symfony/filesystem", - "version": "v5.4.25", - "source": { - "type": "git", - "url": "https://github.com/symfony/filesystem.git", - "reference": "0ce3a62c9579a53358d3a7eb6b3dfb79789a6364" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/0ce3a62c9579a53358d3a7eb6b3dfb79789a6364", - "reference": "0ce3a62c9579a53358d3a7eb6b3dfb79789a6364", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-mbstring": "~1.8", - "symfony/polyfill-php80": "^1.16" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Filesystem\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides basic utilities for the filesystem", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/filesystem/tree/v5.4.25" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2023-05-31T13:04:02+00:00" - }, { "name": "symfony/options-resolver", "version": "v5.4.21", @@ -4656,9 +4659,9 @@ "prefer-lowest": false, "platform": { "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", - "ext-pdo": "*", + "ext-json": "*", "ext-libxml": "*", - "ext-json": "*" + "ext-pdo": "*" }, "platform-dev": { "ext-simplexml": "*" From 68be0b836a3c4d136ca4fba823094c6aca450cc8 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 21 Jun 2024 13:43:48 +0200 Subject: [PATCH 120/136] [skip ci] Added cweagans/composer-patches --- composer.json | 1 + composer.lock | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d55cb34a7..9ac9c64c0 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ "ext-json": "*", "ext-libxml": "*", "ext-pdo": "*", + "cweagans/composer-patches": "^1.7", "fakerphp/faker": "^1.20", "n98/junit-xml": "~1.0", "psy/psysh": "~0.4", diff --git a/composer.lock b/composer.lock index 96b1010e7..4527db38a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,56 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ab8065053994350841e8aec111da3a6f", + "content-hash": "69b5f3c3dff49928a24d2f65ba765f73", "packages": [ + { + "name": "cweagans/composer-patches", + "version": "1.7.3", + "source": { + "type": "git", + "url": "https://github.com/cweagans/composer-patches.git", + "reference": "e190d4466fe2b103a55467dfa83fc2fecfcaf2db" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/cweagans/composer-patches/zipball/e190d4466fe2b103a55467dfa83fc2fecfcaf2db", + "reference": "e190d4466fe2b103a55467dfa83fc2fecfcaf2db", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0 || ^2.0", + "php": ">=5.3.0" + }, + "require-dev": { + "composer/composer": "~1.0 || ~2.0", + "phpunit/phpunit": "~4.6" + }, + "type": "composer-plugin", + "extra": { + "class": "cweagans\\Composer\\Patches" + }, + "autoload": { + "psr-4": { + "cweagans\\Composer\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Cameron Eagans", + "email": "me@cweagans.net" + } + ], + "description": "Provides a way to patch Composer packages.", + "support": { + "issues": "https://github.com/cweagans/composer-patches/issues", + "source": "https://github.com/cweagans/composer-patches/tree/1.7.3" + }, + "time": "2022-12-20T22:53:13+00:00" + }, { "name": "fakerphp/faker", "version": "v1.23.0", From 2d89e80a25d5400807a1d09ca34e6b897d43d811 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sat, 22 Jun 2024 12:37:43 +0200 Subject: [PATCH 121/136] [skip ci] Updated composer.json --- composer.json | 2 +- composer.lock | 1618 ++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 1466 insertions(+), 154 deletions(-) diff --git a/composer.json b/composer.json index 9ac9c64c0..af331ada0 100644 --- a/composer.json +++ b/composer.json @@ -67,7 +67,7 @@ "extra": { "patches": { "symfony/filesystem": { - "Add readFile() to symfony/filesystem (v7.1)": "https://raw.githubusercontent.com/sreichel/openmage-patches/main/symfony/filesystem.patch" + "Add readFile() to symfony/filesystem (from v7.1)": "https://github.com/sreichel/openmage-patches/commit/e3f9027a07f64f196685467951f4949f14b5c1fb/n98/magerun/symfony-filesystem.patch" } } }, diff --git a/composer.lock b/composer.lock index 4527db38a..c04cd5712 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "69b5f3c3dff49928a24d2f65ba765f73", + "content-hash": "2531e2450a3bc9018efabb1e41cd58ec", "packages": [ { "name": "cweagans/composer-patches", @@ -220,27 +220,22 @@ }, { "name": "psr/container", - "version": "2.0.2", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", - "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", "shasum": "" }, "require": { "php": ">=7.4.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, "autoload": { "psr-4": { "Psr\\Container\\": "src/" @@ -267,9 +262,9 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/2.0.2" + "source": "https://github.com/php-fig/container/tree/1.1.2" }, - "time": "2021-11-05T16:47:00+00:00" + "time": "2021-11-05T16:50:12+00:00" }, { "name": "psr/event-dispatcher", @@ -579,16 +574,16 @@ }, { "name": "symfony/deprecation-contracts", - "version": "v2.5.2", + "version": "v2.5.3", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66" + "reference": "80d075412b557d41002320b96a096ca65aa2c98d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/80d075412b557d41002320b96a096ca65aa2c98d", + "reference": "80d075412b557d41002320b96a096ca65aa2c98d", "shasum": "" }, "require": { @@ -626,7 +621,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.2" + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.3" }, "funding": [ { @@ -642,20 +637,20 @@ "type": "tidelift" } ], - "time": "2022-01-02T09:53:40+00:00" + "time": "2023-01-24T14:02:46+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v5.4.26", + "version": "v5.4.40", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "5dcc00e03413f05c1e7900090927bb7247cb0aac" + "reference": "a54e2a8a114065f31020d6a89ede83e34c3b27a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/5dcc00e03413f05c1e7900090927bb7247cb0aac", - "reference": "5dcc00e03413f05c1e7900090927bb7247cb0aac", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/a54e2a8a114065f31020d6a89ede83e34c3b27a4", + "reference": "a54e2a8a114065f31020d6a89ede83e34c3b27a4", "shasum": "" }, "require": { @@ -711,7 +706,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v5.4.26" + "source": "https://github.com/symfony/event-dispatcher/tree/v5.4.40" }, "funding": [ { @@ -727,20 +722,20 @@ "type": "tidelift" } ], - "time": "2023-07-06T06:34:20+00:00" + "time": "2024-05-31T14:33:22+00:00" }, { "name": "symfony/event-dispatcher-contracts", - "version": "v2.5.2", + "version": "v2.5.3", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "f98b54df6ad059855739db6fcbc2d36995283fe1" + "reference": "540f4c73e87fd0c71ca44a6aa305d024ac68cb73" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/f98b54df6ad059855739db6fcbc2d36995283fe1", - "reference": "f98b54df6ad059855739db6fcbc2d36995283fe1", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/540f4c73e87fd0c71ca44a6aa305d024ac68cb73", + "reference": "540f4c73e87fd0c71ca44a6aa305d024ac68cb73", "shasum": "" }, "require": { @@ -790,7 +785,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v2.5.2" + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v2.5.3" }, "funding": [ { @@ -806,7 +801,7 @@ "type": "tidelift" } ], - "time": "2022-01-02T09:53:40+00:00" + "time": "2024-01-23T13:51:25+00:00" }, { "name": "symfony/filesystem", @@ -877,16 +872,16 @@ }, { "name": "symfony/finder", - "version": "v5.4.27", + "version": "v5.4.40", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "ff4bce3c33451e7ec778070e45bd23f74214cd5d" + "reference": "f51cff4687547641c7d8180d74932ab40b2205ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/ff4bce3c33451e7ec778070e45bd23f74214cd5d", - "reference": "ff4bce3c33451e7ec778070e45bd23f74214cd5d", + "url": "https://api.github.com/repos/symfony/finder/zipball/f51cff4687547641c7d8180d74932ab40b2205ce", + "reference": "f51cff4687547641c7d8180d74932ab40b2205ce", "shasum": "" }, "require": { @@ -920,7 +915,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v5.4.27" + "source": "https://github.com/symfony/finder/tree/v5.4.40" }, "funding": [ { @@ -936,20 +931,20 @@ "type": "tidelift" } ], - "time": "2023-07-31T08:02:31+00:00" + "time": "2024-05-31T14:33:22+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.28.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb" + "reference": "0424dff1c58f028c451efff2045f5d92410bd540" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", - "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/0424dff1c58f028c451efff2045f5d92410bd540", + "reference": "0424dff1c58f028c451efff2045f5d92410bd540", "shasum": "" }, "require": { @@ -963,9 +958,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -1002,7 +994,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.30.0" }, "funding": [ { @@ -1018,7 +1010,7 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "symfony/polyfill-intl-grapheme", @@ -1103,16 +1095,16 @@ }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.28.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92" + "reference": "a95281b0be0d9ab48050ebd988b967875cdb9fdb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", - "reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/a95281b0be0d9ab48050ebd988b967875cdb9fdb", + "reference": "a95281b0be0d9ab48050ebd988b967875cdb9fdb", "shasum": "" }, "require": { @@ -1123,9 +1115,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -1167,7 +1156,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.30.0" }, "funding": [ { @@ -1183,20 +1172,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.28.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "42292d99c55abe617799667f454222c54c60e229" + "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229", - "reference": "42292d99c55abe617799667f454222c54c60e229", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fd22ab50000ef01661e2a31d850ebaa297f8e03c", + "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c", "shasum": "" }, "require": { @@ -1210,9 +1199,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -1250,7 +1236,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.30.0" }, "funding": [ { @@ -1266,20 +1252,20 @@ "type": "tidelift" } ], - "time": "2023-07-28T09:04:16+00:00" + "time": "2024-06-19T12:30:46+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.28.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "fe2f306d1d9d346a7fee353d0d5012e401e984b5" + "reference": "ec444d3f3f6505bb28d11afa41e75faadebc10a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fe2f306d1d9d346a7fee353d0d5012e401e984b5", - "reference": "fe2f306d1d9d346a7fee353d0d5012e401e984b5", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/ec444d3f3f6505bb28d11afa41e75faadebc10a1", + "reference": "ec444d3f3f6505bb28d11afa41e75faadebc10a1", "shasum": "" }, "require": { @@ -1287,9 +1273,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -1329,7 +1312,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.30.0" }, "funding": [ { @@ -1345,20 +1328,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.28.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5" + "reference": "77fa7995ac1b21ab60769b7323d600a991a90433" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/6caa57379c4aec19c0a12a38b59b26487dcfe4b5", - "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/77fa7995ac1b21ab60769b7323d600a991a90433", + "reference": "77fa7995ac1b21ab60769b7323d600a991a90433", "shasum": "" }, "require": { @@ -1366,9 +1349,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -1412,7 +1392,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.30.0" }, "funding": [ { @@ -1428,20 +1408,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "symfony/polyfill-php81", - "version": "v1.28.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php81.git", - "reference": "7581cd600fa9fd681b797d00b02f068e2f13263b" + "reference": "3fb075789fb91f9ad9af537c4012d523085bd5af" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/7581cd600fa9fd681b797d00b02f068e2f13263b", - "reference": "7581cd600fa9fd681b797d00b02f068e2f13263b", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/3fb075789fb91f9ad9af537c4012d523085bd5af", + "reference": "3fb075789fb91f9ad9af537c4012d523085bd5af", "shasum": "" }, "require": { @@ -1449,9 +1429,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -1491,7 +1468,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-php81/tree/v1.30.0" }, "funding": [ { @@ -1507,20 +1484,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-06-19T12:30:46+00:00" }, { "name": "symfony/process", - "version": "v5.4.28", + "version": "v5.4.40", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "45261e1fccad1b5447a8d7a8e67aa7b4a9798b7b" + "reference": "deedcb3bb4669cae2148bc920eafd2b16dc7c046" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/45261e1fccad1b5447a8d7a8e67aa7b4a9798b7b", - "reference": "45261e1fccad1b5447a8d7a8e67aa7b4a9798b7b", + "url": "https://api.github.com/repos/symfony/process/zipball/deedcb3bb4669cae2148bc920eafd2b16dc7c046", + "reference": "deedcb3bb4669cae2148bc920eafd2b16dc7c046", "shasum": "" }, "require": { @@ -1553,7 +1530,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v5.4.28" + "source": "https://github.com/symfony/process/tree/v5.4.40" }, "funding": [ { @@ -1569,33 +1546,41 @@ "type": "tidelift" } ], - "time": "2023-08-07T10:36:04+00:00" + "time": "2024-05-31T14:33:22+00:00" }, { "name": "symfony/service-contracts", - "version": "v1.1.2", + "version": "v2.5.3", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "191afdcb5804db960d26d8566b7e9a2843cab3a0" + "reference": "a2329596ddc8fd568900e3fc76cba42489ecc7f3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/191afdcb5804db960d26d8566b7e9a2843cab3a0", - "reference": "191afdcb5804db960d26d8566b7e9a2843cab3a0", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/a2329596ddc8fd568900e3fc76cba42489ecc7f3", + "reference": "a2329596ddc8fd568900e3fc76cba42489ecc7f3", "shasum": "" }, "require": { - "php": "^7.1.3" + "php": ">=7.2.5", + "psr/container": "^1.1", + "symfony/deprecation-contracts": "^2.1|^3" + }, + "conflict": { + "ext-psr": "<1.1|>=2" }, "suggest": { - "psr/container": "", "symfony/service-implementation": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-main": "2.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -1628,9 +1613,23 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v1.1.2" + "source": "https://github.com/symfony/service-contracts/tree/v2.5.3" }, - "time": "2019-05-28T07:50:59+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-04-21T15:04:16+00:00" }, { "name": "symfony/string", @@ -1720,16 +1719,16 @@ }, { "name": "symfony/translation-contracts", - "version": "v2.5.2", + "version": "v2.5.3", "source": { "type": "git", "url": "https://github.com/symfony/translation-contracts.git", - "reference": "136b19dd05cdf0709db6537d058bcab6dd6e2dbe" + "reference": "b0073a77ac0b7ea55131020e87b1e3af540f4664" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/136b19dd05cdf0709db6537d058bcab6dd6e2dbe", - "reference": "136b19dd05cdf0709db6537d058bcab6dd6e2dbe", + "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/b0073a77ac0b7ea55131020e87b1e3af540f4664", + "reference": "b0073a77ac0b7ea55131020e87b1e3af540f4664", "shasum": "" }, "require": { @@ -1778,7 +1777,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/translation-contracts/tree/v2.5.2" + "source": "https://github.com/symfony/translation-contracts/tree/v2.5.3" }, "funding": [ { @@ -1794,7 +1793,7 @@ "type": "tidelift" } ], - "time": "2022-06-27T16:58:25+00:00" + "time": "2024-01-23T13:51:25+00:00" }, { "name": "symfony/validator", @@ -1910,16 +1909,16 @@ }, { "name": "symfony/var-dumper", - "version": "v5.4.28", + "version": "v5.4.40", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "684b36ff415e1381d4a943c3ca2502cd2debad73" + "reference": "af8868a6e9d6082dfca11f1a1f205ae93a8b6d93" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/684b36ff415e1381d4a943c3ca2502cd2debad73", - "reference": "684b36ff415e1381d4a943c3ca2502cd2debad73", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/af8868a6e9d6082dfca11f1a1f205ae93a8b6d93", + "reference": "af8868a6e9d6082dfca11f1a1f205ae93a8b6d93", "shasum": "" }, "require": { @@ -1979,7 +1978,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v5.4.28" + "source": "https://github.com/symfony/var-dumper/tree/v5.4.40" }, "funding": [ { @@ -1995,7 +1994,7 @@ "type": "tidelift" } ], - "time": "2023-08-24T13:38:36+00:00" + "time": "2024-05-31T14:33:22+00:00" }, { "name": "symfony/yaml", @@ -2074,29 +2073,37 @@ }, { "name": "twig/twig", - "version": "v3.7.1", + "version": "v3.10.3", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "a0ce373a0ca3bf6c64b9e3e2124aca502ba39554" + "reference": "67f29781ffafa520b0bbfbd8384674b42db04572" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/a0ce373a0ca3bf6c64b9e3e2124aca502ba39554", - "reference": "a0ce373a0ca3bf6c64b9e3e2124aca502ba39554", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/67f29781ffafa520b0bbfbd8384674b42db04572", + "reference": "67f29781ffafa520b0bbfbd8384674b42db04572", "shasum": "" }, "require": { "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-ctype": "^1.8", - "symfony/polyfill-mbstring": "^1.3" + "symfony/polyfill-mbstring": "^1.3", + "symfony/polyfill-php80": "^1.22" }, "require-dev": { "psr/container": "^1.0|^2.0", - "symfony/phpunit-bridge": "^5.4.9|^6.3" + "symfony/phpunit-bridge": "^5.4.9|^6.4|^7.0" }, "type": "library", "autoload": { + "files": [ + "src/Resources/core.php", + "src/Resources/debug.php", + "src/Resources/escaper.php", + "src/Resources/string_loader.php" + ], "psr-4": { "Twig\\": "src/" } @@ -2129,7 +2136,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.7.1" + "source": "https://github.com/twigphp/Twig/tree/v3.10.3" }, "funding": [ { @@ -2141,7 +2148,7 @@ "type": "tidelift" } ], - "time": "2023-08-28T11:09:02+00:00" + "time": "2024-05-16T10:04:27+00:00" } ], "packages-dev": [ @@ -3400,6 +3407,55 @@ ], "time": "2023-08-19T07:10:56+00:00" }, + { + "name": "psr/cache", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/cache.git", + "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", + "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for caching libraries", + "keywords": [ + "cache", + "psr", + "psr-6" + ], + "support": { + "source": "https://github.com/php-fig/cache/tree/master" + }, + "time": "2016-08-06T20:24:11+00:00" + }, { "name": "psr/log", "version": "1.1.4", @@ -4519,29 +4575,58 @@ "time": "2022-08-31T10:31:18+00:00" }, { - "name": "symfony/options-resolver", - "version": "v5.4.21", + "name": "symfony/cache", + "version": "v5.4.40", "source": { "type": "git", - "url": "https://github.com/symfony/options-resolver.git", - "reference": "4fe5cf6ede71096839f0e4b4444d65dd3a7c1eb9" + "url": "https://github.com/symfony/cache.git", + "reference": "89005bc368ca02ed0433c592e4d27670d0844a66" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/4fe5cf6ede71096839f0e4b4444d65dd3a7c1eb9", - "reference": "4fe5cf6ede71096839f0e4b4444d65dd3a7c1eb9", + "url": "https://api.github.com/repos/symfony/cache/zipball/89005bc368ca02ed0433c592e4d27670d0844a66", + "reference": "89005bc368ca02ed0433c592e4d27670d0844a66", "shasum": "" }, "require": { "php": ">=7.2.5", + "psr/cache": "^1.0|^2.0", + "psr/log": "^1.1|^2|^3", + "symfony/cache-contracts": "^1.1.7|^2", "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-php73": "~1.0", - "symfony/polyfill-php80": "^1.16" + "symfony/polyfill-php73": "^1.9", + "symfony/polyfill-php80": "^1.16", + "symfony/service-contracts": "^1.1|^2|^3", + "symfony/var-exporter": "^4.4|^5.0|^6.0" + }, + "conflict": { + "doctrine/dbal": "<2.13.1", + "symfony/dependency-injection": "<4.4", + "symfony/http-kernel": "<4.4", + "symfony/var-dumper": "<4.4" + }, + "provide": { + "psr/cache-implementation": "1.0|2.0", + "psr/simple-cache-implementation": "1.0|2.0", + "symfony/cache-implementation": "1.0|2.0" + }, + "require-dev": { + "cache/integration-tests": "dev-master", + "doctrine/cache": "^1.6|^2.0", + "doctrine/dbal": "^2.13.1|^3|^4", + "predis/predis": "^1.1|^2.0", + "psr/simple-cache": "^1.0|^2.0", + "symfony/config": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/filesystem": "^4.4|^5.0|^6.0", + "symfony/http-kernel": "^4.4|^5.0|^6.0", + "symfony/messenger": "^4.4|^5.0|^6.0", + "symfony/var-dumper": "^4.4|^5.0|^6.0" }, "type": "library", "autoload": { "psr-4": { - "Symfony\\Component\\OptionsResolver\\": "" + "Symfony\\Component\\Cache\\": "" }, "exclude-from-classmap": [ "/Tests/" @@ -4553,23 +4638,22 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], - "description": "Provides an improved replacement for the array_replace PHP function", + "description": "Provides extended PSR-6, PSR-16 (and tags) implementations", "homepage": "https://symfony.com", "keywords": [ - "config", - "configuration", - "options" + "caching", + "psr6" ], "support": { - "source": "https://github.com/symfony/options-resolver/tree/v5.4.21" + "source": "https://github.com/symfony/cache/tree/v5.4.40" }, "funding": [ { @@ -4585,30 +4669,126 @@ "type": "tidelift" } ], - "time": "2023-02-14T08:03:56+00:00" + "time": "2024-05-31T14:33:22+00:00" }, { - "name": "symfony/stopwatch", - "version": "v5.4.21", + "name": "symfony/cache-contracts", + "version": "v2.5.3", "source": { "type": "git", - "url": "https://github.com/symfony/stopwatch.git", - "reference": "f83692cd869a6f2391691d40a01e8acb89e76fee" + "url": "https://github.com/symfony/cache-contracts.git", + "reference": "fee6db04d913094e2fb55ff8e7db5685a8134463" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/f83692cd869a6f2391691d40a01e8acb89e76fee", - "reference": "f83692cd869a6f2391691d40a01e8acb89e76fee", + "url": "https://api.github.com/repos/symfony/cache-contracts/zipball/fee6db04d913094e2fb55ff8e7db5685a8134463", + "reference": "fee6db04d913094e2fb55ff8e7db5685a8134463", "shasum": "" }, "require": { "php": ">=7.2.5", - "symfony/service-contracts": "^1|^2|^3" + "psr/cache": "^1.0|^2.0|^3.0" + }, + "suggest": { + "symfony/cache-implementation": "" }, "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, "autoload": { "psr-4": { - "Symfony\\Component\\Stopwatch\\": "" + "Symfony\\Contracts\\Cache\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to caching", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/cache-contracts/tree/v2.5.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-23T13:51:25+00:00" + }, + { + "name": "symfony/config", + "version": "v5.4.40", + "source": { + "type": "git", + "url": "https://github.com/symfony/config.git", + "reference": "d4e1db78421163b98dd9971d247fd0df4a57ee5e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/config/zipball/d4e1db78421163b98dd9971d247fd0df4a57ee5e", + "reference": "d4e1db78421163b98dd9971d247fd0df4a57ee5e", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/filesystem": "^4.4|^5.0|^6.0", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-php80": "^1.16", + "symfony/polyfill-php81": "^1.22" + }, + "conflict": { + "symfony/finder": "<4.4" + }, + "require-dev": { + "symfony/event-dispatcher": "^4.4|^5.0|^6.0", + "symfony/finder": "^4.4|^5.0|^6.0", + "symfony/messenger": "^4.4|^5.0|^6.0", + "symfony/service-contracts": "^1.1|^2|^3", + "symfony/yaml": "^4.4|^5.0|^6.0" + }, + "suggest": { + "symfony/yaml": "To use the yaml reference dumper" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Config\\": "" }, "exclude-from-classmap": [ "/Tests/" @@ -4628,10 +4808,10 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Provides a way to profile code", + "description": "Helps you find, load, combine, autofill and validate configuration values of any kind", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/stopwatch/tree/v5.4.21" + "source": "https://github.com/symfony/config/tree/v5.4.40" }, "funding": [ { @@ -4647,7 +4827,1139 @@ "type": "tidelift" } ], - "time": "2023-02-14T08:03:56+00:00" + "time": "2024-05-31T14:33:22+00:00" + }, + { + "name": "symfony/dependency-injection", + "version": "v5.4.40", + "source": { + "type": "git", + "url": "https://github.com/symfony/dependency-injection.git", + "reference": "408b33326496030c201b8051b003e9e8cdb2efc9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/408b33326496030c201b8051b003e9e8cdb2efc9", + "reference": "408b33326496030c201b8051b003e9e8cdb2efc9", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/container": "^1.1.1", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/polyfill-php80": "^1.16", + "symfony/polyfill-php81": "^1.22", + "symfony/service-contracts": "^1.1.6|^2" + }, + "conflict": { + "ext-psr": "<1.1|>=2", + "symfony/config": "<5.3", + "symfony/finder": "<4.4", + "symfony/proxy-manager-bridge": "<4.4", + "symfony/yaml": "<4.4.26" + }, + "provide": { + "psr/container-implementation": "1.0", + "symfony/service-implementation": "1.0|2.0" + }, + "require-dev": { + "symfony/config": "^5.3|^6.0", + "symfony/expression-language": "^4.4|^5.0|^6.0", + "symfony/yaml": "^4.4.26|^5.0|^6.0" + }, + "suggest": { + "symfony/config": "", + "symfony/expression-language": "For using expressions in service container configuration", + "symfony/finder": "For using double-star glob patterns or when GLOB_BRACE portability is required", + "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", + "symfony/yaml": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\DependencyInjection\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Allows you to standardize and centralize the way objects are constructed in your application", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/dependency-injection/tree/v5.4.40" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-05-31T14:33:22+00:00" + }, + { + "name": "symfony/error-handler", + "version": "v5.4.40", + "source": { + "type": "git", + "url": "https://github.com/symfony/error-handler.git", + "reference": "c6c8f965a87b22d5005a7806783c7f10ae7e58cd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/error-handler/zipball/c6c8f965a87b22d5005a7806783c7f10ae7e58cd", + "reference": "c6c8f965a87b22d5005a7806783c7f10ae7e58cd", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/log": "^1|^2|^3", + "symfony/var-dumper": "^4.4|^5.0|^6.0" + }, + "require-dev": { + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/http-kernel": "^4.4|^5.0|^6.0", + "symfony/serializer": "^4.4|^5.0|^6.0" + }, + "bin": [ + "Resources/bin/patch-type-declarations" + ], + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\ErrorHandler\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides tools to manage errors and ease debugging PHP code", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/error-handler/tree/v5.4.40" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-05-31T14:33:22+00:00" + }, + { + "name": "symfony/framework-bundle", + "version": "v5.4.40", + "source": { + "type": "git", + "url": "https://github.com/symfony/framework-bundle.git", + "reference": "603090d8327e279bd233d5ce42a1ed89bc91612f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/framework-bundle/zipball/603090d8327e279bd233d5ce42a1ed89bc91612f", + "reference": "603090d8327e279bd233d5ce42a1ed89bc91612f", + "shasum": "" + }, + "require": { + "ext-xml": "*", + "php": ">=7.2.5", + "symfony/cache": "^5.2|^6.0", + "symfony/config": "^5.3|^6.0", + "symfony/dependency-injection": "^5.4.5|^6.0.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/error-handler": "^4.4.1|^5.0.1|^6.0", + "symfony/event-dispatcher": "^5.1|^6.0", + "symfony/filesystem": "^4.4|^5.0|^6.0", + "symfony/finder": "^4.4|^5.0|^6.0", + "symfony/http-foundation": "^5.4.24|^6.2.11", + "symfony/http-kernel": "^5.4|^6.0", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php80": "^1.16", + "symfony/polyfill-php81": "^1.22", + "symfony/routing": "^5.3|^6.0" + }, + "conflict": { + "doctrine/annotations": "<1.13.1", + "doctrine/cache": "<1.11", + "doctrine/persistence": "<1.3", + "phpdocumentor/reflection-docblock": "<3.2.2", + "phpdocumentor/type-resolver": "<1.4.0", + "symfony/asset": "<5.3", + "symfony/console": "<5.2.5|>=7.0", + "symfony/dom-crawler": "<4.4", + "symfony/dotenv": "<5.1", + "symfony/form": "<5.2", + "symfony/http-client": "<4.4", + "symfony/lock": "<4.4", + "symfony/mailer": "<5.2", + "symfony/messenger": "<5.4", + "symfony/mime": "<4.4", + "symfony/property-access": "<5.3", + "symfony/property-info": "<4.4", + "symfony/security-csrf": "<5.3", + "symfony/serializer": "<5.2", + "symfony/service-contracts": ">=3.0", + "symfony/stopwatch": "<4.4", + "symfony/translation": "<5.3", + "symfony/twig-bridge": "<4.4", + "symfony/twig-bundle": "<4.4", + "symfony/validator": "<5.3.11", + "symfony/web-profiler-bundle": "<4.4", + "symfony/workflow": "<5.2" + }, + "require-dev": { + "doctrine/annotations": "^1.13.1|^2", + "doctrine/cache": "^1.11|^2.0", + "doctrine/persistence": "^1.3|^2|^3", + "phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0", + "symfony/asset": "^5.3|^6.0", + "symfony/browser-kit": "^5.4|^6.0", + "symfony/console": "^5.4.9|^6.0.9", + "symfony/css-selector": "^4.4|^5.0|^6.0", + "symfony/dom-crawler": "^4.4.30|^5.3.7|^6.0", + "symfony/dotenv": "^5.1|^6.0", + "symfony/expression-language": "^4.4|^5.0|^6.0", + "symfony/form": "^5.2|^6.0", + "symfony/http-client": "^4.4|^5.0|^6.0", + "symfony/lock": "^4.4|^5.0|^6.0", + "symfony/mailer": "^5.2|^6.0", + "symfony/messenger": "^5.4|^6.0", + "symfony/mime": "^4.4|^5.0|^6.0", + "symfony/notifier": "^5.4|^6.0", + "symfony/polyfill-intl-icu": "~1.0", + "symfony/process": "^4.4|^5.0|^6.0", + "symfony/property-info": "^4.4|^5.0|^6.0", + "symfony/rate-limiter": "^5.2|^6.0", + "symfony/security-bundle": "^5.4|^6.0", + "symfony/serializer": "^5.4|^6.0", + "symfony/stopwatch": "^4.4|^5.0|^6.0", + "symfony/string": "^5.0|^6.0", + "symfony/translation": "^5.3|^6.0", + "symfony/twig-bundle": "^4.4|^5.0|^6.0", + "symfony/validator": "^5.3.11|^6.0", + "symfony/web-link": "^4.4|^5.0|^6.0", + "symfony/workflow": "^5.2|^6.0", + "symfony/yaml": "^4.4|^5.0|^6.0", + "twig/twig": "^2.10|^3.0.4" + }, + "suggest": { + "ext-apcu": "For best performance of the system caches", + "symfony/console": "For using the console commands", + "symfony/form": "For using forms", + "symfony/property-info": "For using the property_info service", + "symfony/serializer": "For using the serializer service", + "symfony/validator": "For using validation", + "symfony/web-link": "For using web links, features such as preloading, prefetching or prerendering", + "symfony/yaml": "For using the debug:config and lint:yaml commands" + }, + "type": "symfony-bundle", + "autoload": { + "psr-4": { + "Symfony\\Bundle\\FrameworkBundle\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides a tight integration between Symfony components and the Symfony full-stack framework", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/framework-bundle/tree/v5.4.40" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-05-31T14:33:22+00:00" + }, + { + "name": "symfony/http-foundation", + "version": "v5.4.40", + "source": { + "type": "git", + "url": "https://github.com/symfony/http-foundation.git", + "reference": "cf4893ca4eca3fac4ae06da1590afdbbb4217847" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/cf4893ca4eca3fac4ae06da1590afdbbb4217847", + "reference": "cf4893ca4eca3fac4ae06da1590afdbbb4217847", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/polyfill-mbstring": "~1.1", + "symfony/polyfill-php80": "^1.16" + }, + "require-dev": { + "predis/predis": "^1.0|^2.0", + "symfony/cache": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^5.4|^6.0", + "symfony/expression-language": "^4.4|^5.0|^6.0", + "symfony/http-kernel": "^5.4.12|^6.0.12|^6.1.4", + "symfony/mime": "^4.4|^5.0|^6.0", + "symfony/rate-limiter": "^5.2|^6.0" + }, + "suggest": { + "symfony/mime": "To use the file extension guesser" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\HttpFoundation\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Defines an object-oriented layer for the HTTP specification", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/http-foundation/tree/v5.4.40" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-05-31T14:33:22+00:00" + }, + { + "name": "symfony/http-kernel", + "version": "v5.4.40", + "source": { + "type": "git", + "url": "https://github.com/symfony/http-kernel.git", + "reference": "3ad03183c6985adc2eece16f239f8cfe1c4ccbe3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/3ad03183c6985adc2eece16f239f8cfe1c4ccbe3", + "reference": "3ad03183c6985adc2eece16f239f8cfe1c4ccbe3", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/log": "^1|^2", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/error-handler": "^4.4|^5.0|^6.0", + "symfony/event-dispatcher": "^5.0|^6.0", + "symfony/http-foundation": "^5.4.21|^6.2.7", + "symfony/polyfill-ctype": "^1.8", + "symfony/polyfill-php73": "^1.9", + "symfony/polyfill-php80": "^1.16" + }, + "conflict": { + "symfony/browser-kit": "<5.4", + "symfony/cache": "<5.0", + "symfony/config": "<5.0", + "symfony/console": "<4.4", + "symfony/dependency-injection": "<5.3", + "symfony/doctrine-bridge": "<5.0", + "symfony/form": "<5.0", + "symfony/http-client": "<5.0", + "symfony/mailer": "<5.0", + "symfony/messenger": "<5.0", + "symfony/translation": "<5.0", + "symfony/twig-bridge": "<5.0", + "symfony/validator": "<5.0", + "twig/twig": "<2.13" + }, + "provide": { + "psr/log-implementation": "1.0|2.0" + }, + "require-dev": { + "psr/cache": "^1.0|^2.0|^3.0", + "symfony/browser-kit": "^5.4|^6.0", + "symfony/config": "^5.0|^6.0", + "symfony/console": "^4.4|^5.0|^6.0", + "symfony/css-selector": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^5.3|^6.0", + "symfony/dom-crawler": "^4.4|^5.0|^6.0", + "symfony/expression-language": "^4.4|^5.0|^6.0", + "symfony/finder": "^4.4|^5.0|^6.0", + "symfony/http-client-contracts": "^1.1|^2|^3", + "symfony/process": "^4.4|^5.0|^6.0", + "symfony/routing": "^4.4|^5.0|^6.0", + "symfony/stopwatch": "^4.4|^5.0|^6.0", + "symfony/translation": "^4.4|^5.0|^6.0", + "symfony/translation-contracts": "^1.1|^2|^3", + "symfony/var-dumper": "^4.4.31|^5.4", + "twig/twig": "^2.13|^3.0.4" + }, + "suggest": { + "symfony/browser-kit": "", + "symfony/config": "", + "symfony/console": "", + "symfony/dependency-injection": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\HttpKernel\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides a structured process for converting a Request into a Response", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/http-kernel/tree/v5.4.40" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-06-02T15:53:08+00:00" + }, + { + "name": "symfony/options-resolver", + "version": "v5.4.21", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "4fe5cf6ede71096839f0e4b4444d65dd3a7c1eb9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/4fe5cf6ede71096839f0e4b4444d65dd3a7c1eb9", + "reference": "4fe5cf6ede71096839f0e4b4444d65dd3a7c1eb9", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/polyfill-php73": "~1.0", + "symfony/polyfill-php80": "^1.16" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\OptionsResolver\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an improved replacement for the array_replace PHP function", + "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], + "support": { + "source": "https://github.com/symfony/options-resolver/tree/v5.4.21" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-02-14T08:03:56+00:00" + }, + { + "name": "symfony/profiler-pack", + "version": "v1.0.6", + "source": { + "type": "git", + "url": "https://github.com/symfony/profiler-pack.git", + "reference": "bcd6e80af9819454ac18594362e7875fd1d771c7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/profiler-pack/zipball/bcd6e80af9819454ac18594362e7875fd1d771c7", + "reference": "bcd6e80af9819454ac18594362e7875fd1d771c7", + "shasum": "" + }, + "require": { + "symfony/stopwatch": "*", + "symfony/web-profiler-bundle": "*" + }, + "require-dev": { + "symfony/stopwatch": "*", + "symfony/web-profiler-bundle": "*" + }, + "type": "symfony-pack", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A pack for the Symfony web profiler", + "support": { + "issues": "https://github.com/symfony/profiler-pack/issues", + "source": "https://github.com/symfony/profiler-pack/tree/v1.0.6" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-08-20T17:27:58+00:00" + }, + { + "name": "symfony/routing", + "version": "v5.4.40", + "source": { + "type": "git", + "url": "https://github.com/symfony/routing.git", + "reference": "6df1dd8b306649303267a760699cf04cf39b1f7b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/routing/zipball/6df1dd8b306649303267a760699cf04cf39b1f7b", + "reference": "6df1dd8b306649303267a760699cf04cf39b1f7b", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/polyfill-php80": "^1.16" + }, + "conflict": { + "doctrine/annotations": "<1.12", + "symfony/config": "<5.3", + "symfony/dependency-injection": "<4.4", + "symfony/yaml": "<4.4" + }, + "require-dev": { + "doctrine/annotations": "^1.12|^2", + "psr/log": "^1|^2|^3", + "symfony/config": "^5.3|^6.0", + "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/expression-language": "^4.4|^5.0|^6.0", + "symfony/http-foundation": "^4.4|^5.0|^6.0", + "symfony/yaml": "^4.4|^5.0|^6.0" + }, + "suggest": { + "symfony/config": "For using the all-in-one router or any loader", + "symfony/expression-language": "For using expression matching", + "symfony/http-foundation": "For using a Symfony Request object", + "symfony/yaml": "For using the YAML loader" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Routing\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Maps an HTTP request to a set of configuration variables", + "homepage": "https://symfony.com", + "keywords": [ + "router", + "routing", + "uri", + "url" + ], + "support": { + "source": "https://github.com/symfony/routing/tree/v5.4.40" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-05-31T14:33:22+00:00" + }, + { + "name": "symfony/stopwatch", + "version": "v5.4.40", + "source": { + "type": "git", + "url": "https://github.com/symfony/stopwatch.git", + "reference": "0e9daf3b7c805c747638b2cc48f1649e594f9625" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/0e9daf3b7c805c747638b2cc48f1649e594f9625", + "reference": "0e9daf3b7c805c747638b2cc48f1649e594f9625", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/service-contracts": "^1|^2|^3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides a way to profile code", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/stopwatch/tree/v5.4.40" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-05-31T14:33:22+00:00" + }, + { + "name": "symfony/twig-bridge", + "version": "v5.4.40", + "source": { + "type": "git", + "url": "https://github.com/symfony/twig-bridge.git", + "reference": "b982cfa2d15058d2642ca4cf7edab495d6dac707" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/twig-bridge/zipball/b982cfa2d15058d2642ca4cf7edab495d6dac707", + "reference": "b982cfa2d15058d2642ca4cf7edab495d6dac707", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-php80": "^1.16", + "symfony/translation-contracts": "^1.1|^2|^3", + "twig/twig": "^2.13|^3.0.4" + }, + "conflict": { + "phpdocumentor/reflection-docblock": "<3.2.2", + "phpdocumentor/type-resolver": "<1.4.0", + "symfony/console": "<5.3", + "symfony/form": "<5.4.21|>=6,<6.2.7", + "symfony/http-foundation": "<5.3", + "symfony/http-kernel": "<4.4", + "symfony/translation": "<5.2", + "symfony/workflow": "<5.2" + }, + "require-dev": { + "doctrine/annotations": "^1.12|^2", + "egulias/email-validator": "^2.1.10|^3|^4", + "phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0", + "symfony/asset": "^4.4|^5.0|^6.0", + "symfony/console": "^5.3|^6.0", + "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/expression-language": "^4.4|^5.0|^6.0", + "symfony/finder": "^4.4|^5.0|^6.0", + "symfony/form": "^5.4.21|^6.2.7", + "symfony/http-foundation": "^5.3|^6.0", + "symfony/http-kernel": "^4.4|^5.0|^6.0", + "symfony/intl": "^4.4|^5.0|^6.0", + "symfony/mime": "^5.2|^6.0", + "symfony/polyfill-intl-icu": "~1.0", + "symfony/property-info": "^4.4|^5.1|^6.0", + "symfony/routing": "^4.4|^5.0|^6.0", + "symfony/security-acl": "^2.8|^3.0", + "symfony/security-core": "^4.4|^5.0|^6.0", + "symfony/security-csrf": "^4.4|^5.0|^6.0", + "symfony/security-http": "^4.4|^5.0|^6.0", + "symfony/serializer": "^5.4.35|~6.3.12|^6.4.3", + "symfony/stopwatch": "^4.4|^5.0|^6.0", + "symfony/translation": "^5.2|^6.0", + "symfony/web-link": "^4.4|^5.0|^6.0", + "symfony/workflow": "^5.2|^6.0", + "symfony/yaml": "^4.4|^5.0|^6.0", + "twig/cssinliner-extra": "^2.12|^3", + "twig/inky-extra": "^2.12|^3", + "twig/markdown-extra": "^2.12|^3" + }, + "suggest": { + "symfony/asset": "For using the AssetExtension", + "symfony/expression-language": "For using the ExpressionExtension", + "symfony/finder": "", + "symfony/form": "For using the FormExtension", + "symfony/http-kernel": "For using the HttpKernelExtension", + "symfony/routing": "For using the RoutingExtension", + "symfony/security-core": "For using the SecurityExtension", + "symfony/security-csrf": "For using the CsrfExtension", + "symfony/security-http": "For using the LogoutUrlExtension", + "symfony/stopwatch": "For using the StopwatchExtension", + "symfony/translation": "For using the TranslationExtension", + "symfony/var-dumper": "For using the DumpExtension", + "symfony/web-link": "For using the WebLinkExtension", + "symfony/yaml": "For using the YamlExtension" + }, + "type": "symfony-bridge", + "autoload": { + "psr-4": { + "Symfony\\Bridge\\Twig\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides integration for Twig with various Symfony components", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/twig-bridge/tree/v5.4.40" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-05-31T14:33:22+00:00" + }, + { + "name": "symfony/twig-bundle", + "version": "v5.4.40", + "source": { + "type": "git", + "url": "https://github.com/symfony/twig-bundle.git", + "reference": "997c002735c88b50a6325cca8ecf3d8723902666" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/twig-bundle/zipball/997c002735c88b50a6325cca8ecf3d8723902666", + "reference": "997c002735c88b50a6325cca8ecf3d8723902666", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/config": "^4.4|^5.0|^6.0", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/http-foundation": "^4.4|^5.0|^6.0", + "symfony/http-kernel": "^5.0|^6.0", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-php80": "^1.16", + "symfony/twig-bridge": "^5.3|^6.0", + "twig/twig": "^2.13|^3.0.4" + }, + "conflict": { + "symfony/dependency-injection": "<5.3", + "symfony/framework-bundle": "<5.0", + "symfony/service-contracts": ">=3.0", + "symfony/translation": "<5.0" + }, + "require-dev": { + "doctrine/annotations": "^1.10.4|^2", + "doctrine/cache": "^1.0|^2.0", + "symfony/asset": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^5.3|^6.0", + "symfony/expression-language": "^4.4|^5.0|^6.0", + "symfony/finder": "^4.4|^5.0|^6.0", + "symfony/form": "^4.4|^5.0|^6.0", + "symfony/framework-bundle": "^5.0|^6.0", + "symfony/routing": "^4.4|^5.0|^6.0", + "symfony/stopwatch": "^4.4|^5.0|^6.0", + "symfony/translation": "^5.0|^6.0", + "symfony/web-link": "^4.4|^5.0|^6.0", + "symfony/yaml": "^4.4|^5.0|^6.0" + }, + "type": "symfony-bundle", + "autoload": { + "psr-4": { + "Symfony\\Bundle\\TwigBundle\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides a tight integration of Twig into the Symfony full-stack framework", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/twig-bundle/tree/v5.4.40" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-05-31T14:33:22+00:00" + }, + { + "name": "symfony/var-exporter", + "version": "v5.4.40", + "source": { + "type": "git", + "url": "https://github.com/symfony/var-exporter.git", + "reference": "6a13d37336d512927986e09f19a4bed24178baa6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/var-exporter/zipball/6a13d37336d512927986e09f19a4bed24178baa6", + "reference": "6a13d37336d512927986e09f19a4bed24178baa6", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-php80": "^1.16" + }, + "require-dev": { + "symfony/var-dumper": "^4.4.9|^5.0.9|^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\VarExporter\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Allows exporting any serializable PHP data structure to plain PHP code", + "homepage": "https://symfony.com", + "keywords": [ + "clone", + "construct", + "export", + "hydrate", + "instantiate", + "serialize" + ], + "support": { + "source": "https://github.com/symfony/var-exporter/tree/v5.4.40" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-05-31T14:33:22+00:00" + }, + { + "name": "symfony/web-profiler-bundle", + "version": "v5.4.40", + "source": { + "type": "git", + "url": "https://github.com/symfony/web-profiler-bundle.git", + "reference": "a29669617c4e63785f363571a190a706b9022890" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/web-profiler-bundle/zipball/a29669617c4e63785f363571a190a706b9022890", + "reference": "a29669617c4e63785f363571a190a706b9022890", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/config": "^4.4|^5.0|^6.0", + "symfony/framework-bundle": "^5.3|^6.0,<6.4", + "symfony/http-kernel": "^5.3|^6.0", + "symfony/polyfill-php80": "^1.16", + "symfony/routing": "^4.4|^5.0|^6.0", + "symfony/twig-bundle": "^4.4|^5.0|^6.0", + "twig/twig": "^2.13|^3.0.4" + }, + "conflict": { + "symfony/dependency-injection": "<5.2", + "symfony/form": "<4.4", + "symfony/mailer": "<5.4", + "symfony/messenger": "<4.4" + }, + "require-dev": { + "symfony/browser-kit": "^4.4|^5.0|^6.0", + "symfony/console": "^4.4|^5.0|^6.0", + "symfony/css-selector": "^4.4|^5.0|^6.0", + "symfony/stopwatch": "^4.4|^5.0|^6.0" + }, + "type": "symfony-bundle", + "autoload": { + "psr-4": { + "Symfony\\Bundle\\WebProfilerBundle\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides a development tool that gives detailed information about the execution of any request", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/web-profiler-bundle/tree/v5.4.40" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-05-31T14:33:22+00:00" }, { "name": "theseer/tokenizer", From d612735d1fec0cae93fd116a1b89ef5c50cdbab7 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sun, 23 Jun 2024 03:29:19 +0200 Subject: [PATCH 122/136] [skip ci] Updated composer.json --- composer.json | 2 +- composer.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index af331ada0..9ddd2513c 100644 --- a/composer.json +++ b/composer.json @@ -67,7 +67,7 @@ "extra": { "patches": { "symfony/filesystem": { - "Add readFile() to symfony/filesystem (from v7.1)": "https://github.com/sreichel/openmage-patches/commit/e3f9027a07f64f196685467951f4949f14b5c1fb/n98/magerun/symfony-filesystem.patch" + "Add readFile() to symfony/filesystem (from v7.1)": "https://raw.githubusercontent.com/sreichel/openmage-patches/main/n98/magerun/symfony-filesystem.patch" } } }, diff --git a/composer.lock b/composer.lock index c04cd5712..bb98e24cb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2531e2450a3bc9018efabb1e41cd58ec", + "content-hash": "8742faf1a32f1b00524ad7c4d1c3cbe4", "packages": [ { "name": "cweagans/composer-patches", From 3dc126d712562478cbe82de4959cba1fc08180eb Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 24 Jun 2024 17:34:44 +0200 Subject: [PATCH 123/136] [skip ci] Cleanup --- src/N98/Magento/Application.php | 10 +- src/N98/Magento/Command/AbstractCommand.php | 62 ++++++--- .../Admin/DisableNotificationsCommand.php | 5 - .../Admin/User/AbstractAdminUserCommand.php | 6 +- .../Admin/User/ChangePasswordCommand.php | 8 -- .../Admin/User/ChangeStatusCommand.php | 8 -- .../Command/Admin/User/CreateUserCommand.php | 10 +- .../Command/Admin/User/DeleteUserCommand.php | 20 +-- .../Command/Admin/User/ListCommand.php | 41 +++--- .../Magento/Command/Cache/CleanCommand.php | 10 +- .../Command/Cache/Dir/FlushCommand.php | 8 -- .../Magento/Command/Cache/DisableCommand.php | 6 - .../Magento/Command/Cache/EnableCommand.php | 6 - .../Magento/Command/Cache/FlushCommand.php | 5 - src/N98/Magento/Command/Cache/ListCommand.php | 28 ++-- .../Magento/Command/Cache/ReportCommand.php | 76 +++++------ src/N98/Magento/Command/Cache/ViewCommand.php | 17 +-- .../Command/Category/Create/DummyCommand.php | 28 ++-- .../Magento/Command/Cms/Block/ListCommand.php | 46 +++---- .../Command/Cms/Block/ToggleCommand.php | 11 +- ...Interface.php => CommandDataInterface.php} | 9 +- .../Magento/Command/Config/DeleteCommand.php | 8 -- .../Magento/Command/Config/DumpCommand.php | 10 +- src/N98/Magento/Command/Config/GetCommand.php | 8 -- .../Magento/Command/Config/SearchCommand.php | 8 -- src/N98/Magento/Command/Config/SetCommand.php | 8 -- .../Customer/ChangePasswordCommand.php | 8 -- .../Command/Customer/CreateDummyCommand.php | 16 +-- .../Command/Customer/DeleteCommand.php | 8 -- .../Magento/Command/Customer/InfoCommand.php | 8 -- .../Magento/Command/Customer/ListCommand.php | 74 +++++------ .../Command/Database/AbstractShowCommand.php | 63 ++++----- .../Command/Database/ConsoleCommand.php | 22 ++-- .../Magento/Command/Database/InfoCommand.php | 124 ++++++++---------- .../Database/Maintain/CheckTablesCommand.php | 95 ++++++-------- .../Magento/Command/Database/QueryCommand.php | 46 ++++--- .../Command/Database/StatusCommand.php | 13 +- .../Command/Database/VariablesCommand.php | 6 - .../Command/Design/DemoNoticeCommand.php | 5 - .../Command/Developer/ClassLookupCommand.php | 8 -- .../Command/Developer/ConsoleCommand.php | 8 -- .../Developer/EmailTemplate/UsageCommand.php | 57 ++++---- .../Developer/Ide/PhpStorm/MetaCommand.php | 4 +- .../Command/Developer/Log/DbCommand.php | 8 -- .../Command/Developer/Log/LogCommand.php | 5 - .../Command/Developer/Log/SizeCommand.php | 8 -- .../Command/Developer/MergeCssCommand.php | 5 - .../Command/Developer/MergeJsCommand.php | 5 - .../Module/Disableenable/DisableCommand.php | 6 - .../Module/Disableenable/EnableCommand.php | 6 - .../Command/Developer/Module/ListCommand.php | 16 +-- .../Developer/Module/Observer/ListCommand.php | 72 +++++----- .../Developer/Module/Rewrite/ListCommand.php | 40 +++--- .../Command/Developer/ProfilerCommand.php | 5 - .../Command/Developer/Report/CountCommand.php | 8 -- .../Setup/Script/AttributeCommand.php | 20 ++- .../Command/Developer/SymlinksCommand.php | 5 - .../Developer/TemplateHintsBlocksCommand.php | 5 - .../Developer/TemplateHintsCommand.php | 5 - .../Developer/Theme/DuplicatesCommand.php | 8 +- .../Command/Developer/Theme/InfoCommand.php | 9 -- .../Command/Developer/Theme/ListCommand.php | 28 ++-- .../Developer/Translate/ExportCommand.php | 8 -- .../Translate/InlineAdminCommand.php | 5 - .../Developer/Translate/InlineShopCommand.php | 5 - .../Developer/Translate/SetCommand.php | 8 -- .../Eav/Attribute/Create/DummyCommand.php | 5 - .../Command/Eav/Attribute/ListCommand.php | 75 +++++------ .../Command/Eav/Attribute/RemoveCommand.php | 8 -- .../Command/Eav/Attribute/ViewCommand.php | 102 +++++++------- .../Magento/Command/Indexer/ListCommand.php | 30 ++--- .../Command/Indexer/ReindexAllCommand.php | 8 -- .../Command/Indexer/ReindexCommand.php | 8 -- .../Installer/SubCommand/DownloadMagento.php | 2 - .../Installer/SubCommand/InstallComposer.php | 17 ++- .../Installer/SubCommand/InstallMagento.php | 6 +- .../SubCommand/SelectMagentoVersion.php | 6 +- .../Media/Cache/Image/ClearCommand.php | 8 -- .../Media/Cache/JsCss/ClearCommand.php | 11 +- src/N98/Magento/Command/Media/DumpCommand.php | 9 +- .../Magento/Command/OpenBrowserCommand.php | 8 -- .../Command/Script/Repository/ListCommand.php | 52 +++----- .../Command/Script/Repository/RunCommand.php | 17 +-- src/N98/Magento/Command/ScriptCommand.php | 2 +- .../Command/SubCommand/AbstractSubCommand.php | 22 ++-- .../Command/SubCommand/SubCommandFactory.php | 37 +++--- .../SubCommand/SubCommandInterface.php | 10 +- .../System/Check/Filesystem/FilesCheck.php | 6 +- .../Command/System/Cron/HistoryCommand.php | 58 ++++---- .../Command/System/Cron/ListCommand.php | 15 +-- .../Command/System/Cron/RunCommand.php | 11 +- .../Command/System/MaintenanceCommand.php | 22 ++-- .../Store/Config/BaseUrlListCommand.php | 36 ++--- .../Command/System/Store/ListCommand.php | 32 ++--- .../Command/System/Url/ListCommand.php | 41 +++--- .../Command/System/Website/ListCommand.php | 34 ++--- src/N98/Magento/Initialiser.php | 27 ++-- .../Util/Console/Helper/ParameterHelper.php | 7 +- src/N98/Util/Filesystem.php | 13 +- 99 files changed, 765 insertions(+), 1297 deletions(-) rename src/N98/Magento/Command/{CommandFormatInterface.php => CommandDataInterface.php} (58%) diff --git a/src/N98/Magento/Application.php b/src/N98/Magento/Application.php index a5638aebb..fabb7f2f8 100644 --- a/src/N98/Magento/Application.php +++ b/src/N98/Magento/Application.php @@ -70,7 +70,7 @@ class Application extends BaseApplication protected $config; /** - * @see \N98\Magento\Application::setConfigurationLoader() + * @see Application::setConfigurationLoader * @var ConfigurationLoader */ private $configurationLoaderInjected; @@ -423,7 +423,6 @@ public function checkVarDir(OutputInterface $output) * Loads and initializes the Magento application * * @param bool $soft - * * @return bool false if magento root folder is not set, true otherwise */ public function initMagento(bool $soft = false): bool @@ -617,7 +616,7 @@ public function init(array $initConfig = [], InputInterface $input = null, Outpu $output = $output ?: new ConsoleOutput(); if (null !== $this->config) { - throw new UnexpectedValueException(sprintf('Config already initialized')); + throw new UnexpectedValueException('Config already initialized'); } $loadExternalConfig = !$input->hasParameterOption('--skip-config'); @@ -716,10 +715,9 @@ private function setRootDir($path) /** * @param bool $soft - * * @return void */ - protected function _initMagento1(bool $soft = false) + protected function _initMagento1(bool $soft = false): void { // Load Mage class definition Initialiser::bootstrap($this->_magentoRootFolder); @@ -776,7 +774,7 @@ public function setConfigurationLoader(ConfigurationLoader $configurationLoader) $this->config->setLoader($configurationLoader); } else { /* inject loader to be used later when config is created in */ - /* @see N98\Magento\Application::init */ + /* @see Application::init */ $this->configurationLoaderInjected = $configurationLoader; } diff --git a/src/N98/Magento/Command/AbstractCommand.php b/src/N98/Magento/Command/AbstractCommand.php index 76076fc83..78d53d897 100644 --- a/src/N98/Magento/Command/AbstractCommand.php +++ b/src/N98/Magento/Command/AbstractCommand.php @@ -44,6 +44,8 @@ abstract class AbstractCommand extends AbstractCommandHelper protected const NO_DATA_MESSAGE = 'No data found'; + protected const QUESTION_ATTEMPTS = 3; + /** * @var string|null */ @@ -69,6 +71,27 @@ abstract class AbstractCommand extends AbstractCommandHelper */ protected ?array $data = null; + protected static bool $detectMagentoFlag = true; + + protected static bool $detectMagentoSilentFlag = true; + + protected static bool $initMagentoFlag = true; + + protected static bool $initMagentoSoftFlag = false; + + protected function configure(): void + { + if ($this instanceof CommandDataInterface) { + $this->addOption( + self::COMMAND_OPTION_FORMAT, + null, + InputOption::VALUE_OPTIONAL, + 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']', + static::COMMAND_OPTION_FORMAT_DEFAULT + ); + } + } + /** * Initializes the command just after the input has been validated. * @@ -81,12 +104,28 @@ abstract class AbstractCommand extends AbstractCommandHelper protected function initialize(InputInterface $input, OutputInterface $output) { $this->checkDeprecatedAliases($input, $output); + + if (static::$detectMagentoFlag) { + $this->detectMagento($output, static::$detectMagentoSilentFlag); + } + + if (static::$initMagentoFlag) { + $this->initMagento(static::$initMagentoSoftFlag); + } + + if ($this instanceof CommandDataInterface) { + $this->setData($input, $output); + } + } + + protected function getData(): array + { + return $this->data; } private function _initWebsites() { $this->_websiteCodeMap = []; - /** @var \Mage_Core_Model_Website[] $websites */ $websites = Mage::app()->getWebsites(); foreach ($websites as $website) { $this->_websiteCodeMap[$website->getId()] = $website->getCode(); @@ -567,19 +606,6 @@ protected function createSubCommandFactory( ); } - protected function configure(): void - { - if ($this instanceof CommandFormatInterface) { - $this->addOption( - self::COMMAND_OPTION_FORMAT, - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']', - static::COMMAND_OPTION_FORMAT_DEFAULT - ); - } - } - /** * @param InputInterface $input * @param OutputInterface $output @@ -591,11 +617,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->writeSection($output, static::COMMAND_SECTION_TITLE_TEXT); } - $this->detectMagento($output); - $this->initMagento(); - - $data = $this->getData($input, $output); - + $data = $this->getData(); if (count($data) > 0) { $tableHelper = $this->getTableHelper(); $tableHelper @@ -613,7 +635,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int */ protected function getTableHeaders(InputInterface $input, OutputInterface $output): array { - $data = $this->getData($input, $output); + $data = $this->getData(); return array_keys(reset($data)); } diff --git a/src/N98/Magento/Command/Admin/DisableNotificationsCommand.php b/src/N98/Magento/Command/Admin/DisableNotificationsCommand.php index 4016d9e1f..6181ca6b7 100644 --- a/src/N98/Magento/Command/Admin/DisableNotificationsCommand.php +++ b/src/N98/Magento/Command/Admin/DisableNotificationsCommand.php @@ -5,7 +5,6 @@ namespace N98\Magento\Command\Admin; use N98\Magento\Command\AbstractStoreConfigCommand; -use Symfony\Component\Console\Attribute\AsCommand; /** * Toggle admin notifications command @@ -16,15 +15,11 @@ class DisableNotificationsCommand extends AbstractStoreConfigCommand { /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'admin:notifications'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Toggles admin notifications.'; diff --git a/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php b/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php index 179e871e7..39d7a5a7f 100644 --- a/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php +++ b/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php @@ -54,10 +54,10 @@ protected function getRulesModel(): Mage_Admin_Model_Rules */ protected function getUserByIdOrEmail(InputInterface $input, OutputInterface $output): Mage_Admin_Model_User { - $id = $this->getOrAskForArgument(self::COMMAND_ARGUMENT_ID, $input, $output, 'Username or Email'); - $user = $this->getUserModel()->loadByUsername($id); + $identifier = $this->getOrAskForArgument(self::COMMAND_ARGUMENT_ID, $input, $output, 'Username or Email'); + $user = $this->getUserModel()->loadByUsername($identifier); if (!$user->getId()) { - $user = $this->getUserModel()->load($id, 'email'); + $user = $this->getUserModel()->load($identifier, 'email'); } return $user; diff --git a/src/N98/Magento/Command/Admin/User/ChangePasswordCommand.php b/src/N98/Magento/Command/Admin/User/ChangePasswordCommand.php index 8b4fa6006..0cbf6e1f4 100644 --- a/src/N98/Magento/Command/Admin/User/ChangePasswordCommand.php +++ b/src/N98/Magento/Command/Admin/User/ChangePasswordCommand.php @@ -6,7 +6,6 @@ use Exception; use RuntimeException; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -27,15 +26,11 @@ class ChangePasswordCommand extends AbstractAdminUserCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'admin:user:change-password'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Changes the password of a adminhtml user.'; @@ -63,9 +58,6 @@ protected function configure(): void */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - $dialog = $this->getQuestionHelper(); /** @var string|null $username */ diff --git a/src/N98/Magento/Command/Admin/User/ChangeStatusCommand.php b/src/N98/Magento/Command/Admin/User/ChangeStatusCommand.php index d8c72dac4..40562262d 100644 --- a/src/N98/Magento/Command/Admin/User/ChangeStatusCommand.php +++ b/src/N98/Magento/Command/Admin/User/ChangeStatusCommand.php @@ -6,7 +6,6 @@ use Exception; use RuntimeException; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -28,15 +27,11 @@ class ChangeStatusCommand extends AbstractAdminUserCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'admin:user:change-status'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Set active status of an adminhtml user.'; @@ -84,9 +79,6 @@ public function getHelp(): string */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - $user = $this->getUserByIdOrEmail($input, $output); if (!$user->getId()) { $output->writeln('User was not found'); diff --git a/src/N98/Magento/Command/Admin/User/CreateUserCommand.php b/src/N98/Magento/Command/Admin/User/CreateUserCommand.php index 740cd2d8c..c35526f18 100644 --- a/src/N98/Magento/Command/Admin/User/CreateUserCommand.php +++ b/src/N98/Magento/Command/Admin/User/CreateUserCommand.php @@ -5,7 +5,6 @@ namespace N98\Magento\Command\Admin\User; use Mage_Core_Exception; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -34,17 +33,13 @@ class CreateUserCommand extends AbstractAdminUserCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'admin:user:create'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ - protected static $defaultDescription = 'Create admin user.'; + protected static $defaultDescription = 'Creates admin user.'; protected function configure(): void { @@ -91,9 +86,6 @@ protected function configure(): void */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - $username = $this->getOrAskForArgument(self::COMMAND_ARGUMENT_USERNAME, $input, $output); $email = $this->getOrAskForArgument(self::COMMAND_ARGUMENT_EMAIL, $input, $output); if (($password = $input->getArgument(self::COMMAND_ARGUMENT_PASSWORD)) === null) { diff --git a/src/N98/Magento/Command/Admin/User/DeleteUserCommand.php b/src/N98/Magento/Command/Admin/User/DeleteUserCommand.php index 21925912b..f9728d2f4 100644 --- a/src/N98/Magento/Command/Admin/User/DeleteUserCommand.php +++ b/src/N98/Magento/Command/Admin/User/DeleteUserCommand.php @@ -5,7 +5,6 @@ namespace N98\Magento\Command\Admin\User; use Exception; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -25,17 +24,13 @@ class DeleteUserCommand extends AbstractAdminUserCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'admin:user:delete'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ - protected static $defaultDescription = 'Delete the account of a adminhtml user.'; + protected static $defaultDescription = 'Deletes the account of a adminhtml user.'; protected function configure(): void { @@ -64,9 +59,6 @@ protected function configure(): void */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - $dialog = $this->getQuestionHelper(); $user = $this->getUserByIdOrEmail($input, $output); @@ -76,21 +68,21 @@ protected function execute(InputInterface $input, OutputInterface $output): int return Command::INVALID; } - $shouldRemove = $input->getOption(self::COMMAND_OPTION_FORCE); - if (!$shouldRemove) { - $shouldRemove = $dialog->ask( + $force = $input->getOption(self::COMMAND_OPTION_FORCE); + if (!$force) { + $force = $dialog->ask( $input, $output, new ConfirmationQuestion('Are you sure? [n]: ', false), ); } - if ($shouldRemove) { + if ($force) { try { $user->delete(); $output->writeln('User was successfully deleted'); } catch (Exception $e) { - $output->writeln('' . $e->getMessage() . ''); + $output->writeln(sprintf('%s', $e->getMessage())); } } else { $output->writeln('Aborting delete'); diff --git a/src/N98/Magento/Command/Admin/User/ListCommand.php b/src/N98/Magento/Command/Admin/User/ListCommand.php index b05677981..a8fadc97b 100644 --- a/src/N98/Magento/Command/Admin/User/ListCommand.php +++ b/src/N98/Magento/Command/Admin/User/ListCommand.php @@ -5,8 +5,7 @@ namespace N98\Magento\Command\Admin\User; use Mage_Admin_Model_User; -use N98\Magento\Command\CommandFormatInterface; -use Symfony\Component\Console\Attribute\AsCommand; +use N98\Magento\Command\CommandDataInterface; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -15,48 +14,38 @@ * * @package N98\Magento\Command\Admin\User */ -class ListCommand extends AbstractAdminUserCommand implements CommandFormatInterface +class ListCommand extends AbstractAdminUserCommand implements CommandDataInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Admin users'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'admin:user:list'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'List admin users.'; /** - * {@inheritdoc} - * @return array> + * {@inheritDoc} * * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - public function getData(InputInterface $input, OutputInterface $output): array + public function setData(InputInterface $input,OutputInterface $output) : void { - if (is_null($this->data)) { - $this->data = []; - - $userModel = $this->getUserModel(); - $userList = $userModel->getCollection(); - /** @var Mage_Admin_Model_User $user */ - foreach ($userList as $user) { - $this->data[] = [ - 'id' => $user->getId(), - 'username' => $user->getUsername(), - 'email' => $user->getEmail(), - 'status' => $user->getIsActive() ? 'active' : 'inactive' - ]; - } + $this->data = []; + $userModel = $this->getUserModel(); + $userList = $userModel->getCollection(); + /** @var Mage_Admin_Model_User $user */ + foreach ($userList as $user) { + $this->data[] = [ + 'Id' => $user->getId(), + 'Username' => $user->getUsername(), + 'Email' => $user->getEmail(), + 'Status' => $user->getIsActive() ? 'active' : 'inactive' + ]; } - - return $this->data; } } diff --git a/src/N98/Magento/Command/Cache/CleanCommand.php b/src/N98/Magento/Command/Cache/CleanCommand.php index 1e89847d4..d277d1e52 100644 --- a/src/N98/Magento/Command/Cache/CleanCommand.php +++ b/src/N98/Magento/Command/Cache/CleanCommand.php @@ -6,7 +6,6 @@ use Exception; use Mage; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -23,18 +22,16 @@ class CleanCommand extends AbstractCacheCommandReinit /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'cache:clean'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Clean cache.'; + protected static bool $initMagentoSoftFlag = true; + protected function configure(): void { $this @@ -85,9 +82,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->banUseCache(); } - $this->detectMagento($output); - $this->initMagento(true); - try { Mage::app()->loadAreaPart('adminhtml', 'events'); } catch (Exception $e) { diff --git a/src/N98/Magento/Command/Cache/Dir/FlushCommand.php b/src/N98/Magento/Command/Cache/Dir/FlushCommand.php index f5636f415..d4902fa34 100644 --- a/src/N98/Magento/Command/Cache/Dir/FlushCommand.php +++ b/src/N98/Magento/Command/Cache/Dir/FlushCommand.php @@ -9,7 +9,6 @@ use N98\Util\Filesystem; use RuntimeException; use SplFileInfo; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -23,15 +22,11 @@ class FlushCommand extends AbstractCommand { /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'cache:dir:flush'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Flush (empty) cache directory.'; @@ -62,9 +57,6 @@ public function getHelp(): string */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - $workingDirectory = getcwd(); $magentoRootFolder = $this->getApplication()->getMagentoRootFolder(); $cacheDir = $magentoRootFolder . '/var/cache'; diff --git a/src/N98/Magento/Command/Cache/DisableCommand.php b/src/N98/Magento/Command/Cache/DisableCommand.php index 6cf5bc57e..a22ba35a7 100644 --- a/src/N98/Magento/Command/Cache/DisableCommand.php +++ b/src/N98/Magento/Command/Cache/DisableCommand.php @@ -4,8 +4,6 @@ namespace N98\Magento\Command\Cache; -use Symfony\Component\Console\Attribute\AsCommand; - /** * Disable cache command * @@ -15,15 +13,11 @@ class DisableCommand extends AbstractCacheCommandToggle { /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'cache:disable'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Disables caches.'; diff --git a/src/N98/Magento/Command/Cache/EnableCommand.php b/src/N98/Magento/Command/Cache/EnableCommand.php index aae204513..68f5010e5 100644 --- a/src/N98/Magento/Command/Cache/EnableCommand.php +++ b/src/N98/Magento/Command/Cache/EnableCommand.php @@ -4,8 +4,6 @@ namespace N98\Magento\Command\Cache; -use Symfony\Component\Console\Attribute\AsCommand; - /** * Enable cache command * @@ -15,15 +13,11 @@ class EnableCommand extends AbstractCacheCommandToggle { /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'cache:enable'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Enables caches.'; diff --git a/src/N98/Magento/Command/Cache/FlushCommand.php b/src/N98/Magento/Command/Cache/FlushCommand.php index c3b15964e..2d8f5064b 100644 --- a/src/N98/Magento/Command/Cache/FlushCommand.php +++ b/src/N98/Magento/Command/Cache/FlushCommand.php @@ -6,7 +6,6 @@ use Exception; use Mage; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -20,15 +19,11 @@ class FlushCommand extends AbstractCacheCommandReinit { /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'cache:flush'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Flush cache storage.'; diff --git a/src/N98/Magento/Command/Cache/ListCommand.php b/src/N98/Magento/Command/Cache/ListCommand.php index 830b8be0e..471734c5d 100644 --- a/src/N98/Magento/Command/Cache/ListCommand.php +++ b/src/N98/Magento/Command/Cache/ListCommand.php @@ -4,8 +4,7 @@ namespace N98\Magento\Command\Cache; -use N98\Magento\Command\CommandFormatInterface; -use Symfony\Component\Console\Attribute\AsCommand; +use N98\Magento\Command\CommandDataInterface; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -14,42 +13,33 @@ * * @package N98\Magento\Command\Cache */ -class ListCommand extends AbstractCacheCommand implements CommandFormatInterface +class ListCommand extends AbstractCacheCommand implements CommandDataInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Caches'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'cache:list'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Lists all caches.'; /** * {@inheritdoc} - * @return array|string, array> * * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - public function getData(InputInterface $input, OutputInterface $output): array + public function setData(InputInterface $input,OutputInterface $output) : void { - if (is_null($this->data)) { - $this->data = []; - foreach ($this->_getCacheModel()->getTypes() as $cacheCode => $cacheInfo) { - $this->data[] = [ - 'code' => $cacheCode, - 'status' => $cacheInfo['status'] ? 'enabled' : 'disabled' - ]; - } + $this->data = []; + foreach ($this->_getCacheModel()->getTypes() as $cacheCode => $cacheInfo) { + $this->data[] = [ + 'code' => $cacheCode, + 'status' => $cacheInfo['status'] ? 'enabled' : 'disabled' + ]; } - - return $this->data; } } diff --git a/src/N98/Magento/Command/Cache/ReportCommand.php b/src/N98/Magento/Command/Cache/ReportCommand.php index a9744d71c..8980eb8c2 100644 --- a/src/N98/Magento/Command/Cache/ReportCommand.php +++ b/src/N98/Magento/Command/Cache/ReportCommand.php @@ -4,8 +4,7 @@ namespace N98\Magento\Command\Cache; -use N98\Magento\Command\CommandFormatInterface; -use Symfony\Component\Console\Attribute\AsCommand; +use N98\Magento\Command\CommandDataInterface; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -15,7 +14,7 @@ * * @package N98\Magento\Command\Cache */ -class ReportCommand extends AbstractCacheCommand implements CommandFormatInterface +class ReportCommand extends AbstractCacheCommand implements CommandDataInterface { public const COMMAND_OPTION_FILTER_ID = 'filter-id'; @@ -29,15 +28,11 @@ class ReportCommand extends AbstractCacheCommand implements CommandFormatInterfa /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'cache:report'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'View inside the cache.'; @@ -75,54 +70,49 @@ protected function configure(): void /** * {@inheritdoc} - * @return array> * * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - public function getData(InputInterface $input, OutputInterface $output): array + public function setData(InputInterface $input,OutputInterface $output) : void { - if (is_null($this->data)) { - $this->data = []; + $this->data = []; - $cacheInstance = $this->getCacheInstance(); + $cacheInstance = $this->getCacheInstance(); - $filterTag = $input->getOption(self::COMMAND_OPTION_FILTER_TAG); - if ($filterTag !== null) { - $cacheIds = $cacheInstance->getIdsMatchingAnyTags([$filterTag]); - } else { - $cacheIds = $cacheInstance->getIds(); - } - - /** @var string $filterId */ - $filterId = $input->getOption(self::COMMAND_OPTION_FILTER_ID); - if ($filterId !== null) { - // @phpstan-ignore argument.type (@todo SR) - $cacheIds = array_filter($cacheIds, function ($cacheId) use ($filterId) { - return stristr($cacheId, $filterId); - }); - } + $filterTag = $input->getOption(self::COMMAND_OPTION_FILTER_TAG); + if ($filterTag !== null) { + $cacheIds = $cacheInstance->getIdsMatchingAnyTags([$filterTag]); + } else { + $cacheIds = $cacheInstance->getIds(); + } - /** @var string[] $cacheIds */ - foreach ($cacheIds as $cacheId) { - $metaData = $cacheInstance->getMetadatas($cacheId); + /** @var string $filterId */ + $filterId = $input->getOption(self::COMMAND_OPTION_FILTER_ID); + if ($filterId !== null) { + // @phpstan-ignore argument.type (@todo SR) + $cacheIds = array_filter($cacheIds, function ($cacheId) use ($filterId) { + return stristr($cacheId, $filterId); + }); + } - $row = [ - 'ID' => $cacheId, - 'EXPIRE' => date(self::DATE_FORMAT, $metaData['expire']) - ]; + /** @var string[] $cacheIds */ + foreach ($cacheIds as $cacheId) { + $metaData = $cacheInstance->getMetadatas($cacheId); - if ($input->getOption(self::COMMAND_OPTION_MTIME)) { - $row['MTIME'] = date(self::DATE_FORMAT, $metaData['mtime']); - } + $row = [ + 'ID' => $cacheId, + 'EXPIRE' => date(self::DATE_FORMAT, $metaData['expire']) + ]; - if ($input->getOption(self::COMMAND_OPTION_TAGS)) { - $row['TAGS'] = implode(',', $metaData['tags']); - } + if ($input->getOption(self::COMMAND_OPTION_MTIME)) { + $row['MTIME'] = date(self::DATE_FORMAT, $metaData['mtime']); + } - $this->data[] = $row; + if ($input->getOption(self::COMMAND_OPTION_TAGS)) { + $row['TAGS'] = implode(',', $metaData['tags']); } - } - return $this->data; + $this->data[] = $row; + } } } diff --git a/src/N98/Magento/Command/Cache/ViewCommand.php b/src/N98/Magento/Command/Cache/ViewCommand.php index 0913e41c2..9cca8b584 100644 --- a/src/N98/Magento/Command/Cache/ViewCommand.php +++ b/src/N98/Magento/Command/Cache/ViewCommand.php @@ -4,12 +4,14 @@ namespace N98\Magento\Command\Cache; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Question\Question; +use Symfony\Component\Validator\Constraints\NotBlank; +use Symfony\Component\Validator\Validation; /** * View cache command @@ -24,15 +26,11 @@ class ViewCommand extends AbstractCacheCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'cache:view'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Prints a cache entry.'; @@ -54,18 +52,15 @@ protected function configure(): void } /** - * @param InputInterface $input - * @param OutputInterface $output + * {@inheritDoc} * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - - $cacheInstance = $this->getCacheInstance(); /** @var string $cacheId */ $cacheId = $input->getArgument(self::COMMAND_ARGUMENT_ID); + + $cacheInstance = $this->getCacheInstance(); /** @var string $cacheData */ $cacheData = $cacheInstance->load($cacheId); if ($input->getOption(self::COMMAND_OPTION_UNSERIALZE)) { diff --git a/src/N98/Magento/Command/Category/Create/DummyCommand.php b/src/N98/Magento/Command/Category/Create/DummyCommand.php index 54607255d..3c18ce44e 100644 --- a/src/N98/Magento/Command/Category/Create/DummyCommand.php +++ b/src/N98/Magento/Command/Category/Create/DummyCommand.php @@ -1,26 +1,32 @@ setName('category:create:dummy') @@ -42,14 +48,10 @@ protected function configure() /** * @param InputInterface $input * @param OutputInterface $output - * * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output, true); - $this->initMagento(); - $output->writeln("This only create sample categories, do not use on production environment"); // Ask for Arguments @@ -128,13 +130,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int * * @param InputInterface $input * @param OutputInterface $output - * * @return array + * @throws Mage_Core_Exception + * @throws Exception */ private function askForArguments($input, $output) { - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $_argument = []; // Store ID diff --git a/src/N98/Magento/Command/Cms/Block/ListCommand.php b/src/N98/Magento/Command/Cms/Block/ListCommand.php index 0d1d65b64..f01a03239 100644 --- a/src/N98/Magento/Command/Cms/Block/ListCommand.php +++ b/src/N98/Magento/Command/Cms/Block/ListCommand.php @@ -6,8 +6,7 @@ use Mage_Cms_Model_Block; use Mage_Core_Exception; -use N98\Magento\Command\CommandFormatInterface; -use Symfony\Component\Console\Attribute\AsCommand; +use N98\Magento\Command\CommandDataInterface; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -16,52 +15,43 @@ * * @package N98\Magento\Command\Cms\Block */ -class ListCommand extends AbstractCmsBlockCommand implements CommandFormatInterface +class ListCommand extends AbstractCmsBlockCommand implements CommandDataInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'CMS blocks'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'cms:block:list'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'List all CMS blocks.'; /** * {@inheritdoc} - * @return array> * @throws Mage_Core_Exception * * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - public function getData(InputInterface $input, OutputInterface $output): array + public function setData(InputInterface $input,OutputInterface $output) : void { - if (is_null($this->data)) { - $this->data = []; - - /** @var Mage_Cms_Model_Block[] $cmsBlockCollection */ - $cmsBlockCollection = $this->_getBlockModel()->getCollection()->addFieldToSelect('*'); - $resourceModel = $this->_getBlockModel()->getResource(); - foreach ($cmsBlockCollection as $cmsBlock) { - $storeIds = implode(',', $resourceModel->lookupStoreIds((int)$cmsBlock->getId())); - - $this->data[] = [ - 'block_id' => $cmsBlock->getBlockId(), - 'title' => $cmsBlock->getTitle(), - 'identifier' => $cmsBlock->getIdentifier(), - 'is_active' => $cmsBlock->getIsActive() ? 'active' : 'inactive', - 'store_ids' => $storeIds - ]; - } + $this->data = []; + + /** @var Mage_Cms_Model_Block[] $cmsBlockCollection */ + $cmsBlockCollection = $this->_getBlockModel()->getCollection()->addFieldToSelect('*'); + $resourceModel = $this->_getBlockModel()->getResource(); + foreach ($cmsBlockCollection as $cmsBlock) { + $storeIds = implode(',', $resourceModel->lookupStoreIds((int)$cmsBlock->getId())); + + $this->data[] = [ + 'block_id' => $cmsBlock->getBlockId(), + 'title' => $cmsBlock->getTitle(), + 'identifier' => $cmsBlock->getIdentifier(), + 'is_active' => $cmsBlock->getIsActive() ? 'active' : 'inactive', + 'store_ids' => $storeIds + ]; } - - return $this->data; } } diff --git a/src/N98/Magento/Command/Cms/Block/ToggleCommand.php b/src/N98/Magento/Command/Cms/Block/ToggleCommand.php index 2b911928b..dae9d9632 100644 --- a/src/N98/Magento/Command/Cms/Block/ToggleCommand.php +++ b/src/N98/Magento/Command/Cms/Block/ToggleCommand.php @@ -4,7 +4,6 @@ namespace N98\Magento\Command\Cms\Block; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -24,15 +23,11 @@ class ToggleCommand extends AbstractCmsBlockCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'cms:block:toggle'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Toggle a CMS block.'; @@ -49,8 +44,7 @@ protected function configure(): void } /** - * @param InputInterface $input - * @param OutputInterface $output + * {@inheritDoc} * @return int * @throws Throwable */ @@ -58,9 +52,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int { $this->writeSection($output, static::COMMAND_SECTION_TITLE_TEXT); - $this->detectMagento($output); - $this->initMagento(); - /** @var string $blockId */ $blockId = $input->getArgument(self::COMMAND_ARGUMENT_BLOCK_ID); $block = $this->_getBlockModel()->load($blockId, is_numeric($blockId) ? null : 'identifier'); diff --git a/src/N98/Magento/Command/CommandFormatInterface.php b/src/N98/Magento/Command/CommandDataInterface.php similarity index 58% rename from src/N98/Magento/Command/CommandFormatInterface.php rename to src/N98/Magento/Command/CommandDataInterface.php index d03132001..a9ab4d3ef 100644 --- a/src/N98/Magento/Command/CommandFormatInterface.php +++ b/src/N98/Magento/Command/CommandDataInterface.php @@ -8,16 +8,17 @@ use Symfony\Component\Console\Output\OutputInterface; /** - * Interface AbstractCommandFormatInterface + * Interface CommandDataInterface * * @package N98\Magento\Command */ -interface CommandFormatInterface +interface CommandDataInterface { /** + * Set data to display in command output + * * @param InputInterface $input * @param OutputInterface $output - * @return array> */ - public function getData(InputInterface $input, OutputInterface $output): array; + public function setData(InputInterface $input, OutputInterface $output): void; } diff --git a/src/N98/Magento/Command/Config/DeleteCommand.php b/src/N98/Magento/Command/Config/DeleteCommand.php index c79e2b107..25219dbc5 100644 --- a/src/N98/Magento/Command/Config/DeleteCommand.php +++ b/src/N98/Magento/Command/Config/DeleteCommand.php @@ -7,7 +7,6 @@ use Mage; use Mage_Core_Exception; use Mage_Core_Model_Config_Data; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -27,15 +26,11 @@ class DeleteCommand extends AbstractConfigCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'config:delete'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Deletes a store config item.'; @@ -93,9 +88,6 @@ public function getHelp(): string */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - $deleted = []; /** @var bool $allowZeroScope */ diff --git a/src/N98/Magento/Command/Config/DumpCommand.php b/src/N98/Magento/Command/Config/DumpCommand.php index 7e494f0c0..d43f765fa 100644 --- a/src/N98/Magento/Command/Config/DumpCommand.php +++ b/src/N98/Magento/Command/Config/DumpCommand.php @@ -6,7 +6,6 @@ use DOMDocument; use InvalidArgumentException; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -23,15 +22,11 @@ class DumpCommand extends AbstractConfigCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'config:dump'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Dump merged XML config.'; @@ -80,10 +75,7 @@ public function getHelp(): string */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - - /** @var string $xpath */ + /** @var string|null $xpath */ $xpath = $input->getArgument(self::COMMAND_ARGUMENT_XPATH); $config = $this->_getMageConfig()->getNode($xpath); if (!$config) { diff --git a/src/N98/Magento/Command/Config/GetCommand.php b/src/N98/Magento/Command/Config/GetCommand.php index 9f3b440b3..f3f7e150c 100644 --- a/src/N98/Magento/Command/Config/GetCommand.php +++ b/src/N98/Magento/Command/Config/GetCommand.php @@ -7,7 +7,6 @@ use Mage_Core_Exception; use Mage_Core_Model_Config_Data; use N98\Util\Console\Helper\Table\Renderer\RendererFactory; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -30,15 +29,11 @@ class GetCommand extends AbstractConfigCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'config:get'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Get a core config item.'; @@ -112,9 +107,6 @@ public function getHelp(): string protected function execute(InputInterface $input, OutputInterface $output): int { $table = []; - $this->detectMagento($output); - $this->initMagento(); - $collection = $this->_getConfigDataModel()->getCollection(); /** @var string $searchPath */ diff --git a/src/N98/Magento/Command/Config/SearchCommand.php b/src/N98/Magento/Command/Config/SearchCommand.php index d0040eea5..5a685a074 100644 --- a/src/N98/Magento/Command/Config/SearchCommand.php +++ b/src/N98/Magento/Command/Config/SearchCommand.php @@ -7,7 +7,6 @@ use Mage_Core_Model_Config_Element; use RuntimeException; use stdClass; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -28,15 +27,11 @@ class SearchCommand extends AbstractConfigCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'config:search'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Search system configuration descriptions.'; @@ -68,9 +63,6 @@ public function getHelp(): string */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output, true); - $this->initMagento(); - $this->writeSection($output, 'Config Search'); /** @var string $searchString */ diff --git a/src/N98/Magento/Command/Config/SetCommand.php b/src/N98/Magento/Command/Config/SetCommand.php index eb88b03d0..e0cacbdc3 100644 --- a/src/N98/Magento/Command/Config/SetCommand.php +++ b/src/N98/Magento/Command/Config/SetCommand.php @@ -6,7 +6,6 @@ use InvalidArgumentException; use Mage_Core_Exception; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -30,15 +29,11 @@ class SetCommand extends AbstractConfigCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'config:set'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Set a core config item.'; @@ -110,9 +105,6 @@ public function getHelp(): string */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - $config = $this->_getConfigModel(); if (!$config->getResourceModel()) { // without a resource model, a config option can't be saved. diff --git a/src/N98/Magento/Command/Customer/ChangePasswordCommand.php b/src/N98/Magento/Command/Customer/ChangePasswordCommand.php index 60e01ef20..d16bc1270 100644 --- a/src/N98/Magento/Command/Customer/ChangePasswordCommand.php +++ b/src/N98/Magento/Command/Customer/ChangePasswordCommand.php @@ -8,7 +8,6 @@ use Mage_Core_Exception; use Mage_Core_Model_Website; use RuntimeException; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -31,15 +30,11 @@ class ChangePasswordCommand extends AbstractCustomerCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'customer:change-password'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Changes the password of a customer.'; @@ -83,9 +78,6 @@ public function getHelp(): string */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - if (($password = $input->getArgument(self::COMMAND_ARGUMENT_PASSWORD)) == null) { $dialog = $this->getQuestionHelper(); $question = new Question('Password: '); diff --git a/src/N98/Magento/Command/Customer/CreateDummyCommand.php b/src/N98/Magento/Command/Customer/CreateDummyCommand.php index bbe41cbff..f17bc5dfb 100644 --- a/src/N98/Magento/Command/Customer/CreateDummyCommand.php +++ b/src/N98/Magento/Command/Customer/CreateDummyCommand.php @@ -1,12 +1,12 @@ detectMagento($output, true); - $this->initMagento(); - $res = $this->getCustomerModel()->getResource(); $faker = Factory::create($input->getArgument('locale')); $faker->addProvider(new Internet($faker)); - /** @var ParameterHelper $parameterHelper */ - $parameterHelper = $this->getHelper('parameter'); + $parameterHelper = $this->getParameterHelper(); $website = $parameterHelper->askWebsite($input, $output); @@ -135,8 +132,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $res->commit(); if (!$outputPlain) { - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['email', 'password', 'firstname', 'lastname']) ->renderByFormat($output, $table, $input->getOption('format')); diff --git a/src/N98/Magento/Command/Customer/DeleteCommand.php b/src/N98/Magento/Command/Customer/DeleteCommand.php index e52c6d81b..6985ecf0f 100644 --- a/src/N98/Magento/Command/Customer/DeleteCommand.php +++ b/src/N98/Magento/Command/Customer/DeleteCommand.php @@ -10,7 +10,6 @@ use Mage_Customer_Model_Customer; use Mage_Customer_Model_Resource_Customer_Collection; use RuntimeException; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -37,15 +36,11 @@ class DeleteCommand extends AbstractCustomerCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'customer:delete'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Deletes customers.'; @@ -103,9 +98,6 @@ public function getHelp(): string */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - $dialog = $this->getQuestionHelper(); /** @var string $id */ diff --git a/src/N98/Magento/Command/Customer/InfoCommand.php b/src/N98/Magento/Command/Customer/InfoCommand.php index 593940419..71bb365b2 100644 --- a/src/N98/Magento/Command/Customer/InfoCommand.php +++ b/src/N98/Magento/Command/Customer/InfoCommand.php @@ -8,7 +8,6 @@ use Mage_Core_Exception; use Mage_Core_Model_Website; use Mage_Customer_Model_Attribute; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -27,15 +26,11 @@ class InfoCommand extends AbstractCustomerCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'customer:info'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Loads basic customer info by email address.'; @@ -68,9 +63,6 @@ protected function configure(): void */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - $parameterHelper = $this->getParameterHelper(); $email = $parameterHelper->askEmail($input, $output); diff --git a/src/N98/Magento/Command/Customer/ListCommand.php b/src/N98/Magento/Command/Customer/ListCommand.php index 879f7b405..5745a7aac 100644 --- a/src/N98/Magento/Command/Customer/ListCommand.php +++ b/src/N98/Magento/Command/Customer/ListCommand.php @@ -6,8 +6,7 @@ use Mage_Core_Exception; use Mage_Customer_Model_Customer; -use N98\Magento\Command\CommandFormatInterface; -use Symfony\Component\Console\Attribute\AsCommand; +use N98\Magento\Command\CommandDataInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -17,7 +16,7 @@ * * @package N98\Magento\Command\Customer */ -class ListCommand extends AbstractCustomerCommand implements CommandFormatInterface +class ListCommand extends AbstractCustomerCommand implements CommandDataInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Customer list'; @@ -27,15 +26,11 @@ class ListCommand extends AbstractCustomerCommand implements CommandFormatInterf /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'customer:list'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Lists customers.'; @@ -62,47 +57,42 @@ public function getHelp(): string } /** - * {@inheritdoc} - * @return array> + * {@inheritDoc} * @throws Mage_Core_Exception * * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - public function getData(InputInterface $input, OutputInterface $output): array + public function setData(InputInterface $input,OutputInterface $output) : void { - if (is_null($this->data)) { - $this->data = []; - - $config = $this->getCommandConfig(); - - $collection = $this->getCustomerCollection(); - $collection->addAttributeToSelect(['entity_id', 'email', 'firstname', 'lastname', 'website_id']); - - $search = $input->getArgument(self::COMMAND_ARGUMENT_SEARCH); - if ($search) { - $collection->addAttributeToFilter( - [ - ['attribute' => 'email', 'like' => '%' . $search . '%'], - ['attribute' => 'firstname', 'like' => '%' . $search . '%'], - ['attribute' => 'lastname', 'like' => '%' . $search . '%'] - ] - ); - } - - $collection->setPageSize($config['limit']); - - /** @var Mage_Customer_Model_Customer $customer */ - foreach ($collection as $customer) { - $this->data[] = [ - 'ID' => $customer->getId(), - 'Email' => $customer->getEmail(), - 'Firstname' => $customer->getFirstname(), - 'Lastname' => $customer->getLastname(), - 'Website' => $this->_getWebsiteCodeById($customer->getwebsiteId()) - ]; - } + $this->data = []; + + $config = $this->getCommandConfig(); + + $collection = $this->getCustomerCollection(); + $collection->addAttributeToSelect(['entity_id', 'email', 'firstname', 'lastname', 'website_id']); + + $search = $input->getArgument(self::COMMAND_ARGUMENT_SEARCH); + if ($search) { + $collection->addAttributeToFilter( + [ + ['attribute' => 'email', 'like' => '%' . $search . '%'], + ['attribute' => 'firstname', 'like' => '%' . $search . '%'], + ['attribute' => 'lastname', 'like' => '%' . $search . '%'] + ] + ); } - return $this->data; + $collection->setPageSize($config['limit']); + + /** @var Mage_Customer_Model_Customer $customer */ + foreach ($collection as $customer) { + $this->data[] = [ + 'id' => $customer->getId(), + 'email' => $customer->getEmail(), + 'firstname' => $customer->getFirstname(), + 'lastname' => $customer->getLastname(), + 'website' => $this->_getWebsiteCodeById((int)$customer->getwebsiteId()) + ]; + } } } diff --git a/src/N98/Magento/Command/Database/AbstractShowCommand.php b/src/N98/Magento/Command/Database/AbstractShowCommand.php index eb5e2c8ea..1d0812b24 100644 --- a/src/N98/Magento/Command/Database/AbstractShowCommand.php +++ b/src/N98/Magento/Command/Database/AbstractShowCommand.php @@ -1,51 +1,61 @@ value method name in this class * * @var array */ - protected $_specialFormat = []; + protected array $_specialFormat = []; /** * Contains all variables * * @var array */ - protected $_allVariables = []; + protected array $_allVariables = []; - protected function configure() + protected function configure(): void { $this ->addArgument( @@ -77,8 +87,7 @@ protected function configure() /** * @param InputInterface $input * @param OutputInterface $output - * - * @return void + * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int { @@ -99,24 +108,22 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $this->renderTable($header, $this->generateRows($outputVars, $hasDescription)); - return 0; + + return Command::SUCCESS; } /** * @param array $outputVars - * @param bool $hasDescription - * + * @param bool $hasDescription * @return array */ - protected function generateRows(array $outputVars, $hasDescription) + protected function generateRows(array $outputVars, bool $hasDescription): array { $rows = []; $i = 0; foreach ($outputVars as $variableName => $variableValue) { $rows[$i] = [$variableName, $variableValue]; - if (true === $hasDescription && - isset($this->_importantVars[$variableName], $this->_importantVars[$variableName]['desc']) - ) { + if (isset($this->_importantVars[$variableName]['desc']) && true === $hasDescription) { $rows[$i][] = $this->formatDesc($this->_importantVars[$variableName]['desc']); } $i++; @@ -137,10 +144,9 @@ protected function generateRows(array $outputVars, $hasDescription) * Extend or modify this method to add descriptions to other variables * * @param array $row - * * @return array */ - protected function getVariableDescription(array $row) + protected function getVariableDescription(array $row): array { $row[] = ''; return $row; @@ -150,10 +156,9 @@ protected function getVariableDescription(array $row) * Formats the description * * @param string $desc - * * @return string */ - protected function formatDesc($desc) + protected function formatDesc(string $desc): string { $desc = preg_replace('~\s+~', ' ', $desc); return wordwrap($desc); @@ -165,8 +170,7 @@ protected function formatDesc($desc) */ protected function renderTable(array $header, array $rows) { - /** @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper->setHeaders($header) ->renderByFormat($this->_output, $rows, $this->_input->getOption('format')); } @@ -174,7 +178,7 @@ protected function renderTable(array $header, array $rows) /** * @param string|null $variable */ - protected function initVariables($variable = null) + protected function initVariables(?string $variable = null) { /** @var DatabaseHelper $database */ $database = $this->getHelper('database'); @@ -183,10 +187,9 @@ protected function initVariables($variable = null) /** * @param array $vars - * * @return array */ - protected function formatVariables(array $vars) + protected function formatVariables(array $vars): array { $isStandardFormat = $this->_input->getOption('format') === null; $rounding = (int) $this->_input->getOption('rounding'); @@ -220,10 +223,9 @@ protected function formatVariables(array $vars) /** * @param array $vars - * * @return int */ - protected function getMaxValueWidth(array $vars) + protected function getMaxValueWidth(array $vars): int { $maxWidth = 0; foreach ($vars as $v) { @@ -237,8 +239,7 @@ protected function getMaxValueWidth(array $vars) /** * @param string $name - * * @return bool */ - abstract protected function allowRounding($name); + abstract protected function allowRounding(string $name): bool; } diff --git a/src/N98/Magento/Command/Database/ConsoleCommand.php b/src/N98/Magento/Command/Database/ConsoleCommand.php index f9502b33a..176d7afea 100644 --- a/src/N98/Magento/Command/Database/ConsoleCommand.php +++ b/src/N98/Magento/Command/Database/ConsoleCommand.php @@ -4,12 +4,16 @@ namespace N98\Magento\Command\Database; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +/** + * Database console command + * + * @package N98\Magento\Command\Database + */ class ConsoleCommand extends AbstractDatabaseCommand { public const COMMAND_OPTION_USE_MYCLI_INSTEAD_OF_MYSQL = 'use-mycli-instead-of-mysql'; @@ -18,18 +22,16 @@ class ConsoleCommand extends AbstractDatabaseCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'db:console'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Opens mysql client by database config from local.xml.'; + protected static bool $initMagentoFlag = false; + protected function configure(): void { $this @@ -51,15 +53,13 @@ protected function configure(): void } /** - * @param InputInterface $input - * @param OutputInterface $output - * + * {@inheritDoc} * @return int + * + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectDbSettings($output); - $args = [$input->getOption(self::COMMAND_OPTION_USE_MYCLI_INSTEAD_OF_MYSQL) ? 'mycli' : 'mysql']; if ($input->getOption(self::COMMAND_OPTION_NO_AUTO_REHASH)) { @@ -74,7 +74,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } /** - * execute a command + * Execute a command * * @param string $command */ diff --git a/src/N98/Magento/Command/Database/InfoCommand.php b/src/N98/Magento/Command/Database/InfoCommand.php index dbb67d088..5ede1f436 100644 --- a/src/N98/Magento/Command/Database/InfoCommand.php +++ b/src/N98/Magento/Command/Database/InfoCommand.php @@ -5,9 +5,8 @@ namespace N98\Magento\Command\Database; use InvalidArgumentException; -use N98\Magento\Command\CommandFormatInterface; +use N98\Magento\Command\CommandDataInterface; use N98\Magento\DbSettings; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -18,7 +17,7 @@ * * @package N98\Magento\Command\Database */ -class InfoCommand extends AbstractDatabaseCommand implements CommandFormatInterface +class InfoCommand extends AbstractDatabaseCommand implements CommandDataInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Database information'; @@ -26,15 +25,11 @@ class InfoCommand extends AbstractDatabaseCommand implements CommandFormatInterf /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'db:info'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Dumps database information.'; @@ -72,7 +67,7 @@ public function getHelp(): string protected function execute(InputInterface $input, OutputInterface $output): int { if (($settingArgument = $input->getArgument(self::COMMAND_ARGUMENT_SETTING)) !== null) { - $settings = $this->getData($input, $output); + $settings = $this->getData(); if (!isset($settings[$settingArgument])) { throw new InvalidArgumentException('Unknown setting: ' . $settingArgument); } @@ -86,74 +81,69 @@ protected function execute(InputInterface $input, OutputInterface $output): int /** * {@inheritdoc} - * @return array> * * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - public function getData(InputInterface $input, OutputInterface $output): array + public function setData(InputInterface $input,OutputInterface $output) : void { - if (is_null($this->data)) { - $this->detectDbSettings($output); + $this->detectDbSettings($output); - $settings = []; - foreach ($this->dbSettings as $key => $value) { - $settings[$key] = (string) $value; - } + $settings = []; + foreach ($this->dbSettings as $key => $value) { + $settings[$key] = (string) $value; + } - if ($this->dbSettings instanceof DbSettings) { - $isSocketConnect = $this->dbSettings->isSocketConnect(); - } else { - $isSocketConnect = false; - } + if ($this->dbSettings instanceof DbSettings) { + $isSocketConnect = $this->dbSettings->isSocketConnect(); + } else { + $isSocketConnect = false; + } - // note: there is no need to specify the default port neither for PDO, nor JDBC nor CLI. - $portOrDefault = $this->dbSettings['port'] ?? 3306; - - $pdoConnectionString = ''; - if ($isSocketConnect) { - $pdoConnectionString = sprintf( - 'mysql:unix_socket=%s;dbname=%s', - $this->dbSettings['unix_socket'], - $this->dbSettings['dbname'] - ); - } else { - $pdoConnectionString = sprintf( - 'mysql:host=%s;port=%s;dbname=%s', - $this->dbSettings['host'], - $portOrDefault, - $this->dbSettings['dbname'] - ); - } - $settings['PDO-Connection-String'] = $pdoConnectionString; - - $jdbcConnectionString = ''; - if ($isSocketConnect) { - // isn't supported according to this post: http://stackoverflow.com/a/18493673/145829 - $jdbcConnectionString = 'Connecting using JDBC through a unix socket isn\'t supported!'; - } else { - $jdbcConnectionString = sprintf( - 'jdbc:mysql://%s:%s/%s?username=%s&password=%s', - $this->dbSettings['host'], - $portOrDefault, - $this->dbSettings['dbname'], - $this->dbSettings['username'], - $this->dbSettings['password'] - ); - } - $settings['JDBC-Connection-String'] = $jdbcConnectionString; + // note: there is no need to specify the default port neither for PDO, nor JDBC nor CLI. + $portOrDefault = $this->dbSettings['port'] ?? 3306; + + $pdoConnectionString = ''; + if ($isSocketConnect) { + $pdoConnectionString = sprintf( + 'mysql:unix_socket=%s;dbname=%s', + $this->dbSettings['unix_socket'], + $this->dbSettings['dbname'] + ); + } else { + $pdoConnectionString = sprintf( + 'mysql:host=%s;port=%s;dbname=%s', + $this->dbSettings['host'], + $portOrDefault, + $this->dbSettings['dbname'] + ); + } + $settings['PDO-Connection-String'] = $pdoConnectionString; + + $jdbcConnectionString = ''; + if ($isSocketConnect) { + // isn't supported according to this post: http://stackoverflow.com/a/18493673/145829 + $jdbcConnectionString = 'Connecting using JDBC through a unix socket isn\'t supported!'; + } else { + $jdbcConnectionString = sprintf( + 'jdbc:mysql://%s:%s/%s?username=%s&password=%s', + $this->dbSettings['host'], + $portOrDefault, + $this->dbSettings['dbname'], + $this->dbSettings['username'], + $this->dbSettings['password'] + ); + } + $settings['JDBC-Connection-String'] = $jdbcConnectionString; - $database = $this->getDatabaseHelper(); - $mysqlCliString = 'mysql ' . $database->getMysqlClientToolConnectionString(); - $settings['MySQL-Cli-String'] = $mysqlCliString; + $database = $this->getDatabaseHelper(); + $mysqlCliString = 'mysql ' . $database->getMysqlClientToolConnectionString(); + $settings['MySQL-Cli-String'] = $mysqlCliString; - foreach ($settings as $settingName => $settingValue) { - $this->data[$settingName] = [ - 'Name' => $settingName, - 'Value' => $settingValue - ]; - } + foreach ($settings as $settingName => $settingValue) { + $this->data[$settingName] = [ + 'Name' => $settingName, + 'Value' => $settingValue + ]; } - - return $this->data; } } diff --git a/src/N98/Magento/Command/Database/Maintain/CheckTablesCommand.php b/src/N98/Magento/Command/Database/Maintain/CheckTablesCommand.php index 52fad6a1f..bd557d49d 100644 --- a/src/N98/Magento/Command/Database/Maintain/CheckTablesCommand.php +++ b/src/N98/Magento/Command/Database/Maintain/CheckTablesCommand.php @@ -6,10 +6,8 @@ use InvalidArgumentException; use N98\Magento\Command\AbstractCommand; -use N98\Magento\Command\CommandFormatInterface; -use N98\Util\Console\Helper\Table\Renderer\RendererFactory; +use N98\Magento\Command\CommandDataInterface; use PDO; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -20,7 +18,7 @@ * * @package N98\Magento\Command\Database\Maintain */ -class CheckTablesCommand extends AbstractCommand implements CommandFormatInterface +class CheckTablesCommand extends AbstractCommand implements CommandDataInterface { public const COMMAND_OPTION_TYPE = 'type'; @@ -34,15 +32,11 @@ class CheckTablesCommand extends AbstractCommand implements CommandFormatInterfa /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'db:maintain:check-tables'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Check database tables.'; @@ -141,66 +135,61 @@ protected function progressAdvance(ProgressBar $progress): void /** * {@inheritdoc} - * @return array> * * @uses self::_checkInnoDB() * @uses self::_checkMEMORY() * @uses self::_checkMyISAM() */ - public function getData(InputInterface $input, OutputInterface $output): array + public function setData(InputInterface $input,OutputInterface $output) : void { - if (is_null($this->data)) { - $data = []; - $this->isTypeAllowed($input); - $database = $this->getDatabaseHelper(); - $this->showProgress = $input->getOption(self::COMMAND_OPTION_FORMAT) === null; - - /** @var string $table */ - $table = $input->getOption(self::COMMAND_OPTION_TABLE); - if ($table) { - $resolvedTables = [$database->resolveTables( - ['@check'], - ['check' => ['tables' => explode(' ', $table)]] - )]; - $tables = $resolvedTables[0]; - } else { - $tables = $database->getTables(); - } + $data = []; + $this->isTypeAllowed($input); + $database = $this->getDatabaseHelper(); + $this->showProgress = $input->getOption(self::COMMAND_OPTION_FORMAT) === null; + + /** @var string $table */ + $table = $input->getOption(self::COMMAND_OPTION_TABLE); + if ($table) { + $resolvedTables = [$database->resolveTables( + ['@check'], + ['check' => ['tables' => explode(' ', $table)]] + )]; + $tables = $resolvedTables[0]; + } else { + $tables = $database->getTables(); + } - $allTableStatus = $database->getTablesStatus(); + $allTableStatus = $database->getTablesStatus(); - $progress = new ProgressBar($output, 50); + $progress = new ProgressBar($output, 50); - if ($this->showProgress) { - $progress->start(count($tables)); - } + if ($this->showProgress) { + $progress->start(count($tables)); + } - $methods = ['InnoDB' => 1, 'MEMORY' => 1, 'MyISAM' => 1]; - - foreach ($tables as $tableName) { - if (isset($allTableStatus[$tableName]) && isset($methods[$allTableStatus[$tableName]['Engine']])) { - $m = '_check' . $allTableStatus[$tableName]['Engine']; - $data = array_merge($data, $this->$m($input, $output, $tableName)); - } else { - $data[] = [ - 'Table' => $tableName, - 'Operation' => 'not supported', - 'Type' => '', - 'Status' => '' - ]; - } - $this->progressAdvance($progress); - } + $methods = ['InnoDB' => 1, 'MEMORY' => 1, 'MyISAM' => 1]; - if ($this->showProgress) { - $progress->finish(); - $output->writeln(''); + foreach ($tables as $tableName) { + if (isset($allTableStatus[$tableName]) && isset($methods[$allTableStatus[$tableName]['Engine']])) { + $m = '_check' . $allTableStatus[$tableName]['Engine']; + $data = array_merge($data, $this->$m($input, $output, $tableName)); + } else { + $data[] = [ + 'Table' => $tableName, + 'Operation' => 'not supported', + 'Type' => '', + 'Status' => '' + ]; } + $this->progressAdvance($progress); + } - $this->data = $data; + if ($this->showProgress) { + $progress->finish(); + $output->writeln(''); } - return $this->data; + $this->data = $data; } /** diff --git a/src/N98/Magento/Command/Database/QueryCommand.php b/src/N98/Magento/Command/Database/QueryCommand.php index 86f62020c..f567b692e 100644 --- a/src/N98/Magento/Command/Database/QueryCommand.php +++ b/src/N98/Magento/Command/Database/QueryCommand.php @@ -5,7 +5,6 @@ namespace N98\Magento\Command\Database; use N98\Util\Exec; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -25,18 +24,18 @@ class QueryCommand extends AbstractDatabaseCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'db:query'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Executes an SQL query on the database defined in local.xml.'; + protected static bool $detectMagentoFlag = false; + + protected static bool $initMagentoFlag = false; + protected function configure(): void { $this @@ -105,26 +104,35 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->detectDbSettings($output); $query = $this->getOrAskForArgument(self::COMMAND_ARGUMENT_QUERY, $input, $output, 'SQL Query'); - - $helper = $this->getDatabaseHelper(); - $exec = sprintf( - 'mysql %s -e %s', - $helper->getMysqlClientToolConnectionString(), - escapeshellarg($query) - ); + $exec = $this->getQueryString($query); if ($input->getOption(self::COMMAND_OPTION_ONLY_COMMAND)) { $output->writeln($exec); - } else { - Exec::run($exec, $commandOutput, $returnValue); - if ($commandOutput) { - $output->writeln($commandOutput); - if ($returnValue > 0) { - $output->writeln('' . $commandOutput . ''); - } + return Command::SUCCESS; + } + + Exec::run($exec, $commandOutput, $returnValue); + if ($commandOutput) { + $output->writeln($commandOutput); + if ($returnValue > 0) { + $output->writeln('' . $commandOutput . ''); } } return Command::SUCCESS; } + + /** + * @param string $query + * @return string + */ + private function getQueryString(string $query): string + { + $helper = $this->getDatabaseHelper(); + return sprintf( + 'mysql %s -e %s', + $helper->getMysqlClientToolConnectionString(), + escapeshellarg($query) + ); + } } diff --git a/src/N98/Magento/Command/Database/StatusCommand.php b/src/N98/Magento/Command/Database/StatusCommand.php index f4bf10124..d57387b2a 100644 --- a/src/N98/Magento/Command/Database/StatusCommand.php +++ b/src/N98/Magento/Command/Database/StatusCommand.php @@ -6,7 +6,6 @@ use DateTime; use Exception; -use Symfony\Component\Console\Attribute\AsCommand; /** * Database status command @@ -17,15 +16,11 @@ class StatusCommand extends AbstractShowCommand { /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'db:status'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Shows important server information or custom selected status values.'; @@ -184,11 +179,11 @@ protected function timeElapsedString(string $datetime, bool $full = false): stri 'i' => 'minute', 's' => 'second' ]; - foreach ($string as $k => &$v) { - if ($diff->$k) { - $v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 's' : ''); + foreach ($string as $key => &$value) { + if ($diff->$key) { + $value = $diff->$key . ' ' . $value . ($diff->$key > 1 ? 's' : ''); } else { - unset($string[$k]); + unset($string[$key]); } } diff --git a/src/N98/Magento/Command/Database/VariablesCommand.php b/src/N98/Magento/Command/Database/VariablesCommand.php index c566c9c2f..054e24531 100644 --- a/src/N98/Magento/Command/Database/VariablesCommand.php +++ b/src/N98/Magento/Command/Database/VariablesCommand.php @@ -4,8 +4,6 @@ namespace N98\Magento\Command\Database; -use Symfony\Component\Console\Attribute\AsCommand; - /** * Database variables command * @@ -15,15 +13,11 @@ class VariablesCommand extends AbstractShowCommand { /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'db:variables'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Shows important variables or custom selected.'; diff --git a/src/N98/Magento/Command/Design/DemoNoticeCommand.php b/src/N98/Magento/Command/Design/DemoNoticeCommand.php index 884cec41b..591deb14b 100644 --- a/src/N98/Magento/Command/Design/DemoNoticeCommand.php +++ b/src/N98/Magento/Command/Design/DemoNoticeCommand.php @@ -5,7 +5,6 @@ namespace N98\Magento\Command\Design; use N98\Magento\Command\AbstractStoreConfigCommand; -use Symfony\Component\Console\Attribute\AsCommand; /** * Toggle demo store notice command @@ -16,15 +15,11 @@ class DemoNoticeCommand extends AbstractStoreConfigCommand { /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'design:demo-notice'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Toggles demo store notice for a store view'; diff --git a/src/N98/Magento/Command/Developer/ClassLookupCommand.php b/src/N98/Magento/Command/Developer/ClassLookupCommand.php index c88695090..fa42fb822 100644 --- a/src/N98/Magento/Command/Developer/ClassLookupCommand.php +++ b/src/N98/Magento/Command/Developer/ClassLookupCommand.php @@ -5,7 +5,6 @@ namespace N98\Magento\Command\Developer; use N98\Magento\Command\AbstractCommand; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -24,15 +23,11 @@ class ClassLookupCommand extends AbstractCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'dev:class:lookup'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Resolves a grouped class name.'; @@ -59,9 +54,6 @@ protected function configure(): void */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - /** @var string $type */ $type = $input->getArgument(self::COMMAND_ARGUMENT_TYPE); /** @var string $name */ diff --git a/src/N98/Magento/Command/Developer/ConsoleCommand.php b/src/N98/Magento/Command/Developer/ConsoleCommand.php index a9c87a0e4..b33a31db8 100644 --- a/src/N98/Magento/Command/Developer/ConsoleCommand.php +++ b/src/N98/Magento/Command/Developer/ConsoleCommand.php @@ -9,7 +9,6 @@ use N98\Util\Unicode\Charset; use Psy\Configuration; use Psy\Output\ShellOutput; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -23,15 +22,11 @@ class ConsoleCommand extends AbstractCommand { /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'dev:console'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Opens PHP interactive shell with initialized Mage::app() (Experimental).'; @@ -42,9 +37,6 @@ class ConsoleCommand extends AbstractCommand */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - $consoleOutput = new ShellOutput(); $config = new Configuration(); $shell = new Shell($config); diff --git a/src/N98/Magento/Command/Developer/EmailTemplate/UsageCommand.php b/src/N98/Magento/Command/Developer/EmailTemplate/UsageCommand.php index 18bc3c17b..13f4041ee 100644 --- a/src/N98/Magento/Command/Developer/EmailTemplate/UsageCommand.php +++ b/src/N98/Magento/Command/Developer/EmailTemplate/UsageCommand.php @@ -1,27 +1,27 @@ - * @author Tom Klingenberg - */ + +declare(strict_types=1); namespace N98\Magento\Command\Developer\EmailTemplate; use Mage; use Mage_Adminhtml_Model_Email_Template; +use Mage_Core_Exception; use Mage_Core_Model_Template; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use N98\Util\Console\Helper\Table\Renderer\RendererFactory; -use N98\Util\Console\Helper\TableHelper; use Path; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -class UsageCommand extends AbstractMagentoCommand +/** + * @author Mike Parkin + * @author Tom Klingenberg + */ +class UsageCommand extends AbstractCommand { - protected function configure() + protected function configure(): void { $this ->setName('dev:email-template:usage') @@ -37,18 +37,18 @@ protected function configure() /** * @param InputInterface $input * @param OutputInterface $output - * * @return int + * @throws Mage_Core_Exception */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output, true); + $this->detectMagento($output); $this->initMagento(); + $templates = $this->findEmailTemplates(); if (!empty($templates)) { - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); + $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['id', 'Name', 'Scope', 'Scope Id', Path::class]) ->renderByFormat($output, $templates, $input->getOption('format')); @@ -58,7 +58,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int return 0; } - protected function findEmailTemplates() + /** + * @throws Mage_Core_Exception + */ + protected function findEmailTemplates(): array { /** @var Mage_Core_Model_Template[] $templates */ $templates = Mage::getModel('adminhtml/email_template')->getCollection(); @@ -66,11 +69,8 @@ protected function findEmailTemplates() $return = []; foreach ($templates as $template) { - - /** - * Some modules overload the template class so that the method getSystemConfigPathsWhereUsedCurrently - * is not available, this is a workaround for that - */ + // Some modules overload the template class so that the method getSystemConfigPathsWhereUsedCurrently + // is not available, this is a workaround for that if (!method_exists($template, 'getSystemConfigPathsWhereUsedCurrently')) { $instance = new Mage_Adminhtml_Model_Email_Template(); $template = $instance->load($template->getId()); @@ -79,11 +79,21 @@ protected function findEmailTemplates() $configPaths = $template->getSystemConfigPathsWhereUsedCurrently(); if (!(is_countable($configPaths) ? count($configPaths) : 0)) { - $configPaths[] = ['scope' => 'Unused', 'scope_id' => 'Unused', 'path' => 'Unused']; + $configPaths[] = [ + 'scope' => 'Unused', + 'scope_id' => 'Unused', + 'path' => 'Unused' + ]; } foreach ($configPaths as $configPath) { - $return[] = ['id' => $this->sanitizeEmailProperty($template->getId()), 'Template Code' => $this->sanitizeEmailProperty($template->getTemplateCode()), 'Scope' => $this->sanitizeEmailProperty($configPath['scope']), 'Scope Id' => $this->sanitizeEmailProperty($configPath['scope_id']), Path::class => $this->sanitizeEmailProperty($configPath['path'])]; + $return[] = [ + 'id' => $this->sanitizeEmailProperty($template->getId()), + 'Template Code' => $this->sanitizeEmailProperty($template->getTemplateCode()), + 'Scope' => $this->sanitizeEmailProperty($configPath['scope']), + 'Scope Id' => $this->sanitizeEmailProperty($configPath['scope_id']), + Path::class => $this->sanitizeEmailProperty($configPath['path']) + ]; } } @@ -92,10 +102,9 @@ protected function findEmailTemplates() /** * @param string $input Module property to be sanitized - * * @return string */ - private function sanitizeEmailProperty($input) + private function sanitizeEmailProperty(string $input): string { return trim($input); } diff --git a/src/N98/Magento/Command/Developer/Ide/PhpStorm/MetaCommand.php b/src/N98/Magento/Command/Developer/Ide/PhpStorm/MetaCommand.php index abfdda8ea..f3732b4ad 100644 --- a/src/N98/Magento/Command/Developer/Ide/PhpStorm/MetaCommand.php +++ b/src/N98/Magento/Command/Developer/Ide/PhpStorm/MetaCommand.php @@ -5,7 +5,7 @@ use Directory; use Exception; use Mage; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -14,7 +14,7 @@ use UnexpectedValueException; use Varien_Simplexml_Element; -class MetaCommand extends AbstractMagentoCommand +class MetaCommand extends AbstractCommand { /** * @var array diff --git a/src/N98/Magento/Command/Developer/Log/DbCommand.php b/src/N98/Magento/Command/Developer/Log/DbCommand.php index 79b80b6a6..9f0fd2240 100644 --- a/src/N98/Magento/Command/Developer/Log/DbCommand.php +++ b/src/N98/Magento/Command/Developer/Log/DbCommand.php @@ -5,7 +5,6 @@ namespace N98\Magento\Command\Developer\Log; use RuntimeException; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -24,15 +23,11 @@ class DbCommand extends AbstractLogCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'dev:log:db'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Turn on/off database query logging'; @@ -69,9 +64,6 @@ protected function _getVarienAdapterPhpFile(): string */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - $output->writeln("Looking in " . $this->_getVarienAdapterPhpFile() . ""); $this->_replaceVariable($input, $output, '$_debug'); diff --git a/src/N98/Magento/Command/Developer/Log/LogCommand.php b/src/N98/Magento/Command/Developer/Log/LogCommand.php index ae573facf..cda3b167f 100644 --- a/src/N98/Magento/Command/Developer/Log/LogCommand.php +++ b/src/N98/Magento/Command/Developer/Log/LogCommand.php @@ -5,7 +5,6 @@ namespace N98\Magento\Command\Developer\Log; use N98\Magento\Command\AbstractStoreConfigCommand; -use Symfony\Component\Console\Attribute\AsCommand; /** * Toggle development log command @@ -16,15 +15,11 @@ class LogCommand extends AbstractStoreConfigCommand { /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'dev:log'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Toggle development log (system.log, exception.log)'; diff --git a/src/N98/Magento/Command/Developer/Log/SizeCommand.php b/src/N98/Magento/Command/Developer/Log/SizeCommand.php index 132325139..89e3e2c84 100644 --- a/src/N98/Magento/Command/Developer/Log/SizeCommand.php +++ b/src/N98/Magento/Command/Developer/Log/SizeCommand.php @@ -6,7 +6,6 @@ use N98\Util\Filesystem; use RuntimeException; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -26,15 +25,11 @@ class SizeCommand extends AbstractLogCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'dev:log:size'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Get size of log file.'; @@ -63,9 +58,6 @@ protected function configure(): void */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - $fileName = $input->getArgument(self::COMMAND_ARGUMENT_LOG_FILENAME); if ($fileName === null) { /** @var string $path */ diff --git a/src/N98/Magento/Command/Developer/MergeCssCommand.php b/src/N98/Magento/Command/Developer/MergeCssCommand.php index bd63a1f03..c8eca30f5 100644 --- a/src/N98/Magento/Command/Developer/MergeCssCommand.php +++ b/src/N98/Magento/Command/Developer/MergeCssCommand.php @@ -5,7 +5,6 @@ namespace N98\Magento\Command\Developer; use N98\Magento\Command\AbstractStoreConfigCommand; -use Symfony\Component\Console\Attribute\AsCommand; /** * Toggle CSS merging command @@ -16,15 +15,11 @@ class MergeCssCommand extends AbstractStoreConfigCommand { /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'dev:merge-css'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Toggles CSS merging'; diff --git a/src/N98/Magento/Command/Developer/MergeJsCommand.php b/src/N98/Magento/Command/Developer/MergeJsCommand.php index 6d25a023c..fb89dfbb0 100644 --- a/src/N98/Magento/Command/Developer/MergeJsCommand.php +++ b/src/N98/Magento/Command/Developer/MergeJsCommand.php @@ -5,7 +5,6 @@ namespace N98\Magento\Command\Developer; use N98\Magento\Command\AbstractStoreConfigCommand; -use Symfony\Component\Console\Attribute\AsCommand; /** * Toggle JS merging command @@ -16,15 +15,11 @@ class MergeJsCommand extends AbstractStoreConfigCommand { /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'dev:merge-js'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Toggles JS Merging'; diff --git a/src/N98/Magento/Command/Developer/Module/Disableenable/DisableCommand.php b/src/N98/Magento/Command/Developer/Module/Disableenable/DisableCommand.php index 47969e3b3..514b11909 100644 --- a/src/N98/Magento/Command/Developer/Module/Disableenable/DisableCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Disableenable/DisableCommand.php @@ -4,8 +4,6 @@ namespace N98\Magento\Command\Developer\Module\Disableenable; -use Symfony\Component\Console\Attribute\AsCommand; - /** * Disable module(s) command * @@ -15,15 +13,11 @@ class DisableCommand extends AbstractDisableenableCommand { /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'dev:module:disable'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Disables a module or all modules in codePool.'; diff --git a/src/N98/Magento/Command/Developer/Module/Disableenable/EnableCommand.php b/src/N98/Magento/Command/Developer/Module/Disableenable/EnableCommand.php index 21cb3c3d4..02089a6c7 100644 --- a/src/N98/Magento/Command/Developer/Module/Disableenable/EnableCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Disableenable/EnableCommand.php @@ -4,8 +4,6 @@ namespace N98\Magento\Command\Developer\Module\Disableenable; -use Symfony\Component\Console\Attribute\AsCommand; - /** * Enable module(s) command * @@ -15,15 +13,11 @@ class EnableCommand extends AbstractDisableenableCommand { /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'dev:module:enable'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Enables a module or all modules in codePool.'; diff --git a/src/N98/Magento/Command/Developer/Module/ListCommand.php b/src/N98/Magento/Command/Developer/Module/ListCommand.php index 060880214..fedc471b8 100644 --- a/src/N98/Magento/Command/Developer/Module/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Module/ListCommand.php @@ -5,9 +5,8 @@ namespace N98\Magento\Command\Developer\Module; use N98\Magento\Command\AbstractCommand; -use N98\Magento\Command\CommandFormatInterface; +use N98\Magento\Command\CommandDataInterface; use N98\Magento\Modules; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -17,7 +16,7 @@ * * @package N98\Magento\Command\Developer\Module */ -class ListCommand extends AbstractCommand implements CommandFormatInterface +class ListCommand extends AbstractCommand implements CommandDataInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Installed Modules'; @@ -31,15 +30,11 @@ class ListCommand extends AbstractCommand implements CommandFormatInterface /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'dev:module:list'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'List all installed modules.'; @@ -70,14 +65,13 @@ protected function configure(): void } /** - * {@inheritdoc} - * @return array> + * {@inheritDoc} * * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - public function getData(InputInterface $input, OutputInterface $output): array + public function setData(InputInterface $input,OutputInterface $output) : void { - return iterator_to_array($this->filterModules($input)); + $this->data =iterator_to_array($this->filterModules($input)); } /** diff --git a/src/N98/Magento/Command/Developer/Module/Observer/ListCommand.php b/src/N98/Magento/Command/Developer/Module/Observer/ListCommand.php index 279a5ddab..0e5c38848 100644 --- a/src/N98/Magento/Command/Developer/Module/Observer/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Observer/ListCommand.php @@ -6,8 +6,7 @@ use InvalidArgumentException; use N98\Magento\Command\AbstractCommand; -use N98\Magento\Command\CommandFormatInterface; -use Symfony\Component\Console\Attribute\AsCommand; +use N98\Magento\Command\CommandDataInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -18,7 +17,7 @@ * * @package N98\Magento\Command\Developer\Module\Observer */ -class ListCommand extends AbstractCommand implements CommandFormatInterface +class ListCommand extends AbstractCommand implements CommandDataInterface { public const COMMAND_ARGUMENT_TYPE = 'type'; @@ -26,15 +25,11 @@ class ListCommand extends AbstractCommand implements CommandFormatInterface /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'dev:module:observer:list'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Lists all registered observers.'; @@ -57,51 +52,46 @@ protected function configure(): void } /** - * {@inheritdoc} - * @return array> + * {@inheritDoc} */ - public function getData(InputInterface $input, OutputInterface $output): array + public function setData(InputInterface $input,OutputInterface $output) : void { - if (is_null($this->data)) { - $this->data = []; + $this->data = []; - /** @var string $type */ - $type = $input->getArgument(self::COMMAND_ARGUMENT_TYPE); + /** @var string $type */ + $type = $input->getArgument(self::COMMAND_ARGUMENT_TYPE); - $areas = ['global', 'adminhtml', 'frontend', 'crontab']; + $areas = ['global', 'adminhtml', 'frontend', 'crontab']; - if ($type === null) { - /** @var string $type */ - $type = $this->askForArrayEntry($areas, $input, $output, 'Please select an area:'); - } + if ($type === null) { + /** @var string $type */ + $type = $this->askForArrayEntry($areas, $input, $output, 'Please select an area:'); + } - if (!in_array($type, $areas)) { - throw new InvalidArgumentException('Invalid type! Use one of: ' . implode(', ', $areas)); - } + if (!in_array($type, $areas)) { + throw new InvalidArgumentException('Invalid type! Use one of: ' . implode(', ', $areas)); + } - if ($input->getOption(parent::COMMAND_OPTION_FORMAT) === null) { - $this->writeSection($output, 'Observers: ' . $type); - } + if ($input->getOption(parent::COMMAND_OPTION_FORMAT) === null) { + $this->writeSection($output, 'Observers: ' . $type); + } - $frontendEvents = $this->_getMageConfig()->getNode($type . '/events')->asArray(); - if (true === $input->getOption(self::COMMAND_OPTION_SORT)) { - // sorting for Observers is a bad idea because the order in which observers will be called is important. - ksort($frontendEvents); - } + $frontendEvents = $this->_getMageConfig()->getNode($type . '/events')->asArray(); + if (true === $input->getOption(self::COMMAND_OPTION_SORT)) { + // sorting for Observers is a bad idea because the order in which observers will be called is important. + ksort($frontendEvents); + } - foreach ($frontendEvents as $eventName => $eventData) { - $observerList = []; - foreach ($eventData['observers'] as $observer) { - $observerList[] = $this->getObserver($observer, $type); - } - $this->data[] = [ - 'Event' => $eventName, - 'Observers' => implode("\n", $observerList) - ]; + foreach ($frontendEvents as $eventName => $eventData) { + $observerList = []; + foreach ($eventData['observers'] as $observer) { + $observerList[] = $this->getObserver($observer, $type); } + $this->data[] = [ + 'Event' => $eventName, + 'Observers' => implode("\n", $observerList) + ]; } - - return $this->data; } /** diff --git a/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php b/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php index f99dc8ac2..50ac4be3e 100644 --- a/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php @@ -4,8 +4,7 @@ namespace N98\Magento\Command\Developer\Module\Rewrite; -use N98\Magento\Command\CommandFormatInterface; -use Symfony\Component\Console\Attribute\AsCommand; +use N98\Magento\Command\CommandDataInterface; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -14,7 +13,7 @@ * * @package N98\Magento\Command\Developer\Module */ -class ListCommand extends AbstractRewriteCommand implements CommandFormatInterface +class ListCommand extends AbstractRewriteCommand implements CommandDataInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Rewrites'; @@ -22,43 +21,34 @@ class ListCommand extends AbstractRewriteCommand implements CommandFormatInterfa /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'dev:module:rewrite:list'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Lists all rewrites.'; /** - * {@inheritdoc} - * @return array> + * {@inheritDoc} * * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - public function getData(InputInterface $input, OutputInterface $output): array + public function setData(InputInterface $input,OutputInterface $output) : void { - if (is_null($this->data)) { - $this->data = []; - - $rewrites = array_merge($this->loadRewrites(), $this->loadAutoloaderRewrites()); - foreach ($rewrites as $type => $data) { - if ((is_countable($data) ? count($data) : 0) > 0) { - foreach ($data as $class => $rewriteClass) { - $this->data[] = [ - 'Type' => $type, - 'Class' => $class, - 'Rewrite' => implode(', ', $rewriteClass) - ]; - } + $this->data = []; + + $rewrites = array_merge($this->loadRewrites(), $this->loadAutoloaderRewrites()); + foreach ($rewrites as $type => $data) { + if ((is_countable($data) ? count($data) : 0) > 0) { + foreach ($data as $class => $rewriteClass) { + $this->data[] = [ + 'Type' => $type, + 'Class' => $class, + 'Rewrite' => implode(', ', $rewriteClass) + ]; } } } - - return $this->data; } } diff --git a/src/N98/Magento/Command/Developer/ProfilerCommand.php b/src/N98/Magento/Command/Developer/ProfilerCommand.php index c8140e995..22d801a15 100644 --- a/src/N98/Magento/Command/Developer/ProfilerCommand.php +++ b/src/N98/Magento/Command/Developer/ProfilerCommand.php @@ -5,7 +5,6 @@ namespace N98\Magento\Command\Developer; use N98\Magento\Command\AbstractStoreConfigCommand; -use Symfony\Component\Console\Attribute\AsCommand; /** * Toggle profiler command @@ -16,15 +15,11 @@ class ProfilerCommand extends AbstractStoreConfigCommand { /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'dev:profiler'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Toggles profiler for debugging'; diff --git a/src/N98/Magento/Command/Developer/Report/CountCommand.php b/src/N98/Magento/Command/Developer/Report/CountCommand.php index 2a5ef244f..a149f2109 100644 --- a/src/N98/Magento/Command/Developer/Report/CountCommand.php +++ b/src/N98/Magento/Command/Developer/Report/CountCommand.php @@ -6,7 +6,6 @@ use Mage; use N98\Magento\Command\AbstractCommand; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -21,15 +20,11 @@ class CountCommand extends AbstractCommand { /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'dev:report:count'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Get count of report files.'; @@ -40,9 +35,6 @@ class CountCommand extends AbstractCommand */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - $dir = Mage::getBaseDir('var') . DIRECTORY_SEPARATOR . 'report' . DIRECTORY_SEPARATOR; $count = (string) $this->getFileCount($dir); diff --git a/src/N98/Magento/Command/Developer/Setup/Script/AttributeCommand.php b/src/N98/Magento/Command/Developer/Setup/Script/AttributeCommand.php index c504f7a2a..0ed5986a8 100644 --- a/src/N98/Magento/Command/Developer/Setup/Script/AttributeCommand.php +++ b/src/N98/Magento/Command/Developer/Setup/Script/AttributeCommand.php @@ -15,15 +15,15 @@ namespace N98\Magento\Command\Developer\Setup\Script; use Exception; -use N98\Magento\Command\AbstractMagentoCommand; +use N98\Magento\Command\AbstractCommand; use N98\Magento\Command\Developer\Setup\Script\Attribute\EntityType\Factory; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class AttributeCommand extends AbstractMagentoCommand +class AttributeCommand extends AbstractCommand { - protected function configure() + protected function configure(): void { $this ->setName('dev:setup:script:attribute') @@ -41,9 +41,7 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output): int { $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } + $this->initMagento(); try { $entityType = $input->getArgument('entityType'); @@ -53,7 +51,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $generator = Factory::create($entityType, $attribute); $generator->setReadConnection( - $this->_getModel('core/resource', 'Mage_Core_Model_Resource')->getConnection('core_read') + $this->_getModel('core/resource')->getConnection('core_read') ); $code = $generator->generateCode(); $warnings = $generator->getWarnings(); @@ -68,14 +66,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int /** * @param string $entityType * @param string $attributeCode - * * @return mixed */ - protected function getAttribute($entityType, $attributeCode) + protected function getAttribute(string $entityType, string $attributeCode) { - $attribute = $this->_getModel('catalog/resource_eav_attribute', 'Mage_Catalog_Model_Resource_Eav_Attribute') + return $this + ->_getModel('catalog/resource_eav_attribute') ->loadByCode($entityType, $attributeCode); - - return $attribute; } } diff --git a/src/N98/Magento/Command/Developer/SymlinksCommand.php b/src/N98/Magento/Command/Developer/SymlinksCommand.php index cad9c52f1..12fe2d5c8 100644 --- a/src/N98/Magento/Command/Developer/SymlinksCommand.php +++ b/src/N98/Magento/Command/Developer/SymlinksCommand.php @@ -5,7 +5,6 @@ namespace N98\Magento\Command\Developer; use N98\Magento\Command\AbstractStoreConfigCommand; -use Symfony\Component\Console\Attribute\AsCommand; /** * Toggle allow symlinks setting command @@ -16,15 +15,11 @@ class SymlinksCommand extends AbstractStoreConfigCommand { /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'dev:symlinks'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Toggles allow symlinks setting'; diff --git a/src/N98/Magento/Command/Developer/TemplateHintsBlocksCommand.php b/src/N98/Magento/Command/Developer/TemplateHintsBlocksCommand.php index 816061f7b..8a5165374 100644 --- a/src/N98/Magento/Command/Developer/TemplateHintsBlocksCommand.php +++ b/src/N98/Magento/Command/Developer/TemplateHintsBlocksCommand.php @@ -6,7 +6,6 @@ use Mage_Core_Model_Store; use N98\Magento\Command\AbstractStoreConfigCommand; -use Symfony\Component\Console\Attribute\AsCommand; /** * Toggle template hints block command @@ -17,15 +16,11 @@ class TemplateHintsBlocksCommand extends AbstractStoreConfigCommand { /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'dev:template-hints-blocks'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Toggles template hints block names'; diff --git a/src/N98/Magento/Command/Developer/TemplateHintsCommand.php b/src/N98/Magento/Command/Developer/TemplateHintsCommand.php index a944aa1f6..24ea4c31d 100644 --- a/src/N98/Magento/Command/Developer/TemplateHintsCommand.php +++ b/src/N98/Magento/Command/Developer/TemplateHintsCommand.php @@ -6,7 +6,6 @@ use Mage_Core_Model_Store; use N98\Magento\Command\AbstractStoreConfigCommand; -use Symfony\Component\Console\Attribute\AsCommand; /** * Toggle template hints command @@ -17,15 +16,11 @@ class TemplateHintsCommand extends AbstractStoreConfigCommand { /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'dev:template-hints'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Toggles template hints'; diff --git a/src/N98/Magento/Command/Developer/Theme/DuplicatesCommand.php b/src/N98/Magento/Command/Developer/Theme/DuplicatesCommand.php index 4b5df6d96..6d092b15a 100644 --- a/src/N98/Magento/Command/Developer/Theme/DuplicatesCommand.php +++ b/src/N98/Magento/Command/Developer/Theme/DuplicatesCommand.php @@ -5,7 +5,6 @@ use DateTime; use N98\JUnitXml\Document as JUnitXmlDocument; use N98\Magento\Command\AbstractCommand; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -29,18 +28,16 @@ class DuplicatesCommand extends AbstractCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'dev:theme:duplicates'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Find duplicate files (templates, layout, locale, etc.) between two themes.'; + protected static bool $initMagentoFlag = false; + protected function configure(): void { $this @@ -83,7 +80,6 @@ public function getHelp(): string protected function execute(InputInterface $input, OutputInterface $output): int { $time = microtime(true); - $this->detectMagento($output); $referenceFiles = $this->getChecksums( $this->_magentoRootFolder . '/app/design/frontend/' diff --git a/src/N98/Magento/Command/Developer/Theme/InfoCommand.php b/src/N98/Magento/Command/Developer/Theme/InfoCommand.php index 2bdd73540..cc04f64d1 100644 --- a/src/N98/Magento/Command/Developer/Theme/InfoCommand.php +++ b/src/N98/Magento/Command/Developer/Theme/InfoCommand.php @@ -7,8 +7,6 @@ use Mage_Core_Model_Store; use Mage_Core_Model_Website; use N98\Magento\Command\AbstractCommand; -use N98\Magento\Command\AbstractMagentoStoreConfigCommand; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -24,15 +22,11 @@ class InfoCommand extends AbstractCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'dev:theme:info'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Displays settings of current design on particular store view.'; @@ -61,9 +55,6 @@ class InfoCommand extends AbstractCommand */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - foreach ($this->_getMage()->getWebsites() as $website) { foreach ($website->getStores() as $store) { $this->_displayTable($output, $store); diff --git a/src/N98/Magento/Command/Developer/Theme/ListCommand.php b/src/N98/Magento/Command/Developer/Theme/ListCommand.php index 082fdf78b..34e6a2c22 100644 --- a/src/N98/Magento/Command/Developer/Theme/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Theme/ListCommand.php @@ -6,8 +6,7 @@ use Mage; use N98\Magento\Command\AbstractCommand; -use N98\Magento\Command\CommandFormatInterface; -use Symfony\Component\Console\Attribute\AsCommand; +use N98\Magento\Command\CommandDataInterface; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -16,45 +15,36 @@ * * @package N98\Magento\Command\Developer\Theme */ -class ListCommand extends AbstractCommand implements CommandFormatInterface +class ListCommand extends AbstractCommand implements CommandDataInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Themes'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'dev:theme:list'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Lists all available themes.'; /** * {@inheritdoc} - * @return array> * * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - public function getData(InputInterface $input, OutputInterface $output): array + public function setData(InputInterface $input,OutputInterface $output) : void { - if (is_null($this->data)) { - $this->data = []; + $this->data = []; - foreach ($this->getThemes() as $package => $themes) { - foreach ($themes as $theme) { - $this->data[] = [ - 'Theme' => ($package ? $package . '/' : '') . $theme - ]; - } + foreach ($this->getThemes() as $package => $themes) { + foreach ($themes as $theme) { + $this->data[] = [ + 'Theme' => ($package ? $package . '/' : '') . $theme + ]; } } - - return $this->data; } /** diff --git a/src/N98/Magento/Command/Developer/Translate/ExportCommand.php b/src/N98/Magento/Command/Developer/Translate/ExportCommand.php index afef6057b..b150a1a86 100644 --- a/src/N98/Magento/Command/Developer/Translate/ExportCommand.php +++ b/src/N98/Magento/Command/Developer/Translate/ExportCommand.php @@ -8,7 +8,6 @@ use Mage; use Mage_Core_Model_Store_Exception; use N98\Magento\Command\AbstractCommand; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -30,15 +29,11 @@ class ExportCommand extends AbstractCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'dev:translate:export'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Export inline translations.'; @@ -71,9 +66,6 @@ protected function configure(): void */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - $helper = $this->getDatabaseHelper(); $db = $helper->getConnection(); diff --git a/src/N98/Magento/Command/Developer/Translate/InlineAdminCommand.php b/src/N98/Magento/Command/Developer/Translate/InlineAdminCommand.php index 99ff1f198..272160c28 100644 --- a/src/N98/Magento/Command/Developer/Translate/InlineAdminCommand.php +++ b/src/N98/Magento/Command/Developer/Translate/InlineAdminCommand.php @@ -6,7 +6,6 @@ use Mage_Core_Model_Store; use N98\Magento\Command\AbstractStoreConfigCommand; -use Symfony\Component\Console\Attribute\AsCommand; /** * Toggle inline admin translation command @@ -17,15 +16,11 @@ class InlineAdminCommand extends AbstractStoreConfigCommand { /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'dev:translate:admin'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Toggle inline translation tool for admin'; diff --git a/src/N98/Magento/Command/Developer/Translate/InlineShopCommand.php b/src/N98/Magento/Command/Developer/Translate/InlineShopCommand.php index 5b2747193..6f655edda 100644 --- a/src/N98/Magento/Command/Developer/Translate/InlineShopCommand.php +++ b/src/N98/Magento/Command/Developer/Translate/InlineShopCommand.php @@ -6,7 +6,6 @@ use Mage_Core_Model_Store; use N98\Magento\Command\AbstractStoreConfigCommand; -use Symfony\Component\Console\Attribute\AsCommand; /** * Toggle inline translation command @@ -17,15 +16,11 @@ class InlineShopCommand extends AbstractStoreConfigCommand { /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'dev:translate:shop'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Toggle inline translation tool for shop'; diff --git a/src/N98/Magento/Command/Developer/Translate/SetCommand.php b/src/N98/Magento/Command/Developer/Translate/SetCommand.php index 57e22b811..c5dcef8b2 100644 --- a/src/N98/Magento/Command/Developer/Translate/SetCommand.php +++ b/src/N98/Magento/Command/Developer/Translate/SetCommand.php @@ -8,7 +8,6 @@ use Mage; use Mage_Core_Model_Store; use N98\Magento\Command\AbstractCommand; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -31,15 +30,11 @@ class SetCommand extends AbstractCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'dev:translate:set'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Adds a translation to core_translate table. Globally for locale'; @@ -71,9 +66,6 @@ protected function configure(): void */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - $parameterHelper = $this->getParameterHelper(); /** @var Mage_Core_Model_Store $store */ diff --git a/src/N98/Magento/Command/Eav/Attribute/Create/DummyCommand.php b/src/N98/Magento/Command/Eav/Attribute/Create/DummyCommand.php index 803d5ed99..09d1ab09d 100644 --- a/src/N98/Magento/Command/Eav/Attribute/Create/DummyCommand.php +++ b/src/N98/Magento/Command/Eav/Attribute/Create/DummyCommand.php @@ -12,7 +12,6 @@ use Mage_Eav_Model_Resource_Entity_Attribute_Collection; use N98\Magento\Command\AbstractCommand; use RuntimeException; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -38,15 +37,11 @@ class DummyCommand extends AbstractCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'eav:attribute:create-dummy-values'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Create a dummy values for dropdown attributes.'; diff --git a/src/N98/Magento/Command/Eav/Attribute/ListCommand.php b/src/N98/Magento/Command/Eav/Attribute/ListCommand.php index b6de7527c..b0df7f7b5 100644 --- a/src/N98/Magento/Command/Eav/Attribute/ListCommand.php +++ b/src/N98/Magento/Command/Eav/Attribute/ListCommand.php @@ -9,8 +9,7 @@ use Mage_Eav_Model_Entity_Attribute; use Mage_Eav_Model_Entity_Type; use N98\Magento\Command\AbstractCommand; -use N98\Magento\Command\CommandFormatInterface; -use Symfony\Component\Console\Attribute\AsCommand; +use N98\Magento\Command\CommandDataInterface; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -20,7 +19,7 @@ * * @package N98\Magento\Command\Eav\Attribute */ -class ListCommand extends AbstractCommand implements CommandFormatInterface +class ListCommand extends AbstractCommand implements CommandDataInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'EAV attributes'; @@ -32,15 +31,11 @@ class ListCommand extends AbstractCommand implements CommandFormatInterface /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'eav:attribute:list'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Lists all EAV attributes.'; @@ -71,48 +66,44 @@ protected function configure(): void /** * {@inheritdoc} - * @return array> * * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - public function getData(InputInterface $input, OutputInterface $output): array + public function setData(InputInterface $input,OutputInterface $output) : void { - if (is_null($this->data)) { - $this->data = []; - - $attributesCollection = Mage::getResourceModel('eav/entity_attribute_collection'); - $attributesCollection->setOrder('attribute_code', 'asc'); - /** @var Mage_Eav_Model_Entity_Attribute $attribute */ - foreach ($attributesCollection as $attribute) { - $entityType = $this->_getEntityType($attribute); - - /** - * Filter by type - */ - if ($input->getOption(self::COMMAND_OPTION_FILTER_TYPE) !== null - && $input->getOption(self::COMMAND_OPTION_FILTER_TYPE) !== $entityType - ) { - continue; - } - - $row = []; - $row['Code'] = $attribute->getAttributeCode(); - $row['ID'] = $attribute->getId(); - $row['Entity type'] = $entityType; - $row['Label'] = $attribute->getFrontendLabel(); - - if ($input->getOption(self::COMMAND_OPTION_ADD_SOURCE)) { - $row['Source'] = $attribute->getSourceModel() ?: ''; - } - if ($input->getOption(self::COMMAND_OPTION_ADD_BACKEND)) { - $row['Backend type'] = $attribute->getBackendType(); - } - - $this->data[] = $row; + $this->data = []; + + $attributesCollection = Mage::getResourceModel('eav/entity_attribute_collection'); + $attributesCollection->setOrder('attribute_code', 'asc'); + /** @var Mage_Eav_Model_Entity_Attribute $attribute */ + foreach ($attributesCollection as $attribute) { + $entityType = $this->_getEntityType($attribute); + + /** + * Filter by type + */ + if ($input->getOption(self::COMMAND_OPTION_FILTER_TYPE) !== null + && $input->getOption(self::COMMAND_OPTION_FILTER_TYPE) !== $entityType + ) { + continue; } + + $row = []; + $row['Code'] = $attribute->getAttributeCode(); + $row['ID'] = $attribute->getId(); + $row['Entity type'] = $entityType; + $row['Label'] = $attribute->getFrontendLabel(); + + if ($input->getOption(self::COMMAND_OPTION_ADD_SOURCE)) { + $row['Source'] = $attribute->getSourceModel() ?: ''; + } + if ($input->getOption(self::COMMAND_OPTION_ADD_BACKEND)) { + $row['Backend type'] = $attribute->getBackendType(); + } + + $this->data[] = $row; } - return $this->data; } /** diff --git a/src/N98/Magento/Command/Eav/Attribute/RemoveCommand.php b/src/N98/Magento/Command/Eav/Attribute/RemoveCommand.php index 36d80ad9d..f3c9aea10 100644 --- a/src/N98/Magento/Command/Eav/Attribute/RemoveCommand.php +++ b/src/N98/Magento/Command/Eav/Attribute/RemoveCommand.php @@ -10,7 +10,6 @@ use Mage_Core_Exception; use Mage_Eav_Model_Entity_Setup; use N98\Magento\Command\AbstractCommand; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -30,15 +29,11 @@ class RemoveCommand extends AbstractCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'eav:attribute:remove'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Removes attribute for a given attribute code.'; @@ -66,9 +61,6 @@ protected function configure(): void */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - /** @var string $entityType */ $entityType = $input->getArgument(self::COMMAND_ARGUMENT_ENTITY); diff --git a/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php b/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php index 614722a85..b754f8e10 100644 --- a/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php +++ b/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php @@ -9,8 +9,7 @@ use Mage_Core_Exception; use Mage_Eav_Model_Entity_Attribute_Abstract; use N98\Magento\Command\AbstractCommand; -use N98\Magento\Command\CommandFormatInterface; -use Symfony\Component\Console\Attribute\AsCommand; +use N98\Magento\Command\CommandDataInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -20,7 +19,7 @@ * * @package N98\Magento\Command\Eav\Attribute */ -class ViewCommand extends AbstractCommand implements CommandFormatInterface +class ViewCommand extends AbstractCommand implements CommandDataInterface { public const COMMAND_ARGUMENT_ENTITY = 'entityType'; @@ -28,15 +27,11 @@ class ViewCommand extends AbstractCommand implements CommandFormatInterface /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'eav:attribute:view'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'View information about an EAV attribute.'; @@ -60,59 +55,54 @@ protected function configure(): void /** * {@inheritdoc} - * @return array> * @throws Mage_Core_Exception */ - public function getData(InputInterface $input, OutputInterface $output): array + public function setData(InputInterface $input,OutputInterface $output) : void { - if (is_null($this->data)) { - /** @var string $entityType */ - $entityType = $input->getArgument(self::COMMAND_ARGUMENT_ENTITY); - /** @var string $attributeCode */ - $attributeCode = $input->getArgument(self::COMMAND_ARGUMENT_ATTRIBUTE); - - $attribute = $this->getAttribute($entityType, $attributeCode); - if (!$attribute) { - throw new InvalidArgumentException('Attribute was not found.'); - } - - $cacheIdTags = $attribute->getCacheIdTags(); - $cacheTags = $attribute->getCacheTags(); - $flatColumns = $attribute->getFlatColumns(); - - $this->data = [ - ['ID', $attribute->getId()], - ['Code', $attribute->getName()], - ['Attribute-Set-ID', $attribute->getAttributeSetId()], - ['Visible-On-Front', $attribute->getIsVisibleOnFront() ? 'yes' : 'no'], - ['Attribute-Model', $attribute->getAttributeModel() ?: ''], - ['Backend-Model', $attribute->getBackendModel() ?: ''], - ['Backend-Table', $attribute->getBackendTable() ?: ''], - ['Backend-Type', $attribute->getBackendType() ?: ''], - ['Source-Model', $attribute->getSourceModel() ?: ''], - ['Cache-ID-Tags', is_array($cacheIdTags) ? implode(',', $cacheIdTags) : ''], - ['Cache-Tags', is_array($cacheTags) ? implode(',', $cacheTags) : ''], - ['Default-Value', $attribute->getDefaultValue() ?: ''], - ['Flat-Columns', is_array($flatColumns) ? implode(',', array_keys($flatColumns)) : ''] - ]; - - $key = ''; - $flatIndexes = $attribute->getFlatIndexes() ? $attribute->getFlatIndexes() : ''; - if ($flatIndexes) { - $key = array_key_first($flatIndexes); - $flatIndexes = implode(',', $flatIndexes[$key]['fields']); - } - $this->data[] = ['Flat-Indexes', $flatIndexes ? $key . ' - ' . $flatIndexes : '']; - - if ($attribute->getFrontend()) { - $this->data[] = ['Frontend-Label', $attribute->getFrontend()->getLabel()]; - $this->data[] = ['Frontend-Class', trim($attribute->getFrontend()->getClass())]; - $this->data[] = ['Frontend-Input', trim($attribute->getFrontend()->getInputType())]; - $this->data[] = ['Frontend-Input-Renderer-Class', trim((string)$attribute->getFrontend()->getInputRendererClass())]; - } + /** @var string $entityType */ + $entityType = $input->getArgument(self::COMMAND_ARGUMENT_ENTITY); + /** @var string $attributeCode */ + $attributeCode = $input->getArgument(self::COMMAND_ARGUMENT_ATTRIBUTE); + + $attribute = $this->getAttribute($entityType, $attributeCode); + if (!$attribute) { + throw new InvalidArgumentException('Attribute was not found.'); + } + + $cacheIdTags = $attribute->getCacheIdTags(); + $cacheTags = $attribute->getCacheTags(); + $flatColumns = $attribute->getFlatColumns(); + + $this->data = [ + ['ID', $attribute->getId()], + ['Code', $attribute->getName()], + ['Attribute-Set-ID', $attribute->getAttributeSetId()], + ['Visible-On-Front', $attribute->getIsVisibleOnFront() ? 'yes' : 'no'], + ['Attribute-Model', $attribute->getAttributeModel() ?: ''], + ['Backend-Model', $attribute->getBackendModel() ?: ''], + ['Backend-Table', $attribute->getBackendTable() ?: ''], + ['Backend-Type', $attribute->getBackendType() ?: ''], + ['Source-Model', $attribute->getSourceModel() ?: ''], + ['Cache-ID-Tags', is_array($cacheIdTags) ? implode(',', $cacheIdTags) : ''], + ['Cache-Tags', is_array($cacheTags) ? implode(',', $cacheTags) : ''], + ['Default-Value', $attribute->getDefaultValue() ?: ''], + ['Flat-Columns', is_array($flatColumns) ? implode(',', array_keys($flatColumns)) : ''] + ]; + + $key = ''; + $flatIndexes = $attribute->getFlatIndexes() ? $attribute->getFlatIndexes() : ''; + if ($flatIndexes) { + $key = array_key_first($flatIndexes); + $flatIndexes = implode(',', $flatIndexes[$key]['fields']); + } + $this->data[] = ['Flat-Indexes', $flatIndexes ? $key . ' - ' . $flatIndexes : '']; + + if ($attribute->getFrontend()) { + $this->data[] = ['Frontend-Label', $attribute->getFrontend()->getLabel()]; + $this->data[] = ['Frontend-Class', trim($attribute->getFrontend()->getClass())]; + $this->data[] = ['Frontend-Input', trim($attribute->getFrontend()->getInputType())]; + $this->data[] = ['Frontend-Input-Renderer-Class', trim((string)$attribute->getFrontend()->getInputRendererClass())]; } -// ) - return $this->data; } /** diff --git a/src/N98/Magento/Command/Indexer/ListCommand.php b/src/N98/Magento/Command/Indexer/ListCommand.php index 1ff832fc7..4fe14455b 100644 --- a/src/N98/Magento/Command/Indexer/ListCommand.php +++ b/src/N98/Magento/Command/Indexer/ListCommand.php @@ -5,8 +5,7 @@ namespace N98\Magento\Command\Indexer; use Exception; -use N98\Magento\Command\CommandFormatInterface; -use Symfony\Component\Console\Attribute\AsCommand; +use N98\Magento\Command\CommandDataInterface; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -15,21 +14,17 @@ * * @package N98\Magento\Command\Indexer */ -class ListCommand extends AbstractIndexerCommand implements CommandFormatInterface +class ListCommand extends AbstractIndexerCommand implements CommandDataInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Indexes'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'index:list'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Lists all magento indexes.'; @@ -47,20 +42,15 @@ public function getHelp(): string * * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - public function getData(InputInterface $input, OutputInterface $output): array + public function setData(InputInterface $input,OutputInterface $output) : void { - if (is_null($this->data)) { - $this->data = []; - - foreach ($this->getIndexerList() as $index) { - $this->data[] = [ - 'code' => $index['code'], - 'status' => $index['status'], - 'time' => $index['last_runtime'] - ]; - } + $this->data = []; + foreach ($this->getIndexerList() as $index) { + $this->data[] = [ + 'code' => $index['code'], + 'status' => $index['status'], + 'time' => $index['last_runtime'] + ]; } - - return $this->data; } } diff --git a/src/N98/Magento/Command/Indexer/ReindexAllCommand.php b/src/N98/Magento/Command/Indexer/ReindexAllCommand.php index dcd5fba79..068144b07 100644 --- a/src/N98/Magento/Command/Indexer/ReindexAllCommand.php +++ b/src/N98/Magento/Command/Indexer/ReindexAllCommand.php @@ -5,7 +5,6 @@ namespace N98\Magento\Command\Indexer; use Mage_Index_Model_Resource_Process_Collection; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -19,15 +18,11 @@ class ReindexAllCommand extends AbstractIndexerCommand { /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'index:reindex:all'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Reindex all indexes.'; @@ -48,9 +43,6 @@ public function getHelp(): string */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - $this->disableObservers(); /* @var Mage_Index_Model_Resource_Process_Collection $processes */ diff --git a/src/N98/Magento/Command/Indexer/ReindexCommand.php b/src/N98/Magento/Command/Indexer/ReindexCommand.php index 721ea1bc7..cb1886b43 100644 --- a/src/N98/Magento/Command/Indexer/ReindexCommand.php +++ b/src/N98/Magento/Command/Indexer/ReindexCommand.php @@ -8,7 +8,6 @@ use InvalidArgumentException; use Mage_Index_Model_Process; use N98\Util\BinaryString; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -26,15 +25,11 @@ class ReindexCommand extends AbstractIndexerCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'index:reindex'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Reindex a index by code.'; @@ -79,9 +74,6 @@ public function getHelp(): string */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - $this->writeSection($output, 'Reindex'); $this->disableObservers(); $indexCode = $input->getArgument(self::COMMAND_ARGUMENT_INDEX_CODE); diff --git a/src/N98/Magento/Command/Installer/SubCommand/DownloadMagento.php b/src/N98/Magento/Command/Installer/SubCommand/DownloadMagento.php index a0f003ab0..f059d1005 100644 --- a/src/N98/Magento/Command/Installer/SubCommand/DownloadMagento.php +++ b/src/N98/Magento/Command/Installer/SubCommand/DownloadMagento.php @@ -42,7 +42,6 @@ private function implementation() $this->config->setArray('magentoPackage', $package); if (file_exists($this->config->getString('installationFolder') . '/app/etc/local.xml')) { - /* @var QuestionHelper $dialog */ $dialog = $this->command->getHelper('question'); $skipInstallation = $dialog->ask( @@ -54,7 +53,6 @@ private function implementation() if ($skipInstallation) { return; } - } $this->composerCreateProject($package); diff --git a/src/N98/Magento/Command/Installer/SubCommand/InstallComposer.php b/src/N98/Magento/Command/Installer/SubCommand/InstallComposer.php index b405d06e8..6e1e38a21 100644 --- a/src/N98/Magento/Command/Installer/SubCommand/InstallComposer.php +++ b/src/N98/Magento/Command/Installer/SubCommand/InstallComposer.php @@ -1,7 +1,10 @@ output->writeln('Found executable ' . $composerBin . ''); @@ -55,7 +58,7 @@ public function execute() /** * @return string - * @throws \Exception + * @throws Exception */ protected function downloadComposer() { @@ -85,7 +88,7 @@ protected function downloadComposer() unlink($tempComposerInstaller); $installationOutput = implode(PHP_EOL, $installationOutput); if ($returnStatus !== self::EXEC_STATUS_OK) { - throw new \Exception('Installation failed.' . $installationOutput); + throw new Exception('Installation failed.' . $installationOutput); } $this->output->writeln('Successfully installed composer to Magento root'); @@ -99,13 +102,13 @@ protected function downloadComposer() * @param $output * @param $matches * @return int - * @throws \Exception + * @throws Exception */ protected function getMajorComposerVersion(): int { Exec::run(implode(' ', array_merge($this->config['composer_bin'], [' --version'])), $output); if (!preg_match('#(\d+)\.(\d+)\.(\d+)#', $output, $matches)) { - throw new \Exception('Could not detect a valid Composer version'); + throw new Exception('Could not detect a valid Composer version'); } return (int) $matches[1]; diff --git a/src/N98/Magento/Command/Installer/SubCommand/InstallMagento.php b/src/N98/Magento/Command/Installer/SubCommand/InstallMagento.php index 7260c181b..421aa0fbe 100644 --- a/src/N98/Magento/Command/Installer/SubCommand/InstallMagento.php +++ b/src/N98/Magento/Command/Installer/SubCommand/InstallMagento.php @@ -18,12 +18,12 @@ class InstallMagento extends AbstractSubCommand { /** - * @deprecated since since 1.3.1; Use constant from Exec-Utility instead + * @deprecated since 1.3.1; Use constant from Exec-Utility instead * @see Exec::CODE_CLEAN_EXIT */ - const EXEC_STATUS_OK = 0; + public const EXEC_STATUS_OK = 0; - const MAGENTO_INSTALL_SCRIPT_PATH = 'install.php'; + public const MAGENTO_INSTALL_SCRIPT_PATH = 'install.php'; /** * @var \Closure diff --git a/src/N98/Magento/Command/Installer/SubCommand/SelectMagentoVersion.php b/src/N98/Magento/Command/Installer/SubCommand/SelectMagentoVersion.php index af30683e3..1707778ab 100644 --- a/src/N98/Magento/Command/Installer/SubCommand/SelectMagentoVersion.php +++ b/src/N98/Magento/Command/Installer/SubCommand/SelectMagentoVersion.php @@ -22,8 +22,7 @@ public function execute() return; } - if ( - $this->input->getOption('magentoVersion') === null + if ($this->input->getOption('magentoVersion') === null && $this->input->getOption('magentoVersionByName') === null ) { $choices = []; @@ -37,7 +36,8 @@ public function execute() $typeInput - 1, range(0, count($this->commandConfig['magento-packages']) - 1), true - )) { + ) + ) { throw new \InvalidArgumentException('Invalid type'); } diff --git a/src/N98/Magento/Command/Media/Cache/Image/ClearCommand.php b/src/N98/Magento/Command/Media/Cache/Image/ClearCommand.php index 6e8b7f09a..f12cf3360 100644 --- a/src/N98/Magento/Command/Media/Cache/Image/ClearCommand.php +++ b/src/N98/Magento/Command/Media/Cache/Image/ClearCommand.php @@ -6,7 +6,6 @@ use Mage; use N98\Magento\Command\AbstractCommand; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -20,15 +19,11 @@ class ClearCommand extends AbstractCommand { /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'media:cache:image:clear'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Clears image cache'; @@ -39,9 +34,6 @@ class ClearCommand extends AbstractCommand */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - Mage::getModel('catalog/product_image')->clearCache(); Mage::dispatchEvent('clean_catalog_images_cache_after'); $output->writeln('Image cache cleared'); diff --git a/src/N98/Magento/Command/Media/Cache/JsCss/ClearCommand.php b/src/N98/Magento/Command/Media/Cache/JsCss/ClearCommand.php index 7814ebc31..e14e9a40a 100644 --- a/src/N98/Magento/Command/Media/Cache/JsCss/ClearCommand.php +++ b/src/N98/Magento/Command/Media/Cache/JsCss/ClearCommand.php @@ -6,7 +6,6 @@ use Mage; use N98\Magento\Command\AbstractCommand; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -20,28 +19,20 @@ class ClearCommand extends AbstractCommand { /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'media:cache:jscss:clear'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Clears JS/CSS cache.'; /** - * @param InputInterface $input - * @param OutputInterface $output + * {@inheritDoc} * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - Mage::getModel('core/design_package')->cleanMergedJsCss(); Mage::dispatchEvent('clean_media_cache_after'); $output->writeln('Js/CSS cache cleared'); diff --git a/src/N98/Magento/Command/Media/DumpCommand.php b/src/N98/Magento/Command/Media/DumpCommand.php index 26eb651ac..eb42e3677 100644 --- a/src/N98/Magento/Command/Media/DumpCommand.php +++ b/src/N98/Magento/Command/Media/DumpCommand.php @@ -7,7 +7,6 @@ use N98\Magento\Application; use N98\Magento\Command\AbstractCommand; use RuntimeException; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -30,15 +29,13 @@ class DumpCommand extends AbstractCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'media:dump'; + protected static bool $initMagentoFlag = false; + /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Creates an archive with content of media folder'; @@ -70,8 +67,6 @@ protected function configure(): void */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - /** @var Application $app */ $app = $this->getApplication(); if (!$app) { diff --git a/src/N98/Magento/Command/OpenBrowserCommand.php b/src/N98/Magento/Command/OpenBrowserCommand.php index 5d5d2b56d..3d0f80cdc 100644 --- a/src/N98/Magento/Command/OpenBrowserCommand.php +++ b/src/N98/Magento/Command/OpenBrowserCommand.php @@ -10,7 +10,6 @@ use N98\Util\Exec; use N98\Util\OperatingSystem; use RuntimeException; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -26,15 +25,11 @@ class OpenBrowserCommand extends AbstractCommand public const COMMAND_ARGUMENT_STORE = 'store'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'open-browser'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Open current project in browser (experimental).'; @@ -65,9 +60,6 @@ public function isEnabled(): bool */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - $parameterHelper = $this->getParameterHelper(); /** @var Mage_Core_Model_Store $store */ diff --git a/src/N98/Magento/Command/Script/Repository/ListCommand.php b/src/N98/Magento/Command/Script/Repository/ListCommand.php index e252cceb6..b1e63599b 100644 --- a/src/N98/Magento/Command/Script/Repository/ListCommand.php +++ b/src/N98/Magento/Command/Script/Repository/ListCommand.php @@ -4,8 +4,7 @@ namespace N98\Magento\Command\Script\Repository; -use N98\Magento\Command\CommandFormatInterface; -use Symfony\Component\Console\Attribute\AsCommand; +use N98\Magento\Command\CommandDataInterface; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -14,24 +13,24 @@ * * @package N98\Magento\Command\Script\Repository */ -class ListCommand extends AbstractRepositoryCommand implements CommandFormatInterface +class ListCommand extends AbstractRepositoryCommand implements CommandDataInterface { protected const NO_DATA_MESSAGE = 'No script file found'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'script:repo:list'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Lists all scripts in repository.'; + protected static bool $initMagentoFlag = false; + + protected static bool $detectMagentoFlag = false; + /** * @return string */ @@ -53,37 +52,22 @@ public function getHelp(): string /** * {@inheritdoc} - * @return array> * * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - public function getData(InputInterface $input, OutputInterface $output): array + public function setData(InputInterface $input,OutputInterface $output) : void { - if (is_null($this->data)) { - $this->data = []; - - foreach ($this->getScripts() as $file) { - $this->data[] = [ - 'Script' => substr( - $file['fileinfo']->getFilename(), - 0, - -strlen(self::MAGERUN_EXTENSION) - ), - 'Location' => $file['location'], - 'Description' => $file['description'] - ]; - } + $this->data = []; + foreach ($this->getScripts() as $file) { + $this->data[] = [ + 'Script' => substr( + $file['fileinfo']->getFilename(), + 0, + -strlen(self::MAGERUN_EXTENSION) + ), + 'Location' => $file['location'], + 'Description' => $file['description'] + ]; } - - return $this->data; - } - - /** - * Skip initialisation - * - * @param bool $soft - */ - public function initMagento(bool $soft = false): void - { } } diff --git a/src/N98/Magento/Command/Script/Repository/RunCommand.php b/src/N98/Magento/Command/Script/Repository/RunCommand.php index 7dd448c08..c6d547dcd 100644 --- a/src/N98/Magento/Command/Script/Repository/RunCommand.php +++ b/src/N98/Magento/Command/Script/Repository/RunCommand.php @@ -29,18 +29,18 @@ class RunCommand extends AbstractRepositoryCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'script:repo:run'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Run script from repository.'; + protected static bool $initMagentoFlag = false; + + protected static bool $detectMagentoFlag = false; + protected function configure(): void { $this @@ -156,13 +156,4 @@ protected function execute(InputInterface $input, OutputInterface $output): int return Command::SUCCESS; } - - /** - * Skip initialisation - * - * @param bool $soft - */ - public function initMagento(bool $soft = false): void - { - } } diff --git a/src/N98/Magento/Command/ScriptCommand.php b/src/N98/Magento/Command/ScriptCommand.php index 2808799bf..c733c243c 100644 --- a/src/N98/Magento/Command/ScriptCommand.php +++ b/src/N98/Magento/Command/ScriptCommand.php @@ -110,7 +110,7 @@ protected function configure(): void /** * @return bool */ - public function isEnabled() + public function isEnabled(): bool { return Exec::allowed(); } diff --git a/src/N98/Magento/Command/SubCommand/AbstractSubCommand.php b/src/N98/Magento/Command/SubCommand/AbstractSubCommand.php index 9229c94ee..2b7136840 100644 --- a/src/N98/Magento/Command/SubCommand/AbstractSubCommand.php +++ b/src/N98/Magento/Command/SubCommand/AbstractSubCommand.php @@ -1,8 +1,10 @@ command = $command; } @@ -101,9 +103,7 @@ abstract public function execute(); final protected function getOptionalBooleanOption($name, $question, $default = true) { if ($this->input->getOption($name) !== null) { - $flag = $this->getCommand()->parseBoolOption($this->input->getOption($name)); - - return $flag; + return $this->getCommand()->parseBoolOption($this->input->getOption($name)); } else { /** @var $questionHelper QuestionHelper */ $questionHelper = $this->getCommand()->getHelper('question'); @@ -117,13 +117,11 @@ final protected function getOptionalBooleanOption($name, $question, $default = t $default ); - $flag = $questionHelper->ask( + return $questionHelper->ask( $this->input, $this->output, $question ); - - return $flag; } } @@ -143,6 +141,6 @@ final protected function hasFlagOrOptionalBoolOption($name, $default = true) return (bool) $default; } - return (bool) $this->getCommand()->parseBoolOption($value); + return $this->getCommand()->parseBoolOption($value); } } diff --git a/src/N98/Magento/Command/SubCommand/SubCommandFactory.php b/src/N98/Magento/Command/SubCommand/SubCommandFactory.php index 38662eaa2..eae08b61a 100644 --- a/src/N98/Magento/Command/SubCommand/SubCommandFactory.php +++ b/src/N98/Magento/Command/SubCommand/SubCommandFactory.php @@ -1,8 +1,11 @@ baseNamespace = $baseNamespace; $this->command = $command; @@ -71,7 +74,7 @@ public function __construct( * @param bool $userBaseNamespace * @return SubCommandInterface */ - public function create($className, $userBaseNamespace = true) + public function create(string $className, bool $userBaseNamespace = true): SubCommandInterface { if ($userBaseNamespace) { $className = rtrim($this->baseNamespace, '\\') . '\\' . $className; @@ -79,7 +82,7 @@ public function create($className, $userBaseNamespace = true) $subCommand = new $className(); if (!$subCommand instanceof SubCommandInterface) { - throw new \InvalidArgumentException('Subcommand must implement SubCommandInterface.'); + throw new InvalidArgumentException('Subcommand must implement SubCommandInterface.'); } // Inject objects @@ -95,7 +98,7 @@ public function create($className, $userBaseNamespace = true) /** * @return ConfigBag */ - public function getConfig() + public function getConfig(): ConfigBag { return $this->config; } diff --git a/src/N98/Magento/Command/SubCommand/SubCommandInterface.php b/src/N98/Magento/Command/SubCommand/SubCommandInterface.php index 88fd73586..af23c3aa6 100644 --- a/src/N98/Magento/Command/SubCommand/SubCommandInterface.php +++ b/src/N98/Magento/Command/SubCommand/SubCommandInterface.php @@ -1,8 +1,10 @@ > * * @throws Mage_Core_Model_Store_Exception * @throws Mage_Core_Exception */ - public function getData(InputInterface $input, OutputInterface $output): array + public function setData(InputInterface $input,OutputInterface $output) : void { - if (is_null($this->data)) { - $this->data = []; + $this->data = []; - /** @var string $timezone */ - $timezone = $input->getOption(self::COMMAND_OPTION_TIMEZONE) - ?: $this->_getMageStore()->getConfig('general/locale/timezone'); + /** @var string $timezone */ + $timezone = $input->getOption(self::COMMAND_OPTION_TIMEZONE) + ?: $this->_getMageStore()->getConfig('general/locale/timezone'); - $output->writeln(sprintf('Times shown in %s', $timezone)); + $output->writeln(sprintf('Times shown in %s', $timezone)); - $date = Mage::getSingleton('core/date'); - $offset = $date->calculateOffset($timezone); - $collection = Mage::getModel('cron/schedule')->getCollection(); - $collection - ->addFieldToFilter('status', ['neq' => Mage_Cron_Model_Schedule::STATUS_PENDING]) - ->addOrder('finished_at'); + $date = Mage::getSingleton('core/date'); + $offset = $date->calculateOffset($timezone); + $collection = Mage::getModel('cron/schedule')->getCollection(); + $collection + ->addFieldToFilter('status', ['neq' => Mage_Cron_Model_Schedule::STATUS_PENDING]) + ->addOrder('finished_at'); - /** @var Mage_Cron_Model_Schedule $job */ - foreach ($collection as $job) { - $this->data[] = [ - 'Job' => $job->getJobCode(), - 'Status' => $job->getStatus(), - 'Finished' => $job->getFinishedAt() ? $date->gmtDate( - null, - $date->timestamp($job->getFinishedAt()) + $offset - ) : '' - ]; - } + /** @var Mage_Cron_Model_Schedule $job */ + foreach ($collection as $job) { + $this->data[] = [ + 'Job' => $job->getJobCode(), + 'Status' => $job->getStatus(), + 'Finished' => $job->getFinishedAt() ? $date->gmtDate( + null, + $date->timestamp($job->getFinishedAt()) + $offset + ) : '' + ]; } - - return $this->data; } } diff --git a/src/N98/Magento/Command/System/Cron/ListCommand.php b/src/N98/Magento/Command/System/Cron/ListCommand.php index 5d3c9fdfb..ff85cc845 100644 --- a/src/N98/Magento/Command/System/Cron/ListCommand.php +++ b/src/N98/Magento/Command/System/Cron/ListCommand.php @@ -5,9 +5,7 @@ namespace N98\Magento\Command\System\Cron; use Mage_Core_Exception; -use Mage_Core_Model_Config_Element; -use N98\Magento\Command\CommandFormatInterface; -use Symfony\Component\Console\Attribute\AsCommand; +use N98\Magento\Command\CommandDataInterface; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -16,33 +14,28 @@ * * @package N98\Magento\Command\Cron */ -class ListCommand extends AbstractCronCommand implements CommandFormatInterface +class ListCommand extends AbstractCronCommand implements CommandDataInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Cronjobs'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'sys:cron:list'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Lists all cronjobs.'; /** * {@inheritdoc} - * @return array> * * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter * @throws Mage_Core_Exception */ - public function getData(InputInterface $input, OutputInterface $output): array + public function setData(InputInterface $input,OutputInterface $output) : void { - return $this->getJobs(); + $this->data = $this->getJobs(); } } diff --git a/src/N98/Magento/Command/System/Cron/RunCommand.php b/src/N98/Magento/Command/System/Cron/RunCommand.php index f8614e396..156b08b4b 100644 --- a/src/N98/Magento/Command/System/Cron/RunCommand.php +++ b/src/N98/Magento/Command/System/Cron/RunCommand.php @@ -11,7 +11,6 @@ use Mage_Core_Model_Config_Element; use Mage_Cron_Model_Schedule; use RuntimeException; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -36,15 +35,11 @@ class RunCommand extends AbstractCronCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'sys:cron:run'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Runs a cronjob by job code.'; @@ -78,16 +73,12 @@ public function getHelp(): string } /** - * @param InputInterface $input - * @param OutputInterface $output + * {@inheritDoc} * @return int * @throws Exception */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - /** @var string $jobCode */ $jobCode = $input->getArgument(self::COMMAND_ARGUMENT_JOB); if (!$jobCode) { diff --git a/src/N98/Magento/Command/System/MaintenanceCommand.php b/src/N98/Magento/Command/System/MaintenanceCommand.php index 8ad399e3b..14dfee80f 100644 --- a/src/N98/Magento/Command/System/MaintenanceCommand.php +++ b/src/N98/Magento/Command/System/MaintenanceCommand.php @@ -5,12 +5,11 @@ namespace N98\Magento\Command\System; use N98\Magento\Command\AbstractCommand; -use RuntimeException; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Exception\IOExceptionInterface; use Symfony\Component\Filesystem\Filesystem; @@ -25,28 +24,23 @@ class MaintenanceCommand extends AbstractCommand /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'sys:maintenance'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Toggles maintenance mode'; /** * @var Filesystem */ - private Filesystem $filessystem; + private Filesystem $filesystem; public function __construct() { parent:: __construct(); - - $this->filessystem = new Filesystem(); + $this->filesystem = new Filesystem(); } /** @@ -85,7 +79,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } elseif ($input->getOption(self::COMMAND_OPTION_ON)) { $this->switchOn($output, $flagFile); } else { - if ($this->filessystem->exists($flagFile)) { + if ($this->filesystem->exists($flagFile)) { $this->switchOff($output, $flagFile); } else { $this->switchOn($output, $flagFile); @@ -102,9 +96,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int private function switchOn(OutputInterface $output, string $flagFile): void { try { - $this->filessystem->touch($flagFile); + $this->filesystem->touch($flagFile); } catch (IOExceptionInterface $exception) { - throw new RuntimeException($exception->getMessage()); + throw new IOException($exception->getMessage()); } $output->writeln('Maintenance mode on'); @@ -117,9 +111,9 @@ private function switchOn(OutputInterface $output, string $flagFile): void private function switchOff(OutputInterface $output, string $flagFile): void { try { - $this->filessystem->remove($flagFile); + $this->filesystem->remove($flagFile); } catch (IOExceptionInterface $exception) { - throw new RuntimeException($exception->getMessage()); + throw new IOException($exception->getMessage()); } $output->writeln('Maintenance mode off'); diff --git a/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php b/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php index 651382bbb..a6c5b2883 100644 --- a/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php +++ b/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php @@ -7,8 +7,7 @@ use Mage; use Mage_Core_Model_Store as Store; use N98\Magento\Command\AbstractCommand; -use N98\Magento\Command\CommandFormatInterface; -use Symfony\Component\Console\Attribute\AsCommand; +use N98\Magento\Command\CommandDataInterface; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -17,47 +16,38 @@ * * @package N98\Magento\Command\System\Store\Config */ -class BaseUrlListCommand extends AbstractCommand implements CommandFormatInterface +class BaseUrlListCommand extends AbstractCommand implements CommandDataInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Stores - Base URLs'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'sys:store:config:base-url:list'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Lists all base urls.'; /** * {@inheritdoc} - * @return array> * * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - public function getData(InputInterface $input, OutputInterface $output): array + public function setData(InputInterface $input,OutputInterface $output) : void { - if (is_null($this->data)) { - $this->data = []; - foreach ($this->_getMage()->getStores() as $store) { - $storeId = (string) $store->getId(); - $this->data[$storeId] = [ - 'ID' => $storeId, - 'Code' => $store->getCode(), - 'Unsecure base URL' => Mage::getStoreConfig(Store::XML_PATH_UNSECURE_BASE_URL, $store), - 'Secure base URL' => Mage::getStoreConfig(Store::XML_PATH_SECURE_BASE_URL, $store) - ]; - } - - ksort($this->data); + $this->data = []; + foreach ($this->_getMage()->getStores() as $store) { + $storeId = (string) $store->getId(); + $this->data[$storeId] = [ + 'ID' => $storeId, + 'Code' => $store->getCode(), + 'Unsecure base URL' => Mage::getStoreConfig(Store::XML_PATH_UNSECURE_BASE_URL, $store), + 'Secure base URL' => Mage::getStoreConfig(Store::XML_PATH_SECURE_BASE_URL, $store) + ]; } - return $this->data; + ksort($this->data); } } diff --git a/src/N98/Magento/Command/System/Store/ListCommand.php b/src/N98/Magento/Command/System/Store/ListCommand.php index 009c28b26..851f9994e 100644 --- a/src/N98/Magento/Command/System/Store/ListCommand.php +++ b/src/N98/Magento/Command/System/Store/ListCommand.php @@ -5,8 +5,7 @@ namespace N98\Magento\Command\System\Store; use N98\Magento\Command\AbstractCommand; -use N98\Magento\Command\CommandFormatInterface; -use Symfony\Component\Console\Attribute\AsCommand; +use N98\Magento\Command\CommandDataInterface; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -15,45 +14,36 @@ * * @package N98\Magento\Command\System\Store */ -class ListCommand extends AbstractCommand implements CommandFormatInterface +class ListCommand extends AbstractCommand implements CommandDataInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Stores'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'sys:store:list'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Lists all installed store-views'; /** * {@inheritdoc} - * @return array> * * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - public function getData(InputInterface $input, OutputInterface $output): array + public function setData(InputInterface $input,OutputInterface $output) : void { - if (is_null($this->data)) { - $this->data = []; - foreach ($this->_getMage()->getStores() as $store) { - $storeId = (string) $store->getId(); - $this->data[$storeId] = [ - 'id' => $storeId, - 'code' => $store->getCode() - ]; - } - - ksort($this->data); + $this->data = []; + foreach ($this->_getMage()->getStores() as $store) { + $storeId = (string) $store->getId(); + $this->data[$storeId] = [ + 'id' => $storeId, + 'code' => $store->getCode() + ]; } - return $this->data; + ksort($this->data); } } diff --git a/src/N98/Magento/Command/System/Url/ListCommand.php b/src/N98/Magento/Command/System/Url/ListCommand.php index 94919d5cc..faef171b8 100644 --- a/src/N98/Magento/Command/System/Url/ListCommand.php +++ b/src/N98/Magento/Command/System/Url/ListCommand.php @@ -1,15 +1,19 @@ setName('sys:url:list') @@ -40,8 +45,14 @@ protected function configure() ->addArgument('stores', InputArgument::OPTIONAL, 'Stores (comma-separated list of store ids)') ->addArgument('linetemplate', InputArgument::OPTIONAL, 'Line template', '{url}') ->setDescription('Get all urls.'); + } - $help = <<setHelp($help); } /** @@ -64,16 +74,12 @@ protected function configure() * * @param InputInterface $input * @param OutputInterface $output - * * @return int + * @throws Mage_Core_Model_Store_Exception + * @throws Mage_Core_Exception */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } - if ($input->getOption('add-all')) { $input->setOption('add-categories', true); $input->setOption('add-products', true); @@ -85,12 +91,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int $urls = []; foreach ($stores as $storeId) { - $currentStore = Mage::app()->getStore($storeId); /* @var \Mage_Core_Model_Store $currentStore */ + /** @var Mage_Core_Model_Store $currentStore */ + $currentStore = Mage::app()->getStore($storeId); // base url $urls[] = $currentStore->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB); - $linkBaseUrl = $currentStore->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); + $linkBaseUrl = $currentStore->getBaseUrl(); if ($input->getOption('add-categories')) { $urls = $this->getUrls('sitemap/catalog_category', $linkBaseUrl, $storeId, $urls); @@ -122,6 +129,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int // ... and output $output->writeln($line); } + return 0; } @@ -130,10 +138,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int * @param string $linkBaseUrl * @param string $storeId * @param array $urls - * * @return array */ - protected function getUrls($resourceModel, $linkBaseUrl, $storeId, array $urls) + protected function getUrls(string $resourceModel, string $linkBaseUrl, string $storeId, array $urls): array { $resourceModel = Mage::getResourceModel($resourceModel); if (!$resourceModel) { @@ -146,7 +153,7 @@ protected function getUrls($resourceModel, $linkBaseUrl, $storeId, array $urls) } foreach ($collection as $item) { - /* @var \Varien_Object $item */ + /** @var Varien_Object $item */ $urls[] = $linkBaseUrl . $item->getUrl(); } return $urls; diff --git a/src/N98/Magento/Command/System/Website/ListCommand.php b/src/N98/Magento/Command/System/Website/ListCommand.php index 1fc05a014..6fa11c02f 100644 --- a/src/N98/Magento/Command/System/Website/ListCommand.php +++ b/src/N98/Magento/Command/System/Website/ListCommand.php @@ -5,8 +5,7 @@ namespace N98\Magento\Command\System\Website; use N98\Magento\Command\AbstractCommand; -use N98\Magento\Command\CommandFormatInterface; -use Symfony\Component\Console\Attribute\AsCommand; +use N98\Magento\Command\CommandDataInterface; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -15,45 +14,36 @@ * * @package 98\Magento\Command\System\Website */ -class ListCommand extends AbstractCommand implements CommandFormatInterface +class ListCommand extends AbstractCommand implements CommandDataInterface { protected const COMMAND_SECTION_TITLE_TEXT = 'Websites'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'sys:website:list'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultDescription = 'Lists all websites.'; /** - * {@inheritdoc} - * @return array> + * {@inheritDoc} * * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - public function getData(InputInterface $input, OutputInterface $output): array + public function setData(InputInterface $input,OutputInterface $output) : void { - if (is_null($this->data)) { - $this->data = []; - foreach ($this->_getMage()->getWebsites() as $store) { - $storeId = (string) $store->getId(); - $this->data[$storeId] = [ - 'id' => $storeId, - 'code' => $store->getCode() - ]; - } - - ksort($this->data); + $this->data = []; + foreach ($this->_getMage()->getWebsites() as $store) { + $storeId = (string) $store->getId(); + $this->data[$storeId] = [ + 'id' => $storeId, + 'code' => $store->getCode() + ]; } - return $this->data; + ksort($this->data); } } diff --git a/src/N98/Magento/Initialiser.php b/src/N98/Magento/Initialiser.php index ebc75ea15..d9ad8d6af 100644 --- a/src/N98/Magento/Initialiser.php +++ b/src/N98/Magento/Initialiser.php @@ -1,10 +1,6 @@ - */ +declare(strict_types=1); namespace N98\Magento; @@ -12,9 +8,10 @@ use RuntimeException; /** - * Magento initialiser (Magento 1) + * Magento initializer (Magento 1) * * @package N98\Magento + * @author Tom Klingenberg */ class Initialiser { @@ -31,23 +28,23 @@ class Initialiser /** * @var string path to Magento root directory */ - private $magentoPath; + private string $magentoPath; /** * Bootstrap Magento application */ public static function bootstrap($magentoPath) { - $initialiser = new Initialiser($magentoPath); - $initialiser->requireMage(); + $initializer = new Initialiser($magentoPath); + $initializer->requireMage(); } /** - * Initialiser constructor. + * Initializer constructor. * * @param string $magentoPath */ - public function __construct($magentoPath) + public function __construct(string $magentoPath) { $this->magentoPath = $magentoPath; } @@ -71,9 +68,9 @@ public function requireMage() } /** - * Require app/Mage.php in it's own scope while preserving all autoloaders. + * Require app/Mage.php in its own scope while preserving all autoloader. */ - private function requireOnce() + private function requireOnce(): void { // Create a new AutoloadRestorer to capture current auto-loaders $restorer = new AutoloadRestorer(); @@ -81,13 +78,13 @@ private function requireOnce() $path = $this->magentoPath . '/' . self::PATH_APP_MAGE_PHP; initialiser_require_once($path); - // Restore auto-loaders that might be removed by extensions that overwrite Varien/Autoload + // Restore autoloader that might be removed by extensions that overwrite Varien/Autoload $restorer->restore(); } } /** - * use require-once inside a function with it's own variable scope and no $this (?) + * use require-once inside a function with its own variable scope and no $this (?) */ function initialiser_require_once() { diff --git a/src/N98/Util/Console/Helper/ParameterHelper.php b/src/N98/Util/Console/Helper/ParameterHelper.php index 57178ec80..e9a96c6a8 100644 --- a/src/N98/Util/Console/Helper/ParameterHelper.php +++ b/src/N98/Util/Console/Helper/ParameterHelper.php @@ -8,6 +8,7 @@ use Mage; use Mage_Core_Model_App; use Mage_Core_Model_Website; +use N98\Magento\Command\AbstractCommand; use N98\Util\Validator\FakeMetadataFactory; use RuntimeException; use Symfony\Component\Console\Helper\Helper as AbstractHelper; @@ -225,6 +226,7 @@ public function askPassword( $validators[] = new Regex($regex); } + $validators[] = new NotBlank(); $validators[] = new Length(['min' => 6]); $constraints = new Collection( @@ -252,6 +254,7 @@ private function askAndValidate(InputInterface $input, OutputInterface $output, { $dialog = new QuestionHelper(); $questionObj = new Question($question); + $questionObj->setMaxAttempts(AbstractCommand::QUESTION_ATTEMPTS); $questionObj->setValidator($callback); return $dialog->ask($input, $output, $questionObj); @@ -281,7 +284,7 @@ private function validateArgument(InputInterface $input, OutputInterface $outpu $question = '' . ucfirst($name) . ': '; - $value = $this->askAndValidate( + return $this->askAndValidate( $input, $output, $question, @@ -294,8 +297,6 @@ function ($inputValue) use ($constraints, $name) { return $inputValue; } ); - - return $value; } /** diff --git a/src/N98/Util/Filesystem.php b/src/N98/Util/Filesystem.php index 7e9674f37..b15e9392b 100644 --- a/src/N98/Util/Filesystem.php +++ b/src/N98/Util/Filesystem.php @@ -1,9 +1,6 @@ - */ + +declare(strict_types=1); namespace N98\Util; @@ -13,6 +10,7 @@ * Class Filesystem * * @package N98\Util + * @author Tom Klingenberg */ class Filesystem { @@ -127,14 +125,13 @@ public function recursiveRemoveDirectory($directory, $empty = false) } /** - * @param int $bytes + * @param string $bytes * @param int $decimals - * * @return string * @see http://www.php.net/manual/en/function.filesize.php#106569 * */ - public static function humanFileSize(int $bytes, int $decimals = 2): string + public static function humanFileSize(string $bytes, int $decimals = 2): string { $units = ['B', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']; $factor = floor((strlen($bytes) - 1) / 3); From 15e19d44a338782e28ba832e7535dbcc179020f8 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 25 Jun 2024 21:31:23 +0200 Subject: [PATCH 124/136] [skip ci] Updated customer:create command --- .../Customer/AbstractCustomerCommand.php | 6 + .../Customer/ChangePasswordCommand.php | 6 - .../Command/Customer/CreateCommand.php | 206 ++++++++++++------ .../Magento/Command/Customer/InfoCommand.php | 4 - 4 files changed, 142 insertions(+), 80 deletions(-) diff --git a/src/N98/Magento/Command/Customer/AbstractCustomerCommand.php b/src/N98/Magento/Command/Customer/AbstractCustomerCommand.php index 8b83dea53..ebdd49c9b 100644 --- a/src/N98/Magento/Command/Customer/AbstractCustomerCommand.php +++ b/src/N98/Magento/Command/Customer/AbstractCustomerCommand.php @@ -19,6 +19,12 @@ */ abstract class AbstractCustomerCommand extends AbstractCommand { + public const COMMAND_ARGUMENT_EMAIL = 'email'; + + public const COMMAND_ARGUMENT_PASSWORD = 'password'; + + public const COMMAND_ARGUMENT_WEBSITE = 'website'; + /** * @return Mage_Customer_Model_Customer */ diff --git a/src/N98/Magento/Command/Customer/ChangePasswordCommand.php b/src/N98/Magento/Command/Customer/ChangePasswordCommand.php index d16bc1270..f54e93b38 100644 --- a/src/N98/Magento/Command/Customer/ChangePasswordCommand.php +++ b/src/N98/Magento/Command/Customer/ChangePasswordCommand.php @@ -22,12 +22,6 @@ */ class ChangePasswordCommand extends AbstractCustomerCommand { - public const COMMAND_ARGUMENT_EMAIL = 'email'; - - public const COMMAND_ARGUMENT_PASSWORD = 'password'; - - public const COMMAND_ARGUMENT_WEBSITE = 'website'; - /** * @var string */ diff --git a/src/N98/Magento/Command/Customer/CreateCommand.php b/src/N98/Magento/Command/Customer/CreateCommand.php index 4585695e4..69ac3ee9e 100644 --- a/src/N98/Magento/Command/Customer/CreateCommand.php +++ b/src/N98/Magento/Command/Customer/CreateCommand.php @@ -1,15 +1,16 @@ setName('customer:create') - ->addArgument('email', InputArgument::OPTIONAL, 'Email') - ->addArgument('password', InputArgument::OPTIONAL, 'Password') - ->addArgument('firstname', InputArgument::OPTIONAL, 'Firstname') - ->addArgument('lastname', InputArgument::OPTIONAL, 'Lastname') - ->addArgument('website', InputArgument::OPTIONAL, 'Website') - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' + ->addArgument( + self::COMMAND_ARGUMENT_EMAIL, + InputArgument::OPTIONAL, + 'Email' + ) + ->addArgument( + self::COMMAND_ARGUMENT_PASSWORD, + InputArgument::OPTIONAL, + 'Password' ) - ->setDescription('Creates a new customer/user for shop frontend.') + ->addArgument( + self::COMMAND_ARGUMENT_FIRSTNAME, + InputArgument::OPTIONAL, + 'Firstname' + ) + ->addArgument( + self::COMMAND_ARGUMENT_LASTNAME, + InputArgument::OPTIONAL, + 'Lastname' + ) + ->addArgument( + self::COMMAND_ARGUMENT_WEBSITE, + InputArgument::OPTIONAL, + 'Website' + ) + ->addFormatOption() ; } /** - * @param InputInterface $input - * @param OutputInterface $output - * @return int + * {@inheritDoc} + * @return void + * @throws Mage_Core_Exception */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function interact(InputInterface $input,OutputInterface $output): void { - $this->detectMagento($output, true); - $this->initMagento(); + $parameterHelper = $this->getParameterHelper(); - $dialog = $this->getQuestionHelper(); + // Email + $email = $parameterHelper->askEmail($input, $output, self::COMMAND_ARGUMENT_EMAIL); + $input->setArgument(self::COMMAND_ARGUMENT_EMAIL, $email); - // Password - if (($password = $input->getArgument('password')) == null) { - $question = new Question('Password: '); - $question->setHidden(true); - $password = $dialog->ask($input, $output, $question); - } + // password + $password = $parameterHelper->askPassword($input, $output, self::COMMAND_ARGUMENT_PASSWORD); + $input->setArgument(self::COMMAND_ARGUMENT_PASSWORD, $password); // Firstname - if (($firstname = $input->getArgument('firstname')) == null) { - $firstname = $dialog->ask($input, $output, new Question('Firstname: ')); - } + $firstname = $this->getOrAskForArgument(self::COMMAND_ARGUMENT_FIRSTNAME, $input, $output); + $input->setArgument(self::COMMAND_ARGUMENT_FIRSTNAME, $firstname); // Lastname - if (($lastname = $input->getArgument('lastname')) == null) { - $lastname = $dialog->ask($input, $output, new Question('Lastname: ')); - } + $lastname = $this->getOrAskForArgument(self::COMMAND_ARGUMENT_LASTNAME, $input, $output); + $input->setArgument(self::COMMAND_ARGUMENT_LASTNAME, $lastname); - /** @var ParameterHelper $parameterHelper */ - $parameterHelper = $this->getHelper('parameter'); + // Website + $website = $parameterHelper->askWebsite($input, $output, self::COMMAND_ARGUMENT_WEBSITE); + $input->setArgument(self::COMMAND_ARGUMENT_WEBSITE, $website); + } - // Email - $email = $parameterHelper->askEmail($input, $output); + /** + * {@inheritDoc} + * @return int + */ + protected function execute(InputInterface $input, OutputInterface $output): int + { + /** @var string $email */ + $email = $input->getArgument(self::COMMAND_ARGUMENT_EMAIL); + /** @var string $password */ + $password = $input->getArgument(self::COMMAND_ARGUMENT_PASSWORD); + /** @var string $firstname */ + $firstname = $input->getArgument(self::COMMAND_ARGUMENT_FIRSTNAME); + /** @var string $lastname */ + $lastname = $input->getArgument(self::COMMAND_ARGUMENT_LASTNAME); + /** @var Mage_Core_Model_Website $website */ + $website = $input->getArgument(self::COMMAND_ARGUMENT_WEBSITE); + + $this->saveCustomer($email, $password, $firstname, $lastname, $website); + + if (is_null($input->getOption(self::COMMAND_OPTION_FORMAT))) { + $output->writeln(sprintf( + 'Customer %s successfully created', + $email + )); + + return Command::SUCCESS; + } - // Website - $website = $parameterHelper->askWebsite($input, $output); + $this->data[] = [ + 'email' => $email, + 'password' => $password, + 'firstname' => $firstname, + 'lastname' => $lastname + ]; - // create new customer + return parent::execute($input, $output); + } + + /** + * Create new customer + * + * @param string $email + * @param string $password + * @param string $firstname + * @param string $lastname + * @param Mage_Core_Model_Website $website + * @return void + */ + private function saveCustomer( + string $email, + string $password, + string $firstname, + string $lastname, + Mage_Core_Model_Website $website + ): void { $customer = $this->getCustomerModel(); $customer->setWebsiteId($website->getId()); - $customer->loadByEmail($email); - $outputPlain = $input->getOption('format') === null; + try { + $customer->loadByEmail($email); + } catch (Mage_Core_Exception $exception) { + throw new \RuntimeException($exception->getMessage()); + } - $table = []; - if (!$customer->getId()) { - $customer->setWebsiteId($website->getId()); - $customer->setEmail($email); - $customer->setFirstname($firstname); - $customer->setLastname($lastname); - $customer->setPassword($password); + if ($customer->getId()) { + throw new \RuntimeException(sprintf('Customer %s already exists', $email)); + } + $customer->setWebsiteId($website->getId()); + $customer->setEmail($email); + $customer->setFirstname($firstname); + $customer->setLastname($lastname); + $customer->setPassword($password); + + try { $customer->save(); $customer->setConfirmation(null); $customer->save(); - if ($outputPlain) { - $output->writeln('Customer ' . $email . ' successfully created'); - } else { - $table[] = [$email, $password, $firstname, $lastname]; - } - } else { - if ($outputPlain) { - $output->writeln('Customer ' . $email . ' already exists'); - } } - - if (!$outputPlain) { - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); - $tableHelper - ->setHeaders(['email', 'password', 'firstname', 'lastname']) - ->renderByFormat($output, $table, $input->getOption('format')); + catch (Throwable $exception) { + throw new \RuntimeException($exception->getMessage()); } - return 0; + } } diff --git a/src/N98/Magento/Command/Customer/InfoCommand.php b/src/N98/Magento/Command/Customer/InfoCommand.php index 71bb365b2..73352cf6a 100644 --- a/src/N98/Magento/Command/Customer/InfoCommand.php +++ b/src/N98/Magento/Command/Customer/InfoCommand.php @@ -20,10 +20,6 @@ */ class InfoCommand extends AbstractCustomerCommand { - public const COMMAND_ARGUMENT_EMAIL = 'email'; - - public const COMMAND_ARGUMENT_WEBSITE = 'website'; - /** * @var string */ From ac0169c72a1eb5b946a2ed257e24b9daa8c2f252 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 25 Jun 2024 23:13:11 +0200 Subject: [PATCH 125/136] [skip ci] Updated customer:info command --- .../Magento/Command/Customer/InfoCommand.php | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/N98/Magento/Command/Customer/InfoCommand.php b/src/N98/Magento/Command/Customer/InfoCommand.php index 73352cf6a..bcc38c6b1 100644 --- a/src/N98/Magento/Command/Customer/InfoCommand.php +++ b/src/N98/Magento/Command/Customer/InfoCommand.php @@ -51,6 +51,20 @@ protected function configure(): void ; } + public function interact(InputInterface $input,OutputInterface $output) + { + $parameterHelper = $this->getParameterHelper(); + + // Email + $email = $parameterHelper->askEmail($input, $output, self::COMMAND_ARGUMENT_EMAIL); + $input->setArgument(self::COMMAND_ARGUMENT_EMAIL, $email); + + // Website + $website = $parameterHelper->askWebsite($input, $output, self::COMMAND_ARGUMENT_WEBSITE); + $input->setArgument(self::COMMAND_ARGUMENT_WEBSITE, $website); + + } + /** * @param InputInterface $input * @param OutputInterface $output @@ -59,11 +73,10 @@ protected function configure(): void */ protected function execute(InputInterface $input, OutputInterface $output): int { - $parameterHelper = $this->getParameterHelper(); - - $email = $parameterHelper->askEmail($input, $output); + /** @var string $email */ + $email = $input->getArgument(self::COMMAND_ARGUMENT_EMAIL); /** @var Mage_Core_Model_Website $website */ - $website = $parameterHelper->askWebsite($input, $output); + $website = $input->getArgument(self::COMMAND_ARGUMENT_WEBSITE); $customer = $this->getCustomerModel() ->setWebsiteId($website->getId()) From 3497a28154ee71d0692bc6e28fceb231608e48e5 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 26 Jun 2024 16:08:54 +0200 Subject: [PATCH 126/136] [skip ci] Updated dev:module:create command --- .../Developer/Module/CreateCommand.php | 531 +++++++++++++----- 1 file changed, 381 insertions(+), 150 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Module/CreateCommand.php b/src/N98/Magento/Command/Developer/Module/CreateCommand.php index 7f444acd9..f3bd1831b 100644 --- a/src/N98/Magento/Command/Developer/Module/CreateCommand.php +++ b/src/N98/Magento/Command/Developer/Module/CreateCommand.php @@ -1,210 +1,356 @@ filesystem = new Filesystem(); + } + + protected function configure(): void { $this - ->setName('dev:module:create') - ->addArgument('vendorNamespace', InputArgument::REQUIRED, 'Namespace (your company prefix)') - ->addArgument('moduleName', InputArgument::REQUIRED, 'Name of your module.') - ->addArgument('codePool', InputArgument::OPTIONAL, 'Codepool (local, community)', 'local') - ->addOption('add-controllers', null, InputOption::VALUE_NONE, 'Adds controllers') - ->addOption('add-blocks', null, InputOption::VALUE_NONE, 'Adds blocks') - ->addOption('add-helpers', null, InputOption::VALUE_NONE, 'Adds helpers') - ->addOption('add-models', null, InputOption::VALUE_NONE, 'Adds models') - ->addOption('add-setup', null, InputOption::VALUE_NONE, 'Adds SQL setup') - ->addOption('add-all', null, InputOption::VALUE_NONE, 'Adds blocks, helpers and models') - ->addOption('modman', null, InputOption::VALUE_NONE, 'Create all files in folder with a modman file.') - ->addOption('add-readme', null, InputOption::VALUE_NONE, 'Adds a readme.md file to generated module') - ->addOption('add-composer', null, InputOption::VALUE_NONE, 'Adds a composer.json file to generated module') - ->addOption('author-name', null, InputOption::VALUE_OPTIONAL, 'Author for readme.md or composer.json') - ->addOption('author-email', null, InputOption::VALUE_OPTIONAL, 'Author for readme.md or composer.json') - ->addOption('description', null, InputOption::VALUE_OPTIONAL, 'Description for readme.md or composer.json') - ->setDescription('Create and register a new magento module.'); + ->addArgument( + self::COMMAND_ARGUMENT_VENDOR, + InputArgument::REQUIRED, + 'Namespace (your company prefix)' + ) + ->addArgument( + self::COMMAND_ARGUMENT_MODULE, + InputArgument::REQUIRED, + 'Name of your module.' + ) + ->addArgument( + self::COMMAND_ARGUMENT_CODEPOOL, + InputArgument::OPTIONAL, + 'Codepool (local, community)', + 'local', + ) + ->addOption( + self::COMMAND_OPTION_ADD_CONTROLLER, + null, + InputOption::VALUE_NONE, + 'Adds controllers' + ) + ->addOption( + self::COMMAND_OPTION_ADD_BLOCKS, + null, + InputOption::VALUE_NONE, + 'Adds blocks' + ) + ->addOption( + self::COMMAND_OPTION_ADD_HELPERS, + null, + InputOption::VALUE_NONE, + 'Adds helpers' + ) + ->addOption( + self::COMMAND_OPTION_ADD_MODELS, + null, + InputOption::VALUE_NONE, + 'Adds models' + ) + ->addOption( + self::COMMAND_OPTION_ADD_SETUP, + null, + InputOption::VALUE_NONE, + 'Adds SQL setup' + ) + ->addOption( + self::COMMAND_OPTION_ADD_ALL, + null, + InputOption::VALUE_NONE, + 'Adds blocks, helpers and models' + ) + ->addOption( + self::COMMAND_OPTION_MODMAN, + null, + InputOption::VALUE_NONE, + 'Create all files in folder with a modman file.' + ) + ->addOption( + self::COMMAND_OPTION_ADD_README, + null, + InputOption::VALUE_NONE, + 'Adds a readme.md file to generated module' + ) + ->addOption( + self::COMMAND_OPTION_ADD_COMPOSER, + null, + InputOption::VALUE_NONE, + 'Adds a composer.json file to generated module' + ) + ->addOption( + self::COMMAND_OPTION_AUTHOR_NAME, + null, + InputOption::VALUE_OPTIONAL, + 'Author for readme.md or composer.json' + ) + ->addOption( + self::COMMAND_OPTION_AUTHOR_EMAIL, + null, + InputOption::VALUE_OPTIONAL, + 'Author for readme.md or composer.json' + ) + ->addOption( + self::COMMAND_OPTION_DESCRIPTION, + null, + InputOption::VALUE_OPTIONAL, + 'Description for readme.md or composer.json' + ) + ; + } + + public function interact(InputInterface $input, OutputInterface $output) + { + $parameterHelper = $this->getParameterHelper(); + + // Vendor + $vendorNamespace = $this->getOrAskForArgument(self::COMMAND_ARGUMENT_VENDOR, $input, $output); + $input->setArgument(self::COMMAND_ARGUMENT_VENDOR, ucfirst($vendorNamespace)); + + // Module + $moduleName = $this->getOrAskForArgument(self::COMMAND_ARGUMENT_MODULE, $input, $output); + $input->setArgument(self::COMMAND_ARGUMENT_MODULE, ucfirst($moduleName)); + + // Codepool + $codePool = $parameterHelper->askCoodpool($input, $output, self::COMMAND_ARGUMENT_CODEPOOL); + $input->setArgument(self::COMMAND_ARGUMENT_CODEPOOL, $codePool); } /** * @param InputInterface $input * @param OutputInterface $output - * * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->output = $output; - - $this->modmanMode = $input->getOption('modman'); - if ($input->getOption('add-all')) { - $input->setOption('add-controllers', true); - $input->setOption('add-blocks', true); - $input->setOption('add-helpers', true); - $input->setOption('add-models', true); - $input->setOption('add-setup', true); - $input->setOption('add-readme', true); - $input->setOption('add-composer', true); + $this->modmanMode = $input->getOption(self::COMMAND_OPTION_MODMAN); + if ($input->getOption(self::COMMAND_OPTION_ADD_ALL)) { + $input->setOption(self::COMMAND_OPTION_ADD_CONTROLLER, true); + $input->setOption(self::COMMAND_OPTION_ADD_BLOCKS, true); + $input->setOption(self::COMMAND_OPTION_ADD_HELPERS, true); + $input->setOption(self::COMMAND_OPTION_ADD_MODELS, true); + $input->setOption(self::COMMAND_OPTION_ADD_SETUP, true); + $input->setOption(self::COMMAND_OPTION_ADD_README, true); + $input->setOption(self::COMMAND_OPTION_ADD_COMPOSER, true); } if (!$this->modmanMode) { $this->detectMagento($output); } $this->baseFolder = __DIR__ . '/../../../../../../res/module/create'; - $this->vendorNamespace = ucfirst($input->getArgument('vendorNamespace')); - $this->moduleName = ucfirst($input->getArgument('moduleName')); - $this->codePool = $input->getArgument('codePool'); - if (!in_array($this->codePool, ['local', 'community'])) { - throw new InvalidArgumentException('Code pool must "community" or "local"'); - } + $this->vendorNamespace = $input->getArgument(self::COMMAND_ARGUMENT_VENDOR); + $this->moduleName = $input->getArgument(self::COMMAND_ARGUMENT_MODULE); + $this->codePool = $input->getArgument(self::COMMAND_ARGUMENT_CODEPOOL); + $this->initView($input); $this->createModuleDirectories($input, $output); $this->writeEtcModules($output); $this->writeModuleConfig($output); - $this->writeReadme($input, $output); + + if ($input->getOption(self::COMMAND_OPTION_ADD_README)) { + $this->writeReadme($output); + } + if ($this->modmanMode) { $this->writeModmanFile($output); } - $this->writeComposerConfig($input, $output); + + if ($input->getOption(self::COMMAND_OPTION_ADD_COMPOSER)) { + $this->writeComposerConfig($output); + } + $this->addAdditionalFiles($output); - return 0; + + return Command::SUCCESS; } - protected function initView(InputInterface $input) + /** + * @param InputInterface $input + * @return void + */ + protected function initView(InputInterface $input): void { - $this->twigVars = ['vendorNamespace' => $this->vendorNamespace, 'moduleName' => $this->moduleName, 'codePool' => $this->codePool, 'createControllers' => $input->getOption('add-controllers'), 'createBlocks' => $input->getOption('add-blocks'), 'createModels' => $input->getOption('add-models'), 'createHelpers' => $input->getOption('add-helpers'), 'createSetup' => $input->getOption('add-setup'), 'authorName' => $input->getOption('author-name'), 'authorEmail' => $input->getOption('author-email'), 'description' => $input->getOption('description')]; + $this->twigVars = [ + 'vendorNamespace' => $this->vendorNamespace, + 'moduleName' => $this->moduleName, + 'codePool' => $this->codePool, + 'createControllers' => $input->getOption(self::COMMAND_OPTION_ADD_CONTROLLER), + 'createBlocks' => $input->getOption(self::COMMAND_OPTION_ADD_BLOCKS), + 'createHelpers' => $input->getOption(self::COMMAND_OPTION_ADD_HELPERS), + 'createModels' => $input->getOption(self::COMMAND_OPTION_ADD_MODELS), + 'createSetup' => $input->getOption(self::COMMAND_OPTION_ADD_SETUP), + 'authorName' => $input->getOption(self::COMMAND_OPTION_AUTHOR_NAME), + 'authorEmail' => $input->getOption(self::COMMAND_OPTION_AUTHOR_EMAIL), + 'description' => $input->getOption(self::COMMAND_OPTION_DESCRIPTION) + ]; } /** * @param InputInterface $input * @param OutputInterface $output + * @return void */ - protected function createModuleDirectories(InputInterface $input, OutputInterface $output) + protected function createModuleDirectories(InputInterface $input, OutputInterface $output): void { - if ($this->modmanMode) { - $modManDir = $this->vendorNamespace . '_' . $this->moduleName . '/src'; - if (file_exists($modManDir)) { - throw new RuntimeException('Module already exists. Stop.'); - } - mkdir($modManDir, 0777, true); - $this->_magentoRootFolder = './' . $modManDir; - mkdir($this->_magentoRootFolder . '/app/etc/modules', 0777, true); - } - $moduleDir = sprintf( - '%s/app/code/%s/%s/%s', - $this->_magentoRootFolder, - $this->codePool, - $this->vendorNamespace, - $this->moduleName - ); - - if (file_exists($moduleDir)) { - throw new RuntimeException('Module already exists. Stop.'); - } - $this->moduleDirectory = $moduleDir; - mkdir($this->moduleDirectory, 0777, true); - $output->writeln('Created directory: ' . $this->moduleDirectory . ''); + $this->createDirectories($output); + $this->createBaseModuleDirectory($output); // Add etc folder - $this->createModuleDirectory('etc'); + $this->createModuleDirectory($output, 'etc'); // Add controllers folder - if ($input->getOption('add-controllers')) { - $this->createModuleDirectory('controllers'); + if ($input->getOption(self::COMMAND_OPTION_ADD_CONTROLLER)) { + $this->createModuleDirectory($output, 'controllers'); } // Add blocks folder - if ($input->getOption('add-blocks')) { - $this->createModuleDirectory('Block'); + if ($input->getOption(self::COMMAND_OPTION_ADD_BLOCKS)) { + $this->createModuleDirectory($output, 'Block'); } // Add helpers folder - if ($input->getOption('add-helpers')) { - $this->createModuleDirectory('Helper'); + if ($input->getOption(self::COMMAND_OPTION_ADD_HELPERS)) { + $this->createModuleDirectory($output, 'Helper'); } // Add models folder - if ($input->getOption('add-models')) { - $this->createModuleDirectory('Model'); + if ($input->getOption(self::COMMAND_OPTION_ADD_MODELS)) { + $this->createModuleDirectory($output, 'Model'); } // Create SQL and Data folder - if ($input->getOption('add-setup')) { - $sqlSetupFolder = $this->moduleDirectory . '/sql/' . strtolower($this->vendorNamespace) . '_' . - strtolower($this->moduleName) . '_setup'; - mkdir($sqlSetupFolder, 0777, true); - $output->writeln('Created directory: ' . $sqlSetupFolder . ''); - - $dataSetupFolder = $this->moduleDirectory . '/data/' . strtolower($this->vendorNamespace) . '_' . - strtolower($this->moduleName) . '_setup'; - mkdir($dataSetupFolder, 0777, true); - $output->writeln('Created directory: ' . $dataSetupFolder . ''); + if ($input->getOption(self::COMMAND_OPTION_ADD_SETUP)) { + $this->createModuleSetupDirectory($output); } } /** + * @param OutputInterface $output * @param string $directory + * @return void */ - private function createModuleDirectory($directory) + private function createModuleDirectory(OutputInterface $output, string $directory): void { $path = $this->moduleDirectory . '/' . $directory; - mkdir($path); - $this->output->writeln('Created directory: ' . $path . ''); + $this->createDirectory($output, $path); } - protected function writeEtcModules(OutputInterface $output) + /** + * @param OutputInterface $output + * @return void + */ + protected function writeEtcModules(OutputInterface $output): void { $outFile = sprintf( '%s/app/etc/modules/%s_%s.xml', @@ -212,34 +358,33 @@ protected function writeEtcModules(OutputInterface $output) $this->vendorNamespace, $this->moduleName ); + $template = 'dev/module/create/app/etc/modules/definition.twig'; - /** @var TwigHelper $helper */ - $helper = $this->getHelper('twig'); - $buffer = $helper->render('dev/module/create/app/etc/modules/definition.twig', $this->twigVars); - $size = file_put_contents($outFile, $buffer); - - $output->writeln('Created file: ' . $outFile . ' (' . $size . ' bytes)'); + $this->dumpFile($output, $outFile, $template); } - protected function writeModuleConfig(OutputInterface $output) + /** + * @param OutputInterface $output + * @return void + */ + protected function writeModuleConfig(OutputInterface $output): void { $outFile = $this->moduleDirectory . '/etc/config.xml'; - file_put_contents( - $outFile, - $this->getHelper('twig')->render('dev/module/create/app/etc/modules/config.twig', $this->twigVars) - ); + $template = 'dev/module/create/app/etc/modules/config.twig'; - $output->writeln('Created file: ' . $outFile . ''); + $this->dumpFile($output, $outFile, $template); } - protected function writeModmanFile(OutputInterface $output) + /** + * @param OutputInterface $output + * @return void + */ + protected function writeModmanFile(OutputInterface $output): void { $outFile = $this->_magentoRootFolder . '/../modman'; - file_put_contents( - $outFile, - $this->getHelper('twig')->render('dev/module/create/modman.twig', $this->twigVars) - ); - $output->writeln('Created file: ' . $outFile . ''); + $template = 'dev/module/create/modman.twig'; + + $this->dumpFile($output, $outFile, $template); } /** @@ -249,75 +394,161 @@ protected function writeModmanFile(OutputInterface $output) * * @see https://raw.github.com/sprankhub/Magento-Extension-Sample-Readme/master/readme.markdown * - * @param InputInterface $input * @param OutputInterface $output + * @return void */ - protected function writeReadme($input, $output) + protected function writeReadme(OutputInterface $output): void { - if (!$input->getOption('add-readme')) { - return; - } if ($this->modmanMode) { $outFile = $this->_magentoRootFolder . '/../readme.md'; } else { $outFile = $this->moduleDirectory . '/etc/readme.md'; } - file_put_contents( - $outFile, - $this->getHelper('twig')->render('dev/module/create/app/etc/modules/readme.twig', $this->twigVars) - ); - $output->writeln('Created file: ' . $outFile . ''); + $template = 'dev/module/create/app/etc/modules/readme.twig'; + + $this->dumpFile($output, $outFile, $template); } /** * Write composer.json * - * @param InputInterface $input * @param OutputInterface $output */ - protected function writeComposerConfig(InputInterface $input, OutputInterface $output) + protected function writeComposerConfig(OutputInterface $output): void { - if (!$input->getOption('add-composer')) { - return; - } if ($this->modmanMode) { $outFile = $this->_magentoRootFolder . '/../composer.json'; } else { $outFile = $this->moduleDirectory . '/etc/composer.json'; } - file_put_contents( - $outFile, - $this->getHelper('twig')->render('dev/module/create/composer.twig', $this->twigVars) - ); - $output->writeln('Created file: ' . $outFile . ''); + $template = 'dev/module/create/composer.twig'; + + $this->dumpFile($output, $outFile, $template); } - protected function addAdditionalFiles(OutputInterface $output) + /** + * @param OutputInterface $output + * @return void + */ + protected function addAdditionalFiles(OutputInterface $output): void { $config = $this->getCommandConfig(); if (isset($config['additionalFiles']) && is_array($config['additionalFiles'])) { foreach ($config['additionalFiles'] as $template => $outFileTemplate) { $outFile = $this->getOutfile($outFileTemplate); - $outFileDir = dirname($outFile); - if (!is_dir($outFileDir)) { - mkdir($outFileDir, 0777, true); + $outFileDir = Path::getRoot($outFile); + if (!$this->filesystem->exists($outFileDir)) { + $this->filesystem->mkdir($outFileDir); } - file_put_contents($outFile, $this->getHelper('twig')->render($template, $this->twigVars)); - $output->writeln('Created file: ' . $outFile . ''); + $this->dumpFile($output, $outFile, $template); + } + } + } + + private function createDirectories(OutputInterface $output): void + { + if ($this->modmanMode) { + $modManDir = $this->vendorNamespace . '_' . $this->moduleName . '/src'; + if ($this->filesystem->exists($modManDir)) { + throw new RuntimeException('Module already exists. Stop.'); } + + $this->createDirectory($output, $modManDir); + + $this->_magentoRootFolder = './' . $modManDir; + $this->createDirectory($output, $this->_magentoRootFolder . '/app/etc/modules'); + } + } + + /** + * @param OutputInterface $output + * @return void + */ + private function createBaseModuleDirectory(OutputInterface $output): void + { + $moduleDir = sprintf( + '%s/app/code/%s/%s/%s', + $this->_magentoRootFolder, + $this->codePool, + $this->vendorNamespace, + $this->moduleName + ); + + if ($this->filesystem->exists($moduleDir)) { + throw new RuntimeException('Module already exists. Stop.'); + } + $this->moduleDirectory = $moduleDir; + $this->createDirectory($output, $this->moduleDirectory); + } + + /** + * @param OutputInterface $output + * @return void + */ + private function createModuleSetupDirectory(OutputInterface $output): void + { + $sqlSetupFolder = sprintf( + '%s/sql/%s_%s_setup', + $this->moduleDirectory, + strtolower($this->vendorNamespace), + strtolower($this->moduleName) + ); + $this->createDirectory($output, $sqlSetupFolder); + + $dataSetupFolder = sprintf( + '%s/data/%s_%s_setup', + $this->moduleDirectory, + strtolower($this->vendorNamespace), + strtolower($this->moduleName) + ); + $this->createDirectory($output, $dataSetupFolder); + } + + /** + * @param OutputInterface $output + * @param string $directory + * @return void + */ + private function createDirectory(OutputInterface $output, string $directory): void + { + try { + $this->filesystem->mkdir($directory); + } catch (IOExceptionInterface $exception) { + throw new IOException($exception->getMessage()); + } + $output->writeln(sprintf('Created directory: %s', $directory)); + } + + /** + * @param OutputInterface $output + * @param string $outFile + * @param string $template + * @return void + */ + private function dumpFile(OutputInterface $output, string $outFile, string $template): void + { + $helper = $this->getTwigHelper(); + $buffer = $helper->render($template, $this->twigVars); + + try { + $this->filesystem->dumpFile($outFile, $buffer); + } catch (IOExceptionInterface $exception) { + throw new IOException($exception->getMessage()); } + $output->writeln(sprintf('Created file: %s', $outFile)); } /** * @param string $filename * @return string */ - private function getOutfile($filename) + private function getOutfile(string $filename): string { - $paths = ['rootDir' => $this->_magentoRootFolder, 'moduleDir' => $this->moduleDirectory]; + $paths = [ + 'rootDir' => $this->_magentoRootFolder, + 'moduleDir' => $this->moduleDirectory + ]; - /** @var TwigHelper $twig */ - $twig = $this->getHelper('twig'); - return $twig->renderString($filename, array_merge($this->twigVars, $paths)); + return $this->getTwigHelper()->renderString($filename, array_merge($this->twigVars, $paths)); } } From d7916b3bdd041c3d6b571dd59a0f16468f06f052 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 26 Jun 2024 16:48:55 +0200 Subject: [PATCH 127/136] [skip ci] Updated AbstractCommand --- src/N98/Magento/Command/AbstractCommand.php | 87 ++++++++++++++------- 1 file changed, 58 insertions(+), 29 deletions(-) diff --git a/src/N98/Magento/Command/AbstractCommand.php b/src/N98/Magento/Command/AbstractCommand.php index 78d53d897..8cfe09770 100644 --- a/src/N98/Magento/Command/AbstractCommand.php +++ b/src/N98/Magento/Command/AbstractCommand.php @@ -44,7 +44,7 @@ abstract class AbstractCommand extends AbstractCommandHelper protected const NO_DATA_MESSAGE = 'No data found'; - protected const QUESTION_ATTEMPTS = 3; + public const QUESTION_ATTEMPTS = 3; /** * @var string|null @@ -82,13 +82,7 @@ abstract class AbstractCommand extends AbstractCommandHelper protected function configure(): void { if ($this instanceof CommandDataInterface) { - $this->addOption( - self::COMMAND_OPTION_FORMAT, - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']', - static::COMMAND_OPTION_FORMAT_DEFAULT - ); + $this->addFormatOption(); } } @@ -118,6 +112,31 @@ protected function initialize(InputInterface $input, OutputInterface $output) } } + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return int + */ + protected function execute(InputInterface $input, OutputInterface $output): int + { + if (static::COMMAND_SECTION_TITLE_TEXT && $input->getOption(self::COMMAND_OPTION_FORMAT) === null) { + $this->writeSection($output, static::COMMAND_SECTION_TITLE_TEXT); + } + + $data = $this->getData(); + if (!count($data)) { + $output->writeln(sprintf('%s', static::NO_DATA_MESSAGE)); + return Command::SUCCESS; + } + + $tableHelper = $this->getTableHelper(); + $tableHelper + ->setHeaders($this->getTableHeaders($input, $output)) + ->renderByFormat($output, $data, $input->getOption(self::COMMAND_OPTION_FORMAT)); + + return Command::SUCCESS; + } + protected function getData(): array { return $this->data; @@ -521,10 +540,29 @@ protected function getOrAskForArgument( ): string { $inputArgument = $input->getArgument($argument); if ($inputArgument === null) { + $dialog = $this->getQuestionHelper(); $message = $this->getArgumentMessage($argument, $message); - $dialog = $this->getQuestionHelper(); - return $dialog->ask($input, $output, new Question($message)); + $validation = function (string $answer) use ($argument): string { + if (trim($answer) === '') { + $definition = $this->getNativeDefinition()->getArgument($argument)->getDescription(); + throw new InvalidArgumentException( + $definition . ' cannot be empty.' + ); + } + + return $answer; + }; + + $question = new Question($message); + $question->setNormalizer(function (?string $value): string { + // $value can be null here + return $value ? trim($value) : ''; + }); + $question->setValidator($validation); + $question->setMaxAttempts(self::QUESTION_ATTEMPTS); + + return $dialog->ask($input, $output, $question); } return $inputArgument; @@ -607,27 +645,18 @@ protected function createSubCommandFactory( } /** - * @param InputInterface $input - * @param OutputInterface $output - * @return int + * @return $this */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function addFormatOption(): AbstractCommand { - if (static::COMMAND_SECTION_TITLE_TEXT && $input->getOption(self::COMMAND_OPTION_FORMAT) === null) { - $this->writeSection($output, static::COMMAND_SECTION_TITLE_TEXT); - } - - $data = $this->getData(); - if (count($data) > 0) { - $tableHelper = $this->getTableHelper(); - $tableHelper - ->setHeaders($this->getTableHeaders($input, $output)) - ->renderByFormat($output, $data, $input->getOption(self::COMMAND_OPTION_FORMAT)); - } else { - $output->writeln(sprintf('%s', static::NO_DATA_MESSAGE)); - } - - return Command::SUCCESS; + $this->addOption( + self::COMMAND_OPTION_FORMAT, + null, + InputOption::VALUE_OPTIONAL, + 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']', + static::COMMAND_OPTION_FORMAT_DEFAULT + ); + return $this; } /** From 7a61e126ec8fa0fab2d39a47969e3adc8e0b99e6 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 26 Jun 2024 22:01:01 +0200 Subject: [PATCH 128/136] [skip ci] Updated local-config:generate command --- .../Command/LocalConfig/GenerateCommand.php | 119 +++++++++++------- 1 file changed, 77 insertions(+), 42 deletions(-) diff --git a/src/N98/Magento/Command/LocalConfig/GenerateCommand.php b/src/N98/Magento/Command/LocalConfig/GenerateCommand.php index d00991e13..d2aea9f87 100644 --- a/src/N98/Magento/Command/LocalConfig/GenerateCommand.php +++ b/src/N98/Magento/Command/LocalConfig/GenerateCommand.php @@ -6,47 +6,59 @@ use DateTimeInterface; use InvalidArgumentException; -use N98\Magento\Command\AbstractMagentoCommand; -use Symfony\Component\Console\Attribute\AsCommand; +use N98\Magento\Command\AbstractCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\Question; +use Symfony\Component\Filesystem\Exception\IOException; +use Symfony\Component\Filesystem\Exception\IOExceptionInterface; +use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\Filesystem\Path; /** * Generate local.xml command * * @package N98\Magento\Command\LocalConfig */ -class GenerateCommand extends AbstractMagentoCommand +class GenerateCommand extends AbstractCommand { - private const COMMAND_ARGUMENT_DB_HOST = 'db-host'; - private const COMMAND_ARGUMENT_DB_NAME = 'db-name'; - private const COMMAND_ARGUMENT_DB_PASS = 'db-pass'; - private const COMMAND_ARGUMENT_DB_USER = 'db-user'; - private const COMMAND_ARGUMENT_SESSION_SAVE = 'session-save'; - private const COMMAND_ARGUMENT_ADMIN_FRONTNAME = 'admin-frontname'; - private const COMMAND_ARGUMENT_ENCRYPTION_KEY = 'encryption-key'; + public const COMMAND_ARGUMENT_DB_HOST = 'db-host'; + public const COMMAND_ARGUMENT_DB_NAME = 'db-name'; + public const COMMAND_ARGUMENT_DB_PASS = 'db-pass'; + public const COMMAND_ARGUMENT_DB_USER = 'db-user'; + public const COMMAND_ARGUMENT_SESSION_SAVE = 'session-save'; + public const COMMAND_ARGUMENT_ADMIN_FRONTNAME = 'admin-frontname'; + public const COMMAND_ARGUMENT_ENCRYPTION_KEY = 'encryption-key'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ protected static $defaultName = 'local-config:generate'; /** * @var string - * @deprecated with symfony 6.1 - * @see AsCommand */ - protected static $defaultDescription = 'Generates local.xml config'; + protected static $defaultDescription = 'Generates local.xml config.'; + + protected static bool $initMagentoFlag = false; + + /** + * @var Filesystem + */ + private Filesystem $filesystem; + + public function __construct() + { + parent:: __construct(); + $this->filesystem = new Filesystem(); + } /** * @return void */ - protected function configure() + protected function configure(): void { $this ->addArgument( @@ -108,58 +120,81 @@ public function getHelp(): string */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); $configFile = $this->_getLocalConfigFilename(); - $configFileTemplate = dirname($configFile) . '/local.xml.template'; - - if (file_exists($configFile)) { - $output->writeln( - sprintf('local.xml file already exists in folder "%s/app/etc"', dirname($configFile)) - ); - return Command::INVALID; + if ($this->filesystem->exists($configFile)) { + $output->writeln(sprintf( + 'local.xml file already exists in folder "%s/app/etc"', + Path::getDirectory($configFile) + )); + return Command::FAILURE; } $this->writeSection($output, 'Generate local.xml'); $this->askForArguments($input, $output); - if (!file_exists($configFileTemplate)) { + + $configFileTemplate = Path::getDirectory($configFile) . '/local.xml.template'; + if (!$this->filesystem->exists($configFileTemplate)) { $output->writeln(sprintf('File %s does not exist.', $configFileTemplate)); return Command::FAILURE; } - if (!is_writable(dirname($configFileTemplate))) { - $output->writeln(sprintf('Folder %s is not writeable', dirname($configFileTemplate))); - return Command::FAILURE; + try { + $this->filesystem->touch($configFile); + } catch (IOExceptionInterface $exception) { + throw new IOException($exception->getMessage()); } - $content = file_get_contents($configFileTemplate); - if (!$content) { - $output->writeln(sprintf('File %s has no content', dirname($configFileTemplate))); - return Command::FAILURE; + try { + $content = $this->filesystem->readFile($configFileTemplate); + if (!$content) { + $output->writeln(sprintf( + 'File %s has no content', + Path::getDirectory($configFileTemplate) + )); + } + } catch (IOExceptionInterface $exception) { + throw new IOException($exception->getMessage()); } - $key = $this->getArgumentString($input, self::COMMAND_ARGUMENT_ENCRYPTION_KEY) ?: md5(uniqid()); + /** @var string $key */ + $key = $input->getArgument(self::COMMAND_ARGUMENT_ENCRYPTION_KEY) ?: md5(uniqid()); + /** @var string $dbHost */ + $dbHost = $input->getArgument(self::COMMAND_ARGUMENT_DB_HOST); + /** @var string $dbUser */ + $dbUser = $input->getArgument(self::COMMAND_ARGUMENT_DB_USER); + /** @var string $dbPass */ + $dbPass = $input->getArgument(self::COMMAND_ARGUMENT_DB_PASS); + /** @var string $dbName */ + $dbName = $input->getArgument(self::COMMAND_ARGUMENT_DB_NAME); + /** @var string $session */ + $session = $input->getArgument(self::COMMAND_ARGUMENT_SESSION_SAVE); + /** @var string $frontName */ + $frontName = $input->getArgument(self::COMMAND_ARGUMENT_ADMIN_FRONTNAME); $replace = [ '{{date}}' => $this->_wrapCData(date(DateTimeInterface::RFC2822)), '{{key}}' => $this->_wrapCData($key), + // Prefix does not work with sample data '{{db_prefix}}' => $this->_wrapCData(''), - '{{db_host}}' => $this->_wrapCData($this->getArgumentString($input, self::COMMAND_ARGUMENT_DB_HOST)), - '{{db_user}}' => $this->_wrapCData($this->getArgumentString($input, self::COMMAND_ARGUMENT_DB_USER,)), - '{{db_pass}}' => $this->_wrapCData($this->getArgumentString($input, self::COMMAND_ARGUMENT_DB_PASS)), - '{{db_name}}' => $this->_wrapCData($this->getArgumentString($input, self::COMMAND_ARGUMENT_DB_NAME)), + '{{db_host}}' => $this->_wrapCData($dbHost), + '{{db_user}}' => $this->_wrapCData($dbUser), + '{{db_pass}}' => $this->_wrapCData($dbPass), + '{{db_name}}' => $this->_wrapCData($dbName), // typo intended -> magento has a little typo bug "statements". '{{db_init_statemants}}' => $this->_wrapCData('SET NAMES utf8'), '{{db_model}}' => $this->_wrapCData('mysql4'), '{{db_type}}' => $this->_wrapCData('pdo_mysql'), '{{db_pdo_type}}' => $this->_wrapCData(''), - '{{session_save}}' => $this->_wrapCData($this->getArgumentString($input, self::COMMAND_ARGUMENT_SESSION_SAVE)), - '{{admin_frontname}}' => $this->_wrapCData($this->getArgumentString($input, self::COMMAND_ARGUMENT_ADMIN_FRONTNAME)), + '{{session_save}}' => $this->_wrapCData($session), + '{{admin_frontname}}' => $this->_wrapCData($frontName), ]; $newFileContent = str_replace(array_keys($replace), array_values($replace), $content); - if (false === file_put_contents($configFile, $newFileContent)) { - $output->writeln('could not save config'); - return Command::FAILURE; + + try { + $this->filesystem->dumpFile($configFile, $newFileContent); + } catch (IOExceptionInterface $exception) { + throw new IOException($exception->getMessage()); } $output->writeln('Generated config'); From 14890bdcac5bb85f17fe5c2fe851d26bfa5c3031 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 26 Jun 2024 22:04:07 +0200 Subject: [PATCH 129/136] [skip ci] Updated sys:url:list command --- .../Command/System/Url/ListCommand.php | 139 ++++++++++++++---- 1 file changed, 110 insertions(+), 29 deletions(-) diff --git a/src/N98/Magento/Command/System/Url/ListCommand.php b/src/N98/Magento/Command/System/Url/ListCommand.php index faef171b8..441e2557a 100644 --- a/src/N98/Magento/Command/System/Url/ListCommand.php +++ b/src/N98/Magento/Command/System/Url/ListCommand.php @@ -4,11 +4,13 @@ namespace N98\Magento\Command\System\Url; +use InvalidArgumentException; use Mage; use Mage_Core_Exception; use Mage_Core_Model_Store; use Mage_Core_Model_Store_Exception; use N98\Magento\Command\AbstractCommand; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -34,17 +36,67 @@ */ class ListCommand extends AbstractCommand { + public const COMMAND_ARGUMENT_STORES = 'stores'; + + public const COMMAND_ARGUMENT_LINE_TEMPLATE = 'linetemplate'; + + public const COMMAND_OPTION_ADD_ALL = 'add-all'; + + public const COMMAND_OPTION_ADD_CATEGORIES = 'add-categories'; + + public const COMMAND_OPTION_ADD_CMS_PAGES = 'add-cmspages'; + + public const COMMAND_OPTION_ADD_PRODUCTS = 'add-products'; + + /** + * @var string + */ + protected static $defaultName = 'sys:url:list'; + + /** + * @var string + */ + protected static $defaultDescription = 'Get all urls.'; + protected function configure(): void { $this - ->setName('sys:url:list') - ->addOption('add-categories', null, InputOption::VALUE_NONE, 'Adds categories') - ->addOption('add-products', null, InputOption::VALUE_NONE, 'Adds products') - ->addOption('add-cmspages', null, InputOption::VALUE_NONE, 'Adds cms pages') - ->addOption('add-all', null, InputOption::VALUE_NONE, 'Adds categories, products and cms pages') - ->addArgument('stores', InputArgument::OPTIONAL, 'Stores (comma-separated list of store ids)') - ->addArgument('linetemplate', InputArgument::OPTIONAL, 'Line template', '{url}') - ->setDescription('Get all urls.'); + ->addArgument( + self::COMMAND_ARGUMENT_STORES, + InputArgument::OPTIONAL, + 'Stores (comma-separated list of store ids)' + ) + ->addArgument( + self::COMMAND_ARGUMENT_LINE_TEMPLATE, + InputArgument::OPTIONAL, + 'Line template', + '{url}' + ) + ->addOption( + self::COMMAND_OPTION_ADD_CATEGORIES, + null, + InputOption::VALUE_NONE, + 'Adds categories' + ) + ->addOption( + self::COMMAND_OPTION_ADD_PRODUCTS, + null, + InputOption::VALUE_NONE, + 'Adds products' + ) + ->addOption( + self::COMMAND_OPTION_ADD_CMS_PAGES, + null, + InputOption::VALUE_NONE, + 'Adds cms pages' + ) + ->addOption( + self::COMMAND_OPTION_ADD_ALL, + null, + InputOption::VALUE_NONE, + 'Adds categories, products and cms pages' + ) + ; } /** @@ -69,59 +121,88 @@ public function getHelp(): string HELP; } + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return void + */ + public function interact(InputInterface $input,OutputInterface $output): void + { + if ($input->getOption(self::COMMAND_OPTION_ADD_ALL)) { + $input->setOption(self::COMMAND_OPTION_ADD_CATEGORIES, true); + $input->setOption(self::COMMAND_OPTION_ADD_PRODUCTS, true); + $input->setOption(self::COMMAND_OPTION_ADD_CMS_PAGES, true); + } + + $stores = [0]; + if ($input->getOption(self::COMMAND_OPTION_ADD_CATEGORIES) + || $input->getOption(self::COMMAND_OPTION_ADD_PRODUCTS) + ) { + $stores = $this->getOrAskForArgument(self::COMMAND_ARGUMENT_STORES, $input, $output); + $stores = explode(',', $stores); + } + $input->setArgument(self::COMMAND_ARGUMENT_STORES, $stores); + } + /** * Execute command * * @param InputInterface $input * @param OutputInterface $output * @return int - * @throws Mage_Core_Model_Store_Exception * @throws Mage_Core_Exception */ protected function execute(InputInterface $input, OutputInterface $output): int { - if ($input->getOption('add-all')) { - $input->setOption('add-categories', true); - $input->setOption('add-products', true); - $input->setOption('add-cmspages', true); - } - - $stores = explode(',', $input->getArgument('stores') ?? ''); - $urls = []; + /** @var array $stores */ + $stores = $input->getArgument(self::COMMAND_ARGUMENT_STORES); foreach ($stores as $storeId) { - /** @var Mage_Core_Model_Store $currentStore */ - $currentStore = Mage::app()->getStore($storeId); + try { + /** @var Mage_Core_Model_Store $currentStore */ + $currentStore = $this->_getMage()->getStore($storeId); + } catch (Mage_Core_Model_Store_Exception $exception) { + $output->writeln(sprintf('Store with ID %s not found. Skipped.', $storeId)); + continue; + } // base url $urls[] = $currentStore->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB); $linkBaseUrl = $currentStore->getBaseUrl(); - if ($input->getOption('add-categories')) { + if ($input->getOption(self::COMMAND_OPTION_ADD_CATEGORIES)) { $urls = $this->getUrls('sitemap/catalog_category', $linkBaseUrl, $storeId, $urls); } - if ($input->getOption('add-products')) { + if ($input->getOption(self::COMMAND_OPTION_ADD_PRODUCTS)) { $urls = $this->getUrls('sitemap/catalog_product', $linkBaseUrl, $storeId, $urls); } - if ($input->getOption('add-cmspages')) { + if ($input->getOption(self::COMMAND_OPTION_ADD_CMS_PAGES)) { $urls = $this->getUrls('sitemap/cms_page', $linkBaseUrl, $storeId, $urls); } } - if (count($urls) === 0) { - return 0; + if ($urls === []) { + return Command::FAILURE; } + foreach ($urls as $url) { // pre-process - $line = $input->getArgument('linetemplate'); + /** @var string $line */ + $line = $input->getArgument(self::COMMAND_ARGUMENT_LINE_TEMPLATE); $line = str_replace('{url}', $url, $line); + /** @var array $parts */ $parts = parse_url($url); + + /** + * @var string $key + * @var string $value + */ foreach ($parts as $key => $value) { $line = str_replace('{' . $key . '}', $value, $line); } @@ -130,20 +211,20 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln($line); } - return 0; + return Command::SUCCESS; } /** * @param string $resourceModel * @param string $linkBaseUrl * @param string $storeId - * @param array $urls - * @return array + * @param array $urls + * @return array */ protected function getUrls(string $resourceModel, string $linkBaseUrl, string $storeId, array $urls): array { $resourceModel = Mage::getResourceModel($resourceModel); - if (!$resourceModel) { + if (!$resourceModel || !method_exists($resourceModel, 'getCollection')) { return $urls; } From c04ce47755a5754952f25e3f81f7bbfde67d28f5 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 26 Jun 2024 23:22:55 +0200 Subject: [PATCH 130/136] [skip ci] Updated dev:setup:script:attribute command --- .../EntityType/AbstractEntityType.php | 45 +++++------ .../Attribute/EntityType/CatalogProduct.php | 16 ++-- .../Attribute/EntityType/EntityType.php | 16 ++-- .../Script/Attribute/EntityType/Factory.php | 12 ++- .../Setup/Script/AttributeCommand.php | 76 +++++++++++++------ 5 files changed, 105 insertions(+), 60 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Setup/Script/Attribute/EntityType/AbstractEntityType.php b/src/N98/Magento/Command/Developer/Setup/Script/Attribute/EntityType/AbstractEntityType.php index 33538bada..8df250601 100644 --- a/src/N98/Magento/Command/Developer/Setup/Script/Attribute/EntityType/AbstractEntityType.php +++ b/src/N98/Magento/Command/Developer/Setup/Script/Attribute/EntityType/AbstractEntityType.php @@ -1,9 +1,12 @@ */ - protected $warnings = []; + protected array $warnings = []; /** - * @param \Mage_Eav_Model_Entity_Attribute $attribute + * @param Mage_Eav_Model_Entity_Attribute $attribute */ public function __construct(Mage_Eav_Model_Entity_Attribute $attribute) { @@ -41,25 +44,25 @@ public function __construct(Mage_Eav_Model_Entity_Attribute $attribute) } /** - * @param $connection + * @param Varien_Db_Adapter_Interface $connection */ - public function setReadConnection($connection) + public function setReadConnection($connection): void { $this->readConnection = $connection; } /** - * @param array $warnings + * @param array $warnings */ - public function setWarnings($warnings) + public function setWarnings(array $warnings): void { $this->warnings = $warnings; } /** - * @return array + * @return array */ - public function getWarnings() + public function getWarnings(): array { return $this->warnings; } @@ -67,11 +70,10 @@ public function getWarnings() /** * Gets attribute labels from database * - * @param \Mage_Eav_Model_Entity_Attribute $attribute - * - * @return array + * @param Mage_Eav_Model_Entity_Attribute $attribute + * @return array */ - public function getAttributeLabels($attribute) + public function getAttributeLabels($attribute): array { // FIXME: after having this warning in for some time, promote to a parameter type-hint. if (!$attribute instanceof Mage_Eav_Model_Entity_Attribute) { @@ -97,11 +99,10 @@ public function getAttributeLabels($attribute) /** * Gets attribute options from database * - * @param \Mage_Eav_Model_Entity_Attribute $attribute - * - * @return array + * @param Mage_Eav_Model_Entity_Attribute $attribute + * @return array> */ - protected function getOptions(Mage_Eav_Model_Entity_Attribute $attribute) + protected function getOptions(Mage_Eav_Model_Entity_Attribute $attribute): array { $resourceModel = Mage::getSingleton('core/resource'); $select = $this->readConnection->select() diff --git a/src/N98/Magento/Command/Developer/Setup/Script/Attribute/EntityType/CatalogProduct.php b/src/N98/Magento/Command/Developer/Setup/Script/Attribute/EntityType/CatalogProduct.php index 8458dcb60..725172046 100644 --- a/src/N98/Magento/Command/Developer/Setup/Script/Attribute/EntityType/CatalogProduct.php +++ b/src/N98/Magento/Command/Developer/Setup/Script/Attribute/EntityType/CatalogProduct.php @@ -1,15 +1,20 @@ */ - protected function _getKeyMapping() + protected function _getKeyMapping(): array { return [ //catalog @@ -41,12 +46,13 @@ protected function _getKeyMapping() /** * @return string */ - public function generateCode() + public function generateCode(): string { // get a map of "real attribute properties to properties used in setup resource array $realToSetupKeyLegend = $this->_getKeyMapping(); // swap keys from above + /** @var array $data */ $data = $this->attribute->getData(); $keysLegend = array_keys($realToSetupKeyLegend); $newData = []; @@ -59,7 +65,7 @@ public function generateCode() } // unset items from model that we don't need and would be discarded by - // resource script anyways + // resource script anyway unset($newData['attribute_id']); unset($newData['attribute_code']); unset($newData['entity_type_id']); @@ -81,7 +87,7 @@ public function generateCode() //get text for script $arrayCode = var_export($newData, true); - //generate script using simpnle string concatenation, making + //generate script using simple string concatenation, making //a single tear fall down the cheek of a CS professor $script = " */ - public function getWarnings(); + public function getWarnings(): array; /** * @return string */ - public function generateCode(); + public function generateCode(): string; } diff --git a/src/N98/Magento/Command/Developer/Setup/Script/Attribute/EntityType/Factory.php b/src/N98/Magento/Command/Developer/Setup/Script/Attribute/EntityType/Factory.php index 8c3ba2390..09761a53b 100644 --- a/src/N98/Magento/Command/Developer/Setup/Script/Attribute/EntityType/Factory.php +++ b/src/N98/Magento/Command/Developer/Setup/Script/Attribute/EntityType/Factory.php @@ -1,18 +1,22 @@ */ +class AttributeCommand extends AbstractCommand +{ + public const COMMAND_ARGUMENT_ENTITY_TYPE = 'entityType'; -namespace N98\Magento\Command\Developer\Setup\Script; + public const COMMAND_ARGUMENT_ATTRIBUTE_CODE = 'attributeCode'; -use Exception; -use N98\Magento\Command\AbstractCommand; -use N98\Magento\Command\Developer\Setup\Script\Attribute\EntityType\Factory; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; + /** + * @var string + */ + protected static $defaultName = 'dev:setup:script:attribute'; + + /** + * @var string + */ + protected static $defaultDescription = 'Creates attribute script for a given attribute code.'; -class AttributeCommand extends AbstractCommand -{ protected function configure(): void { $this - ->setName('dev:setup:script:attribute') - ->addArgument('entityType', InputArgument::REQUIRED, 'Entity Type Code like catalog_product') - ->addArgument('attributeCode', InputArgument::REQUIRED, 'Attribute Code') - ->setDescription('Creates attribute script for a given attribute code'); + ->addArgument( + self::COMMAND_ARGUMENT_ENTITY_TYPE, + InputArgument::REQUIRED, + 'Entity Type Code like catalog_product' + ) + ->addArgument( + self::COMMAND_ARGUMENT_ATTRIBUTE_CODE, + InputArgument::REQUIRED, + 'Attribute Code' + ) + ; } /** * @param InputInterface $input * @param OutputInterface $output - * * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output, true); - $this->initMagento(); - try { - $entityType = $input->getArgument('entityType'); - $attributeCode = $input->getArgument('attributeCode'); - + /** @var string $entityType */ + $entityType = $input->getArgument(self::COMMAND_ARGUMENT_ENTITY_TYPE); + /** @var string $attributeCode */ + $attributeCode = $input->getArgument(self::COMMAND_ARGUMENT_ATTRIBUTE_CODE); + /** @var string $attribute */ $attribute = $this->getAttribute($entityType, $attributeCode); + /** @var EntityType $generator */ $generator = Factory::create($entityType, $attribute); $generator->setReadConnection( - $this->_getModel('core/resource')->getConnection('core_read') + Mage::getModel('core/resource')->getConnection('core_read') ); $code = $generator->generateCode(); $warnings = $generator->getWarnings(); @@ -60,18 +87,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int } catch (Exception $e) { $output->writeln('' . $e->getMessage() . ''); } - return 0; + + return Command::SUCCESS; } /** * @param string $entityType * @param string $attributeCode * @return mixed + * @throws Mage_Core_Exception */ protected function getAttribute(string $entityType, string $attributeCode) { - return $this - ->_getModel('catalog/resource_eav_attribute') + return Mage::getModel('catalog/resource_eav_attribute') ->loadByCode($entityType, $attributeCode); } } From 493ed2d6e11938c7d45860f8f70a0c3660e94a78 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 27 Jun 2024 00:20:51 +0200 Subject: [PATCH 131/136] [skip ci] Updated customer:create:dummy command --- .../Command/Customer/CreateDummyCommand.php | 100 ++++++++++++------ 1 file changed, 69 insertions(+), 31 deletions(-) diff --git a/src/N98/Magento/Command/Customer/CreateDummyCommand.php b/src/N98/Magento/Command/Customer/CreateDummyCommand.php index f17bc5dfb..2b6b0a2c8 100644 --- a/src/N98/Magento/Command/Customer/CreateDummyCommand.php +++ b/src/N98/Magento/Command/Customer/CreateDummyCommand.php @@ -5,9 +5,11 @@ namespace N98\Magento\Command\Customer; use Faker\Factory; -use Locale; -use N98\Util\Console\Helper\Table\Renderer\RendererFactory; +use Faker\Generator; +use Mage_Core_Model_Website; +use Mage_Customer_Model_Address; use N98\Util\Faker\Provider\Internet; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -20,9 +22,56 @@ */ class CreateDummyCommand extends AbstractCustomerCommand { + public const COMMAND_ARGUMENT_COUNT = 'count'; + + public const COMMAND_ARGUMENT_LOCALE = 'locale'; + + public const COMMAND_OPTION_WITH_ADDRESSES = 'with-addresses'; + + /** + * @var string + */ + protected static $defaultName = 'customer:create:dummy'; + + /** + * @var string + */ + protected static $defaultDescription = 'Generate dummy customers. You can specify a count and a locale.'; + protected function configure(): void { - $help = <<addArgument( + self::COMMAND_ARGUMENT_COUNT, + InputArgument::REQUIRED, + 'Count' + ) + ->addArgument( + self::COMMAND_ARGUMENT_LOCALE, + InputArgument::REQUIRED, + 'Locale' + ) + ->addArgument( + self::COMMAND_ARGUMENT_WEBSITE, + InputArgument::OPTIONAL, + 'Website' + ) + ->addOption( + self::COMMAND_OPTION_WITH_ADDRESSES, + null, + InputOption::VALUE_NONE, + 'Create dummy billing/shipping addresses for each customers' + ) + ->addFormatOption() + ; + } + + /** + * @return string + */ + public function getHelp(): string + { + return <<setName('customer:create:dummy') - ->addArgument('count', InputArgument::REQUIRED, 'Count') - ->addArgument('locale', InputArgument::REQUIRED, Locale::class) - ->addArgument('website', InputArgument::OPTIONAL, 'Website') - ->addOption( - 'with-addresses', - null, - InputOption::VALUE_NONE, - 'Create dummy billing/shipping addresses for each customers' - ) - ->setDescription('Generate dummy customers. You can specify a count and a locale.') - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' - ) - ->setHelp($help) - ; } /** @@ -74,16 +102,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int { $res = $this->getCustomerModel()->getResource(); - $faker = Factory::create($input->getArgument('locale')); + /** @var string $locale */ + $locale = $input->getArgument(self::COMMAND_ARGUMENT_LOCALE); + $faker = Factory::create($locale); $faker->addProvider(new Internet($faker)); $parameterHelper = $this->getParameterHelper(); + /** @var Mage_Core_Model_Website $website */ $website = $parameterHelper->askWebsite($input, $output); $res->beginTransaction(); - $count = $input->getArgument('count'); - $outputPlain = $input->getOption('format') === null; + $count = $input->getArgument(self::COMMAND_ARGUMENT_COUNT); + $outputPlain = $input->getOption(self::COMMAND_OPTION_FORMAT) === null; $table = []; for ($i = 0; $i < $count; $i++) { @@ -102,7 +133,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $customer->setLastname($faker->lastName); $customer->setPassword($password); - if ($input->hasOption('with-addresses')) { + if ($input->hasOption(self::COMMAND_OPTION_WITH_ADDRESSES)) { $address = $this->createAddress($faker); $customer->addAddress($address); } @@ -132,15 +163,22 @@ protected function execute(InputInterface $input, OutputInterface $output): int $res->commit(); if (!$outputPlain) { + /** @var string $format */ + $format = $input->getOption(self::COMMAND_OPTION_FORMAT); $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['email', 'password', 'firstname', 'lastname']) - ->renderByFormat($output, $table, $input->getOption('format')); + ->renderByFormat($output, $table, $format); } - return 0; + + return Command::SUCCESS; } - private function createAddress($faker) + /** + * @param Generator $faker + * @return Mage_Customer_Model_Address + */ + private function createAddress($faker): Mage_Customer_Model_Address { $country = $this->getCountryCollection() ->addCountryCodeFilter($faker->countryCode, 'iso2') From c2d668224d3fe3540136e03d737c3a282fdb9097 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 27 Jun 2024 20:33:13 +0200 Subject: [PATCH 132/136] [skip ci] Updated 'dev:module:dependencies:... commands --- .../AbstractDependenciesCommand.php | 101 +++++++++---- .../Module/Dependencies/FromCommand.php | 39 ++--- .../Module/Dependencies/OnCommand.php | 138 +++++------------- 3 files changed, 136 insertions(+), 142 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Module/Dependencies/AbstractDependenciesCommand.php b/src/N98/Magento/Command/Developer/Module/Dependencies/AbstractDependenciesCommand.php index 7b234b19f..fb863bc5d 100644 --- a/src/N98/Magento/Command/Developer/Module/Dependencies/AbstractDependenciesCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Dependencies/AbstractDependenciesCommand.php @@ -1,33 +1,41 @@ |string>> */ protected array $modules; @@ -36,50 +44,91 @@ abstract class AbstractDependenciesCommand extends AbstractCommand */ protected function configure(): void { - $this->setName(static::COMMAND_NAME) - ->addArgument('moduleName', InputArgument::REQUIRED, 'Module to show dependencies') - ->addOption('all', 'a', InputOption::VALUE_NONE, 'Show all dependencies (dependencies of dependencies)') - ->setDescription(static::COMMAND_DESCRIPTION) + $this + ->addArgument( + self::COMMAND_ARGUMENT_MODULE_NAME, + InputArgument::REQUIRED, + 'Module to show dependencies' + ) ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' + self::COMMAND_OPTION_ALL, + 'a', + InputOption::VALUE_NONE, + 'Show all dependencies (dependencies of dependencies)' ) + ->addFormatOption() ; } /** * @param InputInterface $input * @param OutputInterface $output - * + * @return void + */ + public function initialize(InputInterface $input, OutputInterface $output): void + { + parent::initialize($input, $output); + + $modules = $this->_getMageConfigNode('modules')->asArray(); + ksort($modules); + + $this->modules = $modules; + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return void + */ + public function interact(InputInterface $input,OutputInterface $output): void + { + $moduleName = $input->getArgument(static::COMMAND_ARGUMENT_MODULE_NAME); + + if (is_null($moduleName)) { + $dialog = $this->getQuestionHelper(); + $question = new ChoiceQuestion('Please select a Module: ', array_keys($this->modules)); + $moduleName = $dialog->ask($input, $output, $question); + } + $input->setArgument(static::COMMAND_ARGUMENT_MODULE_NAME, $moduleName); + } + + /** + * @param InputInterface $input + * @param OutputInterface $output * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int { - $moduleName = $input->getArgument('moduleName'); - $recursive = $input->getOption('all'); - if ($input->getOption('format') === null) { + /** @var string $moduleName */ + $moduleName = $input->getArgument(static::COMMAND_ARGUMENT_MODULE_NAME); + /** @var bool $recursive */ + $recursive = $input->getOption(static::COMMAND_OPTION_ALL); + + if ($input->getOption(static::COMMAND_OPTION_FORMAT) === null) { $this->writeSection($output, sprintf(static::COMMAND_SECTION_TITLE_TEXT, $moduleName)); } - $this->detectMagento($output, true); - $this->initMagento(); try { $dependencies = $this->findModuleDependencies($moduleName, $recursive); if (!empty($dependencies)) { usort($dependencies, [$this, 'sortDependencies']); + /** @var string|null $format */ + $format = $input->getOption(static::COMMAND_OPTION_FORMAT); $tableHelper = $this->getTableHelper(); $tableHelper ->setHeaders(['Name', 'Status', 'Current installed version', 'Code pool']) - ->renderByFormat($output, $dependencies, $input->getOption('format')); + ->renderByFormat($output, $dependencies, $format); } else { - $output->writeln(sprintf(static::COMMAND_NO_RESULTS_TEXT, $moduleName)); + if ($input->getOption(static::COMMAND_OPTION_FORMAT) === null) { + $output->writeln(sprintf(static::COMMAND_NO_RESULTS_TEXT, $moduleName)); + } + } } catch (Exception $e) { $output->writeln($e->getMessage()); } - return 0; + + return Command::SUCCESS; } /** @@ -89,17 +138,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int * * @param string $moduleName * @param bool $recursive [optional] - * - * @return array - * @throws InvalidArgumentException of module-name is not found + * @return array> */ abstract protected function findModuleDependencies(string $moduleName, bool $recursive = false): array; /** * Sort dependencies list by module name ascending * - * @param array $a - * @param array $b + * @param string[] $a + * @param string[] $b * @return int */ private function sortDependencies(array $a, array $b) diff --git a/src/N98/Magento/Command/Developer/Module/Dependencies/FromCommand.php b/src/N98/Magento/Command/Developer/Module/Dependencies/FromCommand.php index 1a0d6c182..c6d39e966 100644 --- a/src/N98/Magento/Command/Developer/Module/Dependencies/FromCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Dependencies/FromCommand.php @@ -1,37 +1,37 @@ modules === null) { - $this->modules = Mage::app()->getConfig()->getNode('modules')->asArray(); - } - if (!isset($this->modules[$moduleName])) { - throw new InvalidArgumentException(sprintf("Module %s was not found", $moduleName)); + throw new InvalidArgumentException(sprintf('Module %s was not found', $moduleName)); } $dependencies = []; @@ -40,7 +40,12 @@ protected function findModuleDependencies($moduleName, $recursive = false): arra continue; } - $dependencies[$dependencyName] = [$dependencyName, isset($module['active']) ? $this->formatActive($module['active']) : '-', $module['version'] ?? '-', $module['codePool'] ?? '-']; + $dependencies[$dependencyName] = [ + $dependencyName, + isset($module['active']) && is_string($module['active']) ? $this->formatActive($module['active']) : '-', + $module['version'] ?? '-', + $module['codePool'] ?? '-' + ]; if ($recursive) { $dependencies = array_merge( diff --git a/src/N98/Magento/Command/Developer/Module/Dependencies/OnCommand.php b/src/N98/Magento/Command/Developer/Module/Dependencies/OnCommand.php index 016d77f7f..29a17462b 100644 --- a/src/N98/Magento/Command/Developer/Module/Dependencies/OnCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Dependencies/OnCommand.php @@ -1,127 +1,69 @@ setName('dev:module:dependencies:on') - ->addArgument('moduleName', InputArgument::REQUIRED, 'Module to show dependencies') - ->addOption('all', 'a', InputOption::VALUE_NONE, 'Show all dependencies (dependencies of dependencies)') - ->setDescription('Show list of modules which given module depends on') - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' - ) - ; - } + public const COMMAND_SECTION_TITLE_TEXT = 'List of module %s dependencies'; /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int + * @var string */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $moduleName = $input->getArgument('moduleName'); - $recursive = $input->getOption('all'); + protected static $defaultName = 'dev:module:dependencies:on'; - if ($input->getOption('format') === null) { - $this->writeSection($output, sprintf('List of module %s dependencies', $moduleName)); - } - - $this->detectMagento($output, true); - $this->initMagento(); - - try { - $dependencies = $this->findModuleDependencies($moduleName, $recursive); - if (!empty($dependencies)) { - usort($dependencies, [$this, 'sortDependencies']); - } else { - $dependencies = []; - } - if ($input->getOption('format') === null && count($dependencies) === 0) { - $output->writeln(sprintf("Module %s doesn't have dependencies", $moduleName)); - } else { - $tableHelper = $this->getTableHelper(); - $tableHelper - ->setHeaders(['Name', 'Status', 'Current installed version', 'Code pool']) - ->renderByFormat($output, $dependencies, $input->getOption('format')); - } - } catch (Exception $e) { - $output->writeln($e->getMessage()); - } - return 0; - } + /** + * @var string + */ + protected static $defaultDescription = 'Show list of modules which given module depends on.'; /** * Find dependencies of given module $moduleName. * If $recursive = true, dependencies will be collected recursively for all module dependencies * - * @param string $moduleName - * @param bool $recursive - * @return array - * @throws InvalidArgumentException + * @inheritdoc */ protected function findModuleDependencies(string $moduleName, bool $recursive = false): array { - if ($this->modules === null) { - $this->modules = Mage::app()->getConfig()->getNode('modules')->asArray(); + if (!isset($this->modules[$moduleName])) { + throw new InvalidArgumentException(sprintf("Module %s was not found", $moduleName)); } - if (isset($this->modules[$moduleName])) { - $dependencies = []; - $module = $this->modules[$moduleName]; - if (isset($module['depends']) && is_array($module['depends']) && count($module['depends']) > 0) { - foreach (array_keys($module['depends']) as $dependencyName) { - if (isset($this->modules[$dependencyName])) { - $dependencies[] = [$dependencyName, isset($this->modules[$dependencyName]['active']) - ? $this->formatActive($this->modules[$dependencyName]['active']) - : '-', $this->modules[$dependencyName]['version'] - ?? '-', $this->modules[$dependencyName]['codePool'] - ?? '-' - ]; - if ($recursive) { - $dependencies = array_merge( - $dependencies, - $this->findModuleDependencies($dependencyName, $recursive) - ); - } - } else { - $dependencies[] = [$dependencyName, 'Not installed', '-', '-']; + $dependencies = []; + $module = $this->modules[$moduleName]; + if (isset($module['depends']) && is_array($module['depends']) && count($module['depends']) > 0) { + foreach (array_keys($module['depends']) as $dependencyName) { + if (isset($this->modules[$dependencyName])) { + $dependencies[] = [ + $dependencyName, + isset($this->modules[$dependencyName]['active']) && is_string($this->modules[$dependencyName]['active']) + ? $this->formatActive($this->modules[$dependencyName]['active']) : '-', + $this->modules[$dependencyName]['version'] ?? '-', + $this->modules[$dependencyName]['codePool'] ?? '-' + ]; + if ($recursive) { + $dependencies = array_merge( + $dependencies, + $this->findModuleDependencies($dependencyName, $recursive) + ); } + } else { + $dependencies[] = [ + $dependencyName, + 'Not installed', + '-', + '-' + ]; } } - - return $dependencies; - } else { - throw new InvalidArgumentException(sprintf("Module %s was not found", $moduleName)); } - } - /** - * Sort dependencies list by module name ascending - * - * @param array $a - * @param array $b - * @return int - */ - private function sortDependencies(array $a, array $b): int - { - return strcmp($a[0], $b[0]); + return $dependencies; } } From be57aba965cb4d14f7ac7e616d9faf51b0dccdb7 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 27 Jun 2024 23:04:20 +0200 Subject: [PATCH 133/136] [skip ci] Updated dev:module:update command --- .../Developer/Module/CreateCommand.php | 89 ++-- .../Developer/Module/UpdateCommand.php | 402 +++++++++++------- 2 files changed, 319 insertions(+), 172 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Module/CreateCommand.php b/src/N98/Magento/Command/Developer/Module/CreateCommand.php index f3bd1831b..fd0949d56 100644 --- a/src/N98/Magento/Command/Developer/Module/CreateCommand.php +++ b/src/N98/Magento/Command/Developer/Module/CreateCommand.php @@ -4,7 +4,6 @@ namespace N98\Magento\Command\Developer\Module; -use InvalidArgumentException; use N98\Magento\Command\AbstractCommand; use RuntimeException; use Symfony\Component\Console\Command\Command; @@ -69,7 +68,7 @@ class CreateCommand extends AbstractCommand protected static bool $detectMagentoFlag = false; /** - * @var array + * @var array */ protected array $twigVars = []; @@ -210,8 +209,29 @@ protected function configure(): void ; } - public function interact(InputInterface $input, OutputInterface $output) + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return void + */ + public function interact(InputInterface $input, OutputInterface $output): void { + /** @var bool $modman */ + $modman = $input->getOption(self::COMMAND_OPTION_MODMAN); + $this->modmanMode = $modman; + if ($input->getOption(self::COMMAND_OPTION_ADD_ALL)) { + $input->setOption(self::COMMAND_OPTION_ADD_CONTROLLER, true); + $input->setOption(self::COMMAND_OPTION_ADD_BLOCKS, true); + $input->setOption(self::COMMAND_OPTION_ADD_HELPERS, true); + $input->setOption(self::COMMAND_OPTION_ADD_MODELS, true); + $input->setOption(self::COMMAND_OPTION_ADD_SETUP, true); + $input->setOption(self::COMMAND_OPTION_ADD_README, true); + $input->setOption(self::COMMAND_OPTION_ADD_COMPOSER, true); + } + if (!$this->modmanMode) { + $this->detectMagento($output); + } + $parameterHelper = $this->getParameterHelper(); // Vendor @@ -234,24 +254,18 @@ public function interact(InputInterface $input, OutputInterface $output) */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->modmanMode = $input->getOption(self::COMMAND_OPTION_MODMAN); - if ($input->getOption(self::COMMAND_OPTION_ADD_ALL)) { - $input->setOption(self::COMMAND_OPTION_ADD_CONTROLLER, true); - $input->setOption(self::COMMAND_OPTION_ADD_BLOCKS, true); - $input->setOption(self::COMMAND_OPTION_ADD_HELPERS, true); - $input->setOption(self::COMMAND_OPTION_ADD_MODELS, true); - $input->setOption(self::COMMAND_OPTION_ADD_SETUP, true); - $input->setOption(self::COMMAND_OPTION_ADD_README, true); - $input->setOption(self::COMMAND_OPTION_ADD_COMPOSER, true); - } - if (!$this->modmanMode) { - $this->detectMagento($output); - } $this->baseFolder = __DIR__ . '/../../../../../../res/module/create'; - $this->vendorNamespace = $input->getArgument(self::COMMAND_ARGUMENT_VENDOR); - $this->moduleName = $input->getArgument(self::COMMAND_ARGUMENT_MODULE); - $this->codePool = $input->getArgument(self::COMMAND_ARGUMENT_CODEPOOL); + /** @var string $vendorNamespace */ + $vendorNamespace = $input->getArgument(self::COMMAND_ARGUMENT_VENDOR); + /** @var string $moduleName */ + $moduleName = $input->getArgument(self::COMMAND_ARGUMENT_CODEPOOL); + /** @var string $codePool */ + $codePool = $input->getArgument(self::COMMAND_ARGUMENT_CODEPOOL); + + $this->vendorNamespace = $vendorNamespace; + $this->moduleName = $moduleName; + $this->codePool = $codePool; $this->initView($input); $this->createModuleDirectories($input, $output); @@ -281,18 +295,35 @@ protected function execute(InputInterface $input, OutputInterface $output): int */ protected function initView(InputInterface $input): void { + /** @var bool|null $createControllers */ + $createControllers = $input->getOption(self::COMMAND_OPTION_ADD_CONTROLLER); + /** @var bool|null $createBlocks */ + $createBlocks = $input->getOption(self::COMMAND_OPTION_ADD_BLOCKS); + /** @var bool|null $createHelpers */ + $createHelpers = $input->getOption(self::COMMAND_OPTION_ADD_HELPERS); + /** @var bool|null $createModels */ + $createModels = $input->getOption(self::COMMAND_OPTION_ADD_MODELS); + /** @var bool|null $createSetup */ + $createSetup = $input->getOption(self::COMMAND_OPTION_ADD_SETUP); + /** @var string|null $authorName */ + $authorName = $input->getOption(self::COMMAND_OPTION_AUTHOR_NAME); + /** @var string|null $authorEmail */ + $authorEmail = $input->getOption(self::COMMAND_OPTION_AUTHOR_EMAIL); + /** @var string|null $description */ + $description = $input->getOption(self::COMMAND_OPTION_DESCRIPTION); + $this->twigVars = [ 'vendorNamespace' => $this->vendorNamespace, 'moduleName' => $this->moduleName, 'codePool' => $this->codePool, - 'createControllers' => $input->getOption(self::COMMAND_OPTION_ADD_CONTROLLER), - 'createBlocks' => $input->getOption(self::COMMAND_OPTION_ADD_BLOCKS), - 'createHelpers' => $input->getOption(self::COMMAND_OPTION_ADD_HELPERS), - 'createModels' => $input->getOption(self::COMMAND_OPTION_ADD_MODELS), - 'createSetup' => $input->getOption(self::COMMAND_OPTION_ADD_SETUP), - 'authorName' => $input->getOption(self::COMMAND_OPTION_AUTHOR_NAME), - 'authorEmail' => $input->getOption(self::COMMAND_OPTION_AUTHOR_EMAIL), - 'description' => $input->getOption(self::COMMAND_OPTION_DESCRIPTION) + 'createControllers' => $createControllers, + 'createBlocks' => $createBlocks, + 'createHelpers' => $createHelpers, + 'createModels' => $createModels, + 'createSetup' => $createSetup, + 'authorName' => $authorName, + 'authorEmail' => $authorEmail, + 'description' => $description ]; } @@ -434,6 +465,10 @@ protected function addAdditionalFiles(OutputInterface $output): void { $config = $this->getCommandConfig(); if (isset($config['additionalFiles']) && is_array($config['additionalFiles'])) { + /** + * @var string $template + * @var string $outFileTemplate + */ foreach ($config['additionalFiles'] as $template => $outFileTemplate) { $outFile = $this->getOutfile($outFileTemplate); $outFileDir = Path::getRoot($outFile); diff --git a/src/N98/Magento/Command/Developer/Module/UpdateCommand.php b/src/N98/Magento/Command/Developer/Module/UpdateCommand.php index 5439a50a7..954e744c6 100644 --- a/src/N98/Magento/Command/Developer/Module/UpdateCommand.php +++ b/src/N98/Magento/Command/Developer/Module/UpdateCommand.php @@ -1,13 +1,15 @@ testMode = $testMode; } /** - * @return boolean + * @return bool */ - public function getTestMode() + public function getTestMode(): bool { return $this->testMode; } - protected function configure() + protected function configure(): void { $this - ->setName('dev:module:update') - ->addArgument('vendorNamespace', InputArgument::REQUIRED, 'Namespace (your company prefix)') - ->addArgument('moduleName', InputArgument::REQUIRED, 'Name of your module.') - ->addOption('set-version', null, InputOption::VALUE_NONE, 'Set module version in config.xml') - ->addOption('add-blocks', null, InputOption::VALUE_NONE, 'Adds blocks class to config.xml') - ->addOption('add-helpers', null, InputOption::VALUE_NONE, 'Adds helpers class to config.xml') - ->addOption('add-models', null, InputOption::VALUE_NONE, 'Adds models class to config.xml') + ->addArgument( + self::COMMAND_ARGUMENT_VENDOR, + InputArgument::REQUIRED, + 'Namespace (your company prefix)' + ) + ->addArgument( + self::COMMAND_ARGUMENT_MODULE, + InputArgument::REQUIRED, + 'Name of your module.' + ) ->addOption( - 'add-all', + self::COMMAND_OPTION_SET_VERSION, + null, + InputOption::VALUE_NONE, + 'Set module version in config.xml' + ) + ->addOption( + self::COMMAND_OPTION_ADD_BLOCKS, + null, + InputOption::VALUE_NONE, + 'Adds blocks class to config.xml' + ) + ->addOption( + self::COMMAND_OPTION_ADD_HELPERS, + null, + InputOption::VALUE_NONE, + 'Adds helpers class to config.xml' + ) + ->addOption( + self::COMMAND_OPTION_ADD_MODELS, + null, + InputOption::VALUE_NONE, + 'Adds models class to config.xml' + ) + ->addOption( + self::COMMAND_OPTION_ADD_ALL, null, InputOption::VALUE_NONE, 'Adds blocks, helpers and models classes to config.xml' ) ->addOption( - 'add-resource-model', + self::COMMAND_OPTION_ADD_RESOURCE_MODEL, null, InputOption::VALUE_NONE, 'Adds resource model class and entities to config.xml' ) ->addOption( - 'add-routers', + self::COMMAND_OPTION_ADD_ROUTERS, null, InputOption::VALUE_NONE, 'Adds routers for frontend or admin areas to config.xml' ) ->addOption( - 'add-events', + self::COMMAND_OPTION_ADD_EVENTS, null, InputOption::VALUE_NONE, 'Adds events observer to global, frontend or adminhtml areas to config.xml' ) ->addOption( - 'add-layout-updates', + self::COMMAND_OPTION_ADD_LAYOUT_UPDATES, null, InputOption::VALUE_NONE, 'Adds layout updates to frontend or adminhtml areas to config.xml' ) ->addOption( - 'add-translate', + self::COMMAND_OPTION_ADD_TRANSLATE, null, InputOption::VALUE_NONE, 'Adds translate configuration to frontend or adminhtml areas to config.xml' ) ->addOption( - 'add-default', + self::COMMAND_OPTION_ADD_DEFAULT, null, InputOption::VALUE_NONE, 'Adds default value (related to system.xml groups/fields)' ) - ->setDescription('Update a Magento module.'); + ; } /** * @param InputInterface $input * @param OutputInterface $output - * * @return int + * @throws Exception */ protected function execute(InputInterface $input, OutputInterface $output): int { @@ -165,16 +233,22 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->setModuleDirectory($this->getModuleDir()); $this->writeModuleConfig($input, $output); - return 0; + + return Command::SUCCESS; } /** * @param InputInterface $input */ - protected function initArguments(InputInterface $input) + protected function initArguments(InputInterface $input): void { - $this->vendorNamespace = ucfirst($input->getArgument('vendorNamespace')); - $this->moduleName = ucfirst($input->getArgument('moduleName')); + /** @var string $vendorNamespace */ + $vendorNamespace = $input->getArgument(self::COMMAND_ARGUMENT_VENDOR); + /** @var string $moduleName */ + $moduleName = $input->getArgument(self::COMMAND_ARGUMENT_MODULE); + + $this->vendorNamespace = ucfirst($vendorNamespace); + $this->moduleName = ucfirst($moduleName); $this->determineModuleCodePool(); } @@ -183,7 +257,7 @@ protected function initArguments(InputInterface $input) * * @return string */ - protected function determineModuleCodePool() + protected function determineModuleCodePool(): string { if ($this->testMode === true) { $this->codePool = 'local'; @@ -212,7 +286,7 @@ protected function determineModuleCodePool() * @param string $moduleDir * @throws RuntimeException */ - protected function setModuleDirectory($moduleDir) + protected function setModuleDirectory(string $moduleDir): void { if (!file_exists($moduleDir)) { throw new RuntimeException( @@ -228,8 +302,9 @@ protected function setModuleDirectory($moduleDir) * * @param InputInterface $input * @param OutputInterface $output + * @throws Exception */ - protected function writeModuleConfig(InputInterface $input, OutputInterface $output) + protected function writeModuleConfig(InputInterface $input, OutputInterface $output): void { $configXml = $this->getConfigXml(); @@ -251,15 +326,16 @@ protected function writeModuleConfig(InputInterface $input, OutputInterface $out * @param OutputInterface $output * @param SimpleXMLElement $configXml */ - protected function setVersion(InputInterface $input, OutputInterface $output, \SimpleXMLElement $configXml) + protected function setVersion(InputInterface $input, OutputInterface $output, SimpleXMLElement $configXml): void { if ($this->shouldSetVersion($input)) { $modulesNode = $configXml->modules->{$this->getModuleNamespace()}; - /** @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new Question('Enter version number: '); - $version = trim($dialog->ask($input, $output, $question)); + /** @var string $version */ + $version = $dialog->ask($input, $output, $question); + $version = trim($version); $modulesNode->version = $version; } } @@ -271,7 +347,7 @@ protected function setVersion(InputInterface $input, OutputInterface $output, \S * @param OutputInterface $output * @param SimpleXMLElement $configXml */ - protected function setGlobalNode(InputInterface $input, OutputInterface $output, SimpleXMLElement $configXml) + protected function setGlobalNode(InputInterface $input, OutputInterface $output, SimpleXMLElement $configXml): void { if ($this->shouldAddAll($input)) { $this->addGlobalNode($configXml, 'blocks', '_Block'); @@ -299,10 +375,12 @@ protected function setGlobalNode(InputInterface $input, OutputInterface $output, * @param OutputInterface $output * @param SimpleXMLElement $configXml */ - protected function addResourceModelNodeIfConfirmed(InputInterface $input, OutputInterface $output, \SimpleXMLElement $configXml) - { - /** @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + protected function addResourceModelNodeIfConfirmed( + InputInterface $input, + OutputInterface $output, + SimpleXMLElement $configXml + ): void { + $dialog = $this->getQuestionHelper(); $question = new ConfirmationQuestion( 'Would you like to also add a Resource Model(y/n)?', @@ -311,7 +389,9 @@ protected function addResourceModelNodeIfConfirmed(InputInterface $input, Output if ($dialog->ask($input, $output, $question)) { $question = new Question('Resource Model: '); - $resourceModel = trim($dialog->ask($input, $output, $question)); + /** @var string $resourceModel */ + $resourceModel = $dialog->ask($input, $output, $question); + $resourceModel = trim($resourceModel); $configXml->global->models ->{$this->getLowercaseModuleNamespace()}->addChild('resourceModel', $resourceModel); } @@ -321,7 +401,7 @@ protected function addResourceModelNodeIfConfirmed(InputInterface $input, Output * @param InputInterface $input * @param SimpleXMLElement $configXml */ - protected function setResourceModelNode(InputInterface $input, \SimpleXMLElement $configXml) + protected function setResourceModelNode(InputInterface $input, SimpleXMLElement $configXml): void { if ($this->hasAddResourceModelOption($input)) { $this->addResourceModel($configXml); @@ -332,7 +412,7 @@ protected function setResourceModelNode(InputInterface $input, \SimpleXMLElement * @param InputInterface $input * @param SimpleXMLElement $configXml */ - protected function setRoutersNode(InputInterface $input, \SimpleXMLElement $configXml) + protected function setRoutersNode(InputInterface $input, SimpleXMLElement $configXml): void { if ($this->hasAddRoutersOption($input)) { $this->addRouter($configXml, $this->configNodes['router_area']); @@ -343,7 +423,7 @@ protected function setRoutersNode(InputInterface $input, \SimpleXMLElement $conf * @param InputInterface $input * @param SimpleXMLElement $configXml */ - protected function setEventsNode(InputInterface $input, \SimpleXMLElement $configXml) + protected function setEventsNode(InputInterface $input, SimpleXMLElement $configXml): void { if ($this->hasAddEventsOption($input)) { $this->addEvent($configXml, $this->configNodes['events_area'], $this->configNodes['event_name']); @@ -354,7 +434,7 @@ protected function setEventsNode(InputInterface $input, \SimpleXMLElement $confi * @param InputInterface $input * @param SimpleXMLElement $configXml */ - protected function setLayoutUpdatesNode(InputInterface $input, \SimpleXMLElement $configXml) + protected function setLayoutUpdatesNode(InputInterface $input, SimpleXMLElement $configXml): void { if ($this->hasAddLayoutUpdatesOptions($input)) { $this->addLayoutUpdate( @@ -369,7 +449,7 @@ protected function setLayoutUpdatesNode(InputInterface $input, \SimpleXMLElement * @param InputInterface $input * @param SimpleXMLElement $configXml */ - protected function setTranslateNode(InputInterface $input, \SimpleXMLElement $configXml) + protected function setTranslateNode(InputInterface $input, SimpleXMLElement $configXml): void { if ($this->hasAddTranslateOption($input)) { $this->addTranslate( @@ -384,7 +464,7 @@ protected function setTranslateNode(InputInterface $input, \SimpleXMLElement $co * @param InputInterface $input * @param SimpleXMLElement $configXml */ - protected function setDefaultNode(InputInterface $input, \SimpleXMLElement $configXml) + protected function setDefaultNode(InputInterface $input, SimpleXMLElement $configXml): void { if ($this->hasAddDefaultOption($input)) { $this->addDefault($configXml); @@ -395,19 +475,19 @@ protected function setDefaultNode(InputInterface $input, \SimpleXMLElement $conf * Gets config XML * * @return SimpleXMLElement + * @throws Exception */ - protected function getConfigXml() + protected function getConfigXml(): SimpleXMLElement { + /** @var string $currentConfigXml */ $currentConfigXml = $this->getCurrentConfigContent(); - $simpleXml = new \SimpleXMLElement($currentConfigXml); - - return $simpleXml; + return new SimpleXMLElement($currentConfigXml); } /** * Returns current content of /etc/config.xml * - * @return string + * @return string|false */ protected function getCurrentConfigContent() { @@ -419,15 +499,15 @@ protected function getCurrentConfigContent() /** * @return string */ - protected function getModuleDir() + protected function getModuleDir(): string { - return $this->moduleDirectory ?? Mage::getModuleDir(false, $this->getModuleNamespace()); + return $this->moduleDirectory ?? Mage::getModuleDir('', $this->getModuleNamespace()); } /** * Initiates resource nodes specific values */ - protected function initResourceModelConfigNodes() + protected function initResourceModelConfigNodes(): void { $this->configNodes['resource_node_name'] = $this->getLowercaseModuleNamespace() . '_resource'; $this->configNodes['resource_model_class'] = $this->getModuleNamespace() . '_Model_Resource'; @@ -438,7 +518,7 @@ protected function initResourceModelConfigNodes() /** * Initiates routers config nodes specific values */ - protected function initRoutersConfigNodes() + protected function initRoutersConfigNodes(): void { $this->configNodes['router_area'] = false; $this->configNodes['use'] = false; @@ -448,7 +528,7 @@ protected function initRoutersConfigNodes() /** * Initiates events config nodes specific values */ - protected function initEventsConfigNodes() + protected function initEventsConfigNodes(): void { $this->configNodes['events_area'] = false; $this->configNodes['event_name'] = false; @@ -460,7 +540,7 @@ protected function initEventsConfigNodes() /** * Initiates layout updates nodes specific values */ - protected function initLayoutUpdatesConfigNodes() + protected function initLayoutUpdatesConfigNodes(): void { $this->configNodes['layout_updates_area'] = false; $this->configNodes['layout_update_module'] = false; @@ -470,7 +550,7 @@ protected function initLayoutUpdatesConfigNodes() /** * Initiates layout updates nodes specific values */ - protected function initTranslateConfigNodes() + protected function initTranslateConfigNodes(): void { $this->configNodes['translate_area'] = false; $this->configNodes['translate_module'] = $this->getModuleNamespace(); @@ -480,7 +560,7 @@ protected function initTranslateConfigNodes() /** * Initiates resource nodes specific values */ - protected function initDefaultConfigNodes() + protected function initDefaultConfigNodes(): void { $this->configNodes['default_section_name'] = false; $this->configNodes['default_group_name'] = false; @@ -495,12 +575,11 @@ protected function initDefaultConfigNodes() * @param OutputInterface $output * @throws RuntimeException */ - protected function askResourceModelOptions(InputInterface $input, OutputInterface $output) + protected function askResourceModelOptions(InputInterface $input, OutputInterface $output): void { $this->initResourceModelConfigNodes(); - /** @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new ConfirmationQuestion( 'Would you like to set mysql4 deprecated node(y/n)?', @@ -514,13 +593,17 @@ protected function askResourceModelOptions(InputInterface $input, OutputInterfac while ($entityName) { $question = new Question('Entity Name (leave blank to exit): '); - $entityName = trim($dialog->ask($input, $output, $question)); + /** @var string $entityName */ + $entityName = $dialog->ask($input, $output, $question); + $entityName = trim($entityName); if (!$entityName) { break; } $question = new Question('Entity Table: '); - $entityTable = trim($dialog->ask($input, $output, $question)); + /** @var string $entityTable */ + $entityTable = $dialog->ask($input, $output, $question); + $entityTable = trim($entityTable); $this->configNodes['resource_entities'][$entityName] = $entityTable; } } @@ -532,24 +615,29 @@ protected function askResourceModelOptions(InputInterface $input, OutputInterfac * @param OutputInterface $output * @throws RuntimeException */ - protected function askRoutersOptions(InputInterface $input, OutputInterface $output) + protected function askRoutersOptions(InputInterface $input, OutputInterface $output): void { $this->initRoutersConfigNodes(); - /** @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new ChoiceQuestion( 'Area (frontend|admin): ', ['frontend', 'admin'] ); - $area = trim($dialog->ask($input, $output, $question)); + /** @var string $area */ + $area = $dialog->ask($input, $output, $question); + $area = trim($area); $question = new Question('Use: '); - $use = trim($dialog->ask($input, $output, $question)); + /** @var string $use */ + $use = $dialog->ask($input, $output, $question); + $use = trim($use); $question = new Question('Frontname: '); - $frontName = trim($dialog->ask($input, $output, $question)); + /** @var string $frontName */ + $frontName = $dialog->ask($input, $output, $question); + $frontName = trim($frontName); if ($area != 'frontend' && $area != 'admin') { throw new RuntimeException('Router area must be either "frontend" or "admin"'); @@ -567,30 +655,39 @@ protected function askRoutersOptions(InputInterface $input, OutputInterface $out * @param OutputInterface $output * @throws RuntimeException */ - protected function askEventsOptions(InputInterface $input, OutputInterface $output) + protected function askEventsOptions(InputInterface $input, OutputInterface $output): void { $this->initEventsConfigNodes(); - /** @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new ChoiceQuestion( 'Area (global|frontend|adminhtml): ', ['global', 'frontend', 'admin'] ); - $area = trim($dialog->ask($input, $output, $question)); + /** @var string $area */ + $area = $dialog->ask($input, $output, $question); + $area = trim($area); $question = new Question('Event: '); - $event = trim($dialog->ask($input, $output, $question)); + /** @var string $event */ + $event = $dialog->ask($input, $output, $question); + $event = trim($event); $question = new Question('Event Observer: '); - $observer = trim($dialog->ask($input, $output, $question)); + /** @var string $observer */ + $observer = $dialog->ask($input, $output, $question); + $observer = trim($observer); $question = new Question('Event Observer Class: '); - $observerClass = trim($dialog->ask($input, $output, $question)); + /** @var string $observerClass */ + $observerClass = $dialog->ask($input, $output, $question); + $observerClass = trim($observerClass); $question = new Question('Event Observer Method: '); - $observerMethod = trim($dialog->ask($input, $output, $question)); + /** @var string $observerMethod */ + $observerMethod = $dialog->ask($input, $output, $question); + $observerMethod = trim($observerMethod); if ($area != 'global' && $area != 'frontend' && $area != 'adminhtml') { throw new RuntimeException('Event area must be either "global", "frontend" or "adminhtml"'); @@ -610,24 +707,29 @@ protected function askEventsOptions(InputInterface $input, OutputInterface $outp * @param OutputInterface $output * @throws RuntimeException */ - protected function askLayoutUpdatesOptions(InputInterface $input, OutputInterface $output) + protected function askLayoutUpdatesOptions(InputInterface $input, OutputInterface $output): void { $this->initLayoutUpdatesConfigNodes(); - /** @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new ChoiceQuestion( 'Area (frontend|admin): ', ['frontend', 'admin'] ); - $area = trim($dialog->ask($input, $output, $question)); + /** @var string $area */ + $area = $dialog->ask($input, $output, $question); + $area = trim($area); $question = new Question('Module: '); - $module = trim($dialog->ask($input, $output, $question)); + /** @var string $module */ + $module = $dialog->ask($input, $output, $question); + $module = trim($module); $question = new Question('File: '); - $file = trim($dialog->ask($input, $output, $question)); + /** @var string $file */ + $file = $dialog->ask($input, $output, $question); + $file = trim($file); if ($area != 'frontend' && $area != 'adminhtml') { throw new RuntimeException('Layout updates area must be either "frontend" or "adminhtml"'); @@ -645,21 +747,24 @@ protected function askLayoutUpdatesOptions(InputInterface $input, OutputInterfac * @param OutputInterface $output * @throws RuntimeException */ - protected function askTranslateOptions(InputInterface $input, OutputInterface $output) + protected function askTranslateOptions(InputInterface $input, OutputInterface $output): void { $this->initTranslateConfigNodes(); - /** @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new ChoiceQuestion( 'Area (frontend|admin): ', ['frontend', 'admin'] ); - $area = trim($dialog->ask($input, $output, $question)); + /** @var string $area */ + $area = $dialog->ask($input, $output, $question); + $area = trim($area); $question = new Question('File: '); - $file = trim($dialog->ask($input, $output, $question)); + /** @var string $file */ + $file = $dialog->ask($input, $output, $question); + $file = trim($file); if ($area != 'frontend' && $area != 'adminhtml') { throw new RuntimeException('Layout updates area must be either "frontend" or "adminhtml"'); @@ -672,27 +777,34 @@ protected function askTranslateOptions(InputInterface $input, OutputInterface $o /** * Asks for default node options * + * @param InputInterface $input * @param OutputInterface $output - * @throws RuntimeException */ - protected function askDefaultOptions(InputInterface $input, OutputInterface $output) + protected function askDefaultOptions(InputInterface $input, OutputInterface $output): void { $this->initDefaultConfigNodes(); - /** @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); + $dialog = $this->getQuestionHelper(); $question = new Question('Section Name (lowercase): '); - $sectionName = strtolower(trim($dialog->ask($input, $output, $question))); + /** @var string $sectionName */ + $sectionName = $dialog->ask($input, $output, $question); + $sectionName = strtolower(trim($sectionName)); $question = new Question('Group Name (lowercase): '); - $groupName = strtolower(trim($dialog->ask($input, $output, $question))); + /** @var string $groupName */ + $groupName = $dialog->ask($input, $output, $question); + $groupName = strtolower(trim($groupName)); $question = new Question('Field Name: '); - $fieldName = strtolower(trim($dialog->ask($input, $output, $question))); + /** @var string $fieldName */ + $fieldName = $dialog->ask($input, $output, $question); + $fieldName = strtolower(trim($fieldName)); $question = new Question('Field Value: '); - $fieldValue = strtolower(trim($dialog->ask($input, $output, $question))); + /** @var string $fieldValue */ + $fieldValue = $dialog->ask($input, $output, $question); + $fieldValue = strtolower(trim($fieldValue)); $this->configNodes['default_section_name'] = $sectionName; $this->configNodes['default_group_name'] = $groupName; @@ -705,7 +817,7 @@ protected function askDefaultOptions(InputInterface $input, OutputInterface $out * @param string $type e.g. "blocks" * @param string $classSuffix e.g. "_Block" */ - protected function addGlobalNode(\SimpleXMLElement $configXml, $type, $classSuffix) + protected function addGlobalNode(SimpleXMLElement $configXml, string $type, string $classSuffix): void { $this->removeChildNodeIfNotNull($configXml->global, $type); $global = $configXml->global ?: $configXml->addChild('global'); @@ -717,7 +829,7 @@ protected function addGlobalNode(\SimpleXMLElement $configXml, $type, $classSuff /** * @param SimpleXMLElement $simpleXml */ - protected function addResourceModel(\SimpleXMLElement $simpleXml) + protected function addResourceModel(SimpleXMLElement $simpleXml): void { if (is_null($simpleXml->global->models)) { throw new RuntimeException( @@ -751,9 +863,9 @@ protected function addResourceModel(\SimpleXMLElement $simpleXml) /** * @param SimpleXMLElement $simpleXml - * @param $area + * @param string $area */ - protected function addRouter(\SimpleXMLElement $simpleXml, $area) + protected function addRouter(SimpleXMLElement $simpleXml, string $area): void { $this->removeChildNodeIfNotNull($simpleXml->{$area}, 'routers'); $areaNode = $simpleXml->{$area} ?: $simpleXml->addChild($area); @@ -767,10 +879,10 @@ protected function addRouter(\SimpleXMLElement $simpleXml, $area) /** * @param SimpleXMLElement $simpleXml - * @param $area - * @param $event + * @param string $area + * @param string $event */ - protected function addEvent(\SimpleXMLElement $simpleXml, $area, $event) + protected function addEvent(SimpleXMLElement $simpleXml, string $area, string $event): void { $areaNode = $simpleXml->{$area} ?: $simpleXml->addChild($area); $eventsNode = $areaNode->events ?: $areaNode->addChild('events'); @@ -784,10 +896,10 @@ protected function addEvent(\SimpleXMLElement $simpleXml, $area, $event) /** * @param SimpleXMLElement $simpleXml - * @param $area - * @param $module + * @param string $area + * @param string $module */ - protected function addLayoutUpdate(\SimpleXMLElement $simpleXml, $area, $module) + protected function addLayoutUpdate(SimpleXMLElement $simpleXml, string $area, string $module): void { $areaNode = $simpleXml->{$area} ?: $simpleXml->addChild($area); $layoutNode = $areaNode->layout ?: $areaNode->addChild('layout'); @@ -799,10 +911,10 @@ protected function addLayoutUpdate(\SimpleXMLElement $simpleXml, $area, $module) /** * @param SimpleXMLElement $simpleXml - * @param $area - * @param $module + * @param string $area + * @param string $module */ - protected function addTranslate(\SimpleXMLElement $simpleXml, $area, $module) + protected function addTranslate(SimpleXMLElement $simpleXml, string $area, string $module): void { $areaNode = $simpleXml->{$area} ?: $simpleXml->addChild($area); $translateNode = $areaNode->translate ?: $areaNode->addChild('translate'); @@ -816,7 +928,7 @@ protected function addTranslate(\SimpleXMLElement $simpleXml, $area, $module) /** * @param SimpleXMLElement $simpleXml */ - protected function addDefault(\SimpleXMLElement $simpleXml) + protected function addDefault(SimpleXMLElement $simpleXml): void { $defaultNode = $simpleXml->default ?: $simpleXml->addChild('default'); $sectionNode = $defaultNode->{$this->configNodes['default_section_name']} ?: $defaultNode->addChild($this->configNodes['default_section_name']); @@ -828,7 +940,7 @@ protected function addDefault(\SimpleXMLElement $simpleXml) /** * @return string */ - protected function getOutFile() + protected function getOutFile(): string { return $this->moduleDirectory . '/etc/config.xml'; } @@ -836,7 +948,7 @@ protected function getOutFile() /** * @param SimpleXMLElement $configXml */ - protected function putConfigXml(SimpleXMLElement $configXml) + protected function putConfigXml(SimpleXMLElement $configXml): void { $outFile = $this->getOutFile(); @@ -854,7 +966,7 @@ protected function putConfigXml(SimpleXMLElement $configXml) */ protected function hasAddResourceModelOption(InputInterface $input) { - return $input->getOption('add-resource-model'); + return $input->getOption(self::COMMAND_OPTION_ADD_RESOURCE_MODEL); } /** @@ -863,7 +975,7 @@ protected function hasAddResourceModelOption(InputInterface $input) */ protected function hasAddRoutersOption(InputInterface $input) { - return $input->getOption('add-routers'); + return $input->getOption(self::COMMAND_OPTION_ADD_ROUTERS); } /** @@ -872,7 +984,7 @@ protected function hasAddRoutersOption(InputInterface $input) */ protected function hasAddEventsOption(InputInterface $input) { - return $input->getOption('add-events'); + return $input->getOption(self::COMMAND_OPTION_ADD_EVENTS); } /** @@ -881,7 +993,7 @@ protected function hasAddEventsOption(InputInterface $input) */ protected function hasAddLayoutUpdatesOptions(InputInterface $input) { - return $input->getOption('add-layout-updates'); + return $input->getOption(self::COMMAND_OPTION_ADD_LAYOUT_UPDATES); } /** @@ -890,7 +1002,7 @@ protected function hasAddLayoutUpdatesOptions(InputInterface $input) */ protected function hasAddTranslateOption(InputInterface $input) { - return $input->getOption('add-translate'); + return $input->getOption(self::COMMAND_OPTION_ADD_TRANSLATE); } /** @@ -899,7 +1011,7 @@ protected function hasAddTranslateOption(InputInterface $input) */ protected function hasAddDefaultOption(InputInterface $input) { - return $input->getOption('add-default'); + return $input->getOption(self::COMMAND_OPTION_ADD_DEFAULT); } /** @@ -908,7 +1020,7 @@ protected function hasAddDefaultOption(InputInterface $input) */ protected function shouldSetVersion(InputInterface $input) { - return $input->getOption('set-version'); + return $input->getOption(self::COMMAND_OPTION_SET_VERSION); } /** @@ -917,7 +1029,7 @@ protected function shouldSetVersion(InputInterface $input) */ protected function shouldAddBlocks(InputInterface $input) { - return $input->getOption('add-blocks'); + return $input->getOption(self::COMMAND_OPTION_ADD_BLOCKS); } /** @@ -926,7 +1038,7 @@ protected function shouldAddBlocks(InputInterface $input) */ protected function shouldAddHelpers(InputInterface $input) { - return $input->getOption('add-helpers'); + return $input->getOption(self::COMMAND_OPTION_ADD_HELPERS); } /** @@ -935,7 +1047,7 @@ protected function shouldAddHelpers(InputInterface $input) */ protected function shouldAddModels(InputInterface $input) { - return $input->getOption('add-models'); + return $input->getOption(self::COMMAND_OPTION_ADD_MODELS); } /** @@ -944,7 +1056,7 @@ protected function shouldAddModels(InputInterface $input) */ protected function shouldAddAll(InputInterface $input) { - return $input->getOption('add-all'); + return $input->getOption(self::COMMAND_OPTION_ADD_ALL); } /** @@ -952,7 +1064,7 @@ protected function shouldAddAll(InputInterface $input) * * @return string */ - protected function getModuleNamespace() + protected function getModuleNamespace(): string { return $this->vendorNamespace . '_' . $this->moduleName; } @@ -960,7 +1072,7 @@ protected function getModuleNamespace() /** * @return string */ - protected function getLowercaseModuleNamespace() + protected function getLowercaseModuleNamespace(): string { return strtolower($this->vendorNamespace . '_' . $this->moduleName); } @@ -968,7 +1080,7 @@ protected function getLowercaseModuleNamespace() /** * @return string */ - protected function getLowercaseModuleName() + protected function getLowercaseModuleName(): string { return strtolower($this->moduleName); } @@ -977,10 +1089,10 @@ protected function getLowercaseModuleName() * Removes a child node if not null. * Deals with duplications of nodes when already in config * - * @param $node - * @param $child + * @param SimpleXMLElement $node + * @param string $child */ - protected function removeChildNodeIfNotNull($node, $child) + protected function removeChildNodeIfNotNull(SimpleXMLElement $node, string $child): void { if (!is_null($node->{$child})) { unset($node->{$child}); @@ -991,11 +1103,11 @@ protected function removeChildNodeIfNotNull($node, $child) * Formats given string as pretty xml * * @param string $string - * * @return string */ - protected function asPrettyXml($string) + protected function asPrettyXml(string $string): string { + /** @var string $string */ $string = preg_replace("/>\\s*\n<", $string); $xmlArray = explode("\n", $string); $currIndent = 0; @@ -1004,9 +1116,9 @@ protected function asPrettyXml($string) foreach ($xmlArray as $element) { if (preg_match('/^<([\w])+[^>\/]*>$/U', $element)) { $string .= str_repeat($indent, $currIndent) . $element . "\n"; - $currIndent += 1; + ++$currIndent; } elseif (preg_match('/^<\/.+>$/', $element)) { - $currIndent -= 1; + --$currIndent; $string .= str_repeat($indent, $currIndent) . $element . "\n"; } else { $string .= str_repeat($indent, $currIndent) . $element . "\n"; From 96cbe40f84ed67d5c4697f61420296719971f416 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 27 Jun 2024 23:09:50 +0200 Subject: [PATCH 134/136] [skip ci] Updated dev:module:rewrite:... commands --- .../Developer/Module/Observer/ListCommand.php | 2 +- .../Module/Rewrite/AbstractRewriteCommand.php | 81 ++++++++++++++----- ...nNotAutoloadCollaboratorClassException.php | 8 +- .../Module/Rewrite/ClassExistsChecker.php | 36 ++++----- .../Rewrite/ClassExistsThrownException.php | 8 +- .../Developer/Module/Rewrite/ClassUtil.php | 17 ++-- .../Module/Rewrite/ConflictsCommand.php | 73 ++++++++++++----- .../Developer/Module/Rewrite/ListCommand.php | 2 +- .../Command/Developer/Theme/InfoCommand.php | 5 +- 9 files changed, 151 insertions(+), 81 deletions(-) diff --git a/src/N98/Magento/Command/Developer/Module/Observer/ListCommand.php b/src/N98/Magento/Command/Developer/Module/Observer/ListCommand.php index 0e5c38848..dac18819c 100644 --- a/src/N98/Magento/Command/Developer/Module/Observer/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Observer/ListCommand.php @@ -76,7 +76,7 @@ public function setData(InputInterface $input,OutputInterface $output) : void $this->writeSection($output, 'Observers: ' . $type); } - $frontendEvents = $this->_getMageConfig()->getNode($type . '/events')->asArray(); + $frontendEvents = $this->_getMageConfigNode($type . '/events')->asArray(); if (true === $input->getOption(self::COMMAND_OPTION_SORT)) { // sorting for Observers is a bad idea because the order in which observers will be called is important. ksort($frontendEvents); diff --git a/src/N98/Magento/Command/Developer/Module/Rewrite/AbstractRewriteCommand.php b/src/N98/Magento/Command/Developer/Module/Rewrite/AbstractRewriteCommand.php index a867535e0..7a1c8d20f 100644 --- a/src/N98/Magento/Command/Developer/Module/Rewrite/AbstractRewriteCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Rewrite/AbstractRewriteCommand.php @@ -1,27 +1,58 @@ >> */ - protected function loadRewrites() + protected function loadRewrites(): array { $prototype = $this->_rewriteTypes; - $return = array_combine($prototype, array_fill(0, is_countable($prototype) ? count($prototype) : 0, [])); + /** @var array>> $return */ + $return = array_combine( + $prototype, + array_fill(0, count($prototype), []) + ); // Load config of each module because modules can overwrite config each other. Global config is already merged - $modules = Mage::getConfig()->getNode('modules')->children(); + $modules = $this->_getMageConfigNode('modules')->children(); + /** + * @var string $moduleName + * @var Mage_Core_Model_Config_Element $moduleData + */ foreach ($modules as $moduleName => $moduleData) { // Check only active modules if (!$moduleData->is('active')) { @@ -29,25 +60,39 @@ protected function loadRewrites() } // Load config of module - $configXmlFile = Mage::getConfig()->getModuleDir('etc', $moduleName) . DIRECTORY_SEPARATOR . 'config.xml'; - if (!is_readable($configXmlFile)) { + $configXmlFile = $this->_getMageConfig()->getModuleDir('etc', $moduleName) . DIRECTORY_SEPARATOR . 'config.xml'; + if (!\is_readable($configXmlFile)) { continue; } - $xml = \simplexml_load_file($configXmlFile); + $xml = simplexml_load_file($configXmlFile); if (!$xml) { continue; } $rewriteElements = $xml->xpath('//*/*/rewrite'); foreach ($rewriteElements as $element) { - $type = dom_import_simplexml($element)->parentNode->parentNode->nodeName; + /** @var DOMElement $domNode */ + $domNode = dom_import_simplexml($element); + /** @var DOMElement $parent */ + $parent = $domNode->parentNode; + /** @var DOMElement $parent */ + $parent = $parent->parentNode; + /** @var string $type */ + $type = $parent->nodeName; + if (!isset($return[$type])) { continue; } foreach ($element->children() as $child) { - $groupClassName = dom_import_simplexml($element)->parentNode->nodeName; + /** @var DOMElement $domNode */ + $domNode = dom_import_simplexml($element); + /** @var DOMElement $parent */ + $parent = $domNode->parentNode; + /** @var string $groupClassName */ + $groupClassName = $parent->nodeName; + $modelName = $child->getName(); $return[$type][$groupClassName . '/' . $modelName][] = (string) $child; } @@ -60,14 +105,12 @@ protected function loadRewrites() /** * Check codepools for core overwrites. * - * @return array + * @return array>> */ - protected function loadAutoloaderRewrites() + protected function loadAutoloaderRewrites(): array { $return = $this->loadAutoloaderRewritesByCodepool('community'); - $return = array_merge($return, $this->loadAutoloaderRewritesByCodepool('local')); - - return $return; + return array_merge($return, $this->loadAutoloaderRewritesByCodepool('local')); } /** @@ -75,9 +118,9 @@ protected function loadAutoloaderRewrites() * Mage, Zend, Varien namespaces. * * @param string $codePool - * @return array + * @return array>> */ - protected function loadAutoloaderRewritesByCodepool($codePool) + protected function loadAutoloaderRewritesByCodepool(string $codePool): array { $return = []; $localCodeFolder = Mage::getBaseDir('code') . '/' . $codePool; @@ -93,7 +136,7 @@ protected function loadAutoloaderRewritesByCodepool($codePool) $finder = new Finder(); $finder ->files() - ->ignoreUnreadableDirs(true) + ->ignoreUnreadableDirs() ->followLinks() ->in($folder); foreach ($finder as $file) { diff --git a/src/N98/Magento/Command/Developer/Module/Rewrite/CanNotAutoloadCollaboratorClassException.php b/src/N98/Magento/Command/Developer/Module/Rewrite/CanNotAutoloadCollaboratorClassException.php index 9e8fc38da..04ccb40b7 100644 --- a/src/N98/Magento/Command/Developer/Module/Rewrite/CanNotAutoloadCollaboratorClassException.php +++ b/src/N98/Magento/Command/Developer/Module/Rewrite/CanNotAutoloadCollaboratorClassException.php @@ -1,9 +1,6 @@ - */ + +declare(strict_types=1); namespace N98\Magento\Command\Developer\Module\Rewrite; @@ -13,6 +10,7 @@ * Class CanNotAutoloadParentClassException * * @package N98\Magento\Command\Developer\Module\Rewrite + * @author Tom Klingenberg */ class CanNotAutoloadCollaboratorClassException extends Exception { diff --git a/src/N98/Magento/Command/Developer/Module/Rewrite/ClassExistsChecker.php b/src/N98/Magento/Command/Developer/Module/Rewrite/ClassExistsChecker.php index 4acc8f9b4..49f2b9cc7 100644 --- a/src/N98/Magento/Command/Developer/Module/Rewrite/ClassExistsChecker.php +++ b/src/N98/Magento/Command/Developer/Module/Rewrite/ClassExistsChecker.php @@ -1,9 +1,6 @@ - */ + +declare(strict_types=1); namespace N98\Magento\Command\Developer\Module\Rewrite; @@ -16,25 +13,26 @@ * More robust (against fatal errors in the inheritance chain) class_exists checker * * @package N98\Magento\Command\Developer\Module\Rewrite + * @author Tom Klingenberg */ final class ClassExistsChecker { /** * @var string */ - private $className; + private string $className; /** - * @var stdClass + * @var stdClass|null */ - private $context; + private ?stdClass $context; /** * @param string $className * * @return ClassExistsChecker */ - public static function create($className) + public static function create(string $className): ClassExistsChecker { return new self($className); } @@ -44,7 +42,7 @@ public static function create($className) * * @param string $className */ - public function __construct($className) + public function __construct(string $className) { $this->className = $className; } @@ -55,7 +53,7 @@ public function __construct($className) * * @return bool */ - public function existsExtendsSafe() + public function existsExtendsSafe(): bool { $context = $this->startContext(); try { @@ -71,7 +69,7 @@ public function existsExtendsSafe() /** * @return stdClass */ - private function startContext() + private function startContext(): stdClass { $context = new stdClass(); $context->lastException = null; @@ -83,11 +81,11 @@ private function startContext() } /** - * @param $context + * @param stdClass $context * @param Exception $ex * @return bool */ - private function exceptionContext($context, Exception $ex) + private function exceptionContext(stdClass $context, Exception $ex): bool { /** @var AutoloadHandler $terminator */ $terminator = $context->terminator; @@ -102,9 +100,9 @@ private function exceptionContext($context, Exception $ex) } /** - * @param $context + * @param stdClass $context */ - private function endContext($context) + private function endContext(stdClass $context): void { if (isset($context->terminator)) { /** @var AutoloadHandler $terminator */ @@ -115,13 +113,13 @@ private function endContext($context) } /** - * Method is called as last auto-loader (if all others have failed), so the class does not exists (is not + * Method is called as last autoloader (if all others have failed), so the class does not exists (is not * resolve-able) * - * @param $notFoundClass + * @param string $notFoundClass * @throws CanNotAutoloadCollaboratorClassException */ - public function autoloadTerminator($notFoundClass) + public function autoloadTerminator(string $notFoundClass): void { $className = $this->className; if (null === $context = $this->context) { diff --git a/src/N98/Magento/Command/Developer/Module/Rewrite/ClassExistsThrownException.php b/src/N98/Magento/Command/Developer/Module/Rewrite/ClassExistsThrownException.php index ef07c5f98..75bd53d56 100644 --- a/src/N98/Magento/Command/Developer/Module/Rewrite/ClassExistsThrownException.php +++ b/src/N98/Magento/Command/Developer/Module/Rewrite/ClassExistsThrownException.php @@ -1,9 +1,6 @@ - */ + +declare(strict_types=1); namespace N98\Magento\Command\Developer\Module\Rewrite; @@ -15,6 +12,7 @@ * The previous exception is the one that was thrown within the class exists check * * @package N98\Magento\Command\Developer\Module\Rewrite + * @author Tom Klingenberg */ class ClassExistsThrownException extends RuntimeException { diff --git a/src/N98/Magento/Command/Developer/Module/Rewrite/ClassUtil.php b/src/N98/Magento/Command/Developer/Module/Rewrite/ClassUtil.php index 5aec5ef53..07fa39af3 100644 --- a/src/N98/Magento/Command/Developer/Module/Rewrite/ClassUtil.php +++ b/src/N98/Magento/Command/Developer/Module/Rewrite/ClassUtil.php @@ -12,29 +12,32 @@ final class ClassUtil /** * @var string */ - private $className; + private string $className; /** - * @var bool + * @var bool|null */ - private $exists; + private ?bool $exists; /** * @param string $className * * @return ClassUtil */ - public static function create($className) + public static function create(string $className): ClassUtil { return new self($className); } - public function __construct($className) + public function __construct(string $className) { $this->className = $className; } - public function exists() + /** + * @return bool + */ + public function exists(): bool { if (null === $this->exists) { $this->exists = ClassExistsChecker::create($this->className)->existsExtendsSafe(); @@ -49,7 +52,7 @@ public function exists() * @param ClassUtil $class * @return bool */ - public function isA(ClassUtil $class) + public function isA(ClassUtil $class): bool { return is_a($this->className, $class->className, true); } diff --git a/src/N98/Magento/Command/Developer/Module/Rewrite/ConflictsCommand.php b/src/N98/Magento/Command/Developer/Module/Rewrite/ConflictsCommand.php index b482f3888..20b1d5b11 100644 --- a/src/N98/Magento/Command/Developer/Module/Rewrite/ConflictsCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Rewrite/ConflictsCommand.php @@ -1,10 +1,11 @@ setName('dev:module:rewrite:conflicts') ->addOption( - 'log-junit', + self::COMMAND_OPTION_LOG_JUNIT, null, InputOption::VALUE_REQUIRED, 'Log conflicts in JUnit XML format to defined file.' ) - ->setDescription('Lists all magento rewrite conflicts'); + ; + } - $help = <<setHelp($help); } /** * @param InputInterface $input * @param OutputInterface $output - * * @return int exit code: 0 no conflicts found, 1 conflicts found, 2 magento could not be initialized + * @throws Zend_Text_Table_Exception */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output, true); - $this->initMagento(); - $conflicts = []; $time = microtime(true); $rewrites = $this->loadRewrites(); @@ -57,18 +76,28 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (!is_array($data)) { continue; } + /** + * @var string $class + * @var string[] $rewriteClasses + */ foreach ($data as $class => $rewriteClasses) { if (!$this->_isInheritanceConflict($rewriteClasses)) { continue; } - $conflicts[] = ['Type' => $type, 'Class' => $class, 'Rewrites' => implode(', ', $rewriteClasses), 'Loaded Class' => $this->_getLoadedClass($type, $class)]; + $conflicts[] = [ + 'Type' => $type, + 'Class' => $class, + 'Rewrites' => implode(', ', $rewriteClasses), + 'Loaded Class' => $this->_getLoadedClass($type, $class) + ]; } } - if ($input->getOption('log-junit')) { - $duration = microtime($time) - $time; - $this->logJUnit($conflicts, $input->getOption('log-junit'), $duration); + $logJunit = $input->getOption(self::COMMAND_OPTION_LOG_JUNIT); + if (is_string($logJunit)) { + $duration = microtime(true) - $time; + $this->logJUnit($conflicts, $logJunit, $duration); } else { $this->writeOutput($output, $conflicts); } @@ -87,24 +116,24 @@ protected function _getLoadedClass(string $type, string $class): string { switch ($type) { case 'blocks': - return Mage::getConfig()->getBlockClassName($class); + return $this->_getMageConfig()->getBlockClassName($class); case 'helpers': - return Mage::getConfig()->getHelperClassName($class); + return $this->_getMageConfig()->getHelperClassName($class); case 'models': // fall-through intended default: /** @noinspection PhpParamsInspection */ - return Mage::getConfig()->getModelClassName($class); + return $this->_getMageConfig()->getModelClassName($class); } } /** - * @param array $conflicts + * @param array> $conflicts * @param string $filename - * @param float $duration + * @param float $duration */ - protected function logJUnit(array $conflicts, $filename, $duration) + protected function logJUnit(array $conflicts, string $filename, float $duration): void { $document = new JUnitXmlDocument(); $suite = $document->addTestSuite(); @@ -134,7 +163,7 @@ protected function logJUnit(array $conflicts, $filename, $duration) * If yes we have no conflict. The top class can extend every core class. * So we cannot check this. * - * @param array $classes + * @param array $classes * @return bool */ protected function _isInheritanceConflict(array $classes): bool @@ -161,7 +190,7 @@ protected function _isInheritanceConflict(array $classes): bool /** * @param OutputInterface $output - * @param array $conflicts + * @param array> $conflicts * @throws Zend_Text_Table_Exception */ private function writeOutput(OutputInterface $output, array $conflicts): void diff --git a/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php b/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php index 50ac4be3e..fc495464a 100644 --- a/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php @@ -11,7 +11,7 @@ /** * List rewrites command * - * @package N98\Magento\Command\Developer\Module + * @package N98\Magento\Command\Developer\Module\Rewrite */ class ListCommand extends AbstractRewriteCommand implements CommandDataInterface { diff --git a/src/N98/Magento/Command/Developer/Theme/InfoCommand.php b/src/N98/Magento/Command/Developer/Theme/InfoCommand.php index cc04f64d1..48c638316 100644 --- a/src/N98/Magento/Command/Developer/Theme/InfoCommand.php +++ b/src/N98/Magento/Command/Developer/Theme/InfoCommand.php @@ -7,6 +7,7 @@ use Mage_Core_Model_Store; use Mage_Core_Model_Website; use N98\Magento\Command\AbstractCommand; +use N98\Magento\Command\AbstractStoreConfigCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -104,7 +105,7 @@ protected function _parse(array $nodes, Mage_Core_Model_Store $store, bool $with $nodeLabel, (string) $this->_getMageConfig()->getNode( $node, - AbstractMagentoStoreConfigCommand::SCOPE_STORE_VIEW, + AbstractStoreConfigCommand::SCOPE_STORE_VIEW, $store->getCode() ) ]; @@ -128,7 +129,7 @@ protected function _parseException(string $node, Mage_Core_Model_Store $store): { $exception = (string) $this->_getMageConfig()->getNode( $node . self::THEMES_EXCEPTION, - AbstractMagentoStoreConfigCommand::SCOPE_STORE_VIEW, + AbstractStoreConfigCommand::SCOPE_STORE_VIEW, $store->getCode() ); From b345506cf4a5f6fb4a580febf10f1a05a5808396 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 3 Jul 2024 00:15:05 +0200 Subject: [PATCH 135/136] [skip ci] Updated composer.json --- composer.json | 2 + composer.lock | 3663 +++++++++++++++++++++---------------------------- 2 files changed, 1559 insertions(+), 2106 deletions(-) diff --git a/composer.json b/composer.json index 9ddd2513c..7be0fb28d 100644 --- a/composer.json +++ b/composer.json @@ -26,6 +26,7 @@ "symfony/event-dispatcher": "~5.4", "symfony/filesystem": "^5.4", "symfony/finder": "~5.4", + "symfony/polyfill-php84": "^1.30", "symfony/process": "~5.4", "symfony/validator": "~5.4", "symfony/yaml": "~5.4", @@ -34,6 +35,7 @@ "require-dev": { "ext-simplexml": "*", "bamarni/symfony-console-autocomplete": "^1.2.0", + "composer/composer": "^2.7", "friendsofphp/php-cs-fixer": "^3.4", "mikey179/vfsstream": "^1.6", "phing/phing": "~2.17.0", diff --git a/composer.lock b/composer.lock index bb98e24cb..78e71dce2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8742faf1a32f1b00524ad7c4d1c3cbe4", + "content-hash": "4f54abc83e7e6d10c21570829e12ee86", "packages": [ { "name": "cweagans/composer-patches", @@ -1486,6 +1486,82 @@ ], "time": "2024-06-19T12:30:46+00:00" }, + { + "name": "symfony/polyfill-php84", + "version": "v1.30.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php84.git", + "reference": "1ae77f8809b8e7aa85f185c850ede8e5e7b50503" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php84/zipball/1ae77f8809b8e7aa85f185c850ede8e5e7b50503", + "reference": "1ae77f8809b8e7aa85f185c850ede8e5e7b50503", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php84\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.4+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php84/tree/v1.30.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-06-19T12:35:24+00:00" + }, { "name": "symfony/process", "version": "v5.4.40", @@ -2208,36 +2284,39 @@ "time": "2022-04-11T12:08:44+00:00" }, { - "name": "composer/pcre", - "version": "3.1.0", + "name": "composer/ca-bundle", + "version": "1.5.0", "source": { "type": "git", - "url": "https://github.com/composer/pcre.git", - "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2" + "url": "https://github.com/composer/ca-bundle.git", + "reference": "0c5ccfcfea312b5c5a190a21ac5cef93f74baf99" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", - "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/0c5ccfcfea312b5c5a190a21ac5cef93f74baf99", + "reference": "0c5ccfcfea312b5c5a190a21ac5cef93f74baf99", "shasum": "" }, "require": { - "php": "^7.4 || ^8.0" + "ext-openssl": "*", + "ext-pcre": "*", + "php": "^7.2 || ^8.0" }, "require-dev": { - "phpstan/phpstan": "^1.3", - "phpstan/phpstan-strict-rules": "^1.1", - "symfony/phpunit-bridge": "^5" + "phpstan/phpstan": "^1.10", + "psr/log": "^1.0", + "symfony/phpunit-bridge": "^4.2 || ^5", + "symfony/process": "^4.0 || ^5.0 || ^6.0 || ^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.x-dev" + "dev-main": "1.x-dev" } }, "autoload": { "psr-4": { - "Composer\\Pcre\\": "src" + "Composer\\CaBundle\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -2251,16 +2330,18 @@ "homepage": "http://seld.be" } ], - "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "description": "Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle.", "keywords": [ - "PCRE", - "preg", - "regex", - "regular expression" + "cabundle", + "cacert", + "certificate", + "ssl", + "tls" ], "support": { - "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.1.0" + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/ca-bundle/issues", + "source": "https://github.com/composer/ca-bundle/tree/1.5.0" }, "funding": [ { @@ -2276,38 +2357,44 @@ "type": "tidelift" } ], - "time": "2022-11-17T09:50:14+00:00" + "time": "2024-03-15T14:00:32+00:00" }, { - "name": "composer/semver", - "version": "3.4.0", + "name": "composer/class-map-generator", + "version": "1.3.4", "source": { "type": "git", - "url": "https://github.com/composer/semver.git", - "reference": "35e8d0af4486141bc745f23a29cc2091eb624a32" + "url": "https://github.com/composer/class-map-generator.git", + "reference": "b1b3fd0b4eaf3ddf3ee230bc340bf3fff454a1a3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/35e8d0af4486141bc745f23a29cc2091eb624a32", - "reference": "35e8d0af4486141bc745f23a29cc2091eb624a32", + "url": "https://api.github.com/repos/composer/class-map-generator/zipball/b1b3fd0b4eaf3ddf3ee230bc340bf3fff454a1a3", + "reference": "b1b3fd0b4eaf3ddf3ee230bc340bf3fff454a1a3", "shasum": "" }, "require": { - "php": "^5.3.2 || ^7.0 || ^8.0" + "composer/pcre": "^2.1 || ^3.1", + "php": "^7.2 || ^8.0", + "symfony/finder": "^4.4 || ^5.3 || ^6 || ^7" }, "require-dev": { - "phpstan/phpstan": "^1.4", - "symfony/phpunit-bridge": "^4.2 || ^5" + "phpstan/phpstan": "^1.6", + "phpstan/phpstan-deprecation-rules": "^1", + "phpstan/phpstan-phpunit": "^1", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/filesystem": "^5.4 || ^6", + "symfony/phpunit-bridge": "^5" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.x-dev" + "dev-main": "1.x-dev" } }, "autoload": { "psr-4": { - "Composer\\Semver\\": "src" + "Composer\\ClassMapGenerator\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -2315,33 +2402,19 @@ "MIT" ], "authors": [ - { - "name": "Nils Adermann", - "email": "naderman@naderman.de", - "homepage": "http://www.naderman.de" - }, { "name": "Jordi Boggiano", "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" - }, - { - "name": "Rob Bast", - "email": "rob.bast@gmail.com", - "homepage": "http://robbast.nl" + "homepage": "https://seld.be" } ], - "description": "Semver library that offers utilities, version constraint parsing and validation.", + "description": "Utilities to scan PHP code and generate class maps.", "keywords": [ - "semantic", - "semver", - "validation", - "versioning" + "classmap" ], "support": { - "irc": "ircs://irc.libera.chat:6697/composer", - "issues": "https://github.com/composer/semver/issues", - "source": "https://github.com/composer/semver/tree/3.4.0" + "issues": "https://github.com/composer/class-map-generator/issues", + "source": "https://github.com/composer/class-map-generator/tree/1.3.4" }, "funding": [ { @@ -2357,36 +2430,75 @@ "type": "tidelift" } ], - "time": "2023-08-31T09:50:34+00:00" + "time": "2024-06-12T14:13:04+00:00" }, { - "name": "composer/xdebug-handler", - "version": "3.0.3", + "name": "composer/composer", + "version": "2.7.7", "source": { "type": "git", - "url": "https://github.com/composer/xdebug-handler.git", - "reference": "ced299686f41dce890debac69273b47ffe98a40c" + "url": "https://github.com/composer/composer.git", + "reference": "291942978f39435cf904d33739f98d7d4eca7b23" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/ced299686f41dce890debac69273b47ffe98a40c", - "reference": "ced299686f41dce890debac69273b47ffe98a40c", + "url": "https://api.github.com/repos/composer/composer/zipball/291942978f39435cf904d33739f98d7d4eca7b23", + "reference": "291942978f39435cf904d33739f98d7d4eca7b23", "shasum": "" }, "require": { - "composer/pcre": "^1 || ^2 || ^3", + "composer/ca-bundle": "^1.0", + "composer/class-map-generator": "^1.3.3", + "composer/metadata-minifier": "^1.0", + "composer/pcre": "^2.1 || ^3.1", + "composer/semver": "^3.3", + "composer/spdx-licenses": "^1.5.7", + "composer/xdebug-handler": "^2.0.2 || ^3.0.3", + "justinrainbow/json-schema": "^5.2.11", "php": "^7.2.5 || ^8.0", - "psr/log": "^1 || ^2 || ^3" + "psr/log": "^1.0 || ^2.0 || ^3.0", + "react/promise": "^2.8 || ^3", + "seld/jsonlint": "^1.4", + "seld/phar-utils": "^1.2", + "seld/signal-handler": "^2.0", + "symfony/console": "^5.4.11 || ^6.0.11 || ^7", + "symfony/filesystem": "^5.4 || ^6.0 || ^7", + "symfony/finder": "^5.4 || ^6.0 || ^7", + "symfony/polyfill-php73": "^1.24", + "symfony/polyfill-php80": "^1.24", + "symfony/polyfill-php81": "^1.24", + "symfony/process": "^5.4 || ^6.0 || ^7" }, "require-dev": { - "phpstan/phpstan": "^1.0", - "phpstan/phpstan-strict-rules": "^1.1", - "symfony/phpunit-bridge": "^6.0" + "phpstan/phpstan": "^1.11.0", + "phpstan/phpstan-deprecation-rules": "^1.2.0", + "phpstan/phpstan-phpunit": "^1.4.0", + "phpstan/phpstan-strict-rules": "^1.6.0", + "phpstan/phpstan-symfony": "^1.4.0", + "symfony/phpunit-bridge": "^6.4.1 || ^7.0.1" }, + "suggest": { + "ext-openssl": "Enabling the openssl extension allows you to access https URLs for repositories and packages", + "ext-zip": "Enabling the zip extension allows you to unzip archives", + "ext-zlib": "Allow gzip compression of HTTP requests" + }, + "bin": [ + "bin/composer" + ], "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.7-dev" + }, + "phpstan": { + "includes": [ + "phpstan/rules.neon" + ] + } + }, "autoload": { "psr-4": { - "Composer\\XdebugHandler\\": "src" + "Composer\\": "src/Composer/" } }, "notification-url": "https://packagist.org/downloads/", @@ -2395,19 +2507,28 @@ ], "authors": [ { - "name": "John Stevenson", - "email": "john-stevenson@blueyonder.co.uk" + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "https://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "https://seld.be" } ], - "description": "Restarts a process without Xdebug.", + "description": "Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.", + "homepage": "https://getcomposer.org/", "keywords": [ - "Xdebug", - "performance" + "autoload", + "dependency", + "package" ], "support": { - "irc": "irc://irc.freenode.org/composer", - "issues": "https://github.com/composer/xdebug-handler/issues", - "source": "https://github.com/composer/xdebug-handler/tree/3.0.3" + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/composer/issues", + "security": "https://github.com/composer/composer/security/policy", + "source": "https://github.com/composer/composer/tree/2.7.7" }, "funding": [ { @@ -2423,39 +2544,39 @@ "type": "tidelift" } ], - "time": "2022-02-25T21:32:43+00:00" + "time": "2024-06-10T20:11:12+00:00" }, { - "name": "doctrine/instantiator", - "version": "1.5.0", + "name": "composer/metadata-minifier", + "version": "1.0.0", "source": { "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b" + "url": "https://github.com/composer/metadata-minifier.git", + "reference": "c549d23829536f0d0e984aaabbf02af91f443207" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b", - "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b", + "url": "https://api.github.com/repos/composer/metadata-minifier/zipball/c549d23829536f0d0e984aaabbf02af91f443207", + "reference": "c549d23829536f0d0e984aaabbf02af91f443207", "shasum": "" }, "require": { - "php": "^7.1 || ^8.0" + "php": "^5.3.2 || ^7.0 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^9 || ^11", - "ext-pdo": "*", - "ext-phar": "*", - "phpbench/phpbench": "^0.16 || ^1", - "phpstan/phpstan": "^1.4", - "phpstan/phpstan-phpunit": "^1", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "vimeo/psalm": "^4.30 || ^5.4" + "composer/composer": "^2", + "phpstan/phpstan": "^0.12.55", + "symfony/phpunit-bridge": "^4.2 || ^5" }, "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } + }, "autoload": { "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + "Composer\\MetadataMinifier\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -2464,97 +2585,67 @@ ], "authors": [ { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "https://ocramius.github.io/" + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" } ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://www.doctrine-project.org/projects/instantiator.html", + "description": "Small utility library that handles metadata minification and expansion.", "keywords": [ - "constructor", - "instantiate" + "composer", + "compression" ], "support": { - "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.5.0" + "issues": "https://github.com/composer/metadata-minifier/issues", + "source": "https://github.com/composer/metadata-minifier/tree/1.0.0" }, "funding": [ { - "url": "https://www.doctrine-project.org/sponsorship.html", + "url": "https://packagist.com", "type": "custom" }, { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" + "url": "https://github.com/composer", + "type": "github" }, { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "url": "https://tidelift.com/funding/github/packagist/composer/composer", "type": "tidelift" } ], - "time": "2022-12-30T00:15:36+00:00" + "time": "2021-04-07T13:37:33+00:00" }, { - "name": "friendsofphp/php-cs-fixer", - "version": "v3.25.1", + "name": "composer/pcre", + "version": "3.1.0", "source": { "type": "git", - "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "8e21d69801de6b5ecb0dbe0bcdf967b335b1260b" + "url": "https://github.com/composer/pcre.git", + "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/8e21d69801de6b5ecb0dbe0bcdf967b335b1260b", - "reference": "8e21d69801de6b5ecb0dbe0bcdf967b335b1260b", + "url": "https://api.github.com/repos/composer/pcre/zipball/4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", + "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", "shasum": "" }, "require": { - "composer/semver": "^3.3", - "composer/xdebug-handler": "^3.0.3", - "ext-json": "*", - "ext-tokenizer": "*", - "php": "^7.4 || ^8.0", - "sebastian/diff": "^4.0 || ^5.0", - "symfony/console": "^5.4 || ^6.0", - "symfony/event-dispatcher": "^5.4 || ^6.0", - "symfony/filesystem": "^5.4 || ^6.0", - "symfony/finder": "^5.4 || ^6.0", - "symfony/options-resolver": "^5.4 || ^6.0", - "symfony/polyfill-mbstring": "^1.27", - "symfony/polyfill-php80": "^1.27", - "symfony/polyfill-php81": "^1.27", - "symfony/process": "^5.4 || ^6.0", - "symfony/stopwatch": "^5.4 || ^6.0" + "php": "^7.4 || ^8.0" }, "require-dev": { - "facile-it/paraunit": "^1.3 || ^2.0", - "justinrainbow/json-schema": "^5.2", - "keradus/cli-executor": "^2.0", - "mikey179/vfsstream": "^1.6.11", - "php-coveralls/php-coveralls": "^2.5.3", - "php-cs-fixer/accessible-object": "^1.1", - "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.2", - "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.2.1", - "phpspec/prophecy": "^1.16", - "phpspec/prophecy-phpunit": "^2.0", - "phpunit/phpunit": "^9.5", - "phpunitgoodpractices/polyfill": "^1.6", - "phpunitgoodpractices/traits": "^1.9.2", - "symfony/phpunit-bridge": "^6.2.3", - "symfony/yaml": "^5.4 || ^6.0" + "phpstan/phpstan": "^1.3", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/phpunit-bridge": "^5" }, - "suggest": { - "ext-dom": "For handling output formats in XML", - "ext-mbstring": "For handling non-UTF8 characters." + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } }, - "bin": [ - "php-cs-fixer" - ], - "type": "application", "autoload": { "psr-4": { - "PhpCsFixer\\": "src/" + "Composer\\Pcre\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -2563,810 +2654,530 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Dariusz Rumiński", - "email": "dariusz.ruminski@gmail.com" + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" } ], - "description": "A tool to automatically fix PHP code style", + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", "keywords": [ - "Static code analysis", - "fixer", - "standards", - "static analysis" + "PCRE", + "preg", + "regex", + "regular expression" ], "support": { - "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.25.1" + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/3.1.0" }, "funding": [ { - "url": "https://github.com/keradus", + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" } ], - "time": "2023-09-04T01:22:52+00:00" + "time": "2022-11-17T09:50:14+00:00" }, { - "name": "mikey179/vfsstream", - "version": "v1.6.11", + "name": "composer/semver", + "version": "3.4.0", "source": { "type": "git", - "url": "https://github.com/bovigo/vfsStream.git", - "reference": "17d16a85e6c26ce1f3e2fa9ceeacdc2855db1e9f" + "url": "https://github.com/composer/semver.git", + "reference": "35e8d0af4486141bc745f23a29cc2091eb624a32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bovigo/vfsStream/zipball/17d16a85e6c26ce1f3e2fa9ceeacdc2855db1e9f", - "reference": "17d16a85e6c26ce1f3e2fa9ceeacdc2855db1e9f", + "url": "https://api.github.com/repos/composer/semver/zipball/35e8d0af4486141bc745f23a29cc2091eb624a32", + "reference": "35e8d0af4486141bc745f23a29cc2091eb624a32", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": "^5.3.2 || ^7.0 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^4.5|^5.0" + "phpstan/phpstan": "^1.4", + "symfony/phpunit-bridge": "^4.2 || ^5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6.x-dev" + "dev-main": "3.x-dev" } }, "autoload": { - "psr-0": { - "org\\bovigo\\vfs\\": "src/main/php" + "psr-4": { + "Composer\\Semver\\": "src" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Frank Kleine", - "homepage": "http://frankkleine.de/", - "role": "Developer" + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" } ], - "description": "Virtual file system to mock the real file system in unit tests.", - "homepage": "http://vfs.bovigo.org/", + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], "support": { - "issues": "https://github.com/bovigo/vfsStream/issues", - "source": "https://github.com/bovigo/vfsStream/tree/master", - "wiki": "https://github.com/bovigo/vfsStream/wiki" + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/semver/issues", + "source": "https://github.com/composer/semver/tree/3.4.0" }, - "time": "2022-02-23T02:02:42+00:00" + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2023-08-31T09:50:34+00:00" }, { - "name": "myclabs/deep-copy", - "version": "1.11.1", + "name": "composer/spdx-licenses", + "version": "1.5.8", "source": { "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" + "url": "https://github.com/composer/spdx-licenses.git", + "reference": "560bdcf8deb88ae5d611c80a2de8ea9d0358cc0a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "url": "https://api.github.com/repos/composer/spdx-licenses/zipball/560bdcf8deb88ae5d611c80a2de8ea9d0358cc0a", + "reference": "560bdcf8deb88ae5d611c80a2de8ea9d0358cc0a", "shasum": "" }, "require": { - "php": "^7.1 || ^8.0" - }, - "conflict": { - "doctrine/collections": "<1.6.8", - "doctrine/common": "<2.13.3 || >=3,<3.2.2" + "php": "^5.3.2 || ^7.0 || ^8.0" }, "require-dev": { - "doctrine/collections": "^1.6.8", - "doctrine/common": "^2.13.3 || ^3.2.2", - "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" + "phpstan/phpstan": "^0.12.55", + "symfony/phpunit-bridge": "^4.2 || ^5" }, "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } + }, "autoload": { - "files": [ - "src/DeepCopy/deep_copy.php" - ], "psr-4": { - "DeepCopy\\": "src/DeepCopy/" + "Composer\\Spdx\\": "src" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "description": "Create deep copies (clones) of your objects", + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "SPDX licenses list and validation library.", "keywords": [ - "clone", - "copy", - "duplicate", - "object", - "object graph" + "license", + "spdx", + "validator" ], "support": { - "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/spdx-licenses/issues", + "source": "https://github.com/composer/spdx-licenses/tree/1.5.8" }, "funding": [ { - "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", "type": "tidelift" } ], - "time": "2023-03-08T13:26:56+00:00" + "time": "2023-11-20T07:44:33+00:00" }, { - "name": "phar-io/manifest", - "version": "2.0.3", + "name": "composer/xdebug-handler", + "version": "3.0.3", "source": { "type": "git", - "url": "https://github.com/phar-io/manifest.git", - "reference": "97803eca37d319dfa7826cc2437fc020857acb53" + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "ced299686f41dce890debac69273b47ffe98a40c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", - "reference": "97803eca37d319dfa7826cc2437fc020857acb53", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/ced299686f41dce890debac69273b47ffe98a40c", + "reference": "ced299686f41dce890debac69273b47ffe98a40c", "shasum": "" }, "require": { - "ext-dom": "*", - "ext-phar": "*", - "ext-xmlwriter": "*", - "phar-io/version": "^3.0.1", - "php": "^7.2 || ^8.0" + "composer/pcre": "^1 || ^2 || ^3", + "php": "^7.2.5 || ^8.0", + "psr/log": "^1 || ^2 || ^3" }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } + "require-dev": { + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/phpunit-bridge": "^6.0" }, + "type": "library", "autoload": { - "classmap": [ - "src/" - ] + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without Xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/xdebug-handler/issues", + "source": "https://github.com/composer/xdebug-handler/tree/3.0.3" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" }, { - "name": "Sebastian Heuer", - "email": "sebastian@phpeople.de", - "role": "Developer" + "url": "https://github.com/composer", + "type": "github" }, { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "Developer" + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" } ], - "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", - "support": { - "issues": "https://github.com/phar-io/manifest/issues", - "source": "https://github.com/phar-io/manifest/tree/2.0.3" - }, - "time": "2021-07-20T11:28:43+00:00" + "time": "2022-02-25T21:32:43+00:00" }, { - "name": "phar-io/version", - "version": "3.2.1", - "source": { - "type": "git", - "url": "https://github.com/phar-io/version.git", - "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", - "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - }, - { - "name": "Sebastian Heuer", - "email": "sebastian@phpeople.de", - "role": "Developer" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "Developer" - } - ], - "description": "Library for handling version information and constraints", - "support": { - "issues": "https://github.com/phar-io/version/issues", - "source": "https://github.com/phar-io/version/tree/3.2.1" - }, - "time": "2022-02-21T01:04:05+00:00" - }, - { - "name": "phing/phing", - "version": "2.17.4", + "name": "doctrine/instantiator", + "version": "1.5.0", "source": { "type": "git", - "url": "https://github.com/phingofficial/phing.git", - "reference": "9f3bc8c72e65452686dcf64497e02a082f138908" + "url": "https://github.com/doctrine/instantiator.git", + "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phingofficial/phing/zipball/9f3bc8c72e65452686dcf64497e02a082f138908", - "reference": "9f3bc8c72e65452686dcf64497e02a082f138908", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b", + "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b", "shasum": "" }, "require": { - "php": ">=5.2.0" + "php": "^7.1 || ^8.0" }, "require-dev": { - "ext-pdo_sqlite": "*", - "mikey179/vfsstream": "^1.6", - "pdepend/pdepend": "2.x", - "pear/archive_tar": "1.4.x", - "pear/http_request2": "dev-trunk", - "pear/net_growl": "dev-trunk", - "pear/pear-core-minimal": "1.10.1", - "pear/versioncontrol_git": "@dev", - "pear/versioncontrol_svn": "~0.5", - "phpdocumentor/phpdocumentor": "2.x", - "phploc/phploc": "~2.0.6", - "phpmd/phpmd": "~2.2", - "phpunit/phpunit": ">=3.7", - "sebastian/git": "~1.0", - "sebastian/phpcpd": "2.x", - "siad007/versioncontrol_hg": "^1.0", - "simpletest/simpletest": "^1.1", - "squizlabs/php_codesniffer": "~2.2", - "symfony/yaml": "^2.8 || ^3.1 || ^4.0" - }, - "suggest": { - "pdepend/pdepend": "PHP version of JDepend", - "pear/archive_tar": "Tar file management class", - "pear/versioncontrol_git": "A library that provides OO interface to handle Git repository", - "pear/versioncontrol_svn": "A simple OO-style interface for Subversion, the free/open-source version control system", - "phpdocumentor/phpdocumentor": "Documentation Generator for PHP", - "phploc/phploc": "A tool for quickly measuring the size of a PHP project", - "phpmd/phpmd": "PHP version of PMD tool", - "phpunit/php-code-coverage": "Library that provides collection, processing, and rendering functionality for PHP code coverage information", - "phpunit/phpunit": "The PHP Unit Testing Framework", - "sebastian/phpcpd": "Copy/Paste Detector (CPD) for PHP code", - "siad007/versioncontrol_hg": "A library for interfacing with Mercurial repositories.", - "tedivm/jshrink": "Javascript Minifier built in PHP" + "doctrine/coding-standard": "^9 || ^11", + "ext-pdo": "*", + "ext-phar": "*", + "phpbench/phpbench": "^0.16 || ^1", + "phpstan/phpstan": "^1.4", + "phpstan/phpstan-phpunit": "^1", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "vimeo/psalm": "^4.30 || ^5.4" }, - "bin": [ - "bin/phing" - ], "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.16.x-dev" - } - }, "autoload": { - "classmap": [ - "classes/phing/" - ] + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "classes" - ], "license": [ - "LGPL-3.0-only" + "MIT" ], "authors": [ { - "name": "Michiel Rook", - "email": "mrook@php.net" - }, - { - "name": "Phing Community", - "homepage": "https://www.phing.info/trac/wiki/Development/Contributors" + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "https://ocramius.github.io/" } ], - "description": "PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant.", - "homepage": "https://www.phing.info/", + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", "keywords": [ - "build", - "phing", - "task", - "tool" + "constructor", + "instantiate" ], "support": { - "irc": "irc://irc.freenode.net/phing", - "issues": "https://www.phing.info/trac/report", - "source": "https://github.com/phingofficial/phing/tree/2.17.4" + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/1.5.0" }, "funding": [ { - "url": "https://github.com/mrook", - "type": "github" - }, - { - "url": "https://github.com/siad007", - "type": "github" + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" }, { - "url": "https://www.patreon.com/michielrook", + "url": "https://www.patreon.com/phpdoctrine", "type": "patreon" - } - ], - "time": "2022-07-08T09:07:07+00:00" - }, - { - "name": "phpstan/phpstan", - "version": "1.10.33", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan.git", - "reference": "03b1cf9f814ba0863c4e9affea49a4d1ed9a2ed1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/03b1cf9f814ba0863c4e9affea49a4d1ed9a2ed1", - "reference": "03b1cf9f814ba0863c4e9affea49a4d1ed9a2ed1", - "shasum": "" - }, - "require": { - "php": "^7.2|^8.0" - }, - "conflict": { - "phpstan/phpstan-shim": "*" - }, - "bin": [ - "phpstan", - "phpstan.phar" - ], - "type": "library", - "autoload": { - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPStan - PHP Static Analysis Tool", - "keywords": [ - "dev", - "static analysis" - ], - "support": { - "docs": "https://phpstan.org/user-guide/getting-started", - "forum": "https://github.com/phpstan/phpstan/discussions", - "issues": "https://github.com/phpstan/phpstan/issues", - "security": "https://github.com/phpstan/phpstan/security/policy", - "source": "https://github.com/phpstan/phpstan-src" - }, - "funding": [ - { - "url": "https://github.com/ondrejmirtes", - "type": "github" }, { - "url": "https://github.com/phpstan", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", "type": "tidelift" } ], - "time": "2023-09-04T12:20:53+00:00" + "time": "2022-12-30T00:15:36+00:00" }, { - "name": "phpunit/php-code-coverage", - "version": "9.2.27", + "name": "friendsofphp/php-cs-fixer", + "version": "v3.25.1", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1" + "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", + "reference": "8e21d69801de6b5ecb0dbe0bcdf967b335b1260b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/b0a88255cb70d52653d80c890bd7f38740ea50d1", - "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/8e21d69801de6b5ecb0dbe0bcdf967b335b1260b", + "reference": "8e21d69801de6b5ecb0dbe0bcdf967b335b1260b", "shasum": "" }, "require": { - "ext-dom": "*", - "ext-libxml": "*", - "ext-xmlwriter": "*", - "nikic/php-parser": "^4.15", - "php": ">=7.3", - "phpunit/php-file-iterator": "^3.0.3", - "phpunit/php-text-template": "^2.0.2", - "sebastian/code-unit-reverse-lookup": "^2.0.2", - "sebastian/complexity": "^2.0", - "sebastian/environment": "^5.1.2", - "sebastian/lines-of-code": "^1.0.3", - "sebastian/version": "^3.0.1", - "theseer/tokenizer": "^1.2.0" + "composer/semver": "^3.3", + "composer/xdebug-handler": "^3.0.3", + "ext-json": "*", + "ext-tokenizer": "*", + "php": "^7.4 || ^8.0", + "sebastian/diff": "^4.0 || ^5.0", + "symfony/console": "^5.4 || ^6.0", + "symfony/event-dispatcher": "^5.4 || ^6.0", + "symfony/filesystem": "^5.4 || ^6.0", + "symfony/finder": "^5.4 || ^6.0", + "symfony/options-resolver": "^5.4 || ^6.0", + "symfony/polyfill-mbstring": "^1.27", + "symfony/polyfill-php80": "^1.27", + "symfony/polyfill-php81": "^1.27", + "symfony/process": "^5.4 || ^6.0", + "symfony/stopwatch": "^5.4 || ^6.0" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "facile-it/paraunit": "^1.3 || ^2.0", + "justinrainbow/json-schema": "^5.2", + "keradus/cli-executor": "^2.0", + "mikey179/vfsstream": "^1.6.11", + "php-coveralls/php-coveralls": "^2.5.3", + "php-cs-fixer/accessible-object": "^1.1", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.2", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.2.1", + "phpspec/prophecy": "^1.16", + "phpspec/prophecy-phpunit": "^2.0", + "phpunit/phpunit": "^9.5", + "phpunitgoodpractices/polyfill": "^1.6", + "phpunitgoodpractices/traits": "^1.9.2", + "symfony/phpunit-bridge": "^6.2.3", + "symfony/yaml": "^5.4 || ^6.0" }, "suggest": { - "ext-pcov": "PHP extension that provides line coverage", - "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "9.2-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.27" + "ext-dom": "For handling output formats in XML", + "ext-mbstring": "For handling non-UTF8 characters." }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } + "bin": [ + "php-cs-fixer" ], - "time": "2023-07-26T13:44:30+00:00" - }, - { - "name": "phpunit/php-file-iterator", - "version": "3.0.6", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", - "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, + "type": "application", "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2021-12-02T12:48:52+00:00" - }, - { - "name": "phpunit/php-invoker", - "version": "3.1.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-invoker.git", - "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", - "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "ext-pcntl": "*", - "phpunit/phpunit": "^9.3" - }, - "suggest": { - "ext-pcntl": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.1-dev" + "psr-4": { + "PhpCsFixer\\": "src/" } }, - "autoload": { - "classmap": [ - "src/" - ] - }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Invoke callables with a timeout", - "homepage": "https://github.com/sebastianbergmann/php-invoker/", - "keywords": [ - "process" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-invoker/issues", - "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-09-28T05:58:55+00:00" - }, - { - "name": "phpunit/php-text-template", - "version": "2.0.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", - "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "name": "Dariusz Rumiński", + "email": "dariusz.ruminski@gmail.com" } ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "description": "A tool to automatically fix PHP code style", "keywords": [ - "template" + "Static code analysis", + "fixer", + "standards", + "static analysis" ], "support": { - "issues": "https://github.com/sebastianbergmann/php-text-template/issues", - "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" + "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.25.1" }, "funding": [ { - "url": "https://github.com/sebastianbergmann", + "url": "https://github.com/keradus", "type": "github" } ], - "time": "2020-10-26T05:33:50+00:00" + "time": "2023-09-04T01:22:52+00:00" }, { - "name": "phpunit/php-timer", - "version": "5.0.3", + "name": "justinrainbow/json-schema", + "version": "v5.2.13", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" + "url": "https://github.com/jsonrainbow/json-schema.git", + "reference": "fbbe7e5d79f618997bc3332a6f49246036c45793" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", - "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "url": "https://api.github.com/repos/jsonrainbow/json-schema/zipball/fbbe7e5d79f618997bc3332a6f49246036c45793", + "reference": "fbbe7e5d79f618997bc3332a6f49246036c45793", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=5.3.3" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "friendsofphp/php-cs-fixer": "~2.2.20||~2.15.1", + "json-schema/json-schema-test-suite": "1.2.0", + "phpunit/phpunit": "^4.8.35" }, + "bin": [ + "bin/validate-json" + ], "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0-dev" + "dev-master": "5.0.x-dev" } }, "autoload": { - "classmap": [ - "src/" - ] + "psr-4": { + "JsonSchema\\": "src/JsonSchema/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "name": "Bruno Prieto Reis", + "email": "bruno.p.reis@gmail.com" + }, + { + "name": "Justin Rainbow", + "email": "justin.rainbow@gmail.com" + }, + { + "name": "Igor Wiedler", + "email": "igor@wiedler.ch" + }, + { + "name": "Robert Schönthal", + "email": "seroscho@googlemail.com" } ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", + "description": "A library to validate a json schema.", + "homepage": "https://github.com/justinrainbow/json-schema", "keywords": [ - "timer" + "json", + "schema" ], "support": { - "issues": "https://github.com/sebastianbergmann/php-timer/issues", - "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" + "issues": "https://github.com/jsonrainbow/json-schema/issues", + "source": "https://github.com/jsonrainbow/json-schema/tree/v5.2.13" }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-10-26T13:16:10+00:00" + "time": "2023-09-26T02:20:38+00:00" }, { - "name": "phpunit/phpunit", - "version": "9.6.11", + "name": "mikey179/vfsstream", + "version": "v1.6.11", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "810500e92855eba8a7a5319ae913be2da6f957b0" + "url": "https://github.com/bovigo/vfsStream.git", + "reference": "17d16a85e6c26ce1f3e2fa9ceeacdc2855db1e9f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/810500e92855eba8a7a5319ae913be2da6f957b0", - "reference": "810500e92855eba8a7a5319ae913be2da6f957b0", + "url": "https://api.github.com/repos/bovigo/vfsStream/zipball/17d16a85e6c26ce1f3e2fa9ceeacdc2855db1e9f", + "reference": "17d16a85e6c26ce1f3e2fa9ceeacdc2855db1e9f", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.3.1 || ^2", - "ext-dom": "*", - "ext-json": "*", - "ext-libxml": "*", - "ext-mbstring": "*", - "ext-xml": "*", - "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.10.1", - "phar-io/manifest": "^2.0.3", - "phar-io/version": "^3.0.2", - "php": ">=7.3", - "phpunit/php-code-coverage": "^9.2.13", - "phpunit/php-file-iterator": "^3.0.5", - "phpunit/php-invoker": "^3.1.1", - "phpunit/php-text-template": "^2.0.3", - "phpunit/php-timer": "^5.0.2", - "sebastian/cli-parser": "^1.0.1", - "sebastian/code-unit": "^1.0.6", - "sebastian/comparator": "^4.0.8", - "sebastian/diff": "^4.0.3", - "sebastian/environment": "^5.1.3", - "sebastian/exporter": "^4.0.5", - "sebastian/global-state": "^5.0.1", - "sebastian/object-enumerator": "^4.0.3", - "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^3.2", - "sebastian/version": "^3.0.2" + "php": ">=5.3.0" }, - "suggest": { - "ext-soap": "To be able to generate mocks based on WSDL files", - "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" + "require-dev": { + "phpunit/phpunit": "^4.5|^5.0" }, - "bin": [ - "phpunit" - ], "type": "library", "extra": { "branch-alias": { - "dev-master": "9.6-dev" + "dev-master": "1.6.x-dev" } }, "autoload": { - "files": [ - "src/Framework/Assert/Functions.php" - ], - "classmap": [ - "src/" - ] + "psr-0": { + "org\\bovigo\\vfs\\": "src/main/php" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -3374,330 +3185,404 @@ ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "name": "Frank Kleine", + "homepage": "http://frankkleine.de/", + "role": "Developer" } ], - "description": "The PHP Unit Testing framework.", - "homepage": "https://phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], + "description": "Virtual file system to mock the real file system in unit tests.", + "homepage": "http://vfs.bovigo.org/", "support": { - "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.11" + "issues": "https://github.com/bovigo/vfsStream/issues", + "source": "https://github.com/bovigo/vfsStream/tree/master", + "wiki": "https://github.com/bovigo/vfsStream/wiki" }, - "funding": [ - { - "url": "https://phpunit.de/sponsors.html", - "type": "custom" - }, - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", - "type": "tidelift" - } - ], - "time": "2023-08-19T07:10:56+00:00" + "time": "2022-02-23T02:02:42+00:00" }, { - "name": "psr/cache", - "version": "1.0.1", + "name": "myclabs/deep-copy", + "version": "1.11.1", "source": { "type": "git", - "url": "https://github.com/php-fig/cache.git", - "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", - "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": "^7.1 || ^8.0" }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3,<3.2.2" + }, + "require-dev": { + "doctrine/collections": "^1.6.8", + "doctrine/common": "^2.13.3 || ^3.2.2", + "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" }, + "type": "library", "autoload": { + "files": [ + "src/DeepCopy/deep_copy.php" + ], "psr-4": { - "Psr\\Cache\\": "src/" + "DeepCopy\\": "src/DeepCopy/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for caching libraries", + "description": "Create deep copies (clones) of your objects", "keywords": [ - "cache", - "psr", - "psr-6" + "clone", + "copy", + "duplicate", + "object", + "object graph" ], "support": { - "source": "https://github.com/php-fig/cache/tree/master" + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" }, - "time": "2016-08-06T20:24:11+00:00" + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2023-03-08T13:26:56+00:00" }, { - "name": "psr/log", - "version": "1.1.4", + "name": "phar-io/manifest", + "version": "2.0.3", "source": { "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + "url": "https://github.com/phar-io/manifest.git", + "reference": "97803eca37d319dfa7826cc2437fc020857acb53" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", + "reference": "97803eca37d319dfa7826cc2437fc020857acb53", "shasum": "" }, "require": { - "php": ">=5.3.0" + "ext-dom": "*", + "ext-phar": "*", + "ext-xmlwriter": "*", + "phar-io/version": "^3.0.1", + "php": "^7.2 || ^8.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" } ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", "support": { - "source": "https://github.com/php-fig/log/tree/1.1.4" + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/2.0.3" }, - "time": "2021-05-03T11:20:27+00:00" + "time": "2021-07-20T11:28:43+00:00" }, { - "name": "rector/rector", - "version": "0.18.2", + "name": "phar-io/version", + "version": "3.2.1", "source": { "type": "git", - "url": "https://github.com/rectorphp/rector.git", - "reference": "8606564b50ce70f99839d35c67f4536dc2ea090d" + "url": "https://github.com/phar-io/version.git", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" }, "dist": { - "type": "zip", - "url": "https://api.github.com/repos/rectorphp/rector/zipball/8606564b50ce70f99839d35c67f4536dc2ea090d", - "reference": "8606564b50ce70f99839d35c67f4536dc2ea090d", + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", "shasum": "" }, "require": { - "php": "^7.2|^8.0", - "phpstan/phpstan": "^1.10.31" - }, - "conflict": { - "rector/rector-doctrine": "*", - "rector/rector-downgrade-php": "*", - "rector/rector-phpunit": "*", - "rector/rector-symfony": "*" + "php": "^7.2 || ^8.0" }, - "bin": [ - "bin/rector" - ], "type": "library", "autoload": { - "files": [ - "bootstrap.php" + "classmap": [ + "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" - ], - "description": "Instant Upgrade and Automated Refactoring of any PHP code", - "keywords": [ - "automation", - "dev", - "migration", - "refactoring" + "BSD-3-Clause" ], - "support": { - "issues": "https://github.com/rectorphp/rector/issues", - "source": "https://github.com/rectorphp/rector/tree/0.18.2" - }, - "funding": [ + "authors": [ { - "url": "https://github.com/tomasvotruba", - "type": "github" + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" } ], - "time": "2023-09-06T08:50:38+00:00" + "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/3.2.1" + }, + "time": "2022-02-21T01:04:05+00:00" }, { - "name": "sebastian/cli-parser", - "version": "1.0.1", + "name": "phing/phing", + "version": "2.17.4", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" + "url": "https://github.com/phingofficial/phing.git", + "reference": "9f3bc8c72e65452686dcf64497e02a082f138908" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", - "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "url": "https://api.github.com/repos/phingofficial/phing/zipball/9f3bc8c72e65452686dcf64497e02a082f138908", + "reference": "9f3bc8c72e65452686dcf64497e02a082f138908", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=5.2.0" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "ext-pdo_sqlite": "*", + "mikey179/vfsstream": "^1.6", + "pdepend/pdepend": "2.x", + "pear/archive_tar": "1.4.x", + "pear/http_request2": "dev-trunk", + "pear/net_growl": "dev-trunk", + "pear/pear-core-minimal": "1.10.1", + "pear/versioncontrol_git": "@dev", + "pear/versioncontrol_svn": "~0.5", + "phpdocumentor/phpdocumentor": "2.x", + "phploc/phploc": "~2.0.6", + "phpmd/phpmd": "~2.2", + "phpunit/phpunit": ">=3.7", + "sebastian/git": "~1.0", + "sebastian/phpcpd": "2.x", + "siad007/versioncontrol_hg": "^1.0", + "simpletest/simpletest": "^1.1", + "squizlabs/php_codesniffer": "~2.2", + "symfony/yaml": "^2.8 || ^3.1 || ^4.0" + }, + "suggest": { + "pdepend/pdepend": "PHP version of JDepend", + "pear/archive_tar": "Tar file management class", + "pear/versioncontrol_git": "A library that provides OO interface to handle Git repository", + "pear/versioncontrol_svn": "A simple OO-style interface for Subversion, the free/open-source version control system", + "phpdocumentor/phpdocumentor": "Documentation Generator for PHP", + "phploc/phploc": "A tool for quickly measuring the size of a PHP project", + "phpmd/phpmd": "PHP version of PMD tool", + "phpunit/php-code-coverage": "Library that provides collection, processing, and rendering functionality for PHP code coverage information", + "phpunit/phpunit": "The PHP Unit Testing Framework", + "sebastian/phpcpd": "Copy/Paste Detector (CPD) for PHP code", + "siad007/versioncontrol_hg": "A library for interfacing with Mercurial repositories.", + "tedivm/jshrink": "Javascript Minifier built in PHP" }, + "bin": [ + "bin/phing" + ], "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "2.16.x-dev" } }, "autoload": { "classmap": [ - "src/" + "classes/phing/" ] }, "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "classes" + ], "license": [ - "BSD-3-Clause" + "LGPL-3.0-only" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "name": "Michiel Rook", + "email": "mrook@php.net" + }, + { + "name": "Phing Community", + "homepage": "https://www.phing.info/trac/wiki/Development/Contributors" } ], - "description": "Library for parsing CLI options", - "homepage": "https://github.com/sebastianbergmann/cli-parser", + "description": "PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant.", + "homepage": "https://www.phing.info/", + "keywords": [ + "build", + "phing", + "task", + "tool" + ], "support": { - "issues": "https://github.com/sebastianbergmann/cli-parser/issues", - "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" + "irc": "irc://irc.freenode.net/phing", + "issues": "https://www.phing.info/trac/report", + "source": "https://github.com/phingofficial/phing/tree/2.17.4" }, "funding": [ { - "url": "https://github.com/sebastianbergmann", + "url": "https://github.com/mrook", + "type": "github" + }, + { + "url": "https://github.com/siad007", "type": "github" + }, + { + "url": "https://www.patreon.com/michielrook", + "type": "patreon" } ], - "time": "2020-09-28T06:08:49+00:00" + "time": "2022-07-08T09:07:07+00:00" }, { - "name": "sebastian/code-unit", - "version": "1.0.8", + "name": "phpstan/phpstan", + "version": "1.10.33", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/code-unit.git", - "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" + "url": "https://github.com/phpstan/phpstan.git", + "reference": "03b1cf9f814ba0863c4e9affea49a4d1ed9a2ed1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", - "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/03b1cf9f814ba0863c4e9affea49a4d1ed9a2ed1", + "reference": "03b1cf9f814ba0863c4e9affea49a4d1ed9a2ed1", "shasum": "" }, "require": { - "php": ">=7.3" + "php": "^7.2|^8.0" }, - "require-dev": { - "phpunit/phpunit": "^9.3" + "conflict": { + "phpstan/phpstan-shim": "*" }, + "bin": [ + "phpstan", + "phpstan.phar" + ], "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, "autoload": { - "classmap": [ - "src/" + "files": [ + "bootstrap.php" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" ], - "description": "Collection of value objects that represent the PHP code units", - "homepage": "https://github.com/sebastianbergmann/code-unit", "support": { - "issues": "https://github.com/sebastianbergmann/code-unit/issues", - "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" }, "funding": [ { - "url": "https://github.com/sebastianbergmann", + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" } ], - "time": "2020-10-26T13:08:54+00:00" + "time": "2023-09-04T12:20:53+00:00" }, { - "name": "sebastian/code-unit-reverse-lookup", - "version": "2.0.3", + "name": "phpunit/php-code-coverage", + "version": "9.2.27", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", - "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/b0a88255cb70d52653d80c890bd7f38740ea50d1", + "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1", "shasum": "" }, "require": { - "php": ">=7.3" + "ext-dom": "*", + "ext-libxml": "*", + "ext-xmlwriter": "*", + "nikic/php-parser": "^4.15", + "php": ">=7.3", + "phpunit/php-file-iterator": "^3.0.3", + "phpunit/php-text-template": "^2.0.2", + "sebastian/code-unit-reverse-lookup": "^2.0.2", + "sebastian/complexity": "^2.0", + "sebastian/environment": "^5.1.2", + "sebastian/lines-of-code": "^1.0.3", + "sebastian/version": "^3.0.1", + "theseer/tokenizer": "^1.2.0" }, "require-dev": { "phpunit/phpunit": "^9.3" }, + "suggest": { + "ext-pcov": "PHP extension that provides line coverage", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "9.2-dev" } }, "autoload": { @@ -3712,14 +3597,21 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "Looks up which function or method a line of code belongs to", - "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], "support": { - "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", - "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.27" }, "funding": [ { @@ -3727,26 +3619,24 @@ "type": "github" } ], - "time": "2020-09-28T05:30:19+00:00" + "time": "2023-07-26T13:44:30+00:00" }, { - "name": "sebastian/comparator", - "version": "4.0.8", + "name": "phpunit/php-file-iterator", + "version": "3.0.6", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "fa0f136dd2334583309d32b62544682ee972b51a" + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a", - "reference": "fa0f136dd2334583309d32b62544682ee972b51a", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", "shasum": "" }, "require": { - "php": ">=7.3", - "sebastian/diff": "^4.0", - "sebastian/exporter": "^4.0" + "php": ">=7.3" }, "require-dev": { "phpunit/phpunit": "^9.3" @@ -3754,7 +3644,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -3769,31 +3659,19 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "https://github.com/sebastianbergmann/comparator", + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", "keywords": [ - "comparator", - "compare", - "equality" + "filesystem", + "iterator" ], "support": { - "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8" + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" }, "funding": [ { @@ -3801,33 +3679,36 @@ "type": "github" } ], - "time": "2022-09-14T12:41:17+00:00" + "time": "2021-12-02T12:48:52+00:00" }, { - "name": "sebastian/complexity", - "version": "2.0.2", + "name": "phpunit/php-invoker", + "version": "3.1.1", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", "shasum": "" }, "require": { - "nikic/php-parser": "^4.7", "php": ">=7.3" }, "require-dev": { + "ext-pcntl": "*", "phpunit/phpunit": "^9.3" }, + "suggest": { + "ext-pcntl": "*" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -3846,11 +3727,14 @@ "role": "lead" } ], - "description": "Library for calculating the complexity of PHP code units", - "homepage": "https://github.com/sebastianbergmann/complexity", + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], "support": { - "issues": "https://github.com/sebastianbergmann/complexity/issues", - "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" }, "funding": [ { @@ -3858,33 +3742,32 @@ "type": "github" } ], - "time": "2020-10-26T15:52:27+00:00" + "time": "2020-09-28T05:58:55+00:00" }, { - "name": "sebastian/diff", - "version": "4.0.5", + "name": "phpunit/php-text-template", + "version": "2.0.4", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131" + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/74be17022044ebaaecfdf0c5cd504fc9cd5a7131", - "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", "shasum": "" }, "require": { "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^9.3", - "symfony/process": "^4.2 || ^5" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -3899,24 +3782,18 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "Diff implementation", - "homepage": "https://github.com/sebastianbergmann/diff", + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", "keywords": [ - "diff", - "udiff", - "unidiff", - "unified diff" + "template" ], "support": { - "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/4.0.5" + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" }, "funding": [ { @@ -3924,20 +3801,20 @@ "type": "github" } ], - "time": "2023-05-07T05:35:17+00:00" + "time": "2020-10-26T05:33:50+00:00" }, { - "name": "sebastian/environment", - "version": "5.1.5", + "name": "phpunit/php-timer", + "version": "5.0.3", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed" + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", - "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", "shasum": "" }, "require": { @@ -3946,13 +3823,10 @@ "require-dev": { "phpunit/phpunit": "^9.3" }, - "suggest": { - "ext-posix": "*" - }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.1-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -3967,19 +3841,18 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", "keywords": [ - "Xdebug", - "environment", - "hhvm" + "timer" ], "support": { - "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/5.1.5" + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" }, "funding": [ { @@ -3987,37 +3860,68 @@ "type": "github" } ], - "time": "2023-02-03T06:03:51+00:00" + "time": "2020-10-26T13:16:10+00:00" }, { - "name": "sebastian/exporter", - "version": "4.0.5", + "name": "phpunit/phpunit", + "version": "9.6.11", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d" + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "810500e92855eba8a7a5319ae913be2da6f957b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", - "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/810500e92855eba8a7a5319ae913be2da6f957b0", + "reference": "810500e92855eba8a7a5319ae913be2da6f957b0", "shasum": "" }, "require": { + "doctrine/instantiator": "^1.3.1 || ^2", + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.10.1", + "phar-io/manifest": "^2.0.3", + "phar-io/version": "^3.0.2", "php": ">=7.3", - "sebastian/recursion-context": "^4.0" + "phpunit/php-code-coverage": "^9.2.13", + "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-invoker": "^3.1.1", + "phpunit/php-text-template": "^2.0.3", + "phpunit/php-timer": "^5.0.2", + "sebastian/cli-parser": "^1.0.1", + "sebastian/code-unit": "^1.0.6", + "sebastian/comparator": "^4.0.8", + "sebastian/diff": "^4.0.3", + "sebastian/environment": "^5.1.3", + "sebastian/exporter": "^4.0.5", + "sebastian/global-state": "^5.0.1", + "sebastian/object-enumerator": "^4.0.3", + "sebastian/resource-operations": "^3.0.3", + "sebastian/type": "^3.2", + "sebastian/version": "^3.0.2" }, - "require-dev": { - "ext-mbstring": "*", - "phpunit/phpunit": "^9.3" + "suggest": { + "ext-soap": "To be able to generate mocks based on WSDL files", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" }, + "bin": [ + "phpunit" + ], "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "9.6-dev" } }, "autoload": { + "files": [ + "src/Framework/Assert/Functions.php" + ], "classmap": [ "src/" ] @@ -4029,233 +3933,229 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "https://www.github.com/sebastianbergmann/exporter", + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", "keywords": [ - "export", - "exporter" + "phpunit", + "testing", + "xunit" ], "support": { - "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5" + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.11" }, "funding": [ + { + "url": "https://phpunit.de/sponsors.html", + "type": "custom" + }, { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" } ], - "time": "2022-09-14T06:03:37+00:00" + "time": "2023-08-19T07:10:56+00:00" }, { - "name": "sebastian/global-state", - "version": "5.0.6", + "name": "psr/log", + "version": "1.1.4", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bde739e7565280bda77be70044ac1047bc007e34" + "url": "https://github.com/php-fig/log.git", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bde739e7565280bda77be70044ac1047bc007e34", - "reference": "bde739e7565280bda77be70044ac1047bc007e34", + "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11", "shasum": "" }, "require": { - "php": ">=7.3", - "sebastian/object-reflector": "^2.0", - "sebastian/recursion-context": "^4.0" - }, - "require-dev": { - "ext-dom": "*", - "phpunit/phpunit": "^9.3" - }, - "suggest": { - "ext-uopz": "*" + "php": ">=5.3.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0-dev" + "dev-master": "1.1.x-dev" } }, "autoload": { - "classmap": [ - "src/" - ] + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" } ], - "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", "keywords": [ - "global state" + "log", + "psr", + "psr-3" ], "support": { - "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.6" + "source": "https://github.com/php-fig/log/tree/1.1.4" }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2023-08-02T09:26:13+00:00" + "time": "2021-05-03T11:20:27+00:00" }, { - "name": "sebastian/lines-of-code", - "version": "1.0.3", + "name": "react/promise", + "version": "v3.2.0", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" + "url": "https://github.com/reactphp/promise.git", + "reference": "8a164643313c71354582dc850b42b33fa12a4b63" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "url": "https://api.github.com/repos/reactphp/promise/zipball/8a164643313c71354582dc850b42b33fa12a4b63", + "reference": "8a164643313c71354582dc850b42b33fa12a4b63", "shasum": "" }, "require": { - "nikic/php-parser": "^4.6", - "php": ">=7.3" + "php": ">=7.1.0" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpstan/phpstan": "1.10.39 || 1.4.10", + "phpunit/phpunit": "^9.6 || ^7.5" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, "autoload": { - "classmap": [ - "src/" - ] + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "React\\Promise\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" } ], - "description": "Library for counting the lines of code in PHP source code", - "homepage": "https://github.com/sebastianbergmann/lines-of-code", + "description": "A lightweight implementation of CommonJS Promises/A for PHP", + "keywords": [ + "promise", + "promises" + ], "support": { - "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", - "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" + "issues": "https://github.com/reactphp/promise/issues", + "source": "https://github.com/reactphp/promise/tree/v3.2.0" }, "funding": [ { - "url": "https://github.com/sebastianbergmann", - "type": "github" + "url": "https://opencollective.com/reactphp", + "type": "open_collective" } ], - "time": "2020-11-28T06:42:11+00:00" + "time": "2024-05-24T10:39:05+00:00" }, { - "name": "sebastian/object-enumerator", - "version": "4.0.4", + "name": "rector/rector", + "version": "0.18.2", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" + "url": "https://github.com/rectorphp/rector.git", + "reference": "8606564b50ce70f99839d35c67f4536dc2ea090d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", - "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/8606564b50ce70f99839d35c67f4536dc2ea090d", + "reference": "8606564b50ce70f99839d35c67f4536dc2ea090d", "shasum": "" }, "require": { - "php": ">=7.3", - "sebastian/object-reflector": "^2.0", - "sebastian/recursion-context": "^4.0" + "php": "^7.2|^8.0", + "phpstan/phpstan": "^1.10.31" }, - "require-dev": { - "phpunit/phpunit": "^9.3" + "conflict": { + "rector/rector-doctrine": "*", + "rector/rector-downgrade-php": "*", + "rector/rector-phpunit": "*", + "rector/rector-symfony": "*" }, + "bin": [ + "bin/rector" + ], "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0-dev" - } - }, "autoload": { - "classmap": [ - "src/" + "files": [ + "bootstrap.php" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } + "description": "Instant Upgrade and Automated Refactoring of any PHP code", + "keywords": [ + "automation", + "dev", + "migration", + "refactoring" ], - "description": "Traverses array structures and object graphs to enumerate all referenced objects", - "homepage": "https://github.com/sebastianbergmann/object-enumerator/", "support": { - "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", - "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" + "issues": "https://github.com/rectorphp/rector/issues", + "source": "https://github.com/rectorphp/rector/tree/0.18.2" }, "funding": [ { - "url": "https://github.com/sebastianbergmann", + "url": "https://github.com/tomasvotruba", "type": "github" } ], - "time": "2020-10-26T13:12:34+00:00" + "time": "2023-09-06T08:50:38+00:00" }, { - "name": "sebastian/object-reflector", - "version": "2.0.4", + "name": "sebastian/cli-parser", + "version": "1.0.1", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" + "url": "https://github.com/sebastianbergmann/cli-parser.git", + "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", - "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", "shasum": "" }, "require": { @@ -4267,7 +4167,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "1.0-dev" } }, "autoload": { @@ -4282,14 +4182,15 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "Allows reflection of object attributes, including inherited and non-public ones", - "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "description": "Library for parsing CLI options", + "homepage": "https://github.com/sebastianbergmann/cli-parser", "support": { - "issues": "https://github.com/sebastianbergmann/object-reflector/issues", - "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" + "issues": "https://github.com/sebastianbergmann/cli-parser/issues", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" }, "funding": [ { @@ -4297,20 +4198,20 @@ "type": "github" } ], - "time": "2020-10-26T13:14:26+00:00" + "time": "2020-09-28T06:08:49+00:00" }, { - "name": "sebastian/recursion-context", - "version": "4.0.5", + "name": "sebastian/code-unit", + "version": "1.0.8", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1" + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", - "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", "shasum": "" }, "require": { @@ -4322,7 +4223,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "1.0-dev" } }, "autoload": { @@ -4337,22 +4238,15 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "Provides functionality to recursively process PHP variables", - "homepage": "https://github.com/sebastianbergmann/recursion-context", + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", "support": { - "issues": "https://github.com/sebastianbergmann/recursion-context/issues", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.5" + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" }, "funding": [ { @@ -4360,32 +4254,32 @@ "type": "github" } ], - "time": "2023-02-03T06:07:39+00:00" + "time": "2020-10-26T13:08:54+00:00" }, { - "name": "sebastian/resource-operations", - "version": "3.0.3", + "name": "sebastian/code-unit-reverse-lookup", + "version": "2.0.3", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", - "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", "shasum": "" }, "require": { "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^9.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -4403,11 +4297,11 @@ "email": "sebastian@phpunit.de" } ], - "description": "Provides a list of PHP built-in functions that operate on resources", - "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", "support": { - "issues": "https://github.com/sebastianbergmann/resource-operations/issues", - "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" }, "funding": [ { @@ -4415,32 +4309,34 @@ "type": "github" } ], - "time": "2020-09-28T06:45:17+00:00" + "time": "2020-09-28T05:30:19+00:00" }, { - "name": "sebastian/type", - "version": "3.2.1", + "name": "sebastian/comparator", + "version": "4.0.8", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/type.git", - "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7" + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "fa0f136dd2334583309d32b62544682ee972b51a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", - "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a", + "reference": "fa0f136dd2334583309d32b62544682ee972b51a", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=7.3", + "sebastian/diff": "^4.0", + "sebastian/exporter": "^4.0" }, "require-dev": { - "phpunit/phpunit": "^9.5" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -4455,15 +4351,31 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" } ], - "description": "Collection of value objects that represent the types of the PHP type system", - "homepage": "https://github.com/sebastianbergmann/type", + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], "support": { - "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/3.2.1" + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8" }, "funding": [ { @@ -4471,29 +4383,33 @@ "type": "github" } ], - "time": "2023-02-03T06:13:03+00:00" + "time": "2022-09-14T12:41:17+00:00" }, { - "name": "sebastian/version", - "version": "3.0.2", + "name": "sebastian/complexity", + "version": "2.0.2", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "c6c1022351a901512170118436c764e473f6de8c" + "url": "https://github.com/sebastianbergmann/complexity.git", + "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", - "reference": "c6c1022351a901512170118436c764e473f6de8c", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", + "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", "shasum": "" }, "require": { + "nikic/php-parser": "^4.7", "php": ">=7.3" }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -4512,11 +4428,11 @@ "role": "lead" } ], - "description": "Library that helps with managing the version number of Git-hosted PHP projects", - "homepage": "https://github.com/sebastianbergmann/version", + "description": "Library for calculating the complexity of PHP code units", + "homepage": "https://github.com/sebastianbergmann/complexity", "support": { - "issues": "https://github.com/sebastianbergmann/version/issues", - "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" + "issues": "https://github.com/sebastianbergmann/complexity/issues", + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" }, "funding": [ { @@ -4524,1043 +4440,703 @@ "type": "github" } ], - "time": "2020-09-28T06:39:44+00:00" + "time": "2020-10-26T15:52:27+00:00" }, { - "name": "seld/phar-utils", - "version": "1.2.1", + "name": "sebastian/diff", + "version": "4.0.5", "source": { "type": "git", - "url": "https://github.com/Seldaek/phar-utils.git", - "reference": "ea2f4014f163c1be4c601b9b7bd6af81ba8d701c" + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/phar-utils/zipball/ea2f4014f163c1be4c601b9b7bd6af81ba8d701c", - "reference": "ea2f4014f163c1be4c601b9b7bd6af81ba8d701c", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/74be17022044ebaaecfdf0c5cd504fc9cd5a7131", + "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131", "shasum": "" }, "require": { - "php": ">=5.3" + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3", + "symfony/process": "^4.2 || ^5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Seld\\PharUtils\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be" + "dev-master": "4.0-dev" } - ], - "description": "PHAR file format utilities, for when PHP phars you up", - "keywords": [ - "phar" - ], - "support": { - "issues": "https://github.com/Seldaek/phar-utils/issues", - "source": "https://github.com/Seldaek/phar-utils/tree/1.2.1" - }, - "time": "2022-08-31T10:31:18+00:00" - }, - { - "name": "symfony/cache", - "version": "v5.4.40", - "source": { - "type": "git", - "url": "https://github.com/symfony/cache.git", - "reference": "89005bc368ca02ed0433c592e4d27670d0844a66" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/cache/zipball/89005bc368ca02ed0433c592e4d27670d0844a66", - "reference": "89005bc368ca02ed0433c592e4d27670d0844a66", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "psr/cache": "^1.0|^2.0", - "psr/log": "^1.1|^2|^3", - "symfony/cache-contracts": "^1.1.7|^2", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-php73": "^1.9", - "symfony/polyfill-php80": "^1.16", - "symfony/service-contracts": "^1.1|^2|^3", - "symfony/var-exporter": "^4.4|^5.0|^6.0" - }, - "conflict": { - "doctrine/dbal": "<2.13.1", - "symfony/dependency-injection": "<4.4", - "symfony/http-kernel": "<4.4", - "symfony/var-dumper": "<4.4" - }, - "provide": { - "psr/cache-implementation": "1.0|2.0", - "psr/simple-cache-implementation": "1.0|2.0", - "symfony/cache-implementation": "1.0|2.0" - }, - "require-dev": { - "cache/integration-tests": "dev-master", - "doctrine/cache": "^1.6|^2.0", - "doctrine/dbal": "^2.13.1|^3|^4", - "predis/predis": "^1.1|^2.0", - "psr/simple-cache": "^1.0|^2.0", - "symfony/config": "^4.4|^5.0|^6.0", - "symfony/dependency-injection": "^4.4|^5.0|^6.0", - "symfony/filesystem": "^4.4|^5.0|^6.0", - "symfony/http-kernel": "^4.4|^5.0|^6.0", - "symfony/messenger": "^4.4|^5.0|^6.0", - "symfony/var-dumper": "^4.4|^5.0|^6.0" }, - "type": "library", "autoload": { - "psr-4": { - "Symfony\\Component\\Cache\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" + "classmap": [ + "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" }, { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" } ], - "description": "Provides extended PSR-6, PSR-16 (and tags) implementations", - "homepage": "https://symfony.com", + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", "keywords": [ - "caching", - "psr6" + "diff", + "udiff", + "unidiff", + "unified diff" ], "support": { - "source": "https://github.com/symfony/cache/tree/v5.4.40" + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.5" }, "funding": [ { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", + "url": "https://github.com/sebastianbergmann", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" } ], - "time": "2024-05-31T14:33:22+00:00" + "time": "2023-05-07T05:35:17+00:00" }, { - "name": "symfony/cache-contracts", - "version": "v2.5.3", + "name": "sebastian/environment", + "version": "5.1.5", "source": { "type": "git", - "url": "https://github.com/symfony/cache-contracts.git", - "reference": "fee6db04d913094e2fb55ff8e7db5685a8134463" + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/cache-contracts/zipball/fee6db04d913094e2fb55ff8e7db5685a8134463", - "reference": "fee6db04d913094e2fb55ff8e7db5685a8134463", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", "shasum": "" }, "require": { - "php": ">=7.2.5", - "psr/cache": "^1.0|^2.0|^3.0" + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" }, "suggest": { - "symfony/cache-implementation": "" + "ext-posix": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "2.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" + "dev-master": "5.1-dev" } }, "autoload": { - "psr-4": { - "Symfony\\Contracts\\Cache\\": "" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" } ], - "description": "Generic abstractions related to caching", - "homepage": "https://symfony.com", + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", "keywords": [ - "abstractions", - "contracts", - "decoupling", - "interfaces", - "interoperability", - "standards" + "Xdebug", + "environment", + "hhvm" ], "support": { - "source": "https://github.com/symfony/cache-contracts/tree/v2.5.3" + "issues": "https://github.com/sebastianbergmann/environment/issues", + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.5" }, "funding": [ { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", + "url": "https://github.com/sebastianbergmann", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" } ], - "time": "2024-01-23T13:51:25+00:00" + "time": "2023-02-03T06:03:51+00:00" }, { - "name": "symfony/config", - "version": "v5.4.40", + "name": "sebastian/exporter", + "version": "4.0.5", "source": { "type": "git", - "url": "https://github.com/symfony/config.git", - "reference": "d4e1db78421163b98dd9971d247fd0df4a57ee5e" + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/d4e1db78421163b98dd9971d247fd0df4a57ee5e", - "reference": "d4e1db78421163b98dd9971d247fd0df4a57ee5e", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/filesystem": "^4.4|^5.0|^6.0", - "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-php80": "^1.16", - "symfony/polyfill-php81": "^1.22" + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", + "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", + "shasum": "" }, - "conflict": { - "symfony/finder": "<4.4" + "require": { + "php": ">=7.3", + "sebastian/recursion-context": "^4.0" }, "require-dev": { - "symfony/event-dispatcher": "^4.4|^5.0|^6.0", - "symfony/finder": "^4.4|^5.0|^6.0", - "symfony/messenger": "^4.4|^5.0|^6.0", - "symfony/service-contracts": "^1.1|^2|^3", - "symfony/yaml": "^4.4|^5.0|^6.0" - }, - "suggest": { - "symfony/yaml": "To use the yaml reference dumper" + "ext-mbstring": "*", + "phpunit/phpunit": "^9.3" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, "autoload": { - "psr-4": { - "Symfony\\Component\\Config\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" + "classmap": [ + "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" }, { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" } ], - "description": "Helps you find, load, combine, autofill and validate configuration values of any kind", - "homepage": "https://symfony.com", + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "https://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], "support": { - "source": "https://github.com/symfony/config/tree/v5.4.40" + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5" }, "funding": [ { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", + "url": "https://github.com/sebastianbergmann", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" } ], - "time": "2024-05-31T14:33:22+00:00" + "time": "2022-09-14T06:03:37+00:00" }, { - "name": "symfony/dependency-injection", - "version": "v5.4.40", + "name": "sebastian/global-state", + "version": "5.0.6", "source": { "type": "git", - "url": "https://github.com/symfony/dependency-injection.git", - "reference": "408b33326496030c201b8051b003e9e8cdb2efc9" + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "bde739e7565280bda77be70044ac1047bc007e34" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/408b33326496030c201b8051b003e9e8cdb2efc9", - "reference": "408b33326496030c201b8051b003e9e8cdb2efc9", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bde739e7565280bda77be70044ac1047bc007e34", + "reference": "bde739e7565280bda77be70044ac1047bc007e34", "shasum": "" }, "require": { - "php": ">=7.2.5", - "psr/container": "^1.1.1", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-php80": "^1.16", - "symfony/polyfill-php81": "^1.22", - "symfony/service-contracts": "^1.1.6|^2" - }, - "conflict": { - "ext-psr": "<1.1|>=2", - "symfony/config": "<5.3", - "symfony/finder": "<4.4", - "symfony/proxy-manager-bridge": "<4.4", - "symfony/yaml": "<4.4.26" - }, - "provide": { - "psr/container-implementation": "1.0", - "symfony/service-implementation": "1.0|2.0" + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" }, "require-dev": { - "symfony/config": "^5.3|^6.0", - "symfony/expression-language": "^4.4|^5.0|^6.0", - "symfony/yaml": "^4.4.26|^5.0|^6.0" + "ext-dom": "*", + "phpunit/phpunit": "^9.3" }, "suggest": { - "symfony/config": "", - "symfony/expression-language": "For using expressions in service container configuration", - "symfony/finder": "For using double-star glob patterns or when GLOB_BRACE portability is required", - "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", - "symfony/yaml": "" + "ext-uopz": "*" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, "autoload": { - "psr-4": { - "Symfony\\Component\\DependencyInjection\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" + "classmap": [ + "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" } ], - "description": "Allows you to standardize and centralize the way objects are constructed in your application", - "homepage": "https://symfony.com", + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], "support": { - "source": "https://github.com/symfony/dependency-injection/tree/v5.4.40" + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.6" }, "funding": [ { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", + "url": "https://github.com/sebastianbergmann", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" } ], - "time": "2024-05-31T14:33:22+00:00" + "time": "2023-08-02T09:26:13+00:00" }, { - "name": "symfony/error-handler", - "version": "v5.4.40", + "name": "sebastian/lines-of-code", + "version": "1.0.3", "source": { "type": "git", - "url": "https://github.com/symfony/error-handler.git", - "reference": "c6c8f965a87b22d5005a7806783c7f10ae7e58cd" + "url": "https://github.com/sebastianbergmann/lines-of-code.git", + "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/error-handler/zipball/c6c8f965a87b22d5005a7806783c7f10ae7e58cd", - "reference": "c6c8f965a87b22d5005a7806783c7f10ae7e58cd", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", "shasum": "" }, "require": { - "php": ">=7.2.5", - "psr/log": "^1|^2|^3", - "symfony/var-dumper": "^4.4|^5.0|^6.0" + "nikic/php-parser": "^4.6", + "php": ">=7.3" }, "require-dev": { - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/http-kernel": "^4.4|^5.0|^6.0", - "symfony/serializer": "^4.4|^5.0|^6.0" + "phpunit/phpunit": "^9.3" }, - "bin": [ - "Resources/bin/patch-type-declarations" - ], "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, "autoload": { - "psr-4": { - "Symfony\\Component\\ErrorHandler\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" + "classmap": [ + "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "Provides tools to manage errors and ease debugging PHP code", - "homepage": "https://symfony.com", + "description": "Library for counting the lines of code in PHP source code", + "homepage": "https://github.com/sebastianbergmann/lines-of-code", "support": { - "source": "https://github.com/symfony/error-handler/tree/v5.4.40" + "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" }, "funding": [ { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", + "url": "https://github.com/sebastianbergmann", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" } ], - "time": "2024-05-31T14:33:22+00:00" + "time": "2020-11-28T06:42:11+00:00" }, { - "name": "symfony/framework-bundle", - "version": "v5.4.40", + "name": "sebastian/object-enumerator", + "version": "4.0.4", "source": { "type": "git", - "url": "https://github.com/symfony/framework-bundle.git", - "reference": "603090d8327e279bd233d5ce42a1ed89bc91612f" + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/framework-bundle/zipball/603090d8327e279bd233d5ce42a1ed89bc91612f", - "reference": "603090d8327e279bd233d5ce42a1ed89bc91612f", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", "shasum": "" }, "require": { - "ext-xml": "*", - "php": ">=7.2.5", - "symfony/cache": "^5.2|^6.0", - "symfony/config": "^5.3|^6.0", - "symfony/dependency-injection": "^5.4.5|^6.0.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/error-handler": "^4.4.1|^5.0.1|^6.0", - "symfony/event-dispatcher": "^5.1|^6.0", - "symfony/filesystem": "^4.4|^5.0|^6.0", - "symfony/finder": "^4.4|^5.0|^6.0", - "symfony/http-foundation": "^5.4.24|^6.2.11", - "symfony/http-kernel": "^5.4|^6.0", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php80": "^1.16", - "symfony/polyfill-php81": "^1.22", - "symfony/routing": "^5.3|^6.0" - }, - "conflict": { - "doctrine/annotations": "<1.13.1", - "doctrine/cache": "<1.11", - "doctrine/persistence": "<1.3", - "phpdocumentor/reflection-docblock": "<3.2.2", - "phpdocumentor/type-resolver": "<1.4.0", - "symfony/asset": "<5.3", - "symfony/console": "<5.2.5|>=7.0", - "symfony/dom-crawler": "<4.4", - "symfony/dotenv": "<5.1", - "symfony/form": "<5.2", - "symfony/http-client": "<4.4", - "symfony/lock": "<4.4", - "symfony/mailer": "<5.2", - "symfony/messenger": "<5.4", - "symfony/mime": "<4.4", - "symfony/property-access": "<5.3", - "symfony/property-info": "<4.4", - "symfony/security-csrf": "<5.3", - "symfony/serializer": "<5.2", - "symfony/service-contracts": ">=3.0", - "symfony/stopwatch": "<4.4", - "symfony/translation": "<5.3", - "symfony/twig-bridge": "<4.4", - "symfony/twig-bundle": "<4.4", - "symfony/validator": "<5.3.11", - "symfony/web-profiler-bundle": "<4.4", - "symfony/workflow": "<5.2" + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" }, "require-dev": { - "doctrine/annotations": "^1.13.1|^2", - "doctrine/cache": "^1.11|^2.0", - "doctrine/persistence": "^1.3|^2|^3", - "phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0", - "symfony/asset": "^5.3|^6.0", - "symfony/browser-kit": "^5.4|^6.0", - "symfony/console": "^5.4.9|^6.0.9", - "symfony/css-selector": "^4.4|^5.0|^6.0", - "symfony/dom-crawler": "^4.4.30|^5.3.7|^6.0", - "symfony/dotenv": "^5.1|^6.0", - "symfony/expression-language": "^4.4|^5.0|^6.0", - "symfony/form": "^5.2|^6.0", - "symfony/http-client": "^4.4|^5.0|^6.0", - "symfony/lock": "^4.4|^5.0|^6.0", - "symfony/mailer": "^5.2|^6.0", - "symfony/messenger": "^5.4|^6.0", - "symfony/mime": "^4.4|^5.0|^6.0", - "symfony/notifier": "^5.4|^6.0", - "symfony/polyfill-intl-icu": "~1.0", - "symfony/process": "^4.4|^5.0|^6.0", - "symfony/property-info": "^4.4|^5.0|^6.0", - "symfony/rate-limiter": "^5.2|^6.0", - "symfony/security-bundle": "^5.4|^6.0", - "symfony/serializer": "^5.4|^6.0", - "symfony/stopwatch": "^4.4|^5.0|^6.0", - "symfony/string": "^5.0|^6.0", - "symfony/translation": "^5.3|^6.0", - "symfony/twig-bundle": "^4.4|^5.0|^6.0", - "symfony/validator": "^5.3.11|^6.0", - "symfony/web-link": "^4.4|^5.0|^6.0", - "symfony/workflow": "^5.2|^6.0", - "symfony/yaml": "^4.4|^5.0|^6.0", - "twig/twig": "^2.10|^3.0.4" + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } }, - "suggest": { - "ext-apcu": "For best performance of the system caches", - "symfony/console": "For using the console commands", - "symfony/form": "For using forms", - "symfony/property-info": "For using the property_info service", - "symfony/serializer": "For using the serializer service", - "symfony/validator": "For using validation", - "symfony/web-link": "For using web links, features such as preloading, prefetching or prerendering", - "symfony/yaml": "For using the debug:config and lint:yaml commands" - }, - "type": "symfony-bundle", "autoload": { - "psr-4": { - "Symfony\\Bundle\\FrameworkBundle\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" + "classmap": [ + "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" } ], - "description": "Provides a tight integration between Symfony components and the Symfony full-stack framework", - "homepage": "https://symfony.com", + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", "support": { - "source": "https://github.com/symfony/framework-bundle/tree/v5.4.40" + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" }, "funding": [ { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" + "url": "https://github.com/sebastianbergmann", + "type": "github" } ], - "time": "2024-05-31T14:33:22+00:00" + "time": "2020-10-26T13:12:34+00:00" }, { - "name": "symfony/http-foundation", - "version": "v5.4.40", + "name": "sebastian/object-reflector", + "version": "2.0.4", "source": { "type": "git", - "url": "https://github.com/symfony/http-foundation.git", - "reference": "cf4893ca4eca3fac4ae06da1590afdbbb4217847" + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/cf4893ca4eca3fac4ae06da1590afdbbb4217847", - "reference": "cf4893ca4eca3fac4ae06da1590afdbbb4217847", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-mbstring": "~1.1", - "symfony/polyfill-php80": "^1.16" + "php": ">=7.3" }, "require-dev": { - "predis/predis": "^1.0|^2.0", - "symfony/cache": "^4.4|^5.0|^6.0", - "symfony/dependency-injection": "^5.4|^6.0", - "symfony/expression-language": "^4.4|^5.0|^6.0", - "symfony/http-kernel": "^5.4.12|^6.0.12|^6.1.4", - "symfony/mime": "^4.4|^5.0|^6.0", - "symfony/rate-limiter": "^5.2|^6.0" - }, - "suggest": { - "symfony/mime": "To use the file extension guesser" + "phpunit/phpunit": "^9.3" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, "autoload": { - "psr-4": { - "Symfony\\Component\\HttpFoundation\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" + "classmap": [ + "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" } ], - "description": "Defines an object-oriented layer for the HTTP specification", - "homepage": "https://symfony.com", + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v5.4.40" + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" }, "funding": [ { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", + "url": "https://github.com/sebastianbergmann", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" } ], - "time": "2024-05-31T14:33:22+00:00" + "time": "2020-10-26T13:14:26+00:00" }, { - "name": "symfony/http-kernel", - "version": "v5.4.40", + "name": "sebastian/recursion-context", + "version": "4.0.5", "source": { "type": "git", - "url": "https://github.com/symfony/http-kernel.git", - "reference": "3ad03183c6985adc2eece16f239f8cfe1c4ccbe3" + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/3ad03183c6985adc2eece16f239f8cfe1c4ccbe3", - "reference": "3ad03183c6985adc2eece16f239f8cfe1c4ccbe3", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", + "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", "shasum": "" }, "require": { - "php": ">=7.2.5", - "psr/log": "^1|^2", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/error-handler": "^4.4|^5.0|^6.0", - "symfony/event-dispatcher": "^5.0|^6.0", - "symfony/http-foundation": "^5.4.21|^6.2.7", - "symfony/polyfill-ctype": "^1.8", - "symfony/polyfill-php73": "^1.9", - "symfony/polyfill-php80": "^1.16" - }, - "conflict": { - "symfony/browser-kit": "<5.4", - "symfony/cache": "<5.0", - "symfony/config": "<5.0", - "symfony/console": "<4.4", - "symfony/dependency-injection": "<5.3", - "symfony/doctrine-bridge": "<5.0", - "symfony/form": "<5.0", - "symfony/http-client": "<5.0", - "symfony/mailer": "<5.0", - "symfony/messenger": "<5.0", - "symfony/translation": "<5.0", - "symfony/twig-bridge": "<5.0", - "symfony/validator": "<5.0", - "twig/twig": "<2.13" - }, - "provide": { - "psr/log-implementation": "1.0|2.0" + "php": ">=7.3" }, "require-dev": { - "psr/cache": "^1.0|^2.0|^3.0", - "symfony/browser-kit": "^5.4|^6.0", - "symfony/config": "^5.0|^6.0", - "symfony/console": "^4.4|^5.0|^6.0", - "symfony/css-selector": "^4.4|^5.0|^6.0", - "symfony/dependency-injection": "^5.3|^6.0", - "symfony/dom-crawler": "^4.4|^5.0|^6.0", - "symfony/expression-language": "^4.4|^5.0|^6.0", - "symfony/finder": "^4.4|^5.0|^6.0", - "symfony/http-client-contracts": "^1.1|^2|^3", - "symfony/process": "^4.4|^5.0|^6.0", - "symfony/routing": "^4.4|^5.0|^6.0", - "symfony/stopwatch": "^4.4|^5.0|^6.0", - "symfony/translation": "^4.4|^5.0|^6.0", - "symfony/translation-contracts": "^1.1|^2|^3", - "symfony/var-dumper": "^4.4.31|^5.4", - "twig/twig": "^2.13|^3.0.4" - }, - "suggest": { - "symfony/browser-kit": "", - "symfony/config": "", - "symfony/console": "", - "symfony/dependency-injection": "" + "phpunit/phpunit": "^9.3" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, "autoload": { - "psr-4": { - "Symfony\\Component\\HttpKernel\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" + "classmap": [ + "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" }, { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" } ], - "description": "Provides a structured process for converting a Request into a Response", - "homepage": "https://symfony.com", + "description": "Provides functionality to recursively process PHP variables", + "homepage": "https://github.com/sebastianbergmann/recursion-context", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v5.4.40" + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.5" }, "funding": [ { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", + "url": "https://github.com/sebastianbergmann", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" } ], - "time": "2024-06-02T15:53:08+00:00" + "time": "2023-02-03T06:07:39+00:00" }, { - "name": "symfony/options-resolver", - "version": "v5.4.21", + "name": "sebastian/resource-operations", + "version": "3.0.3", "source": { "type": "git", - "url": "https://github.com/symfony/options-resolver.git", - "reference": "4fe5cf6ede71096839f0e4b4444d65dd3a7c1eb9" + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/4fe5cf6ede71096839f0e4b4444d65dd3a7c1eb9", - "reference": "4fe5cf6ede71096839f0e4b4444d65dd3a7c1eb9", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", + "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-php73": "~1.0", - "symfony/polyfill-php80": "^1.16" + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, "autoload": { - "psr-4": { - "Symfony\\Component\\OptionsResolver\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" + "classmap": [ + "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" } ], - "description": "Provides an improved replacement for the array_replace PHP function", - "homepage": "https://symfony.com", - "keywords": [ - "config", - "configuration", - "options" - ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", "support": { - "source": "https://github.com/symfony/options-resolver/tree/v5.4.21" + "issues": "https://github.com/sebastianbergmann/resource-operations/issues", + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" }, "funding": [ { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", + "url": "https://github.com/sebastianbergmann", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" } ], - "time": "2023-02-14T08:03:56+00:00" + "time": "2020-09-28T06:45:17+00:00" }, { - "name": "symfony/profiler-pack", - "version": "v1.0.6", + "name": "sebastian/type", + "version": "3.2.1", "source": { "type": "git", - "url": "https://github.com/symfony/profiler-pack.git", - "reference": "bcd6e80af9819454ac18594362e7875fd1d771c7" + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/profiler-pack/zipball/bcd6e80af9819454ac18594362e7875fd1d771c7", - "reference": "bcd6e80af9819454ac18594362e7875fd1d771c7", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", "shasum": "" }, "require": { - "symfony/stopwatch": "*", - "symfony/web-profiler-bundle": "*" + "php": ">=7.3" }, "require-dev": { - "symfony/stopwatch": "*", - "symfony/web-profiler-bundle": "*" + "phpunit/phpunit": "^9.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] }, - "type": "symfony-pack", "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], - "description": "A pack for the Symfony web profiler", + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", "support": { - "issues": "https://github.com/symfony/profiler-pack/issues", - "source": "https://github.com/symfony/profiler-pack/tree/v1.0.6" + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/3.2.1" }, "funding": [ { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", + "url": "https://github.com/sebastianbergmann", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" } ], - "time": "2021-08-20T17:27:58+00:00" + "time": "2023-02-03T06:13:03+00:00" }, { - "name": "symfony/routing", - "version": "v5.4.40", + "name": "sebastian/version", + "version": "3.0.2", "source": { "type": "git", - "url": "https://github.com/symfony/routing.git", - "reference": "6df1dd8b306649303267a760699cf04cf39b1f7b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/6df1dd8b306649303267a760699cf04cf39b1f7b", - "reference": "6df1dd8b306649303267a760699cf04cf39b1f7b", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-php80": "^1.16" - }, - "conflict": { - "doctrine/annotations": "<1.12", - "symfony/config": "<5.3", - "symfony/dependency-injection": "<4.4", - "symfony/yaml": "<4.4" + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "c6c1022351a901512170118436c764e473f6de8c" }, - "require-dev": { - "doctrine/annotations": "^1.12|^2", - "psr/log": "^1|^2|^3", - "symfony/config": "^5.3|^6.0", - "symfony/dependency-injection": "^4.4|^5.0|^6.0", - "symfony/expression-language": "^4.4|^5.0|^6.0", - "symfony/http-foundation": "^4.4|^5.0|^6.0", - "symfony/yaml": "^4.4|^5.0|^6.0" + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", + "reference": "c6c1022351a901512170118436c764e473f6de8c", + "shasum": "" }, - "suggest": { - "symfony/config": "For using the all-in-one router or any loader", - "symfony/expression-language": "For using expression matching", - "symfony/http-foundation": "For using a Symfony Request object", - "symfony/yaml": "For using the YAML loader" + "require": { + "php": ">=7.3" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, "autoload": { - "psr-4": { - "Symfony\\Component\\Routing\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" + "classmap": [ + "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "Maps an HTTP request to a set of configuration variables", - "homepage": "https://symfony.com", - "keywords": [ - "router", - "routing", - "uri", - "url" - ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", "support": { - "source": "https://github.com/symfony/routing/tree/v5.4.40" + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" }, "funding": [ { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", + "url": "https://github.com/sebastianbergmann", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" } ], - "time": "2024-05-31T14:33:22+00:00" + "time": "2020-09-28T06:39:44+00:00" }, { - "name": "symfony/stopwatch", - "version": "v5.4.40", + "name": "seld/jsonlint", + "version": "1.10.2", "source": { "type": "git", - "url": "https://github.com/symfony/stopwatch.git", - "reference": "0e9daf3b7c805c747638b2cc48f1649e594f9625" + "url": "https://github.com/Seldaek/jsonlint.git", + "reference": "9bb7db07b5d66d90f6ebf542f09fc67d800e5259" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/0e9daf3b7c805c747638b2cc48f1649e594f9625", - "reference": "0e9daf3b7c805c747638b2cc48f1649e594f9625", + "url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/9bb7db07b5d66d90f6ebf542f09fc67d800e5259", + "reference": "9bb7db07b5d66d90f6ebf542f09fc67d800e5259", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/service-contracts": "^1|^2|^3" + "php": "^5.3 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.5", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0 || ^8.5.13" }, + "bin": [ + "bin/jsonlint" + ], "type": "library", "autoload": { "psr-4": { - "Symfony\\Component\\Stopwatch\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] + "Seld\\JsonLint\\": "src/Seld/JsonLint/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -5568,120 +5144,61 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "https://seld.be" } ], - "description": "Provides a way to profile code", - "homepage": "https://symfony.com", + "description": "JSON Linter", + "keywords": [ + "json", + "linter", + "parser", + "validator" + ], "support": { - "source": "https://github.com/symfony/stopwatch/tree/v5.4.40" + "issues": "https://github.com/Seldaek/jsonlint/issues", + "source": "https://github.com/Seldaek/jsonlint/tree/1.10.2" }, "funding": [ { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", + "url": "https://github.com/Seldaek", "type": "github" }, { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "url": "https://tidelift.com/funding/github/packagist/seld/jsonlint", "type": "tidelift" } ], - "time": "2024-05-31T14:33:22+00:00" + "time": "2024-02-07T12:57:50+00:00" }, { - "name": "symfony/twig-bridge", - "version": "v5.4.40", + "name": "seld/phar-utils", + "version": "1.2.1", "source": { "type": "git", - "url": "https://github.com/symfony/twig-bridge.git", - "reference": "b982cfa2d15058d2642ca4cf7edab495d6dac707" + "url": "https://github.com/Seldaek/phar-utils.git", + "reference": "ea2f4014f163c1be4c601b9b7bd6af81ba8d701c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/twig-bridge/zipball/b982cfa2d15058d2642ca4cf7edab495d6dac707", - "reference": "b982cfa2d15058d2642ca4cf7edab495d6dac707", + "url": "https://api.github.com/repos/Seldaek/phar-utils/zipball/ea2f4014f163c1be4c601b9b7bd6af81ba8d701c", + "reference": "ea2f4014f163c1be4c601b9b7bd6af81ba8d701c", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/polyfill-php80": "^1.16", - "symfony/translation-contracts": "^1.1|^2|^3", - "twig/twig": "^2.13|^3.0.4" - }, - "conflict": { - "phpdocumentor/reflection-docblock": "<3.2.2", - "phpdocumentor/type-resolver": "<1.4.0", - "symfony/console": "<5.3", - "symfony/form": "<5.4.21|>=6,<6.2.7", - "symfony/http-foundation": "<5.3", - "symfony/http-kernel": "<4.4", - "symfony/translation": "<5.2", - "symfony/workflow": "<5.2" + "php": ">=5.3" }, - "require-dev": { - "doctrine/annotations": "^1.12|^2", - "egulias/email-validator": "^2.1.10|^3|^4", - "phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0", - "symfony/asset": "^4.4|^5.0|^6.0", - "symfony/console": "^5.3|^6.0", - "symfony/dependency-injection": "^4.4|^5.0|^6.0", - "symfony/expression-language": "^4.4|^5.0|^6.0", - "symfony/finder": "^4.4|^5.0|^6.0", - "symfony/form": "^5.4.21|^6.2.7", - "symfony/http-foundation": "^5.3|^6.0", - "symfony/http-kernel": "^4.4|^5.0|^6.0", - "symfony/intl": "^4.4|^5.0|^6.0", - "symfony/mime": "^5.2|^6.0", - "symfony/polyfill-intl-icu": "~1.0", - "symfony/property-info": "^4.4|^5.1|^6.0", - "symfony/routing": "^4.4|^5.0|^6.0", - "symfony/security-acl": "^2.8|^3.0", - "symfony/security-core": "^4.4|^5.0|^6.0", - "symfony/security-csrf": "^4.4|^5.0|^6.0", - "symfony/security-http": "^4.4|^5.0|^6.0", - "symfony/serializer": "^5.4.35|~6.3.12|^6.4.3", - "symfony/stopwatch": "^4.4|^5.0|^6.0", - "symfony/translation": "^5.2|^6.0", - "symfony/web-link": "^4.4|^5.0|^6.0", - "symfony/workflow": "^5.2|^6.0", - "symfony/yaml": "^4.4|^5.0|^6.0", - "twig/cssinliner-extra": "^2.12|^3", - "twig/inky-extra": "^2.12|^3", - "twig/markdown-extra": "^2.12|^3" + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } }, - "suggest": { - "symfony/asset": "For using the AssetExtension", - "symfony/expression-language": "For using the ExpressionExtension", - "symfony/finder": "", - "symfony/form": "For using the FormExtension", - "symfony/http-kernel": "For using the HttpKernelExtension", - "symfony/routing": "For using the RoutingExtension", - "symfony/security-core": "For using the SecurityExtension", - "symfony/security-csrf": "For using the CsrfExtension", - "symfony/security-http": "For using the LogoutUrlExtension", - "symfony/stopwatch": "For using the StopwatchExtension", - "symfony/translation": "For using the TranslationExtension", - "symfony/var-dumper": "For using the DumpExtension", - "symfony/web-link": "For using the WebLinkExtension", - "symfony/yaml": "For using the YamlExtension" - }, - "type": "symfony-bridge", "autoload": { "psr-4": { - "Symfony\\Bridge\\Twig\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] + "Seld\\PharUtils\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -5689,89 +5206,55 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be" } ], - "description": "Provides integration for Twig with various Symfony components", - "homepage": "https://symfony.com", + "description": "PHAR file format utilities, for when PHP phars you up", + "keywords": [ + "phar" + ], "support": { - "source": "https://github.com/symfony/twig-bridge/tree/v5.4.40" + "issues": "https://github.com/Seldaek/phar-utils/issues", + "source": "https://github.com/Seldaek/phar-utils/tree/1.2.1" }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-05-31T14:33:22+00:00" + "time": "2022-08-31T10:31:18+00:00" }, { - "name": "symfony/twig-bundle", - "version": "v5.4.40", + "name": "seld/signal-handler", + "version": "2.0.2", "source": { "type": "git", - "url": "https://github.com/symfony/twig-bundle.git", - "reference": "997c002735c88b50a6325cca8ecf3d8723902666" + "url": "https://github.com/Seldaek/signal-handler.git", + "reference": "04a6112e883ad76c0ada8e4a9f7520bbfdb6bb98" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/twig-bundle/zipball/997c002735c88b50a6325cca8ecf3d8723902666", - "reference": "997c002735c88b50a6325cca8ecf3d8723902666", + "url": "https://api.github.com/repos/Seldaek/signal-handler/zipball/04a6112e883ad76c0ada8e4a9f7520bbfdb6bb98", + "reference": "04a6112e883ad76c0ada8e4a9f7520bbfdb6bb98", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/config": "^4.4|^5.0|^6.0", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/http-foundation": "^4.4|^5.0|^6.0", - "symfony/http-kernel": "^5.0|^6.0", - "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-php80": "^1.16", - "symfony/twig-bridge": "^5.3|^6.0", - "twig/twig": "^2.13|^3.0.4" - }, - "conflict": { - "symfony/dependency-injection": "<5.3", - "symfony/framework-bundle": "<5.0", - "symfony/service-contracts": ">=3.0", - "symfony/translation": "<5.0" + "php": ">=7.2.0" }, "require-dev": { - "doctrine/annotations": "^1.10.4|^2", - "doctrine/cache": "^1.0|^2.0", - "symfony/asset": "^4.4|^5.0|^6.0", - "symfony/dependency-injection": "^5.3|^6.0", - "symfony/expression-language": "^4.4|^5.0|^6.0", - "symfony/finder": "^4.4|^5.0|^6.0", - "symfony/form": "^4.4|^5.0|^6.0", - "symfony/framework-bundle": "^5.0|^6.0", - "symfony/routing": "^4.4|^5.0|^6.0", - "symfony/stopwatch": "^4.4|^5.0|^6.0", - "symfony/translation": "^5.0|^6.0", - "symfony/web-link": "^4.4|^5.0|^6.0", - "symfony/yaml": "^4.4|^5.0|^6.0" + "phpstan/phpstan": "^1", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-phpunit": "^1", + "phpstan/phpstan-strict-rules": "^1.3", + "phpunit/phpunit": "^7.5.20 || ^8.5.23", + "psr/log": "^1 || ^2 || ^3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.x-dev" + } }, - "type": "symfony-bundle", "autoload": { "psr-4": { - "Symfony\\Bundle\\TwigBundle\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] + "Seld\\Signal\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -5779,60 +5262,49 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" } ], - "description": "Provides a tight integration of Twig into the Symfony full-stack framework", - "homepage": "https://symfony.com", + "description": "Simple unix signal handler that silently fails where signals are not supported for easy cross-platform development", + "keywords": [ + "posix", + "sigint", + "signal", + "sigterm", + "unix" + ], "support": { - "source": "https://github.com/symfony/twig-bundle/tree/v5.4.40" + "issues": "https://github.com/Seldaek/signal-handler/issues", + "source": "https://github.com/Seldaek/signal-handler/tree/2.0.2" }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-05-31T14:33:22+00:00" + "time": "2023-09-03T09:24:00+00:00" }, { - "name": "symfony/var-exporter", - "version": "v5.4.40", + "name": "symfony/options-resolver", + "version": "v5.4.21", "source": { "type": "git", - "url": "https://github.com/symfony/var-exporter.git", - "reference": "6a13d37336d512927986e09f19a4bed24178baa6" + "url": "https://github.com/symfony/options-resolver.git", + "reference": "4fe5cf6ede71096839f0e4b4444d65dd3a7c1eb9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-exporter/zipball/6a13d37336d512927986e09f19a4bed24178baa6", - "reference": "6a13d37336d512927986e09f19a4bed24178baa6", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/4fe5cf6ede71096839f0e4b4444d65dd3a7c1eb9", + "reference": "4fe5cf6ede71096839f0e4b4444d65dd3a7c1eb9", "shasum": "" }, "require": { "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/polyfill-php73": "~1.0", "symfony/polyfill-php80": "^1.16" }, - "require-dev": { - "symfony/var-dumper": "^4.4.9|^5.0.9|^6.0" - }, "type": "library", "autoload": { "psr-4": { - "Symfony\\Component\\VarExporter\\": "" + "Symfony\\Component\\OptionsResolver\\": "" }, "exclude-from-classmap": [ "/Tests/" @@ -5844,26 +5316,23 @@ ], "authors": [ { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" + "name": "Fabien Potencier", + "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], - "description": "Allows exporting any serializable PHP data structure to plain PHP code", + "description": "Provides an improved replacement for the array_replace PHP function", "homepage": "https://symfony.com", "keywords": [ - "clone", - "construct", - "export", - "hydrate", - "instantiate", - "serialize" + "config", + "configuration", + "options" ], "support": { - "source": "https://github.com/symfony/var-exporter/tree/v5.4.40" + "source": "https://github.com/symfony/options-resolver/tree/v5.4.21" }, "funding": [ { @@ -5879,48 +5348,30 @@ "type": "tidelift" } ], - "time": "2024-05-31T14:33:22+00:00" + "time": "2023-02-14T08:03:56+00:00" }, { - "name": "symfony/web-profiler-bundle", + "name": "symfony/stopwatch", "version": "v5.4.40", "source": { "type": "git", - "url": "https://github.com/symfony/web-profiler-bundle.git", - "reference": "a29669617c4e63785f363571a190a706b9022890" + "url": "https://github.com/symfony/stopwatch.git", + "reference": "0e9daf3b7c805c747638b2cc48f1649e594f9625" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/web-profiler-bundle/zipball/a29669617c4e63785f363571a190a706b9022890", - "reference": "a29669617c4e63785f363571a190a706b9022890", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/0e9daf3b7c805c747638b2cc48f1649e594f9625", + "reference": "0e9daf3b7c805c747638b2cc48f1649e594f9625", "shasum": "" }, "require": { "php": ">=7.2.5", - "symfony/config": "^4.4|^5.0|^6.0", - "symfony/framework-bundle": "^5.3|^6.0,<6.4", - "symfony/http-kernel": "^5.3|^6.0", - "symfony/polyfill-php80": "^1.16", - "symfony/routing": "^4.4|^5.0|^6.0", - "symfony/twig-bundle": "^4.4|^5.0|^6.0", - "twig/twig": "^2.13|^3.0.4" - }, - "conflict": { - "symfony/dependency-injection": "<5.2", - "symfony/form": "<4.4", - "symfony/mailer": "<5.4", - "symfony/messenger": "<4.4" - }, - "require-dev": { - "symfony/browser-kit": "^4.4|^5.0|^6.0", - "symfony/console": "^4.4|^5.0|^6.0", - "symfony/css-selector": "^4.4|^5.0|^6.0", - "symfony/stopwatch": "^4.4|^5.0|^6.0" + "symfony/service-contracts": "^1|^2|^3" }, - "type": "symfony-bundle", + "type": "library", "autoload": { "psr-4": { - "Symfony\\Bundle\\WebProfilerBundle\\": "" + "Symfony\\Component\\Stopwatch\\": "" }, "exclude-from-classmap": [ "/Tests/" @@ -5940,10 +5391,10 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Provides a development tool that gives detailed information about the execution of any request", + "description": "Provides a way to profile code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/web-profiler-bundle/tree/v5.4.40" + "source": "https://github.com/symfony/stopwatch/tree/v5.4.40" }, "funding": [ { From 564fb416cf000a4970220873ecba2f53c5b5b654 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 5 Jul 2024 03:47:28 +0200 Subject: [PATCH 136/136] [skip ci] Updated ... --- config.yaml | 4 +- src/N98/Magento/Application.php | 6 +- .../Command/AbstractStoreConfigCommand.php | 1 + .../Admin/User/AbstractAdminUserCommand.php | 34 ++--- .../Admin/User/ChangePasswordCommand.php | 17 ++- .../Admin/User/ChangeStatusCommand.php | 16 +-- .../Command/Admin/User/CreateUserCommand.php | 25 ++-- .../Command/Admin/User/DeleteUserCommand.php | 16 ++- .../Command/Admin/User/ListCommand.php | 43 ++++-- .../Command/Cache/AbstractCacheCommand.php | 44 +++--- .../Cache/AbstractCacheCommandReinit.php | 15 +- .../Magento/Command/Cache/CleanCommand.php | 6 +- .../Command/Cache/Dir/FlushCommand.php | 25 ++-- .../Magento/Command/Cache/FlushCommand.php | 28 ++-- src/N98/Magento/Command/Cache/ListCommand.php | 30 ++-- .../Magento/Command/Cache/ReportCommand.php | 85 ++++++++---- .../AbstractCacheCommandToggle.php | 44 +++--- .../Cache/{ => Toggle}/DisableCommand.php | 4 +- .../Cache/{ => Toggle}/EnableCommand.php | 6 +- src/N98/Magento/Command/Cache/ViewCommand.php | 23 ++-- .../Cms/Block/AbstractCmsBlockCommand.php | 19 ++- .../Magento/Command/Cms/Block/ListCommand.php | 50 ++++--- .../Command/Cms/Block/ToggleCommand.php | 5 +- src/N98/Magento/Command/CommandAware.php | 4 +- .../Magento/Command/CommandConfigAware.php | 2 +- .../Magento/Command/CommandDataInterface.php | 12 +- .../Magento/Command/Config/DumpCommand.php | 9 +- .../Magento/Command/Config/SearchCommand.php | 18 ++- .../Customer/AbstractCustomerCommand.php | 46 ------- .../Customer/ChangePasswordCommand.php | 20 ++- .../Command/Customer/CreateCommand.php | 28 ++-- .../Command/Customer/CreateDummyCommand.php | 35 +++-- .../Command/Customer/DeleteCommand.php | 48 +++++-- .../Magento/Command/Customer/InfoCommand.php | 25 +++- .../Magento/Command/Customer/ListCommand.php | 83 +++++++----- .../Database/AbstractDatabaseCommand.php | 8 +- .../Command/Database/AbstractShowCommand.php | 28 ++-- .../Compressor/AbstractCompressor.php | 20 ++- .../Database/Compressor/Compressor.php | 14 +- .../Command/Database/Compressor/Gzip.php | 13 +- .../Database/Compressor/Uncompressed.php | 13 +- .../Magento/Command/Database/InfoCommand.php | 128 ++++++++++-------- .../Command/Database/StatusCommand.php | 2 + .../Command/Database/VariablesCommand.php | 1 + .../Command/Developer/ClassLookupCommand.php | 21 ++- .../Developer/EmailTemplate/UsageCommand.php | 119 ++++++++-------- .../Developer/Module/CreateCommand.php | 3 +- .../Command/Developer/Module/ListCommand.php | 20 ++- .../Developer/Module/Rewrite/ListCommand.php | 39 ++++-- .../Command/Developer/Theme/InfoCommand.php | 44 +++++- .../Command/Developer/Theme/ListCommand.php | 39 +++--- .../Command/Eav/Attribute/ListCommand.php | 83 +++++++----- .../Command/Eav/Attribute/ViewCommand.php | 117 +++++++++------- .../Magento/Command/Indexer/ListCommand.php | 33 +++-- .../Media/Cache/JsCss/ClearCommand.php | 11 +- .../Command/Script/Repository/ListCommand.php | 40 ++++-- .../System/Check/MySQL/ResourceCheck.php | 24 ++-- .../System/Check/MySQL/VersionCheck.php | 27 ++-- .../Command/System/Check/ResultCollection.php | 16 ++- .../Command/System/Check/SimpleCheck.php | 5 +- .../Command/System/Check/StoreCheck.php | 4 +- .../Command/System/Check/WebsiteCheck.php | 8 +- .../Command/System/Cron/ListCommand.php | 20 ++- .../Command/System/MaintenanceCommand.php | 2 +- .../Store/Config/BaseUrlListCommand.php | 44 ++++-- .../Command/System/Store/ListCommand.php | 39 ++++-- .../Command/System/Website/ListCommand.php | 38 ++++-- src/N98/Magento/Methods/Admin/Roles.php | 30 ++++ src/N98/Magento/Methods/Admin/Rules.php | 30 ++++ src/N98/Magento/Methods/Admin/User.php | 30 ++++ src/N98/Magento/Methods/Catalog/Category.php | 30 ++++ src/N98/Magento/Methods/Catalog/Product.php | 30 ++++ src/N98/Magento/Methods/Cms/Block.php | 32 +++++ .../Magento/Methods/Core/Design/Package.php | 31 +++++ src/N98/Magento/Methods/Core/Resource.php | 31 +++++ src/N98/Magento/Methods/Customer/Address.php | 30 ++++ src/N98/Magento/Methods/Customer/Customer.php | 30 ++++ .../Methods/Customer/Customer/Collection.php | 30 ++++ .../Methods/Directory/Country/Collection.php | 30 ++++ .../Magento/Methods/Eav/Entity/Attribute.php | 30 ++++ src/N98/Magento/Methods/MageBase.php | 83 ++++++++++++ src/N98/Magento/Methods/ModelInterface.php | 20 +++ .../Methods/ResourceModelInterface.php | 20 +++ src/N98/Magento/Modules.php | 11 +- src/N98/View/PhpView.php | 27 +++- src/N98/View/View.php | 11 +- 86 files changed, 1718 insertions(+), 747 deletions(-) rename src/N98/Magento/Command/Cache/{ => Toggle}/AbstractCacheCommandToggle.php (70%) rename src/N98/Magento/Command/Cache/{ => Toggle}/DisableCommand.php (84%) rename src/N98/Magento/Command/Cache/{ => Toggle}/EnableCommand.php (80%) create mode 100644 src/N98/Magento/Methods/Admin/Roles.php create mode 100644 src/N98/Magento/Methods/Admin/Rules.php create mode 100644 src/N98/Magento/Methods/Admin/User.php create mode 100644 src/N98/Magento/Methods/Catalog/Category.php create mode 100644 src/N98/Magento/Methods/Catalog/Product.php create mode 100644 src/N98/Magento/Methods/Cms/Block.php create mode 100644 src/N98/Magento/Methods/Core/Design/Package.php create mode 100644 src/N98/Magento/Methods/Core/Resource.php create mode 100644 src/N98/Magento/Methods/Customer/Address.php create mode 100644 src/N98/Magento/Methods/Customer/Customer.php create mode 100644 src/N98/Magento/Methods/Customer/Customer/Collection.php create mode 100644 src/N98/Magento/Methods/Directory/Country/Collection.php create mode 100644 src/N98/Magento/Methods/Eav/Entity/Attribute.php create mode 100644 src/N98/Magento/Methods/MageBase.php create mode 100644 src/N98/Magento/Methods/ModelInterface.php create mode 100644 src/N98/Magento/Methods/ResourceModelInterface.php diff --git a/config.yaml b/config.yaml index 8aac255a7..45b6b7778 100644 --- a/config.yaml +++ b/config.yaml @@ -54,8 +54,8 @@ commands: - N98\Magento\Command\Admin\User\ChangeStatusCommand - N98\Magento\Command\Cache\CleanCommand - N98\Magento\Command\Cache\Dir\FlushCommand - - N98\Magento\Command\Cache\DisableCommand - - N98\Magento\Command\Cache\EnableCommand + - N98\Magento\Command\Cache\Toggle\DisableCommand + - N98\Magento\Command\Cache\Toggle\EnableCommand - N98\Magento\Command\Cache\FlushCommand - N98\Magento\Command\Cache\ListCommand - N98\Magento\Command\Cache\ReportCommand diff --git a/src/N98/Magento/Application.php b/src/N98/Magento/Application.php index fabb7f2f8..07d00ac31 100644 --- a/src/N98/Magento/Application.php +++ b/src/N98/Magento/Application.php @@ -674,6 +674,7 @@ protected function registerEventSubscribers() * @return bool * @deprecated 1.97.27 */ + // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore protected function _checkSkipConfigOption(InputInterface $input) { trigger_error( @@ -687,6 +688,7 @@ protected function _checkSkipConfigOption(InputInterface $input) /** * @param InputInterface $input */ + // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore protected function _checkRootDirOption(InputInterface $input) { $rootDir = $input->getParameterOption('--root-dir'); @@ -717,6 +719,7 @@ private function setRootDir($path) * @param bool $soft * @return void */ + // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore protected function _initMagento1(bool $soft = false): void { // Load Mage class definition @@ -738,7 +741,7 @@ protected function _initMagento1(bool $soft = false): void /** * @return EventDispatcher */ - public function getDispatcher() + public function getDispatcher(): EventDispatcher { return $this->dispatcher; } @@ -784,6 +787,7 @@ public function setConfigurationLoader(ConfigurationLoader $configurationLoader) /** * @param OutputInterface $output */ + // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore protected function _addOutputStyles(OutputInterface $output) { $output->getFormatter()->setStyle('debug', new OutputFormatterStyle('magenta', 'white')); diff --git a/src/N98/Magento/Command/AbstractStoreConfigCommand.php b/src/N98/Magento/Command/AbstractStoreConfigCommand.php index 8973f747d..853778ab4 100644 --- a/src/N98/Magento/Command/AbstractStoreConfigCommand.php +++ b/src/N98/Magento/Command/AbstractStoreConfigCommand.php @@ -213,6 +213,7 @@ protected function askAndSetDeveloperIp( $dialog = $this->getQuestionHelper(); $question = new Question('Change developer IP? Enter a new IP to change or leave blank: '); + /** @var string $newDeveloperIp */ $newDeveloperIp = $dialog->ask($input, $output, $question); if (empty($newDeveloperIp)) { diff --git a/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php b/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php index 39d7a5a7f..6531fa612 100644 --- a/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php +++ b/src/N98/Magento/Command/Admin/User/AbstractAdminUserCommand.php @@ -4,11 +4,9 @@ namespace N98\Magento\Command\Admin\User; -use Mage; -use Mage_Admin_Model_Roles; -use Mage_Admin_Model_Rules; use Mage_Admin_Model_User; use N98\Magento\Command\AbstractCommand; +use N98\Magento\Methods\Admin; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -22,27 +20,14 @@ abstract class AbstractAdminUserCommand extends AbstractCommand public const COMMAND_ARGUMENT_ID = 'id'; /** - * @return Mage_Admin_Model_User - */ - protected function getUserModel(): Mage_Admin_Model_User - { - return Mage::getModel('admin/user'); - } - - /** - * @return Mage_Admin_Model_Roles + * {@inheritDoc} */ - protected function getRoleModel(): Mage_Admin_Model_Roles + public function initialize(InputInterface $input, OutputInterface $output): void { - return Mage::getModel('admin/roles'); - } + parent::initialize($input, $output); - /** - * @return Mage_Admin_Model_Rules - */ - protected function getRulesModel(): Mage_Admin_Model_Rules - { - return Mage::getModel('admin/rules'); + $this->detectMagento($output); + $this->initMagento(); } /** @@ -50,14 +35,17 @@ protected function getRulesModel(): Mage_Admin_Model_Rules * * @param InputInterface $input * @param OutputInterface $output + * * @return Mage_Admin_Model_User + * + * @uses Admin\User::getModel() */ protected function getUserByIdOrEmail(InputInterface $input, OutputInterface $output): Mage_Admin_Model_User { $identifier = $this->getOrAskForArgument(self::COMMAND_ARGUMENT_ID, $input, $output, 'Username or Email'); - $user = $this->getUserModel()->loadByUsername($identifier); + $user = Admin\User::getModel()->loadByUsername($identifier); if (!$user->getId()) { - $user = $this->getUserModel()->load($identifier, 'email'); + $user = Admin\User::getModel()->load($identifier, 'email'); } return $user; diff --git a/src/N98/Magento/Command/Admin/User/ChangePasswordCommand.php b/src/N98/Magento/Command/Admin/User/ChangePasswordCommand.php index 0cbf6e1f4..b62cc0d1b 100644 --- a/src/N98/Magento/Command/Admin/User/ChangePasswordCommand.php +++ b/src/N98/Magento/Command/Admin/User/ChangePasswordCommand.php @@ -5,6 +5,7 @@ namespace N98\Magento\Command\Admin\User; use Exception; +use N98\Magento\Methods\Admin; use RuntimeException; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; @@ -13,6 +14,10 @@ use Symfony\Component\Console\Question\Question; use Throwable; +use function implode; +use function is_array; +use function sprintf; + /** * Change admin password command * @@ -34,6 +39,9 @@ class ChangePasswordCommand extends AbstractAdminUserCommand */ protected static $defaultDescription = 'Changes the password of a adminhtml user.'; + /** + * {@inheritdoc} + */ protected function configure(): void { $this @@ -51,10 +59,11 @@ protected function configure(): void } /** - * @param InputInterface $input - * @param OutputInterface $output - * @return int + * {@inheritdoc} + * * @throws Throwable + * + * @uses Admin\User::getModel() */ protected function execute(InputInterface $input, OutputInterface $output): int { @@ -67,7 +76,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $username = $dialog->ask($input, $output, new Question('Username: ')); } - $user = $this->getUserModel()->loadByUsername($username); + $user = Admin\User::getModel()->loadByUsername($username); if ($user->getId() <= 0) { $output->writeln('User was not found'); diff --git a/src/N98/Magento/Command/Admin/User/ChangeStatusCommand.php b/src/N98/Magento/Command/Admin/User/ChangeStatusCommand.php index 40562262d..6e1e62448 100644 --- a/src/N98/Magento/Command/Admin/User/ChangeStatusCommand.php +++ b/src/N98/Magento/Command/Admin/User/ChangeStatusCommand.php @@ -5,19 +5,18 @@ namespace N98\Magento\Command\Admin\User; use Exception; -use RuntimeException; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Throwable; +use Zend_Validate_Exception; /** * Change admin status command * * @package N98\Magento\Command\Admin\User - * @TODO(sr) toggle */ class ChangeStatusCommand extends AbstractAdminUserCommand { @@ -35,6 +34,9 @@ class ChangeStatusCommand extends AbstractAdminUserCommand */ protected static $defaultDescription = 'Set active status of an adminhtml user.'; + /** + * {@inheritdoc} + */ protected function configure(): void { parent::configure(); @@ -61,20 +63,18 @@ protected function configure(): void } /** - * @return string + * {@inheritdoc} */ public function getHelp(): string { return <<validate(); if (is_array($result)) { - throw new RuntimeException(implode(PHP_EOL, $result)); + throw new Zend_Validate_Exception(implode(PHP_EOL, $result)); } if ($input->getOption(self::COMMAND_OPTION_ACTIVATE)) { diff --git a/src/N98/Magento/Command/Admin/User/CreateUserCommand.php b/src/N98/Magento/Command/Admin/User/CreateUserCommand.php index c35526f18..d5722f302 100644 --- a/src/N98/Magento/Command/Admin/User/CreateUserCommand.php +++ b/src/N98/Magento/Command/Admin/User/CreateUserCommand.php @@ -5,6 +5,7 @@ namespace N98\Magento\Command\Admin\User; use Mage_Core_Exception; +use N98\Magento\Methods\Admin; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -41,6 +42,9 @@ class CreateUserCommand extends AbstractAdminUserCommand */ protected static $defaultDescription = 'Creates admin user.'; + /** + * {@inheritdoc} + */ protected function configure(): void { $this @@ -78,16 +82,20 @@ protected function configure(): void } /** - * @param InputInterface $input - * @param OutputInterface $output - * @return int + * {@inheritdoc} + * * @throws Mage_Core_Exception * @throws Throwable + * + * @uses Admin\Roles::getModel() + * @uses Admin\Rules::getModel() + * @uses Admin\User::getModel() */ protected function execute(InputInterface $input, OutputInterface $output): int { $username = $this->getOrAskForArgument(self::COMMAND_ARGUMENT_USERNAME, $input, $output); $email = $this->getOrAskForArgument(self::COMMAND_ARGUMENT_EMAIL, $input, $output); + if (($password = $input->getArgument(self::COMMAND_ARGUMENT_PASSWORD)) === null) { $dialog = $this->getQuestionHelper(); $question = new Question('Password: '); @@ -100,7 +108,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int /** @var string|null $roleName */ $roleName = $input->getArgument(self::COMMAND_ARGUMENT_ROLE); if ($roleName !== null) { - $role = $this->getRoleModel()->load($roleName, 'role_name'); + $role = Admin\Roles::getModel()->load($roleName, 'role_name'); if (!$role->getId()) { $output->writeln('Role was not found'); @@ -108,7 +116,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } else { // create new role if not yet existing - $role = $this->getRoleModel()->load('Development', 'role_name'); + $role = Admin\Roles::getModel()->load('Development', 'role_name'); if (!$role->getId()) { $role ->setName('Development') @@ -116,8 +124,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int ->save(); // give "all" privileges to role - $this - ->getRulesModel() + Admin\Rules::getModel() ->setRoleId($role->getId()) ->setResources(['all']) ->saveRel(); @@ -127,7 +134,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } // create new user - $user = $this->getUserModel() + $user = Admin\User::getModel() ->setData([ 'username' => $username, 'firstname' => $firstname, @@ -142,7 +149,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int ->setRoleUserId($user->getUserId()) ->saveRelations(); - $output->writeln('User ' . $username . ' successfully created'); + $output->writeln(sprintf('User %s successfully created', $username)); return Command::SUCCESS; } diff --git a/src/N98/Magento/Command/Admin/User/DeleteUserCommand.php b/src/N98/Magento/Command/Admin/User/DeleteUserCommand.php index f9728d2f4..4e3064f1b 100644 --- a/src/N98/Magento/Command/Admin/User/DeleteUserCommand.php +++ b/src/N98/Magento/Command/Admin/User/DeleteUserCommand.php @@ -32,6 +32,9 @@ class DeleteUserCommand extends AbstractAdminUserCommand */ protected static $defaultDescription = 'Deletes the account of a adminhtml user.'; + /** + * {@inheritdoc} + */ protected function configure(): void { parent::configure(); @@ -52,9 +55,8 @@ protected function configure(): void } /** - * @param InputInterface $input - * @param OutputInterface $output - * @return int + * {@inheritdoc} + * * @throws Throwable */ protected function execute(InputInterface $input, OutputInterface $output): int @@ -68,16 +70,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int return Command::INVALID; } - $force = $input->getOption(self::COMMAND_OPTION_FORCE); - if (!$force) { - $force = $dialog->ask( + $shouldRemove = $input->getOption(self::COMMAND_OPTION_FORCE); + if (!$shouldRemove) { + $shouldRemove = $dialog->ask( $input, $output, new ConfirmationQuestion('Are you sure? [n]: ', false), ); } - if ($force) { + if ($shouldRemove) { try { $user->delete(); $output->writeln('User was successfully deleted'); diff --git a/src/N98/Magento/Command/Admin/User/ListCommand.php b/src/N98/Magento/Command/Admin/User/ListCommand.php index a8fadc97b..04e9f0a9f 100644 --- a/src/N98/Magento/Command/Admin/User/ListCommand.php +++ b/src/N98/Magento/Command/Admin/User/ListCommand.php @@ -6,9 +6,12 @@ use Mage_Admin_Model_User; use N98\Magento\Command\CommandDataInterface; +use N98\Magento\Methods\Admin; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use function is_null; + /** * List admin command * @@ -28,24 +31,38 @@ class ListCommand extends AbstractAdminUserCommand implements CommandDataInterfa */ protected static $defaultDescription = 'List admin users.'; + /** + * {@inheritdoc} + */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getDataHeaders(InputInterface $input, OutputInterface $output): array + { + return ['Id', 'Username', 'Email', 'Status']; + } + /** * {@inheritDoc} * - * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter + * @uses Admin\User::getModel() */ - public function setData(InputInterface $input,OutputInterface $output) : void + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getData(InputInterface $input, OutputInterface $output): array { - $this->data = []; - $userModel = $this->getUserModel(); - $userList = $userModel->getCollection(); - /** @var Mage_Admin_Model_User $user */ - foreach ($userList as $user) { - $this->data[] = [ - 'Id' => $user->getId(), - 'Username' => $user->getUsername(), - 'Email' => $user->getEmail(), - 'Status' => $user->getIsActive() ? 'active' : 'inactive' - ]; + if (is_null($this->data)) { + $this->data = []; + $userModel = Admin\User::getModel(); + $userList = $userModel->getCollection(); + /** @var Mage_Admin_Model_User $user */ + foreach ($userList as $user) { + $this->data[] = [ + $user->getId(), + $user->getUsername(), + $user->getEmail(), + $user->getIsActive() ? 'active' : 'inactive' + ]; + } } + + return $this->data; } } diff --git a/src/N98/Magento/Command/Cache/AbstractCacheCommand.php b/src/N98/Magento/Command/Cache/AbstractCacheCommand.php index 250009185..3c1c5ad34 100644 --- a/src/N98/Magento/Command/Cache/AbstractCacheCommand.php +++ b/src/N98/Magento/Command/Cache/AbstractCacheCommand.php @@ -5,10 +5,14 @@ namespace N98\Magento\Command\Cache; use InvalidArgumentException; -use Mage_Core_Model_Cache; use N98\Magento\Command\AbstractCommand; -use RuntimeException; -use Zend_Cache_Core; +use N98\Magento\Methods\MageBase as Mage; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Varien_Object; + +use function array_key_exists; +use function is_null; /** * Abstract cache command @@ -18,21 +22,16 @@ abstract class AbstractCacheCommand extends AbstractCommand { /** - * @return Mage_Core_Model_Cache - * - * @throws RuntimeException + * @var array|null */ - protected function _getCacheModel(): Mage_Core_Model_Cache - { - return $this->_getMage()->getCacheInstance(); - } + protected ?array $cacheTypes = null; - /** - * @return Zend_Cache_Core - */ - protected function getCacheInstance(): Zend_Cache_Core + protected function initialize(InputInterface $input, OutputInterface $output): void { - return $this->_getMage()->getCache(); + parent::initialize($input, $output); + + $this->detectMagento($output); + $this->initMagento(); } /** @@ -41,11 +40,24 @@ protected function getCacheInstance(): Zend_Cache_Core */ protected function validateCacheCodes(array $codes): void { - $cacheTypes = $this->_getCacheModel()->getTypes(); + $cacheTypes = $this->getAllCacheTypes(); foreach ($codes as $cacheCode) { if (!array_key_exists($cacheCode, $cacheTypes)) { throw new InvalidArgumentException('Invalid cache type: ' . $cacheCode); } } } + + /** + * @return array + * + * @uses Mage::app() + */ + protected function getAllCacheTypes(): array + { + if (is_null($this->cacheTypes)) { + $this->cacheTypes = Mage::app()->getCacheInstance()->getTypes(); + } + return $this->cacheTypes; + } } diff --git a/src/N98/Magento/Command/Cache/AbstractCacheCommandReinit.php b/src/N98/Magento/Command/Cache/AbstractCacheCommandReinit.php index 922734496..d0fd79b07 100644 --- a/src/N98/Magento/Command/Cache/AbstractCacheCommandReinit.php +++ b/src/N98/Magento/Command/Cache/AbstractCacheCommandReinit.php @@ -4,10 +4,13 @@ namespace N98\Magento\Command\Cache; +use N98\Magento\Methods\MageBase as Mage; use Symfony\Component\Console\Input\InputOption; +use function method_exists; + /** - * Abstract cache reinit class + * Abstract cache re-init class * * @package N98\Magento\Command\Cache */ @@ -54,19 +57,25 @@ protected function banUseCache(): void } } + /** + * @return void + * + * @uses Mage::app() + */ protected function reinitCache(): void { if (!$this->_canUseBanCacheFunction()) { return; } - $this->_getMage()->getConfig()->getOptions()->setData('global_ban_use_cache', false); - $this->_getMage()->getConfig()->reinit(); + Mage::app()->getConfig()->getOptions()->setData('global_ban_use_cache', false); + Mage::app()->getConfig()->reinit(); } /** * @return bool */ + // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore protected function _canUseBanCacheFunction(): bool { // @phpstan-ignore function.alreadyNarrowedType (Phpstan Bleeding edge only) diff --git a/src/N98/Magento/Command/Cache/CleanCommand.php b/src/N98/Magento/Command/Cache/CleanCommand.php index d277d1e52..b0229ccc8 100644 --- a/src/N98/Magento/Command/Cache/CleanCommand.php +++ b/src/N98/Magento/Command/Cache/CleanCommand.php @@ -5,7 +5,7 @@ namespace N98\Magento\Command\Cache; use Exception; -use Mage; +use N98\Magento\MageMethods as Mage; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -73,7 +73,11 @@ public function getHelp(): string /** * @param InputInterface $input * @param OutputInterface $output + * * @return int + * + * @uses Mage::app() + * @uses Mage::dispatchEvent() */ protected function execute(InputInterface $input, OutputInterface $output): int { diff --git a/src/N98/Magento/Command/Cache/Dir/FlushCommand.php b/src/N98/Magento/Command/Cache/Dir/FlushCommand.php index d4902fa34..7b2c2823b 100644 --- a/src/N98/Magento/Command/Cache/Dir/FlushCommand.php +++ b/src/N98/Magento/Command/Cache/Dir/FlushCommand.php @@ -13,6 +13,11 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use function getcwd; +use function sprintf; +use function unlink; +use function var_export; + /** * Flush cache directory command * @@ -30,6 +35,9 @@ class FlushCommand extends AbstractCommand */ protected static $defaultDescription = 'Flush (empty) cache directory.'; + /** + * {@inheritdoc} + */ public function getHelp(): string { return <<isDir()) { if ($output->isVerbose()) { - $output->writeln( - sprintf( - 'Filesystem::recursiveRemoveDirectory() %s', - $file - ) - ); + $output->writeln(sprintf( + 'Filesystem::recursiveRemoveDirectory() %s', + $file + )); } if (!isset($fs)) { diff --git a/src/N98/Magento/Command/Cache/FlushCommand.php b/src/N98/Magento/Command/Cache/FlushCommand.php index 2d8f5064b..c287782c2 100644 --- a/src/N98/Magento/Command/Cache/FlushCommand.php +++ b/src/N98/Magento/Command/Cache/FlushCommand.php @@ -5,7 +5,7 @@ namespace N98\Magento\Command\Cache; use Exception; -use Mage; +use N98\Magento\Methods\MageBase as Mage; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -43,22 +43,30 @@ public function getHelp(): string HELP; } - /** - * @param InputInterface $input - * @param OutputInterface $output - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output): int + protected function initialize(InputInterface $input, OutputInterface $output): void { + parent::initialize($input, $output); + $this->detectMagento($output); - $noReinitOption = $input->getOption(self::COMMAND_OPTION_NO_REINIT); - if (!$noReinitOption) { + if (!$input->getOption(self::COMMAND_OPTION_NO_REINIT)) { $this->banUseCache(); } $this->initMagento(); + } + /** + * @param InputInterface $input + * @param OutputInterface $output + * + * @return int + * + * @uses Mage::app() + * @uses Mage::dispatchEvent() + */ + protected function execute(InputInterface $input, OutputInterface $output): int + { try { Mage::app()->loadAreaPart('adminhtml', 'events'); } catch (Exception $e) { @@ -73,7 +81,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Failed to clear Cache'); } - if (!$noReinitOption) { + if (!$input->getOption(self::COMMAND_OPTION_NO_REINIT)) { $this->reinitCache(); } diff --git a/src/N98/Magento/Command/Cache/ListCommand.php b/src/N98/Magento/Command/Cache/ListCommand.php index 471734c5d..5cc20866a 100644 --- a/src/N98/Magento/Command/Cache/ListCommand.php +++ b/src/N98/Magento/Command/Cache/ListCommand.php @@ -29,17 +29,29 @@ class ListCommand extends AbstractCacheCommand implements CommandDataInterface /** * {@inheritdoc} - * - * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - public function setData(InputInterface $input,OutputInterface $output) : void + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getDataHeaders(InputInterface $input, OutputInterface $output): array { - $this->data = []; - foreach ($this->_getCacheModel()->getTypes() as $cacheCode => $cacheInfo) { - $this->data[] = [ - 'code' => $cacheCode, - 'status' => $cacheInfo['status'] ? 'enabled' : 'disabled' - ]; + return ['Code', 'Status']; + } + + /** + * {@inheritdoc} + */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getData(InputInterface $input, OutputInterface $output): array + { + if (is_null($this->data)) { + $this->data = []; + foreach ($this->getAllCacheTypes() as $cacheCode => $cacheInfo) { + $this->data[] = [ + $cacheCode, + $cacheInfo['status'] ? 'enabled' : 'disabled' + ]; + } } + + return $this->data; } } diff --git a/src/N98/Magento/Command/Cache/ReportCommand.php b/src/N98/Magento/Command/Cache/ReportCommand.php index 8980eb8c2..39b06541e 100644 --- a/src/N98/Magento/Command/Cache/ReportCommand.php +++ b/src/N98/Magento/Command/Cache/ReportCommand.php @@ -5,6 +5,7 @@ namespace N98\Magento\Command\Cache; use N98\Magento\Command\CommandDataInterface; +use N98\Magento\Methods\MageBase as Mage; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -70,49 +71,73 @@ protected function configure(): void /** * {@inheritdoc} - * - * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - public function setData(InputInterface $input,OutputInterface $output) : void + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getDataHeaders(InputInterface $input, OutputInterface $output): array { - $this->data = []; - - $cacheInstance = $this->getCacheInstance(); + $header = ['ID', 'Expires']; - $filterTag = $input->getOption(self::COMMAND_OPTION_FILTER_TAG); - if ($filterTag !== null) { - $cacheIds = $cacheInstance->getIdsMatchingAnyTags([$filterTag]); - } else { - $cacheIds = $cacheInstance->getIds(); + if ($input->getOption(self::COMMAND_OPTION_MTIME)) { + $header[] = 'Time modified'; } - /** @var string $filterId */ - $filterId = $input->getOption(self::COMMAND_OPTION_FILTER_ID); - if ($filterId !== null) { - // @phpstan-ignore argument.type (@todo SR) - $cacheIds = array_filter($cacheIds, function ($cacheId) use ($filterId) { - return stristr($cacheId, $filterId); - }); + if ($input->getOption(self::COMMAND_OPTION_TAGS)) { + $header[] = 'Tags'; } - /** @var string[] $cacheIds */ - foreach ($cacheIds as $cacheId) { - $metaData = $cacheInstance->getMetadatas($cacheId); + return $header; + } - $row = [ - 'ID' => $cacheId, - 'EXPIRE' => date(self::DATE_FORMAT, $metaData['expire']) - ]; + /** + * {@inheritdoc} + * + * @uses Mage::app() + */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getData(InputInterface $input, OutputInterface $output): array + { + if (is_null($this->data)) { + $this->data = []; - if ($input->getOption(self::COMMAND_OPTION_MTIME)) { - $row['MTIME'] = date(self::DATE_FORMAT, $metaData['mtime']); + $cacheInstance = Mage::app()->getCache(); + + $filterTag = $input->getOption(self::COMMAND_OPTION_FILTER_TAG); + if ($filterTag !== null) { + $cacheIds = $cacheInstance->getIdsMatchingAnyTags([$filterTag]); + } else { + $cacheIds = $cacheInstance->getIds(); } - if ($input->getOption(self::COMMAND_OPTION_TAGS)) { - $row['TAGS'] = implode(',', $metaData['tags']); + /** @var string $filterId */ + $filterId = $input->getOption(self::COMMAND_OPTION_FILTER_ID); + if ($filterId !== null) { + // @phpstan-ignore argument.type (@todo SR) + $cacheIds = array_filter($cacheIds, function ($cacheId) use ($filterId) { + return stristr($cacheId, $filterId); + }); } - $this->data[] = $row; + /** @var string[] $cacheIds */ + foreach ($cacheIds as $cacheId) { + $metaData = $cacheInstance->getMetadatas($cacheId); + + $row = [ + 'id' => $cacheId, + 'expire' => date(self::DATE_FORMAT, $metaData['expire']) + ]; + + if ($input->getOption(self::COMMAND_OPTION_MTIME)) { + $row['mtime'] = date(self::DATE_FORMAT, $metaData['mtime']); + } + + if ($input->getOption(self::COMMAND_OPTION_TAGS)) { + $row['tags'] = implode(',', $metaData['tags']); + } + + $this->data[] = $row; + } } + + return $this->data; } } diff --git a/src/N98/Magento/Command/Cache/AbstractCacheCommandToggle.php b/src/N98/Magento/Command/Cache/Toggle/AbstractCacheCommandToggle.php similarity index 70% rename from src/N98/Magento/Command/Cache/AbstractCacheCommandToggle.php rename to src/N98/Magento/Command/Cache/Toggle/AbstractCacheCommandToggle.php index daa2b01c8..994aa8ac7 100644 --- a/src/N98/Magento/Command/Cache/AbstractCacheCommandToggle.php +++ b/src/N98/Magento/Command/Cache/Toggle/AbstractCacheCommandToggle.php @@ -2,18 +2,26 @@ declare(strict_types=1); -namespace N98\Magento\Command\Cache; +namespace N98\Magento\Command\Cache\Toggle; +use N98\Magento\Command\Cache\AbstractCacheCommand; +use N98\Magento\Methods\MageBase as Mage; use N98\Util\BinaryString; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use function array_keys; +use function count; +use function in_array; +use function is_array; +use function sprintf; + /** * Abstract cache toggle class * - * @package N98\Magento\Command\Cache + * @package N98\Magento\Command\Cache\Toggle */ abstract class AbstractCacheCommandToggle extends AbstractCacheCommand { @@ -29,11 +37,14 @@ abstract class AbstractCacheCommandToggle extends AbstractCacheCommand */ protected static string $toggleName; + /** + * {@inheritdoc} + */ protected function configure(): void { $this ->addArgument( - self::COMMAND_ARGUMENT_CODE, + static::COMMAND_ARGUMENT_CODE, InputArgument::OPTIONAL, 'Code of cache (Multiple codes operated by comma)' ); @@ -41,26 +52,22 @@ protected function configure(): void parent::configure(); } - /** - * @param InputInterface $input - * @param OutputInterface $output - * @return int + * {@inheritdoc} + * + * @uses Mage::app() */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->detectMagento($output); - $this->initMagento(); - $codeArgument = BinaryString::trimExplodeEmpty(',', $input->getArgument(self::COMMAND_ARGUMENT_CODE)); $this->saveCacheStatus($codeArgument, static::$cacheStatus); if (static::$cacheStatus === false) { if (empty($codeArgument)) { - $this->_getCacheModel()->flush(); + Mage::app()->getCacheInstance()->flush(); } else { foreach ($codeArgument as $type) { - $this->_getCacheModel()->cleanType($type); + Mage::app()->getCacheInstance()->cleanType($type); } } } @@ -79,23 +86,26 @@ protected function execute(InputInterface $input, OutputInterface $output): int /** * @param string[] $codeArgument * @param bool $status + * * @return void + * + * @uses Mage::app() */ - protected function saveCacheStatus(array $codeArgument, bool $status): void + private function saveCacheStatus(array $codeArgument, bool $status): void { $this->validateCacheCodes($codeArgument); - $cacheTypes = $this->_getCacheModel()->getTypes(); - $enable = $this->_getMage()->useCache(); + $cacheTypes = $this->getAllCacheTypes(); + $enable = Mage::app()->useCache(); if (is_array($enable)) { - foreach ($cacheTypes as $cacheCode => $cacheModel) { + foreach (array_keys($cacheTypes) as $cacheCode) { if (empty($codeArgument) || in_array($cacheCode, $codeArgument)) { $enable[$cacheCode] = $status ? 1 : 0; } } - $this->_getMage()->saveUseCache($enable); + Mage::app()->saveUseCache($enable); } } } diff --git a/src/N98/Magento/Command/Cache/DisableCommand.php b/src/N98/Magento/Command/Cache/Toggle/DisableCommand.php similarity index 84% rename from src/N98/Magento/Command/Cache/DisableCommand.php rename to src/N98/Magento/Command/Cache/Toggle/DisableCommand.php index a22ba35a7..6b8907f4f 100644 --- a/src/N98/Magento/Command/Cache/DisableCommand.php +++ b/src/N98/Magento/Command/Cache/Toggle/DisableCommand.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace N98\Magento\Command\Cache; +namespace N98\Magento\Command\Cache\Toggle; /** * Disable cache command * - * @package N98\Magento\Command\Cache + * @package N98\Magento\Command\Cache\Toggle */ class DisableCommand extends AbstractCacheCommandToggle { diff --git a/src/N98/Magento/Command/Cache/EnableCommand.php b/src/N98/Magento/Command/Cache/Toggle/EnableCommand.php similarity index 80% rename from src/N98/Magento/Command/Cache/EnableCommand.php rename to src/N98/Magento/Command/Cache/Toggle/EnableCommand.php index 68f5010e5..02ab35129 100644 --- a/src/N98/Magento/Command/Cache/EnableCommand.php +++ b/src/N98/Magento/Command/Cache/Toggle/EnableCommand.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace N98\Magento\Command\Cache; +namespace N98\Magento\Command\Cache\Toggle; /** - * Enable cache command + * Enable cache command * - * @package N98\Magento\Command\Cache + * @package N98\Magento\Command\Cache\Toggle */ class EnableCommand extends AbstractCacheCommandToggle { diff --git a/src/N98/Magento/Command/Cache/ViewCommand.php b/src/N98/Magento/Command/Cache/ViewCommand.php index 9cca8b584..3c2b08c89 100644 --- a/src/N98/Magento/Command/Cache/ViewCommand.php +++ b/src/N98/Magento/Command/Cache/ViewCommand.php @@ -4,14 +4,12 @@ namespace N98\Magento\Command\Cache; +use N98\Magento\MageMethods as Mage; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Question\Question; -use Symfony\Component\Validator\Constraints\NotBlank; -use Symfony\Component\Validator\Validation; /** * View cache command @@ -53,22 +51,25 @@ protected function configure(): void /** * {@inheritDoc} - * @return int + * + * @uses Mage::app() */ protected function execute(InputInterface $input, OutputInterface $output): int { /** @var string $cacheId */ $cacheId = $input->getArgument(self::COMMAND_ARGUMENT_ID); - $cacheInstance = $this->getCacheInstance(); - /** @var string $cacheData */ + $cacheInstance = Mage::app()->getCacheInstance(); $cacheData = $cacheInstance->load($cacheId); - if ($input->getOption(self::COMMAND_OPTION_UNSERIALZE)) { - $cacheData = unserialize($cacheData); - $cacheData = print_r($cacheData, true); - } - $output->writeln($cacheData); + if (is_string($cacheData)) { + if ($input->getOption(self::COMMAND_OPTION_UNSERIALZE)) { + $cacheData = unserialize($cacheData); + $cacheData = print_r($cacheData, true); + } + + $output->writeln($cacheData); + } return Command::SUCCESS; } diff --git a/src/N98/Magento/Command/Cms/Block/AbstractCmsBlockCommand.php b/src/N98/Magento/Command/Cms/Block/AbstractCmsBlockCommand.php index 20986305f..fca557d06 100644 --- a/src/N98/Magento/Command/Cms/Block/AbstractCmsBlockCommand.php +++ b/src/N98/Magento/Command/Cms/Block/AbstractCmsBlockCommand.php @@ -4,8 +4,8 @@ namespace N98\Magento\Command\Cms\Block; -use Symfony\Component\Validator\Exception\UnexpectedValueException; -use Mage_Cms_Model_Block; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; use N98\Magento\Command\AbstractCommand; /** @@ -14,16 +14,13 @@ class AbstractCmsBlockCommand extends AbstractCommand { /** - * Get an instance of cms/block - * - * @return Mage_Cms_Model_Block + * {@inheritDoc} */ - protected function _getBlockModel(): Mage_Cms_Model_Block + public function initialize(InputInterface $input, OutputInterface $output): void { - $model = $this->_getModel('cms/block'); - if (!$model instanceof Mage_Cms_Model_Block) { - throw new UnexpectedValueException($model, Mage_Cms_Model_Block::class); - } - return $model; + parent::initialize($input, $output); + + $this->detectMagento($output); + $this->initMagento(); } } diff --git a/src/N98/Magento/Command/Cms/Block/ListCommand.php b/src/N98/Magento/Command/Cms/Block/ListCommand.php index f01a03239..6249d10fe 100644 --- a/src/N98/Magento/Command/Cms/Block/ListCommand.php +++ b/src/N98/Magento/Command/Cms/Block/ListCommand.php @@ -7,6 +7,7 @@ use Mage_Cms_Model_Block; use Mage_Core_Exception; use N98\Magento\Command\CommandDataInterface; +use N98\Magento\Methods\Cms\Block; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -29,29 +30,42 @@ class ListCommand extends AbstractCmsBlockCommand implements CommandDataInterfac */ protected static $defaultDescription = 'List all CMS blocks.'; + /** + * {@inheritdoc} + */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getDataHeaders(InputInterface $input, OutputInterface $output): array + { + return ['block_id', 'title', 'identifier', 'is_active', 'store_ids']; + } + /** * {@inheritdoc} * @throws Mage_Core_Exception - * - * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter + * @uses Block::getModel() */ - public function setData(InputInterface $input,OutputInterface $output) : void + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getData(InputInterface $input, OutputInterface $output): array { - $this->data = []; - - /** @var Mage_Cms_Model_Block[] $cmsBlockCollection */ - $cmsBlockCollection = $this->_getBlockModel()->getCollection()->addFieldToSelect('*'); - $resourceModel = $this->_getBlockModel()->getResource(); - foreach ($cmsBlockCollection as $cmsBlock) { - $storeIds = implode(',', $resourceModel->lookupStoreIds((int)$cmsBlock->getId())); - - $this->data[] = [ - 'block_id' => $cmsBlock->getBlockId(), - 'title' => $cmsBlock->getTitle(), - 'identifier' => $cmsBlock->getIdentifier(), - 'is_active' => $cmsBlock->getIsActive() ? 'active' : 'inactive', - 'store_ids' => $storeIds - ]; + if (is_null($this->data)) { + $this->data = []; + + /** @var Mage_Cms_Model_Block[] $cmsBlockCollection */ + $cmsBlockCollection = Block::getModel()->getCollection()->addFieldToSelect('*'); + $resourceModel = Block::getModel()->getResource(); + foreach ($cmsBlockCollection as $cmsBlock) { + $storeIds = implode(',', $resourceModel->lookupStoreIds((int)$cmsBlock->getId())); + + $this->data[] = [ + $cmsBlock->getBlockId(), + $cmsBlock->getTitle(), + $cmsBlock->getIdentifier(), + $cmsBlock->getIsActive() ? 'active' : 'inactive', + $storeIds + ]; + } } + + return $this->data; } } diff --git a/src/N98/Magento/Command/Cms/Block/ToggleCommand.php b/src/N98/Magento/Command/Cms/Block/ToggleCommand.php index dae9d9632..475dac374 100644 --- a/src/N98/Magento/Command/Cms/Block/ToggleCommand.php +++ b/src/N98/Magento/Command/Cms/Block/ToggleCommand.php @@ -4,6 +4,7 @@ namespace N98\Magento\Command\Cms\Block; +use N98\Magento\Methods\Cms\Block; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -45,8 +46,8 @@ protected function configure(): void /** * {@inheritDoc} - * @return int * @throws Throwable + * @uses Block::getModel() */ protected function execute(InputInterface $input, OutputInterface $output): int { @@ -54,7 +55,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int /** @var string $blockId */ $blockId = $input->getArgument(self::COMMAND_ARGUMENT_BLOCK_ID); - $block = $this->_getBlockModel()->load($blockId, is_numeric($blockId) ? null : 'identifier'); + $block = Block::getModel()->load($blockId, is_numeric($blockId) ? null : 'identifier'); if (!$block->getId()) { $output->writeln('Block was not found'); diff --git a/src/N98/Magento/Command/CommandAware.php b/src/N98/Magento/Command/CommandAware.php index a0c205248..5f571d62e 100644 --- a/src/N98/Magento/Command/CommandAware.php +++ b/src/N98/Magento/Command/CommandAware.php @@ -1,5 +1,7 @@ > */ - public function setData(InputInterface $input, OutputInterface $output): void; + public function getData(InputInterface $input, OutputInterface $output): array; } diff --git a/src/N98/Magento/Command/Config/DumpCommand.php b/src/N98/Magento/Command/Config/DumpCommand.php index d43f765fa..0e4963fa0 100644 --- a/src/N98/Magento/Command/Config/DumpCommand.php +++ b/src/N98/Magento/Command/Config/DumpCommand.php @@ -6,6 +6,7 @@ use DOMDocument; use InvalidArgumentException; +use N98\Magento\MageMethods as Mage; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -68,16 +69,16 @@ public function getHelp(): string } /** - * @param InputInterface $input - * @param OutputInterface $output - * @return int + * {@inheritDoc} * @throws InvalidArgumentException + * + * @uses Mage::getConfig() */ protected function execute(InputInterface $input, OutputInterface $output): int { /** @var string|null $xpath */ $xpath = $input->getArgument(self::COMMAND_ARGUMENT_XPATH); - $config = $this->_getMageConfig()->getNode($xpath); + $config = Mage::getConfig()->getNode($xpath); if (!$config) { throw new InvalidArgumentException('xpath was not found'); } diff --git a/src/N98/Magento/Command/Config/SearchCommand.php b/src/N98/Magento/Command/Config/SearchCommand.php index 5a685a074..8d43668a9 100644 --- a/src/N98/Magento/Command/Config/SearchCommand.php +++ b/src/N98/Magento/Command/Config/SearchCommand.php @@ -5,6 +5,7 @@ namespace N98\Magento\Command\Config; use Mage_Core_Model_Config_Element; +use N98\Magento\Methods\MageBase as Mage; use RuntimeException; use stdClass; use Symfony\Component\Console\Command\Command; @@ -51,15 +52,18 @@ protected function configure(): void */ public function getHelp(): string { - return << and for the indicated text. -EOT; + return << and for the indicated text. +HELP; } /** * @param InputInterface $input * @param OutputInterface $output + * * @return int + * + * @uses Mage::getConfig() */ protected function execute(InputInterface $input, OutputInterface $output): int { @@ -67,12 +71,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int /** @var string $searchString */ $searchString = $input->getArgument(self::COMMAND_ARGUMENT_TEXT); - $system = $this->_getMageConfig()->loadModulesConfiguration('system.xml'); + $system = Mage::getConfig()->loadModulesConfiguration('system.xml'); $matches = $this->_searchConfiguration($searchString, $system); if (count($matches) > 0) { foreach ($matches as $match) { - $output->writeln('Found a ' . $match->type . ' with a match'); + $output->writeln(sprintf('Found a %s with a match', $match->type)); $output->writeln(' ' . $this->_getPhpMageStoreConfigPathFromMatch($match)); $output->writeln(' ' . $this->_getPathFromMatch($match)); @@ -81,7 +85,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int ' ' . str_ireplace( $searchString, - '' . $searchString . '', + sprintf('%s', $searchString), (string) $match->node->comment ) ); @@ -89,7 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln(''); } } else { - $output->writeln('No matches for ' . $searchString . ''); + $output->writeln(sprintf('No matches for %s', $searchString)); } return Command::SUCCESS; diff --git a/src/N98/Magento/Command/Customer/AbstractCustomerCommand.php b/src/N98/Magento/Command/Customer/AbstractCustomerCommand.php index ebdd49c9b..acd4423b3 100644 --- a/src/N98/Magento/Command/Customer/AbstractCustomerCommand.php +++ b/src/N98/Magento/Command/Customer/AbstractCustomerCommand.php @@ -4,12 +4,6 @@ namespace N98\Magento\Command\Customer; -use Mage; -use Mage_Customer_Model_Address; -use Mage_Customer_Model_Customer; -use Mage_Customer_Model_Resource_Customer_Collection; -use Mage_Directory_Model_Resource_Country_Collection; -use Mage_Directory_Model_Resource_Region_Collection; use N98\Magento\Command\AbstractCommand; /** @@ -24,44 +18,4 @@ abstract class AbstractCustomerCommand extends AbstractCommand public const COMMAND_ARGUMENT_PASSWORD = 'password'; public const COMMAND_ARGUMENT_WEBSITE = 'website'; - - /** - * @return Mage_Customer_Model_Customer - */ - protected function getCustomerModel(): Mage_Customer_Model_Customer - { - return Mage::getModel('customer/customer'); - } - - /** - * @return Mage_Customer_Model_Resource_Customer_Collection - */ - protected function getCustomerCollection(): Mage_Customer_Model_Resource_Customer_Collection - { - return Mage::getResourceModel('customer/customer_collection'); - } - - /** - * @return Mage_Customer_Model_Address - */ - protected function getAddressModel(): Mage_Customer_Model_Address - { - return Mage::getModel('customer/address'); - } - - /** - * @return Mage_Directory_Model_Resource_Region_Collection - */ - protected function getRegionCollection(): Mage_Directory_Model_Resource_Region_Collection - { - return Mage::getResourceModel('directory/region_collection'); - } - - /** - * @return Mage_Directory_Model_Resource_Country_Collection - */ - protected function getCountryCollection(): Mage_Directory_Model_Resource_Country_Collection - { - return Mage::getResourceModel('directory/country_collection'); - } } diff --git a/src/N98/Magento/Command/Customer/ChangePasswordCommand.php b/src/N98/Magento/Command/Customer/ChangePasswordCommand.php index f54e93b38..48931066c 100644 --- a/src/N98/Magento/Command/Customer/ChangePasswordCommand.php +++ b/src/N98/Magento/Command/Customer/ChangePasswordCommand.php @@ -7,6 +7,7 @@ use Exception; use Mage_Core_Exception; use Mage_Core_Model_Website; +use N98\Magento\Methods\Customer; use RuntimeException; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; @@ -15,6 +16,9 @@ use Symfony\Component\Console\Question\Question; use Throwable; +use function implode; +use function is_array; + /** * Change password command * @@ -32,6 +36,9 @@ class ChangePasswordCommand extends AbstractCustomerCommand */ protected static $defaultDescription = 'Changes the password of a customer.'; + /** + * {@inheritDoc} + */ protected function configure(): void { $this @@ -54,7 +61,7 @@ protected function configure(): void } /** - * @return string + * {@inheritDoc} */ public function getHelp(): string { @@ -64,11 +71,12 @@ public function getHelp(): string } /** - * @param InputInterface $input - * @param OutputInterface $output - * @return int + * {@inheritDoc} + * * @throws Mage_Core_Exception * @throws Throwable + * + * @uses Customer\Customer::getModel() */ protected function execute(InputInterface $input, OutputInterface $output): int { @@ -85,7 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int /** @var Mage_Core_Model_Website $website */ $website = $parameterHelper->askWebsite($input, $output); - $customer = $this->getCustomerModel() + $customer = Customer\Customer::getModel() ->setWebsiteId($website->getId()) ->loadByEmail($email); if ($customer->getId() <= 0) { @@ -103,7 +111,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $customer->save(); $output->writeln('Password successfully changed'); } catch (Exception $e) { - $output->writeln('' . $e->getMessage() . ''); + $output->writeln(sprintf('%s', $e->getMessage())); } return Command::SUCCESS; diff --git a/src/N98/Magento/Command/Customer/CreateCommand.php b/src/N98/Magento/Command/Customer/CreateCommand.php index 69ac3ee9e..d160aea54 100644 --- a/src/N98/Magento/Command/Customer/CreateCommand.php +++ b/src/N98/Magento/Command/Customer/CreateCommand.php @@ -6,12 +6,17 @@ use Mage_Core_Exception; use Mage_Core_Model_Website; +use N98\Magento\Methods\Customer; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use RuntimeException; use Throwable; +use function is_null; +use function sprintf; + /** * Create customer command * @@ -33,6 +38,9 @@ class CreateCommand extends AbstractCustomerCommand */ protected static $defaultDescription = 'Creates a new customer/user for shop frontend.'; + /** + * {@inheritDoc} + */ protected function configure(): void { $this @@ -67,10 +75,10 @@ protected function configure(): void /** * {@inheritDoc} - * @return void + * * @throws Mage_Core_Exception */ - public function interact(InputInterface $input,OutputInterface $output): void + public function interact(InputInterface $input, OutputInterface $output): void { $parameterHelper = $this->getParameterHelper(); @@ -97,7 +105,6 @@ public function interact(InputInterface $input,OutputInterface $output): void /** * {@inheritDoc} - * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int { @@ -141,7 +148,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int * @param string $firstname * @param string $lastname * @param Mage_Core_Model_Website $website + * * @return void + * + * @uses Customer\Customer::getModel() */ private function saveCustomer( string $email, @@ -150,17 +160,17 @@ private function saveCustomer( string $lastname, Mage_Core_Model_Website $website ): void { - $customer = $this->getCustomerModel(); + $customer = Customer\Customer::getModel(); $customer->setWebsiteId($website->getId()); try { $customer->loadByEmail($email); } catch (Mage_Core_Exception $exception) { - throw new \RuntimeException($exception->getMessage()); + throw new RuntimeException($exception->getMessage()); } if ($customer->getId()) { - throw new \RuntimeException(sprintf('Customer %s already exists', $email)); + throw new RuntimeException(sprintf('Customer %s already exists', $email)); } $customer->setWebsiteId($website->getId()); @@ -173,10 +183,8 @@ private function saveCustomer( $customer->save(); $customer->setConfirmation(null); $customer->save(); + } catch (Throwable $exception) { + throw new RuntimeException($exception->getMessage()); } - catch (Throwable $exception) { - throw new \RuntimeException($exception->getMessage()); - } - } } diff --git a/src/N98/Magento/Command/Customer/CreateDummyCommand.php b/src/N98/Magento/Command/Customer/CreateDummyCommand.php index 2b6b0a2c8..5c9c2dec6 100644 --- a/src/N98/Magento/Command/Customer/CreateDummyCommand.php +++ b/src/N98/Magento/Command/Customer/CreateDummyCommand.php @@ -6,14 +6,18 @@ use Faker\Factory; use Faker\Generator; +use Mage_Core_Exception; use Mage_Core_Model_Website; use Mage_Customer_Model_Address; +use N98\Magento\Methods\Customer; +use N98\Magento\Methods\Directory; use N98\Util\Faker\Provider\Internet; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use Throwable; /** * Create dummy customer command @@ -96,11 +100,15 @@ public function getHelp(): string * @param InputInterface $input * @param OutputInterface $output * @return int - * @throws \Mage_Core_Exception + * @throws Mage_Core_Exception + * @throws Throwable + * + * @uses Customer\Customer::getModel() + * @uses Internet */ protected function execute(InputInterface $input, OutputInterface $output): int { - $res = $this->getCustomerModel()->getResource(); + $res = Customer\Customer::getModel()->getResource(); /** @var string $locale */ $locale = $input->getArgument(self::COMMAND_ARGUMENT_LOCALE); @@ -118,7 +126,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $table = []; for ($i = 0; $i < $count; $i++) { - $customer = $this->getCustomerModel(); + $customer = Customer\Customer::getModel(); $email = $faker->safeEmail; @@ -143,16 +151,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int $customer->save(); if ($outputPlain) { - $output->writeln( - 'Customer ' . $email . ' with password ' . $password . - ' successfully created' - ); + $output->writeln(sprintf( + 'Customer %s with password %s successfully created', + $email, + $password + )); } else { $table[] = [$email, $password, $customer->getFirstname(), $customer->getLastname()]; } } else { if ($outputPlain) { - $output->writeln('Customer ' . $email . ' already exists'); + $output->writeln(sprintf('Customer %s already exists', $email)); } } if ($i % 1000 == 0) { @@ -176,18 +185,22 @@ protected function execute(InputInterface $input, OutputInterface $output): int /** * @param Generator $faker + * * @return Mage_Customer_Model_Address + * + * @uses Customer\Address::getModel() + * @uses Directory\Country\Collection::getResourceModel() */ - private function createAddress($faker): Mage_Customer_Model_Address + private function createAddress(Generator $faker): Mage_Customer_Model_Address { - $country = $this->getCountryCollection() + $country = Directory\Country\Collection::getResourceModel() ->addCountryCodeFilter($faker->countryCode, 'iso2') ->getFirstItem(); $regions = $country->getRegions()->getData(); $region = $regions ? $regions[array_rand($regions)] : null; - $address = $this->getAddressModel(); + $address = Customer\Address::getModel(); $address->setFirstname($faker->firstName); $address->setLastname($faker->lastName); $address->setCity($faker->city); diff --git a/src/N98/Magento/Command/Customer/DeleteCommand.php b/src/N98/Magento/Command/Customer/DeleteCommand.php index 6985ecf0f..eb0960eb0 100644 --- a/src/N98/Magento/Command/Customer/DeleteCommand.php +++ b/src/N98/Magento/Command/Customer/DeleteCommand.php @@ -9,6 +9,7 @@ use Mage_Core_Model_Website; use Mage_Customer_Model_Customer; use Mage_Customer_Model_Resource_Customer_Collection; +use N98\Magento\Methods\Customer; use RuntimeException; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; @@ -19,6 +20,10 @@ use Symfony\Component\Console\Question\Question; use Throwable; +use function sort; +use function sprintf; +use function vsprintf; + /** * Delete customer command * @@ -44,6 +49,9 @@ class DeleteCommand extends AbstractCustomerCommand */ protected static $defaultDescription = 'Deletes customers.'; + /** + * {@inheritDoc} + */ protected function configure(): void { $this @@ -55,24 +63,27 @@ protected function configure(): void ) ->addOption( self::COMMAND_OPTION_ALL, - 'a', InputOption::VALUE_NONE, + 'a', + InputOption::VALUE_NONE, 'Delete all customers' ) ->addOption( self::COMMAND_OPTION_FORCE, - 'f', InputOption::VALUE_NONE, + 'f', + InputOption::VALUE_NONE, 'Force delete' ) ->addOption( self::COMMAND_OPTION_RANGE, - '-r', InputOption::VALUE_NONE, + '-r', + InputOption::VALUE_NONE, 'Delete a range of customers by Id' ) ; } /** - * @return string + * {@inheritDoc} */ public function getHelp(): string { @@ -90,11 +101,12 @@ public function getHelp(): string } /** - * @param InputInterface $input - * @param OutputInterface $output - * @return int + * {@inheritDoc} + * * @throws Mage_Core_Exception * @throws Throwable + * + * @uses Customer\Customer\Collection::getResourceModel() */ protected function execute(InputInterface $input, OutputInterface $output): int { @@ -158,7 +170,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Aborting delete'); } } else { - $customers = $this->getCustomerCollection(); + $customers = Customer\Customer\Collection::getResourceModel(); $customers ->addAttributeToSelect('firstname') ->addAttributeToSelect('lastname') @@ -182,12 +194,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int sort($ranges); // Range delete, takes precedence over --all - $customers->addAttributeToFilter('entity_id', ['from' => $ranges[0], 'to' => $ranges[1]]); + $customers->addAttributeToFilter('entity_id', [ + 'from' => $ranges[0], + 'to' => $ranges[1] + ]); } if ($this->shouldRemove($input, $output)) { $count = $this->batchDelete($output, $customers); - $output->writeln('Successfully deleted ' . $count . ' customer/s'); + $output->writeln(sprintf('Successfully deleted %s customer/s', $count)); } else { $output->writeln('Aborting delete'); } @@ -221,17 +236,21 @@ protected function shouldRemove(InputInterface $input, OutputInterface $output): * @param InputInterface $input * @param OutputInterface $output * @param int|string $id + * * @return Mage_Customer_Model_Customer + * * @throws Mage_Core_Exception + * + * @uses Customer\Customer::getModel() */ protected function getCustomer(InputInterface $input, OutputInterface $output, $id): Mage_Customer_Model_Customer { - $customer = $this->getCustomerModel()->load($id); + $customer = Customer\Customer::getModel()->load($id); if (!$customer->getId()) { $parameterHelper = $this->getParameterHelper(); /** @var Mage_Core_Model_Website $website */ $website = $parameterHelper->askWebsite($input, $output); - $customer = $this->getCustomerModel() + $customer = Customer\Customer::getModel() ->setWebsiteId($website->getId()) ->loadByEmail($id); } @@ -246,7 +265,9 @@ protected function getCustomer(InputInterface $input, OutputInterface $output, $ /** * @param OutputInterface $output * @param Mage_Customer_Model_Customer $customer + * * @return true|Exception + * * @throws Throwable */ protected function deleteCustomer(OutputInterface $output, Mage_Customer_Model_Customer $customer) @@ -260,7 +281,7 @@ protected function deleteCustomer(OutputInterface $output, Mage_Customer_Model_C )); return true; } catch (Exception $e) { - $output->writeln('' . $e->getMessage() . ''); + $output->writeln(sprintf('%s', $e->getMessage())); return $e; } } @@ -305,6 +326,7 @@ public function validateInt(string $answer): string /** * @param string $message * @param string|null $default [optional] + * * @return Question */ private function getQuestion(string $message, ?string $default = null): Question diff --git a/src/N98/Magento/Command/Customer/InfoCommand.php b/src/N98/Magento/Command/Customer/InfoCommand.php index bcc38c6b1..618aaf3a1 100644 --- a/src/N98/Magento/Command/Customer/InfoCommand.php +++ b/src/N98/Magento/Command/Customer/InfoCommand.php @@ -8,11 +8,16 @@ use Mage_Core_Exception; use Mage_Core_Model_Website; use Mage_Customer_Model_Attribute; +use N98\Magento\Methods\Customer; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use function implode; +use function in_array; +use function is_array; + /** * Info customer command * @@ -35,6 +40,9 @@ class InfoCommand extends AbstractCustomerCommand */ protected array $blacklist = ['password_hash', 'increment_id']; + /** + * {@inheritDoc} + */ protected function configure(): void { $this @@ -51,7 +59,12 @@ protected function configure(): void ; } - public function interact(InputInterface $input,OutputInterface $output) + /** + * {@inheritDoc} + * + * @throws Mage_Core_Exception + */ + public function interact(InputInterface $input, OutputInterface $output): void { $parameterHelper = $this->getParameterHelper(); @@ -62,14 +75,14 @@ public function interact(InputInterface $input,OutputInterface $output) // Website $website = $parameterHelper->askWebsite($input, $output, self::COMMAND_ARGUMENT_WEBSITE); $input->setArgument(self::COMMAND_ARGUMENT_WEBSITE, $website); - } /** - * @param InputInterface $input - * @param OutputInterface $output - * @return int + * {@inheritDoc} + * * @throws Mage_Core_Exception + * + * @uses Customer\Customer::getModel() */ protected function execute(InputInterface $input, OutputInterface $output): int { @@ -78,7 +91,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int /** @var Mage_Core_Model_Website $website */ $website = $input->getArgument(self::COMMAND_ARGUMENT_WEBSITE); - $customer = $this->getCustomerModel() + $customer = Customer\Customer::getModel() ->setWebsiteId($website->getId()) ->loadByEmail($email); if ($customer->getId() <= 0) { diff --git a/src/N98/Magento/Command/Customer/ListCommand.php b/src/N98/Magento/Command/Customer/ListCommand.php index 5745a7aac..0c131ec64 100644 --- a/src/N98/Magento/Command/Customer/ListCommand.php +++ b/src/N98/Magento/Command/Customer/ListCommand.php @@ -7,10 +7,13 @@ use Mage_Core_Exception; use Mage_Customer_Model_Customer; use N98\Magento\Command\CommandDataInterface; +use N98\Magento\Methods\Customer; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use function is_null; + /** * List customer command * @@ -34,6 +37,9 @@ class ListCommand extends AbstractCustomerCommand implements CommandDataInterfac */ protected static $defaultDescription = 'Lists customers.'; + /** + * {@inheritDoc} + */ protected function configure(): void { $this->addArgument( @@ -46,7 +52,7 @@ protected function configure(): void } /** - * @return string + * {@inheritDoc} */ public function getHelp(): string { @@ -56,43 +62,58 @@ public function getHelp(): string HELP; } + /** + * {@inheritdoc} + */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getDataHeaders(InputInterface $input, OutputInterface $output): array + { + return ['id', 'email', 'firstname', 'lastname', 'website']; + } + /** * {@inheritDoc} + * * @throws Mage_Core_Exception * - * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter + * @uses Customer\Customer\Collection::getResourceModel() */ - public function setData(InputInterface $input,OutputInterface $output) : void + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getData(InputInterface $input, OutputInterface $output): array { - $this->data = []; - - $config = $this->getCommandConfig(); - - $collection = $this->getCustomerCollection(); - $collection->addAttributeToSelect(['entity_id', 'email', 'firstname', 'lastname', 'website_id']); - - $search = $input->getArgument(self::COMMAND_ARGUMENT_SEARCH); - if ($search) { - $collection->addAttributeToFilter( - [ - ['attribute' => 'email', 'like' => '%' . $search . '%'], - ['attribute' => 'firstname', 'like' => '%' . $search . '%'], - ['attribute' => 'lastname', 'like' => '%' . $search . '%'] - ] - ); + if (is_null($this->data)) { + $this->data = []; + + $config = $this->getCommandConfig(); + + $collection = Customer\Customer\Collection::getResourceModel(); + $collection->addAttributeToSelect(['entity_id', 'email', 'firstname', 'lastname', 'website_id']); + + $search = $input->getArgument(self::COMMAND_ARGUMENT_SEARCH); + if ($search) { + $collection->addAttributeToFilter( + [ + ['attribute' => 'email', 'like' => '%' . $search . '%'], + ['attribute' => 'firstname', 'like' => '%' . $search . '%'], + ['attribute' => 'lastname', 'like' => '%' . $search . '%'] + ] + ); + } + + $collection->setPageSize($config['limit']); + + /** @var Mage_Customer_Model_Customer $customer */ + foreach ($collection as $customer) { + $this->data[] = [ + $customer->getId(), + $customer->getEmail(), + $customer->getFirstname(), + $customer->getLastname(), + $this->_getWebsiteCodeById((int)$customer->getwebsiteId()) + ]; + } } - $collection->setPageSize($config['limit']); - - /** @var Mage_Customer_Model_Customer $customer */ - foreach ($collection as $customer) { - $this->data[] = [ - 'id' => $customer->getId(), - 'email' => $customer->getEmail(), - 'firstname' => $customer->getFirstname(), - 'lastname' => $customer->getLastname(), - 'website' => $this->_getWebsiteCodeById((int)$customer->getwebsiteId()) - ]; - } + return $this->data; } } diff --git a/src/N98/Magento/Command/Database/AbstractDatabaseCommand.php b/src/N98/Magento/Command/Database/AbstractDatabaseCommand.php index e92c81a0f..0055a0c1a 100644 --- a/src/N98/Magento/Command/Database/AbstractDatabaseCommand.php +++ b/src/N98/Magento/Command/Database/AbstractDatabaseCommand.php @@ -19,7 +19,7 @@ abstract class AbstractDatabaseCommand extends AbstractCommand { /** - * @var array|DbSettings + * @var array|DbSettings */ protected $dbSettings; @@ -30,9 +30,9 @@ abstract class AbstractDatabaseCommand extends AbstractCommand /** * @param OutputInterface $output - * @param null $connectionNode + * @param string|null $connectionNode */ - protected function detectDbSettings(OutputInterface $output, $connectionNode = null) + protected function detectDbSettings(OutputInterface $output, ?string $connectionNode = null): void { $database = $this->getDatabaseHelper(); $this->dbSettings = $database->getDbSettings($output); @@ -43,7 +43,7 @@ protected function detectDbSettings(OutputInterface $output, $connectionNode = n * * @return PDO|void */ - public function __get($name) + public function __get(string $name) { if ($name == '_connection') { // TODO(tk): deprecate diff --git a/src/N98/Magento/Command/Database/AbstractShowCommand.php b/src/N98/Magento/Command/Database/AbstractShowCommand.php index 1d0812b24..58fa8e2e1 100644 --- a/src/N98/Magento/Command/Database/AbstractShowCommand.php +++ b/src/N98/Magento/Command/Database/AbstractShowCommand.php @@ -4,9 +4,6 @@ namespace N98\Magento\Command\Database; -use Description; -use N98\Util\Console\Helper\DatabaseHelper; -use N98\Util\Console\Helper\Table\Renderer\RendererFactory; use N98\Util\Filesystem; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; @@ -29,16 +26,19 @@ abstract class AbstractShowCommand extends AbstractDatabaseCommand /** * @var InputInterface|null */ + // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore protected ?InputInterface $_input = null; /** * @var OutputInterface|null */ + // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore protected ?OutputInterface $_output = null; /** * @var array */ + // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore protected array $_importantVars = []; /** @@ -46,6 +46,7 @@ abstract class AbstractShowCommand extends AbstractDatabaseCommand * * @var array */ + // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore protected array $_specialFormat = []; /** @@ -53,6 +54,7 @@ abstract class AbstractShowCommand extends AbstractDatabaseCommand * * @var array */ + // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore protected array $_allVariables = []; protected function configure(): void @@ -63,12 +65,6 @@ protected function configure(): void InputArgument::OPTIONAL, 'Only output variables of specified name. The wildcard % is supported!' ) - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' - ) ->addOption( 'rounding', null, @@ -81,7 +77,9 @@ protected function configure(): void null, InputOption::VALUE_NONE, 'Disable description' - ); + ) + ->addFormatOption() + ; } /** @@ -104,7 +102,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int false === $this->_input->getOption('no-description'); $header = ['Variable Name', 'Value']; if (true === $hasDescription) { - $header[] = Description::class; + $header[] = 'Description'; } $this->renderTable($header, $this->generateRows($outputVars, $hasDescription)); @@ -168,7 +166,7 @@ protected function formatDesc(string $desc): string * @param array $header * @param array $rows */ - protected function renderTable(array $header, array $rows) + protected function renderTable(array $header, array $rows): void { $tableHelper = $this->getTableHelper(); $tableHelper->setHeaders($header) @@ -178,11 +176,9 @@ protected function renderTable(array $header, array $rows) /** * @param string|null $variable */ - protected function initVariables(?string $variable = null) + protected function initVariables(?string $variable = null): void { - /** @var DatabaseHelper $database */ - $database = $this->getHelper('database'); - $this->_allVariables = $database->{$this->showMethod}($variable); + $this->_allVariables = $this->getDatabaseHelper()->{$this->showMethod}($variable); } /** diff --git a/src/N98/Magento/Command/Database/Compressor/AbstractCompressor.php b/src/N98/Magento/Command/Database/Compressor/AbstractCompressor.php index 2ad59b10a..6689c707e 100644 --- a/src/N98/Magento/Command/Database/Compressor/AbstractCompressor.php +++ b/src/N98/Magento/Command/Database/Compressor/AbstractCompressor.php @@ -1,18 +1,24 @@ - */ + +declare(strict_types=1); namespace N98\Magento\Command\Database\Compressor; @@ -11,6 +8,7 @@ * Interface Compressor * * @package N98\Magento\Command\Database\Compressor + * @author Tom Klingenberg */ interface Compressor { @@ -21,7 +19,7 @@ interface Compressor * @param bool $pipe * @return string */ - public function getCompressingCommand($command, $pipe = true); + public function getCompressingCommand(string $command, bool $pipe = true): string; /** * Returns the command line for decompressing the dump file. @@ -31,7 +29,7 @@ public function getCompressingCommand($command, $pipe = true); * @param bool $pipe * @return string */ - public function getDecompressingCommand($command, $fileName, $pipe = true); + public function getDecompressingCommand(string $command, string $fileName, bool $pipe = true): string; /** * Returns the file name for the compressed dump file. @@ -40,5 +38,5 @@ public function getDecompressingCommand($command, $fileName, $pipe = true); * @param bool $pipe * @return string */ - public function getFileName($fileName, $pipe = true); + public function getFileName(string $fileName, bool $pipe = true): string; } diff --git a/src/N98/Magento/Command/Database/Compressor/Gzip.php b/src/N98/Magento/Command/Database/Compressor/Gzip.php index 9080da02e..1056047c8 100644 --- a/src/N98/Magento/Command/Database/Compressor/Gzip.php +++ b/src/N98/Magento/Command/Database/Compressor/Gzip.php @@ -1,7 +1,14 @@ hasPipeViewer()) { @@ -53,7 +60,7 @@ public function getDecompressingCommand($command, $fileName, $pipe = true) * @param bool $pipe * @return string */ - public function getFileName($fileName, $pipe = true) + public function getFileName(string $fileName, bool $pipe = true): string { if (!strlen($fileName)) { return $fileName; diff --git a/src/N98/Magento/Command/Database/Compressor/Uncompressed.php b/src/N98/Magento/Command/Database/Compressor/Uncompressed.php index 1e3ca8ec4..67223cbb1 100644 --- a/src/N98/Magento/Command/Database/Compressor/Uncompressed.php +++ b/src/N98/Magento/Command/Database/Compressor/Uncompressed.php @@ -1,7 +1,14 @@ hasPipeViewer()) { return 'pv ' . $fileName . ' | ' . $command; @@ -40,7 +47,7 @@ public function getDecompressingCommand($command, $fileName, $pipe = true) * @param bool $pipe * @return string */ - public function getFileName($fileName, $pipe = true) + public function getFileName(string $fileName, bool $pipe = true): string { if (!strlen($fileName)) { return $fileName; diff --git a/src/N98/Magento/Command/Database/InfoCommand.php b/src/N98/Magento/Command/Database/InfoCommand.php index 5ede1f436..cbade9e0a 100644 --- a/src/N98/Magento/Command/Database/InfoCommand.php +++ b/src/N98/Magento/Command/Database/InfoCommand.php @@ -58,6 +58,15 @@ public function getHelp(): string HELP; } + /** + * {@inheritdoc} + */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getDataHeaders(InputInterface $input, OutputInterface $output): array + { + return ['Name', 'Value']; + } + /** * @param InputInterface $input * @param OutputInterface $output @@ -67,11 +76,11 @@ public function getHelp(): string protected function execute(InputInterface $input, OutputInterface $output): int { if (($settingArgument = $input->getArgument(self::COMMAND_ARGUMENT_SETTING)) !== null) { - $settings = $this->getData(); + $settings = $this->getData($input, $output); if (!isset($settings[$settingArgument])) { throw new InvalidArgumentException('Unknown setting: ' . $settingArgument); } - $output->writeln((string) $settings[$settingArgument]['Value']); + $output->writeln((string) $settings[$settingArgument][1]); return Command::SUCCESS; } @@ -81,69 +90,72 @@ protected function execute(InputInterface $input, OutputInterface $output): int /** * {@inheritdoc} - * - * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - public function setData(InputInterface $input,OutputInterface $output) : void + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getData(InputInterface $input, OutputInterface $output): array { - $this->detectDbSettings($output); + if (is_null($this->data)) { + $this->detectDbSettings($output); - $settings = []; - foreach ($this->dbSettings as $key => $value) { - $settings[$key] = (string) $value; - } + $settings = []; + foreach ($this->dbSettings as $key => $value) { + $settings[$key] = (string) $value; + } - if ($this->dbSettings instanceof DbSettings) { - $isSocketConnect = $this->dbSettings->isSocketConnect(); - } else { - $isSocketConnect = false; - } + if ($this->dbSettings instanceof DbSettings) { + $isSocketConnect = $this->dbSettings->isSocketConnect(); + } else { + $isSocketConnect = false; + } - // note: there is no need to specify the default port neither for PDO, nor JDBC nor CLI. - $portOrDefault = $this->dbSettings['port'] ?? 3306; - - $pdoConnectionString = ''; - if ($isSocketConnect) { - $pdoConnectionString = sprintf( - 'mysql:unix_socket=%s;dbname=%s', - $this->dbSettings['unix_socket'], - $this->dbSettings['dbname'] - ); - } else { - $pdoConnectionString = sprintf( - 'mysql:host=%s;port=%s;dbname=%s', - $this->dbSettings['host'], - $portOrDefault, - $this->dbSettings['dbname'] - ); - } - $settings['PDO-Connection-String'] = $pdoConnectionString; - - $jdbcConnectionString = ''; - if ($isSocketConnect) { - // isn't supported according to this post: http://stackoverflow.com/a/18493673/145829 - $jdbcConnectionString = 'Connecting using JDBC through a unix socket isn\'t supported!'; - } else { - $jdbcConnectionString = sprintf( - 'jdbc:mysql://%s:%s/%s?username=%s&password=%s', - $this->dbSettings['host'], - $portOrDefault, - $this->dbSettings['dbname'], - $this->dbSettings['username'], - $this->dbSettings['password'] - ); - } - $settings['JDBC-Connection-String'] = $jdbcConnectionString; + // note: there is no need to specify the default port neither for PDO, nor JDBC nor CLI. + $portOrDefault = $this->dbSettings['port'] ?? 3306; + + $pdoConnectionString = ''; + if ($isSocketConnect) { + $pdoConnectionString = sprintf( + 'mysql:unix_socket=%s;dbname=%s', + $this->dbSettings['unix_socket'], + $this->dbSettings['dbname'] + ); + } else { + $pdoConnectionString = sprintf( + 'mysql:host=%s;port=%s;dbname=%s', + $this->dbSettings['host'], + $portOrDefault, + $this->dbSettings['dbname'] + ); + } + $settings['PDO-Connection-String'] = $pdoConnectionString; + + $jdbcConnectionString = ''; + if ($isSocketConnect) { + // isn't supported according to this post: http://stackoverflow.com/a/18493673/145829 + $jdbcConnectionString = 'Connecting using JDBC through a unix socket isn\'t supported!'; + } else { + $jdbcConnectionString = sprintf( + 'jdbc:mysql://%s:%s/%s?username=%s&password=%s', + $this->dbSettings['host'], + $portOrDefault, + $this->dbSettings['dbname'], + $this->dbSettings['username'], + $this->dbSettings['password'] + ); + } + $settings['JDBC-Connection-String'] = $jdbcConnectionString; - $database = $this->getDatabaseHelper(); - $mysqlCliString = 'mysql ' . $database->getMysqlClientToolConnectionString(); - $settings['MySQL-Cli-String'] = $mysqlCliString; + $database = $this->getDatabaseHelper(); + $mysqlCliString = 'mysql ' . $database->getMysqlClientToolConnectionString(); + $settings['MySQL-Cli-String'] = $mysqlCliString; - foreach ($settings as $settingName => $settingValue) { - $this->data[$settingName] = [ - 'Name' => $settingName, - 'Value' => $settingValue - ]; + foreach ($settings as $settingName => $settingValue) { + $this->data[$settingName] = [ + $settingName, + $settingValue + ]; + } } + + return $this->data; } } diff --git a/src/N98/Magento/Command/Database/StatusCommand.php b/src/N98/Magento/Command/Database/StatusCommand.php index d57387b2a..d30da556d 100644 --- a/src/N98/Magento/Command/Database/StatusCommand.php +++ b/src/N98/Magento/Command/Database/StatusCommand.php @@ -31,6 +31,7 @@ class StatusCommand extends AbstractShowCommand * * @var array> */ + // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore protected array $_importantVars = [ 'Threads_connected' => [ 'desc' => 'Total number of clients that have currently open connections to the server.' @@ -80,6 +81,7 @@ class StatusCommand extends AbstractShowCommand /** * @var array */ + // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore protected array $_specialFormat = ['Uptime' => 'timeElapsedString']; /** diff --git a/src/N98/Magento/Command/Database/VariablesCommand.php b/src/N98/Magento/Command/Database/VariablesCommand.php index 054e24531..1a84d022a 100644 --- a/src/N98/Magento/Command/Database/VariablesCommand.php +++ b/src/N98/Magento/Command/Database/VariablesCommand.php @@ -27,6 +27,7 @@ class VariablesCommand extends AbstractShowCommand * http://www.slideshare.net/shinguz/mysql-configuration-the-most-important-variables GERMAN * @var array> */ + // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore protected array $_importantVars = [ 'have_query_cache' => '', 'innodb_additional_mem_pool_size' => '', diff --git a/src/N98/Magento/Command/Developer/ClassLookupCommand.php b/src/N98/Magento/Command/Developer/ClassLookupCommand.php index fa42fb822..a12f3bcfd 100644 --- a/src/N98/Magento/Command/Developer/ClassLookupCommand.php +++ b/src/N98/Magento/Command/Developer/ClassLookupCommand.php @@ -5,11 +5,15 @@ namespace N98\Magento\Command\Developer; use N98\Magento\Command\AbstractCommand; +use N98\Magento\Methods\MageBase as Mage; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use function class_exists; +use function ucfirst; + /** * Class lookup command * @@ -50,7 +54,10 @@ protected function configure(): void /** * @param InputInterface $input * @param OutputInterface $output + * * @return int + * + * @uses Mage::getConfig() */ protected function execute(InputInterface $input, OutputInterface $output): int { @@ -59,15 +66,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int /** @var string $name */ $name = $input->getArgument(self::COMMAND_ARGUMENT_NAME); - $resolved = $this->_getMageConfig()->getGroupedClassName($type, $name); + $resolved = Mage::getConfig()->getGroupedClassName($type, $name); - $output->writeln( - ucfirst($type) . ' ' . $name . " " . - "resolves to " . $resolved . '' - ); + $output->writeln(sprintf( + '%s %s resolves to %s', + ucfirst($type), + $name, + $resolved + )); if (!class_exists('\\' . $resolved)) { - $output->writeln('Note: Class ' . $resolved . ' does not exist!'); + $output->writeln(sprintf('Note: Class %s does not exist!', $resolved)); } return Command::SUCCESS; diff --git a/src/N98/Magento/Command/Developer/EmailTemplate/UsageCommand.php b/src/N98/Magento/Command/Developer/EmailTemplate/UsageCommand.php index 13f4041ee..0d8a490dc 100644 --- a/src/N98/Magento/Command/Developer/EmailTemplate/UsageCommand.php +++ b/src/N98/Magento/Command/Developer/EmailTemplate/UsageCommand.php @@ -9,95 +9,94 @@ use Mage_Core_Exception; use Mage_Core_Model_Template; use N98\Magento\Command\AbstractCommand; -use N98\Util\Console\Helper\Table\Renderer\RendererFactory; -use Path; +use N98\Magento\Command\CommandDataInterface; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; /** + * @package N98\Magento\Command\Developer\EmailTemplate + * * @author Mike Parkin * @author Tom Klingenberg */ -class UsageCommand extends AbstractCommand +class UsageCommand extends AbstractCommand implements CommandDataInterface { - protected function configure(): void - { - $this - ->setName('dev:email-template:usage') - ->setDescription('Display database transactional email template usage') - ->addOption( - 'format', - null, - InputOption::VALUE_OPTIONAL, - 'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']' - ); - } + public const NO_DATA_MESSAGE = 'No transactional email templates stored in the database.'; /** - * @param InputInterface $input - * @param OutputInterface $output - * @return int - * @throws Mage_Core_Exception + * @var string + */ + protected static $defaultName = 'dev:email-template:usage'; + + /** + * @var string + */ + protected static $defaultDescription = 'Display database transactional email template usage.'; + + /** + * {@inheritDoc} */ - protected function execute(InputInterface $input, OutputInterface $output): int + public function initialize(InputInterface $input, OutputInterface $output): void { + parent::initialize($input, $output); + $this->detectMagento($output); $this->initMagento(); + } - $templates = $this->findEmailTemplates(); - - if (!empty($templates)) { - $tableHelper = $this->getTableHelper(); - $tableHelper - ->setHeaders(['id', 'Name', 'Scope', 'Scope Id', Path::class]) - ->renderByFormat($output, $templates, $input->getOption('format')); - } else { - $output->writeln("No transactional email templates stored in the database."); - } - return 0; + /** + * {@inheritdoc} + */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getDataHeaders(InputInterface $input, OutputInterface $output): array + { + return ['id', 'Name', 'Scope', 'Scope Id', 'Path']; } /** + * {@inheritdoc} * @throws Mage_Core_Exception */ - protected function findEmailTemplates(): array + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getData(InputInterface $input, OutputInterface $output): array { - /** @var Mage_Core_Model_Template[] $templates */ - $templates = Mage::getModel('adminhtml/email_template')->getCollection(); + if (is_null($this->data)) { + $this->data = []; - $return = []; + /** @var Mage_Core_Model_Template[] $templates */ + $templates = Mage::getModel('adminhtml/email_template')->getCollection(); - foreach ($templates as $template) { - // Some modules overload the template class so that the method getSystemConfigPathsWhereUsedCurrently - // is not available, this is a workaround for that - if (!method_exists($template, 'getSystemConfigPathsWhereUsedCurrently')) { - $instance = new Mage_Adminhtml_Model_Email_Template(); - $template = $instance->load($template->getId()); - } + foreach ($templates as $template) { + // Some modules overload the template class so that the method getSystemConfigPathsWhereUsedCurrently + // is not available, this is a workaround for that + if (!method_exists($template, 'getSystemConfigPathsWhereUsedCurrently')) { + $instance = new Mage_Adminhtml_Model_Email_Template(); + $template = $instance->load($template->getId()); + } - $configPaths = $template->getSystemConfigPathsWhereUsedCurrently(); + $configPaths = $template->getSystemConfigPathsWhereUsedCurrently(); - if (!(is_countable($configPaths) ? count($configPaths) : 0)) { - $configPaths[] = [ - 'scope' => 'Unused', - 'scope_id' => 'Unused', - 'path' => 'Unused' - ]; - } + if (!(is_countable($configPaths) ? count($configPaths) : 0)) { + $configPaths[] = [ + 'scope' => 'Unused', + 'scope_id' => 'Unused', + 'path' => 'Unused' + ]; + } - foreach ($configPaths as $configPath) { - $return[] = [ - 'id' => $this->sanitizeEmailProperty($template->getId()), - 'Template Code' => $this->sanitizeEmailProperty($template->getTemplateCode()), - 'Scope' => $this->sanitizeEmailProperty($configPath['scope']), - 'Scope Id' => $this->sanitizeEmailProperty($configPath['scope_id']), - Path::class => $this->sanitizeEmailProperty($configPath['path']) - ]; + foreach ($configPaths as $configPath) { + $this->data[] = [ + $this->sanitizeEmailProperty($template->getId()), + $this->sanitizeEmailProperty($template->getTemplateCode()), + $this->sanitizeEmailProperty($configPath['scope']), + $this->sanitizeEmailProperty($configPath['scope_id']), + $this->sanitizeEmailProperty($configPath['path']) + ]; + } } } - return $return; + return $this->data; } /** diff --git a/src/N98/Magento/Command/Developer/Module/CreateCommand.php b/src/N98/Magento/Command/Developer/Module/CreateCommand.php index fd0949d56..9f0a93335 100644 --- a/src/N98/Magento/Command/Developer/Module/CreateCommand.php +++ b/src/N98/Magento/Command/Developer/Module/CreateCommand.php @@ -104,9 +104,8 @@ class CreateCommand extends AbstractCommand /** * @var Filesystem - * - * phpcs:disable Ecg.PHP.PrivateClassMember.PrivateClassMemberError */ + // phpcs:ignore Ecg.PHP.PrivateClassMember.PrivateClassMemberError private Filesystem $filesystem; public function __construct() diff --git a/src/N98/Magento/Command/Developer/Module/ListCommand.php b/src/N98/Magento/Command/Developer/Module/ListCommand.php index fedc471b8..d28835daa 100644 --- a/src/N98/Magento/Command/Developer/Module/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Module/ListCommand.php @@ -64,14 +64,26 @@ protected function configure(): void parent::configure(); } + /** + * {@inheritdoc} + */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getDataHeaders(InputInterface $input, OutputInterface $output): array + { + return ['codePool', 'Name', 'Version', 'Status']; + } + /** * {@inheritDoc} - * - * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - public function setData(InputInterface $input,OutputInterface $output) : void + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getData(InputInterface $input, OutputInterface $output): array { - $this->data =iterator_to_array($this->filterModules($input)); + if (is_null($this->data)) { + $this->data = iterator_to_array($this->filterModules($input)); + } + + return $this->data; } /** diff --git a/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php b/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php index fc495464a..eb24c3d8b 100644 --- a/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Module/Rewrite/ListCommand.php @@ -31,24 +31,35 @@ class ListCommand extends AbstractRewriteCommand implements CommandDataInterface /** * {@inheritDoc} - * - * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - public function setData(InputInterface $input,OutputInterface $output) : void + public function getDataHeaders(InputInterface $input, OutputInterface $output): array { - $this->data = []; - - $rewrites = array_merge($this->loadRewrites(), $this->loadAutoloaderRewrites()); - foreach ($rewrites as $type => $data) { - if ((is_countable($data) ? count($data) : 0) > 0) { - foreach ($data as $class => $rewriteClass) { - $this->data[] = [ - 'Type' => $type, - 'Class' => $class, - 'Rewrite' => implode(', ', $rewriteClass) - ]; + return ['Type', 'Class', 'Rewrite']; + } + + /** + * {@inheritDoc} + */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getData(InputInterface $input, OutputInterface $output): array + { + if (is_null($this->data)) { + $this->data = []; + + $rewrites = array_merge($this->loadRewrites(), $this->loadAutoloaderRewrites()); + foreach ($rewrites as $type => $data) { + if ((is_countable($data) ? count($data) : 0) > 0) { + foreach ($data as $class => $rewriteClass) { + $this->data[] = [ + $type, + $class, + implode(', ', $rewriteClass) + ]; + } } } } + + return $this->data; } } diff --git a/src/N98/Magento/Command/Developer/Theme/InfoCommand.php b/src/N98/Magento/Command/Developer/Theme/InfoCommand.php index 48c638316..3290673b0 100644 --- a/src/N98/Magento/Command/Developer/Theme/InfoCommand.php +++ b/src/N98/Magento/Command/Developer/Theme/InfoCommand.php @@ -8,10 +8,15 @@ use Mage_Core_Model_Website; use N98\Magento\Command\AbstractCommand; use N98\Magento\Command\AbstractStoreConfigCommand; +use N98\Magento\Methods\MageBase as Mage; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use function array_merge; +use function implode; +use function unserialize; + /** * Theme info command * @@ -34,11 +39,13 @@ class InfoCommand extends AbstractCommand /** * @var array */ + // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore protected array $_configNodes = ['Theme translations' => 'design/theme/locale']; /** * @var array */ + // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore protected array $_configNodesWithExceptions = [ 'Design Package Name' => 'design/package/name', 'Theme template' => 'design/theme/template', @@ -47,16 +54,29 @@ class InfoCommand extends AbstractCommand 'Theme default' => 'design/theme/default' ]; + /** + * {@inheritDoc} + */ + public function initialize(InputInterface $input, OutputInterface $output): void + { + parent::initialize($input, $output); + + $this->detectMagento($output); + $this->initMagento(); + } + /** * @param InputInterface $input * @param OutputInterface $output + * * @return int * - * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter + * @uses Mage::app() */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter protected function execute(InputInterface $input, OutputInterface $output): int { - foreach ($this->_getMage()->getWebsites() as $website) { + foreach (Mage::app()->getWebsites() as $website) { foreach ($website->getStores() as $store) { $this->_displayTable($output, $store); } @@ -68,8 +88,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int /** * @param OutputInterface $output * @param Mage_Core_Model_Store $store + * * @return $this */ + // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore protected function _displayTable(OutputInterface $output, Mage_Core_Model_Store $store): InfoCommand { /** @var Mage_Core_Model_Website $website */ @@ -77,7 +99,11 @@ protected function _displayTable(OutputInterface $output, Mage_Core_Model_Store $this->writeSection( $output, - 'Current design setting on store: ' . $website->getCode() . '/' . $store->getCode() + sprintf( + 'Current design setting on store: %s/%s', + $website->getCode(), + $store->getCode() + ) ); $storeInfoLines = $this->_parse($this->_configNodesWithExceptions, $store, true); $storeInfoLines = array_merge($storeInfoLines, $this->_parse($this->_configNodes, $store)); @@ -94,8 +120,12 @@ protected function _displayTable(OutputInterface $output, Mage_Core_Model_Store * @param array $nodes * @param Mage_Core_Model_Store $store * @param bool $withExceptions + * * @return array> + * + * @uses Mage::getConfig() */ + // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore protected function _parse(array $nodes, Mage_Core_Model_Store $store, bool $withExceptions = false): array { $result = []; @@ -103,7 +133,7 @@ protected function _parse(array $nodes, Mage_Core_Model_Store $store, bool $with foreach ($nodes as $nodeLabel => $node) { $result[] = [ $nodeLabel, - (string) $this->_getMageConfig()->getNode( + (string) Mage::getConfig()->getNode( $node, AbstractStoreConfigCommand::SCOPE_STORE_VIEW, $store->getCode() @@ -123,11 +153,15 @@ protected function _parse(array $nodes, Mage_Core_Model_Store $store, bool $with /** * @param string $node * @param Mage_Core_Model_Store $store + * * @return string + * + * @uses Mage::getConfig() */ + // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore protected function _parseException(string $node, Mage_Core_Model_Store $store): string { - $exception = (string) $this->_getMageConfig()->getNode( + $exception = (string) Mage::getConfig()->getNode( $node . self::THEMES_EXCEPTION, AbstractStoreConfigCommand::SCOPE_STORE_VIEW, $store->getCode() diff --git a/src/N98/Magento/Command/Developer/Theme/ListCommand.php b/src/N98/Magento/Command/Developer/Theme/ListCommand.php index 34e6a2c22..334a8e198 100644 --- a/src/N98/Magento/Command/Developer/Theme/ListCommand.php +++ b/src/N98/Magento/Command/Developer/Theme/ListCommand.php @@ -4,9 +4,9 @@ namespace N98\Magento\Command\Developer\Theme; -use Mage; use N98\Magento\Command\AbstractCommand; use N98\Magento\Command\CommandDataInterface; +use N98\Magento\Methods\Core\Design; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -30,28 +30,33 @@ class ListCommand extends AbstractCommand implements CommandDataInterface protected static $defaultDescription = 'Lists all available themes.'; /** - * {@inheritdoc} - * - * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter + * {@inheritDoc} */ - public function setData(InputInterface $input,OutputInterface $output) : void + public function getDataHeaders(InputInterface $input, OutputInterface $output): array { - $this->data = []; - - foreach ($this->getThemes() as $package => $themes) { - foreach ($themes as $theme) { - $this->data[] = [ - 'Theme' => ($package ? $package . '/' : '') . $theme - ]; - } - } + return ['Theme']; } /** - * @return array> + * {@inheritdoc} + * + * @uses Design\Package::getModel() */ - protected function getThemes(): array + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getData(InputInterface $input, OutputInterface $output): array { - return Mage::getModel('core/design_package')->getThemeList(); + if (is_null($this->data)) { + $this->data = []; + + foreach (Design\Package::getModel()->getThemeList() as $package => $themes) { + foreach ($themes as $theme) { + $this->data[] = [ + ($package ? $package . '/' : '') . $theme + ]; + } + } + } + + return $this->data; } } diff --git a/src/N98/Magento/Command/Eav/Attribute/ListCommand.php b/src/N98/Magento/Command/Eav/Attribute/ListCommand.php index b0df7f7b5..747aa147c 100644 --- a/src/N98/Magento/Command/Eav/Attribute/ListCommand.php +++ b/src/N98/Magento/Command/Eav/Attribute/ListCommand.php @@ -65,45 +65,64 @@ protected function configure(): void } /** - * {@inheritdoc} - * - * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter + * {@inheritDoc} */ - public function setData(InputInterface $input,OutputInterface $output) : void + public function getDataHeaders(InputInterface $input, OutputInterface $output): array { - $this->data = []; - - $attributesCollection = Mage::getResourceModel('eav/entity_attribute_collection'); - $attributesCollection->setOrder('attribute_code', 'asc'); - /** @var Mage_Eav_Model_Entity_Attribute $attribute */ - foreach ($attributesCollection as $attribute) { - $entityType = $this->_getEntityType($attribute); - - /** - * Filter by type - */ - if ($input->getOption(self::COMMAND_OPTION_FILTER_TYPE) !== null - && $input->getOption(self::COMMAND_OPTION_FILTER_TYPE) !== $entityType - ) { - continue; - } + $header = ['Code', 'ID', 'Entity type', 'Label']; - $row = []; - $row['Code'] = $attribute->getAttributeCode(); - $row['ID'] = $attribute->getId(); - $row['Entity type'] = $entityType; - $row['Label'] = $attribute->getFrontendLabel(); + if ($input->getOption(self::COMMAND_OPTION_ADD_SOURCE)) { + $header[] = 'Source'; + } + if ($input->getOption(self::COMMAND_OPTION_ADD_BACKEND)) { + $header[] = 'Backend type'; + } - if ($input->getOption(self::COMMAND_OPTION_ADD_SOURCE)) { - $row['Source'] = $attribute->getSourceModel() ?: ''; - } - if ($input->getOption(self::COMMAND_OPTION_ADD_BACKEND)) { - $row['Backend type'] = $attribute->getBackendType(); - } + return $header; + } - $this->data[] = $row; + /** + * {@inheritdoc} + */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getData(InputInterface $input, OutputInterface $output): array + { + if (is_null($this->data)) { + $this->data = []; + + $attributesCollection = Mage::getResourceModel('eav/entity_attribute_collection'); + $attributesCollection->setOrder('attribute_code', 'asc'); + /** @var Mage_Eav_Model_Entity_Attribute $attribute */ + foreach ($attributesCollection as $attribute) { + $entityType = $this->_getEntityType($attribute); + + /** + * Filter by type + */ + if ($input->getOption(self::COMMAND_OPTION_FILTER_TYPE) !== null + && $input->getOption(self::COMMAND_OPTION_FILTER_TYPE) !== $entityType + ) { + continue; + } + + $row = []; + $row['Code'] = $attribute->getAttributeCode(); + $row['ID'] = $attribute->getId(); + $row['Entity type'] = $entityType; + $row['Label'] = $attribute->getFrontendLabel(); + + if ($input->getOption(self::COMMAND_OPTION_ADD_SOURCE)) { + $row['Source'] = $attribute->getSourceModel() ?: ''; + } + if ($input->getOption(self::COMMAND_OPTION_ADD_BACKEND)) { + $row['Backend type'] = $attribute->getBackendType(); + } + + $this->data[] = $row; + } } + return $this->data; } /** diff --git a/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php b/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php index b754f8e10..067cdfcd6 100644 --- a/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php +++ b/src/N98/Magento/Command/Eav/Attribute/ViewCommand.php @@ -55,64 +55,79 @@ protected function configure(): void /** * {@inheritdoc} - * @throws Mage_Core_Exception */ - public function setData(InputInterface $input,OutputInterface $output) : void + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getDataHeaders(InputInterface $input, OutputInterface $output): array { - /** @var string $entityType */ - $entityType = $input->getArgument(self::COMMAND_ARGUMENT_ENTITY); - /** @var string $attributeCode */ - $attributeCode = $input->getArgument(self::COMMAND_ARGUMENT_ATTRIBUTE); - - $attribute = $this->getAttribute($entityType, $attributeCode); - if (!$attribute) { - throw new InvalidArgumentException('Attribute was not found.'); - } - - $cacheIdTags = $attribute->getCacheIdTags(); - $cacheTags = $attribute->getCacheTags(); - $flatColumns = $attribute->getFlatColumns(); - - $this->data = [ - ['ID', $attribute->getId()], - ['Code', $attribute->getName()], - ['Attribute-Set-ID', $attribute->getAttributeSetId()], - ['Visible-On-Front', $attribute->getIsVisibleOnFront() ? 'yes' : 'no'], - ['Attribute-Model', $attribute->getAttributeModel() ?: ''], - ['Backend-Model', $attribute->getBackendModel() ?: ''], - ['Backend-Table', $attribute->getBackendTable() ?: ''], - ['Backend-Type', $attribute->getBackendType() ?: ''], - ['Source-Model', $attribute->getSourceModel() ?: ''], - ['Cache-ID-Tags', is_array($cacheIdTags) ? implode(',', $cacheIdTags) : ''], - ['Cache-Tags', is_array($cacheTags) ? implode(',', $cacheTags) : ''], - ['Default-Value', $attribute->getDefaultValue() ?: ''], - ['Flat-Columns', is_array($flatColumns) ? implode(',', array_keys($flatColumns)) : ''] - ]; - - $key = ''; - $flatIndexes = $attribute->getFlatIndexes() ? $attribute->getFlatIndexes() : ''; - if ($flatIndexes) { - $key = array_key_first($flatIndexes); - $flatIndexes = implode(',', $flatIndexes[$key]['fields']); - } - $this->data[] = ['Flat-Indexes', $flatIndexes ? $key . ' - ' . $flatIndexes : '']; - - if ($attribute->getFrontend()) { - $this->data[] = ['Frontend-Label', $attribute->getFrontend()->getLabel()]; - $this->data[] = ['Frontend-Class', trim($attribute->getFrontend()->getClass())]; - $this->data[] = ['Frontend-Input', trim($attribute->getFrontend()->getInputType())]; - $this->data[] = ['Frontend-Input-Renderer-Class', trim((string)$attribute->getFrontend()->getInputRendererClass())]; - } + return ['Type', 'Value']; } /** - * @return array - * - * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter + * {@inheritdoc} + * @throws Mage_Core_Exception */ - protected function getTableHeaders(InputInterface $input, OutputInterface $output): array + public function getData(InputInterface $input, OutputInterface $output): array { - return ['Type', 'Value']; + if (is_null($this->data)) { + /** @var string $entityType */ + $entityType = $input->getArgument(self::COMMAND_ARGUMENT_ENTITY); + /** @var string $attributeCode */ + $attributeCode = $input->getArgument(self::COMMAND_ARGUMENT_ATTRIBUTE); + + $attribute = $this->getAttribute($entityType, $attributeCode); + if (!$attribute) { + throw new InvalidArgumentException('Attribute was not found.'); + } + + $cacheIdTags = $attribute->getCacheIdTags(); + $cacheTags = $attribute->getCacheTags(); + $flatColumns = $attribute->getFlatColumns(); + + $this->data = [ + ['ID', $attribute->getId()], + ['Code', $attribute->getName()], + ['Attribute-Set-ID', $attribute->getAttributeSetId()], + ['Visible-On-Front', $attribute->getIsVisibleOnFront() ? 'yes' : 'no'], + ['Attribute-Model', $attribute->getAttributeModel() ?: ''], + ['Backend-Model', $attribute->getBackendModel() ?: ''], + ['Backend-Table', $attribute->getBackendTable() ?: ''], + ['Backend-Type', $attribute->getBackendType() ?: ''], + ['Source-Model', $attribute->getSourceModel() ?: ''], + ['Cache-ID-Tags', is_array($cacheIdTags) ? implode(',', $cacheIdTags) : ''], + ['Cache-Tags', is_array($cacheTags) ? implode(',', $cacheTags) : ''], + ['Default-Value', $attribute->getDefaultValue() ?: ''], + ['Flat-Columns', is_array($flatColumns) ? implode(',', array_keys($flatColumns)) : ''] + ]; + + $key = ''; + $flatIndexes = $attribute->getFlatIndexes() ? $attribute->getFlatIndexes() : ''; + if ($flatIndexes) { + $key = array_key_first($flatIndexes); + $flatIndexes = implode(',', $flatIndexes[$key]['fields']); + } + $this->data[] = ['Flat-Indexes', $flatIndexes ? $key . ' - ' . $flatIndexes : '']; + + if ($attribute->getFrontend()) { + $this->data[] = [ + 'Frontend-Label', + $attribute->getFrontend()->getLabel() + ]; + $this->data[] = [ + 'Frontend-Class', + trim($attribute->getFrontend()->getClass()) + ]; + $this->data[] = [ + 'Frontend-Input', + trim($attribute->getFrontend()->getInputType()) + ]; + $this->data[] = [ + 'Frontend-Input-Renderer-Class', + trim((string)$attribute->getFrontend()->getInputRendererClass()) + ]; + } + } + + return $this->data; } /** diff --git a/src/N98/Magento/Command/Indexer/ListCommand.php b/src/N98/Magento/Command/Indexer/ListCommand.php index 4fe14455b..a39f6d071 100644 --- a/src/N98/Magento/Command/Indexer/ListCommand.php +++ b/src/N98/Magento/Command/Indexer/ListCommand.php @@ -37,20 +37,31 @@ public function getHelp(): string /** * {@inheritdoc} - * @return array> + */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getDataHeaders(InputInterface $input, OutputInterface $output): array + { + return ['code', 'status', 'time']; + } + + /** + * {@inheritdoc} * @throws Exception - * - * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - public function setData(InputInterface $input,OutputInterface $output) : void + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getData(InputInterface $input, OutputInterface $output): array { - $this->data = []; - foreach ($this->getIndexerList() as $index) { - $this->data[] = [ - 'code' => $index['code'], - 'status' => $index['status'], - 'time' => $index['last_runtime'] - ]; + if (is_null($this->data)) { + $this->data = []; + foreach ($this->getIndexerList() as $index) { + $this->data[] = [ + $index['code'], + $index['status'], + $index['last_runtime'] + ]; + } } + + return $this->data; } } diff --git a/src/N98/Magento/Command/Media/Cache/JsCss/ClearCommand.php b/src/N98/Magento/Command/Media/Cache/JsCss/ClearCommand.php index e14e9a40a..de339047a 100644 --- a/src/N98/Magento/Command/Media/Cache/JsCss/ClearCommand.php +++ b/src/N98/Magento/Command/Media/Cache/JsCss/ClearCommand.php @@ -4,8 +4,9 @@ namespace N98\Magento\Command\Media\Cache\JsCss; -use Mage; use N98\Magento\Command\AbstractCommand; +use N98\Magento\Methods\Core\Design; +use N98\Magento\Methods\MageBase as Mage; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -28,12 +29,14 @@ class ClearCommand extends AbstractCommand protected static $defaultDescription = 'Clears JS/CSS cache.'; /** - * {@inheritDoc} - * @return int + * {@inheritdoc} + * + * @uses Design\Package::getModel() + * @uses Mage::dispatchEvent() */ protected function execute(InputInterface $input, OutputInterface $output): int { - Mage::getModel('core/design_package')->cleanMergedJsCss(); + Design\Package::getModel()->cleanMergedJsCss(); Mage::dispatchEvent('clean_media_cache_after'); $output->writeln('Js/CSS cache cleared'); diff --git a/src/N98/Magento/Command/Script/Repository/ListCommand.php b/src/N98/Magento/Command/Script/Repository/ListCommand.php index b1e63599b..16965660d 100644 --- a/src/N98/Magento/Command/Script/Repository/ListCommand.php +++ b/src/N98/Magento/Command/Script/Repository/ListCommand.php @@ -52,22 +52,34 @@ public function getHelp(): string /** * {@inheritdoc} - * - * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter */ - public function setData(InputInterface $input,OutputInterface $output) : void + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getDataHeaders(InputInterface $input, OutputInterface $output): array { - $this->data = []; - foreach ($this->getScripts() as $file) { - $this->data[] = [ - 'Script' => substr( - $file['fileinfo']->getFilename(), - 0, - -strlen(self::MAGERUN_EXTENSION) - ), - 'Location' => $file['location'], - 'Description' => $file['description'] - ]; + return ['Script', 'Location', 'Description']; + } + + /** + * {@inheritdoc} + */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getData(InputInterface $input, OutputInterface $output): array + { + if (is_null($this->data)) { + $this->data = []; + foreach ($this->getScripts() as $file) { + $this->data[] = [ + substr( + $file['fileinfo']->getFilename(), + 0, + -strlen(self::MAGERUN_EXTENSION) + ), + $file['location'], + $file['description'] + ]; + } } + + return $this->data; } } diff --git a/src/N98/Magento/Command/System/Check/MySQL/ResourceCheck.php b/src/N98/Magento/Command/System/Check/MySQL/ResourceCheck.php index 43397bf5d..2e556c9ad 100644 --- a/src/N98/Magento/Command/System/Check/MySQL/ResourceCheck.php +++ b/src/N98/Magento/Command/System/Check/MySQL/ResourceCheck.php @@ -1,28 +1,30 @@ - */ + +declare(strict_types=1); namespace N98\Magento\Command\System\Check\MySQL; -use Mage; -use Mage_Core_Model_Resource; use N98\Magento\Command\System\Check\Result; use N98\Magento\Command\System\Check\ResultCollection; use N98\Magento\Command\System\Check\SimpleCheck; +use N98\Magento\Methods\Core; use Varien_Db_Adapter_Interface; +/** + * @package N98\Magento\Command\System\Check\MySQL + * + * @author Tom Klingenberg + */ abstract class ResourceCheck implements SimpleCheck { /** * @param ResultCollection $results + * + * @uses Core\Resource::getModel() */ - public function check(ResultCollection $results) + public function check(ResultCollection $results): void { - /** @var Mage_Core_Model_Resource $resourceModel */ - $resourceModel = Mage::getModel('core/resource'); + $resourceModel = Core\Resource::getModel(); /** @var Varien_Db_Adapter_Interface|false $dbAdapter */ $dbAdapter = $resourceModel->getConnection('core_write'); @@ -44,5 +46,5 @@ public function check(ResultCollection $results) * @param Varien_Db_Adapter_Interface $dbAdapter * @return void */ - abstract protected function checkImplementation(Result $result, Varien_Db_Adapter_Interface $dbAdapter); + abstract protected function checkImplementation(Result $result, Varien_Db_Adapter_Interface $dbAdapter): void; } diff --git a/src/N98/Magento/Command/System/Check/MySQL/VersionCheck.php b/src/N98/Magento/Command/System/Check/MySQL/VersionCheck.php index 8d23a922a..8d841bf62 100644 --- a/src/N98/Magento/Command/System/Check/MySQL/VersionCheck.php +++ b/src/N98/Magento/Command/System/Check/MySQL/VersionCheck.php @@ -1,15 +1,20 @@ - */ + +declare(strict_types=1); namespace N98\Magento\Command\System\Check\MySQL; use N98\Magento\Command\System\Check\Result; use Varien_Db_Adapter_Interface; +use function sprintf; +use function version_compare; + +/** + * @package N98\Magento\Command\System\Check\MySQL + * + * @author Tom Klingenberg + */ class VersionCheck extends ResourceCheck { /** @@ -17,22 +22,24 @@ class VersionCheck extends ResourceCheck * @param Varien_Db_Adapter_Interface $dbAdapter * @return void */ - protected function checkImplementation(Result $result, Varien_Db_Adapter_Interface $dbAdapter) + protected function checkImplementation(Result $result, Varien_Db_Adapter_Interface $dbAdapter): void { /** * Check Version */ $mysqlVersion = $dbAdapter->fetchOne('SELECT VERSION()'); + // @todo raise minimum version? $minimumVersionFound = version_compare($mysqlVersion, '4.1.20', '>='); if ($minimumVersionFound) { $result->setStatus(Result::STATUS_OK); - $result->setMessage("MySQL Version $mysqlVersion found."); + $result->setMessage(sprintf('MySQL Version %s found.', $mysqlVersion)); } else { $result->setStatus(Result::STATUS_ERROR); - $result->setMessage( - "MySQL Version >$mysqlVersion found. Upgrade your MySQL Version." - ); + $result->setMessage(sprintf( + 'MySQL Version >%s found. Upgrade your MySQL Version.', + $mysqlVersion + )); } } } diff --git a/src/N98/Magento/Command/System/Check/ResultCollection.php b/src/N98/Magento/Command/System/Check/ResultCollection.php index aca685da1..d6fae8a1a 100644 --- a/src/N98/Magento/Command/System/Check/ResultCollection.php +++ b/src/N98/Magento/Command/System/Check/ResultCollection.php @@ -1,5 +1,7 @@ _results[] = $result; @@ -39,7 +43,7 @@ public function addResult(Result $result) * @param string $message * @return Result */ - public function createResult($status = Result::STATUS_OK, $message = '') + public function createResult(string $status = Result::STATUS_OK, string $message = ''): Result { $result = new Result($status, $message); $result->setResultGroup($this->_resultGroup); @@ -51,7 +55,7 @@ public function createResult($status = Result::STATUS_OK, $message = '') /** * @param string $resultGroup */ - public function setResultGroup($resultGroup) + public function setResultGroup(string $resultGroup): void { $this->_resultGroup = $resultGroup; } @@ -59,7 +63,7 @@ public function setResultGroup($resultGroup) /** * @return Traversable An instance of an object implementing Iterator or */ - public function getIterator() + public function getIterator(): Traversable { return new ArrayObject($this->_results); } diff --git a/src/N98/Magento/Command/System/Check/SimpleCheck.php b/src/N98/Magento/Command/System/Check/SimpleCheck.php index 726bf2f2f..954102836 100644 --- a/src/N98/Magento/Command/System/Check/SimpleCheck.php +++ b/src/N98/Magento/Command/System/Check/SimpleCheck.php @@ -1,5 +1,7 @@ data = $this->getJobs(); + if (is_null($this->data)) { + $this->data = $this->getJobs(); + } + + return $this->data; } } diff --git a/src/N98/Magento/Command/System/MaintenanceCommand.php b/src/N98/Magento/Command/System/MaintenanceCommand.php index 14dfee80f..e87a6075a 100644 --- a/src/N98/Magento/Command/System/MaintenanceCommand.php +++ b/src/N98/Magento/Command/System/MaintenanceCommand.php @@ -30,7 +30,7 @@ class MaintenanceCommand extends AbstractCommand /** * @var string */ - protected static $defaultDescription = 'Toggles maintenance mode'; + protected static $defaultDescription = 'Toggles maintenance mode.'; /** * @var Filesystem diff --git a/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php b/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php index a6c5b2883..684d899f6 100644 --- a/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php +++ b/src/N98/Magento/Command/System/Store/Config/BaseUrlListCommand.php @@ -4,13 +4,16 @@ namespace N98\Magento\Command\System\Store\Config; -use Mage; use Mage_Core_Model_Store as Store; use N98\Magento\Command\AbstractCommand; use N98\Magento\Command\CommandDataInterface; +use N98\Magento\Methods\MageBase as Mage; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use function is_null; +use function ksort; + /** * List base urls command * @@ -30,24 +33,39 @@ class BaseUrlListCommand extends AbstractCommand implements CommandDataInterface */ protected static $defaultDescription = 'Lists all base urls.'; + /** + * {@inheritdoc} + */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getDataHeaders(InputInterface $input, OutputInterface $output): array + { + return ['ID', 'Code', 'Unsecure base URL', 'Secure base URL']; + } + /** * {@inheritdoc} * - * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter + * @uses Mage::app() + * @uses Mage::getStoreConfigAsString() */ - public function setData(InputInterface $input,OutputInterface $output) : void + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getData(InputInterface $input, OutputInterface $output): array { - $this->data = []; - foreach ($this->_getMage()->getStores() as $store) { - $storeId = (string) $store->getId(); - $this->data[$storeId] = [ - 'ID' => $storeId, - 'Code' => $store->getCode(), - 'Unsecure base URL' => Mage::getStoreConfig(Store::XML_PATH_UNSECURE_BASE_URL, $store), - 'Secure base URL' => Mage::getStoreConfig(Store::XML_PATH_SECURE_BASE_URL, $store) - ]; + if (is_null($this->data)) { + $this->data = []; + foreach (Mage::app()->getStores() as $store) { + $storeId = (string) $store->getId(); + $this->data[$storeId] = [ + $storeId, + $store->getCode(), + Mage::getStoreConfigAsString(Store::XML_PATH_UNSECURE_BASE_URL, $store), + Mage::getStoreConfigAsString(Store::XML_PATH_SECURE_BASE_URL, $store) + ]; + } + + ksort($this->data); } - ksort($this->data); + return $this->data; } } diff --git a/src/N98/Magento/Command/System/Store/ListCommand.php b/src/N98/Magento/Command/System/Store/ListCommand.php index 851f9994e..7f22934cf 100644 --- a/src/N98/Magento/Command/System/Store/ListCommand.php +++ b/src/N98/Magento/Command/System/Store/ListCommand.php @@ -6,9 +6,13 @@ use N98\Magento\Command\AbstractCommand; use N98\Magento\Command\CommandDataInterface; +use N98\Magento\Methods\MageBase as Mage; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use function is_null; +use function ksort; + /** * List stores command * @@ -28,22 +32,37 @@ class ListCommand extends AbstractCommand implements CommandDataInterface */ protected static $defaultDescription = 'Lists all installed store-views'; + /** + * {@inheritdoc} + */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getDataHeaders(InputInterface $input, OutputInterface $output): array + { + return ['ID', 'Code']; + } + /** * {@inheritdoc} * - * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter + * @uses Mage::app() */ - public function setData(InputInterface $input,OutputInterface $output) : void + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getData(InputInterface $input, OutputInterface $output): array { - $this->data = []; - foreach ($this->_getMage()->getStores() as $store) { - $storeId = (string) $store->getId(); - $this->data[$storeId] = [ - 'id' => $storeId, - 'code' => $store->getCode() - ]; + if (is_null($this->data)) { + $this->data = []; + + foreach (Mage::app()->getStores() as $store) { + $storeId = (string) $store->getId(); + $this->data[$storeId] = [ + $storeId, + $store->getCode() + ]; + } + + ksort($this->data); } - ksort($this->data); + return $this->data; } } diff --git a/src/N98/Magento/Command/System/Website/ListCommand.php b/src/N98/Magento/Command/System/Website/ListCommand.php index 6fa11c02f..5c925952e 100644 --- a/src/N98/Magento/Command/System/Website/ListCommand.php +++ b/src/N98/Magento/Command/System/Website/ListCommand.php @@ -6,9 +6,13 @@ use N98\Magento\Command\AbstractCommand; use N98\Magento\Command\CommandDataInterface; +use N98\Magento\Methods\MageBase as Mage; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use function is_null; +use function ksort; + /** * List websites command * @@ -28,22 +32,36 @@ class ListCommand extends AbstractCommand implements CommandDataInterface */ protected static $defaultDescription = 'Lists all websites.'; + /** + * {@inheritdoc} + */ + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getDataHeaders(InputInterface $input, OutputInterface $output): array + { + return ['ID', 'Code']; + } + /** * {@inheritDoc} * - * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter + * @uses Mage::app() */ - public function setData(InputInterface $input,OutputInterface $output) : void + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter + public function getData(InputInterface $input, OutputInterface $output): array { - $this->data = []; - foreach ($this->_getMage()->getWebsites() as $store) { - $storeId = (string) $store->getId(); - $this->data[$storeId] = [ - 'id' => $storeId, - 'code' => $store->getCode() - ]; + if (is_null($this->data)) { + $this->data = []; + foreach (Mage::app()->getWebsites() as $store) { + $storeId = (string) $store->getId(); + $this->data[$storeId] = [ + $storeId, + $store->getCode() + ]; + } + + ksort($this->data); } - ksort($this->data); + return $this->data; } } diff --git a/src/N98/Magento/Methods/Admin/Roles.php b/src/N98/Magento/Methods/Admin/Roles.php new file mode 100644 index 000000000..626210663 --- /dev/null +++ b/src/N98/Magento/Methods/Admin/Roles.php @@ -0,0 +1,30 @@ +getOption(ListCommand::COMMAND_OPTION_VENDOR); if ($vendor) { $filtered = ArrayFunctions::matrixFilterStartswith($filtered, 'Name', $vendor); diff --git a/src/N98/View/PhpView.php b/src/N98/View/PhpView.php index b881525db..efdb7c142 100644 --- a/src/N98/View/PhpView.php +++ b/src/N98/View/PhpView.php @@ -1,24 +1,33 @@ */ - protected $vars = []; + protected array $vars = []; /** * @var string */ - protected $template; + protected string $template; /** * @param string $template * @return PhpView */ - public function setTemplate($template) + public function setTemplate(string $template): self { $this->template = $template; @@ -31,7 +40,7 @@ public function setTemplate($template) * * @return PhpView */ - public function assign($key, $value) + public function assign(string $key, $value): self { $this->vars[$key] = $value; @@ -41,7 +50,7 @@ public function assign($key, $value) /** * @return string */ - public function render() + public function render(): string { extract($this->vars); ob_start(); @@ -49,13 +58,17 @@ public function render() $content = ob_get_contents(); ob_end_clean(); + if (!$content) { + throw new RuntimeException('Template could not be parsed.'); + } + return $content; } /** * @return string */ - protected function xmlProlog() + protected function xmlProlog(): string { return '' . "\n"; } diff --git a/src/N98/View/View.php b/src/N98/View/View.php index 9fef22500..039fbe5c5 100644 --- a/src/N98/View/View.php +++ b/src/N98/View/View.php @@ -1,7 +1,14 @@