From 0ce0a95bd2c68377b68bbd2c661823670d9b9ac4 Mon Sep 17 00:00:00 2001 From: Jisse Reitsma Date: Mon, 24 Jun 2024 15:06:42 +0200 Subject: [PATCH 1/8] Release --- CHANGELOG.md | 4 ++++ Console/Command/ListModulesCommand.php | 30 +++++++++++++++++++++----- composer.json | 2 +- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fecab7..4fe4af1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +# [2.4.1] = 24 June 2024 +### Fixed +- Added JSON format to module list output + # [2.4.0] = 21 June 2024 ### Added - New CLI `yireo_extensionchecker:list:modules` (module name, enabled/disabled, composer version) diff --git a/Console/Command/ListModulesCommand.php b/Console/Command/ListModulesCommand.php index 30f5e41..5d99b86 100644 --- a/Console/Command/ListModulesCommand.php +++ b/Console/Command/ListModulesCommand.php @@ -9,6 +9,7 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputInterface as Input; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface as Output; use Yireo\ExtensionChecker\Composer\ComposerFileFactory; use Yireo\ExtensionChecker\Composer\ComposerProvider; @@ -41,6 +42,7 @@ protected function configure() { $this->setName('yireo_extensionchecker:list:modules'); $this->setDescription('List all Magento modules'); + $this->addOption('format', null, InputOption::VALUE_OPTIONAL, 'Format (json, default)'); } /** @@ -51,6 +53,14 @@ protected function configure() */ protected function execute(Input $input, Output $output): int { + $moduleRows = $this->getModuleRows(); + $format = $input->getOption('format'); + + if ($format === 'json') { + $output->writeln(json_encode($moduleRows)); + return Command::SUCCESS; + } + $table = new Table($output); $table->setHeaders([ 'Module', @@ -59,25 +69,35 @@ protected function execute(Input $input, Output $output): int 'Composer Version' ]); + foreach ($moduleRows as $moduleRow) { + $table->addRow($moduleRow); + } + + $table->render(); + + return Command::SUCCESS; + } + + private function getModuleRows(): array + { $componentPaths = $this->componentRegistrar->getPaths(ComponentRegistrar::MODULE); $moduleNames = array_keys($componentPaths); + $moduleRows = []; foreach ($moduleNames as $moduleName) { $moduleInfo = $this->moduleList->getOne($moduleName); $status = $moduleInfo ? 'enabled' : 'disabled'; $setupVersion = isset($moduleInfo['setup_version']) ? $moduleInfo['setup_version'] : '-'; - $table->addRow([ + $moduleRows[] = [ $moduleName, $status, $setupVersion, $this->getComposerVersion($moduleName) - ]); + ]; } - $table->render(); - - return Command::SUCCESS; + return $moduleRows; } private function getComposerVersion(string $moduleName): string diff --git a/composer.json b/composer.json index 72e4fa2..e306812 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "yireo/magento2-extensionchecker", "license": "OSL-3.0", "type": "magento2-module", - "version": "2.4.0", + "version": "2.4.1", "homepage": "https://github.com/yireo/Yireo_ExtensionChecker", "description": "Scan the code of a Magento module", "keywords": [ From 7a7ef9a667f0d3310da5dec4492cbb1f3d1d2e9a Mon Sep 17 00:00:00 2001 From: Jisse Reitsma Date: Fri, 2 Aug 2024 09:10:21 +0200 Subject: [PATCH 2/8] Increase versions of symfony/finder and nikic/php-parser --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index e306812..8cc0700 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "yireo/magento2-extensionchecker", "license": "OSL-3.0", "type": "magento2-module", - "version": "2.4.1", + "version": "2.4.2", "homepage": "https://github.com/yireo/Yireo_ExtensionChecker", "description": "Scan the code of a Magento module", "keywords": [ @@ -17,9 +17,9 @@ ], "require": { "magento/framework": "^102.0|^103.0", - "symfony/finder": "^3.0|^4.0|^5.0|^6.0", + "symfony/finder": "^3.0|^4.0|^5.0|^6.0|^7.0", "composer/semver": "^1.0|^2.0|^3.0", - "nikic/php-parser": "^3.0|^4.0", + "nikic/php-parser": "^3.0|^4.0|^5.0", "php": "^7.4|^8.1", "ext-json": "*", "ext-pcre": "*", From 5e6de454f3df442222af8222dab2e1c96a689681 Mon Sep 17 00:00:00 2001 From: Jisse Reitsma Date: Mon, 12 Aug 2024 14:36:25 +0200 Subject: [PATCH 3/8] Changed call in Nikic parser --- CHANGELOG.md | 5 +++++ PhpClass/Tokenizer.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fe4af1..4f44129 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +# [2.4.2] = 12 August 2024 +### Fixed +- Changed call in Nikic parser + + # [2.4.1] = 24 June 2024 ### Fixed - Added JSON format to module list output diff --git a/PhpClass/Tokenizer.php b/PhpClass/Tokenizer.php index 1ad4b36..f1015f7 100644 --- a/PhpClass/Tokenizer.php +++ b/PhpClass/Tokenizer.php @@ -64,7 +64,7 @@ public function getImportedClassnamesFromFile(string $filename): array */ public function getImportedClassnamesFromSource(string $source): array { - $parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7); + $parser = (new ParserFactory())->createForNewestSupportedVersion(); $traverser = new NodeTraverser; $traverser->addVisitor(new NameResolver); $stmts = $parser->parse($source); From 084e9b856a9131c4fd56f28ced1ccca413c5b8da Mon Sep 17 00:00:00 2001 From: Jisse Reitsma Date: Fri, 23 Aug 2024 11:53:07 +0200 Subject: [PATCH 4/8] Fixes for dev requirements --- Composer/ComposerFile.php | 6 +++--- Scan/ScanComposerRequirements.php | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Composer/ComposerFile.php b/Composer/ComposerFile.php index d791d02..c45698f 100644 --- a/Composer/ComposerFile.php +++ b/Composer/ComposerFile.php @@ -38,13 +38,13 @@ public function getData(): array { $read = $this->readFactory->create($this->composerFile, 'file'); $composerContents = $read->readAll(); - + try { $extensionData = $this->serializer->unserialize($composerContents); } catch (InvalidArgumentException $invalidArgumentException) { throw new RuntimeException('Unserialize of file "' . $this->composerFile . '" failed: '.$invalidArgumentException->getMessage()); } - + if (empty($extensionData)) { throw new RuntimeException('Empty contents after decoding file "' . $this->composerFile . '"'); } @@ -84,6 +84,6 @@ public function getName(): string public function getRequirements(): array { // @todo: Merge this with require-dev? - return $this->get('require'); + return array_merge($this->get('require'), $this->get('require-dev')); } } diff --git a/Scan/ScanComposerRequirements.php b/Scan/ScanComposerRequirements.php index 831262f..567442b 100644 --- a/Scan/ScanComposerRequirements.php +++ b/Scan/ScanComposerRequirements.php @@ -172,7 +172,10 @@ private function isComposerDependencyNeeded(string $dependency, array $component $validDependencies = [ 'php', - 'magento/magento-composer-installer' + 'magento/magento-composer-installer', + 'phpstan/phpstan', + 'bitexpert/phpstan-magento', + 'yireo/magento2-integration-test-helper', ]; if (\in_array($dependency, $validDependencies)) { From 9438b2fdac577630c18f7c58ceec5d9fc9827884 Mon Sep 17 00:00:00 2001 From: Jisse Reitsma Date: Fri, 23 Aug 2024 11:53:41 +0200 Subject: [PATCH 5/8] Fixes for dev requirements --- CHANGELOG.md | 4 ++++ composer.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f44129..aa8c880 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +# [2.4.3] = 23 August 2024 +### Fixed +- Fixes for dev requirements + # [2.4.2] = 12 August 2024 ### Fixed - Changed call in Nikic parser diff --git a/composer.json b/composer.json index 8cc0700..36efdd4 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "yireo/magento2-extensionchecker", "license": "OSL-3.0", "type": "magento2-module", - "version": "2.4.2", + "version": "2.4.3", "homepage": "https://github.com/yireo/Yireo_ExtensionChecker", "description": "Scan the code of a Magento module", "keywords": [ From 1c4fbebf0dc29f874e5046ae47f9c6e07f7a29ae Mon Sep 17 00:00:00 2001 From: Jisse Reitsma Date: Thu, 29 Aug 2024 14:00:16 +0200 Subject: [PATCH 6/8] Prevent exception when require and/or require-dev is empty --- CHANGELOG.md | 4 ++++ Composer/ComposerFile.php | 14 ++++++++++---- composer.json | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa8c880..bee59b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +# [2.4.4] = 29 August 2024 +### Fixed +- Prevent exception when require and/or require-dev is empty + # [2.4.3] = 23 August 2024 ### Fixed - Fixes for dev requirements diff --git a/Composer/ComposerFile.php b/Composer/ComposerFile.php index c45698f..5d6ee55 100644 --- a/Composer/ComposerFile.php +++ b/Composer/ComposerFile.php @@ -78,12 +78,18 @@ public function getName(): string /** * @return array - * @throws NotFoundException - * @throws RuntimeException */ public function getRequirements(): array { - // @todo: Merge this with require-dev? - return array_merge($this->get('require'), $this->get('require-dev')); + $requirements = []; + try { + $requirements = array_merge($requirements, $this->get('require')); + } catch (RuntimeException) {} + + try { + $requirements = array_merge($requirements, $this->get('require-dev')); + } catch (RuntimeException) {} + + return $requirements; } } diff --git a/composer.json b/composer.json index 36efdd4..15ca78e 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "yireo/magento2-extensionchecker", "license": "OSL-3.0", "type": "magento2-module", - "version": "2.4.3", + "version": "2.4.4", "homepage": "https://github.com/yireo/Yireo_ExtensionChecker", "description": "Scan the code of a Magento module", "keywords": [ From a1f0f424b9c6b7bc9e5be361f969fc0d39bc0d68 Mon Sep 17 00:00:00 2001 From: Jisse Reitsma Date: Thu, 29 Aug 2024 14:01:11 +0200 Subject: [PATCH 7/8] Add PHP 7.4 syntax --- Composer/ComposerFile.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Composer/ComposerFile.php b/Composer/ComposerFile.php index 5d6ee55..2b606ba 100644 --- a/Composer/ComposerFile.php +++ b/Composer/ComposerFile.php @@ -84,11 +84,11 @@ public function getRequirements(): array $requirements = []; try { $requirements = array_merge($requirements, $this->get('require')); - } catch (RuntimeException) {} + } catch (RuntimeException $runtimeException) {} try { $requirements = array_merge($requirements, $this->get('require-dev')); - } catch (RuntimeException) {} + } catch (RuntimeException $runtimeException) {} return $requirements; } From ea2bba1d79a32bc4e5ca0a6de9104477f2ee74b3 Mon Sep 17 00:00:00 2001 From: Jisse Reitsma Date: Thu, 29 Aug 2024 14:06:46 +0200 Subject: [PATCH 8/8] Fix wild-card issue --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 15ca78e..555ce0e 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "ext-xml": "*" }, "require-dev": { - "yireo/magento2-integration-test-helper": "*" + "yireo/magento2-integration-test-helper": "~0.0.13" }, "autoload": { "psr-4": {