From 9807f878c4d89f699d4123773719372f32e30955 Mon Sep 17 00:00:00 2001 From: Thomas Hauschild <7961978+Morgy93@users.noreply.github.com> Date: Wed, 21 Jan 2026 09:28:14 +0100 Subject: [PATCH 1/7] feat: remove continue-on-error from PHPStan step --- .github/workflows/phpstan.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 31d59d8..9cbe22b 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -114,6 +114,5 @@ jobs: - name: Run PHPStan working-directory: magento2 - continue-on-error: true run: | vendor/bin/phpstan analyse -c vendor/openforgeproject/mageforge/phpstan.neon vendor/openforgeproject/mageforge/src From 6feb0821b6b2a224fb051815e3507974e481e41e Mon Sep 17 00:00:00 2001 From: Thomas Hauschild <7961978+Morgy93@users.noreply.github.com> Date: Wed, 21 Jan 2026 09:28:28 +0100 Subject: [PATCH 2/7] fix: downgrade phpstan level to 5 --- phpstan.neon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpstan.neon b/phpstan.neon index 6e451fa..91e6453 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,4 @@ parameters: - level: 6 + level: 5 paths: - src From a5ce1ef5ce2204494bc0d6ad744fcf40d714b1ef Mon Sep 17 00:00:00 2001 From: Thomas Hauschild <7961978+Morgy93@users.noreply.github.com> Date: Wed, 21 Jan 2026 09:29:32 +0100 Subject: [PATCH 3/7] fix: remove unused constants and simplify returns --- src/Console/Command/Dev/InspectorCommand.php | 1 - src/Console/Command/System/VersionCommand.php | 1 - src/Console/Command/Theme/TokensCommand.php | 4 ++-- src/Model/TemplateEngine/Decorator/InspectorHints.php | 4 ++++ src/Model/ThemePath.php | 5 +---- src/Service/Hyva/CompatibilityChecker.php | 3 +-- src/Service/StaticContentCleaner.php | 2 +- 7 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Console/Command/Dev/InspectorCommand.php b/src/Console/Command/Dev/InspectorCommand.php index a5ce56b..048d6e3 100644 --- a/src/Console/Command/Dev/InspectorCommand.php +++ b/src/Console/Command/Dev/InspectorCommand.php @@ -116,7 +116,6 @@ protected function executeCommand(InputInterface $input, OutputInterface $output 'enable' => $this->enableInspector(), 'disable' => $this->disableInspector(), 'status' => $this->showStatus(), - default => Cli::RETURN_FAILURE, }; } diff --git a/src/Console/Command/System/VersionCommand.php b/src/Console/Command/System/VersionCommand.php index d2e5ff6..64392af 100644 --- a/src/Console/Command/System/VersionCommand.php +++ b/src/Console/Command/System/VersionCommand.php @@ -17,7 +17,6 @@ class VersionCommand extends AbstractCommand { private const API_URL = 'https://api.github.com/repos/openforgeproject/mageforge/releases/latest'; - private const PACKAGE_NAME = 'openforgeproject/mageforge'; private const UNKNOWN_VERSION = 'Unknown'; /** diff --git a/src/Console/Command/Theme/TokensCommand.php b/src/Console/Command/Theme/TokensCommand.php index 9255b9c..5b1687c 100644 --- a/src/Console/Command/Theme/TokensCommand.php +++ b/src/Console/Command/Theme/TokensCommand.php @@ -125,7 +125,7 @@ private function validateHyvaTheme(string $themeCode, OutputInterface $output): // If no theme was selected, exit if ($correctedTheme === null) { - return Cli::RETURN_FAILURE; + return null; } // Use the corrected theme code @@ -135,7 +135,7 @@ private function validateHyvaTheme(string $themeCode, OutputInterface $output): // Double-check the corrected theme exists if ($themePath === null) { $this->io->error("Theme $themeCode is not installed."); - return Cli::RETURN_FAILURE; + return null; } $this->io->info("Using theme: $themeCode"); diff --git a/src/Model/TemplateEngine/Decorator/InspectorHints.php b/src/Model/TemplateEngine/Decorator/InspectorHints.php index 0e511fa..09b2b40 100644 --- a/src/Model/TemplateEngine/Decorator/InspectorHints.php +++ b/src/Model/TemplateEngine/Decorator/InspectorHints.php @@ -62,6 +62,10 @@ public function render(BlockInterface $block, $templateFile, array $dictionary = { $result = $this->subject->render($block, $templateFile, $dictionary); + if (!$this->showBlockHints) { + return $result; + } + // Only inject attributes if there's actual HTML content if (empty(trim($result))) { return $result; diff --git a/src/Model/ThemePath.php b/src/Model/ThemePath.php index 37bff14..e4c739e 100644 --- a/src/Model/ThemePath.php +++ b/src/Model/ThemePath.php @@ -6,14 +6,11 @@ use Magento\Framework\Component\ComponentRegistrar; use Magento\Framework\Component\ComponentRegistrarInterface; -use Magento\Theme\Model\ResourceModel\Theme\Collection as ThemeCollection; class ThemePath { public function __construct( - private readonly ThemeList $themeList, - private readonly ComponentRegistrarInterface $componentRegistrar, - private readonly ThemeCollection $themeCollection + private readonly ComponentRegistrarInterface $componentRegistrar ) { } diff --git a/src/Service/Hyva/CompatibilityChecker.php b/src/Service/Hyva/CompatibilityChecker.php index 219475c..2cadd0f 100644 --- a/src/Service/Hyva/CompatibilityChecker.php +++ b/src/Service/Hyva/CompatibilityChecker.php @@ -19,8 +19,7 @@ class CompatibilityChecker { public function __construct( private readonly ComponentRegistrarInterface $componentRegistrar, - private readonly ModuleScanner $moduleScanner, - private readonly IncompatibilityDetector $incompatibilityDetector + private readonly ModuleScanner $moduleScanner ) { } diff --git a/src/Service/StaticContentCleaner.php b/src/Service/StaticContentCleaner.php index bd9cd82..311a261 100644 --- a/src/Service/StaticContentCleaner.php +++ b/src/Service/StaticContentCleaner.php @@ -61,7 +61,7 @@ public function cleanIfNeeded( $cleanedStatic = $this->themeCleaner->cleanPubStatic($themeCode, $io, false, $isVerbose); $cleanedPreprocessed = $this->themeCleaner->cleanViewPreprocessed($themeCode, $io, false, $isVerbose); - return ($cleanedStatic > 0 || $cleanedPreprocessed > 0) || !$this->themeCleaner->hasStaticFiles($themeCode); + return ($cleanedStatic > 0 || $cleanedPreprocessed > 0); } catch (\Exception $e) { $io->error('Failed to check/clean static content: ' . $e->getMessage()); return false; From 60d240ce391bd578d7c6c62182136bc7a3998c28 Mon Sep 17 00:00:00 2001 From: Thomas Hauschild <7961978+Morgy93@users.noreply.github.com> Date: Wed, 21 Jan 2026 10:07:47 +0100 Subject: [PATCH 4/7] fix: update return types and simplify conditions --- src/Console/Command/System/CheckCommand.php | 16 ++++++++-------- src/Console/Command/Theme/BuildCommand.php | 2 +- src/Console/Command/Theme/CleanCommand.php | 2 +- .../TemplateEngine/Decorator/InspectorHints.php | 4 ++-- .../TemplateEngine/Plugin/InspectorHints.php | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Console/Command/System/CheckCommand.php b/src/Console/Command/System/CheckCommand.php index ff69833..ae5dace 100644 --- a/src/Console/Command/System/CheckCommand.php +++ b/src/Console/Command/System/CheckCommand.php @@ -238,7 +238,7 @@ private function getMysqlVersionViaPdo(): ?string /** * Get database configuration from environment variables * - * @return array + * @return array */ private function getDatabaseConfig(): array { @@ -500,7 +500,7 @@ private function checkSearchEngineConnections(): ?string /** * Get potential search engine hosts * - * @return array + * @return string[] */ private function getSearchEngineHosts(): array { @@ -531,7 +531,7 @@ private function getSearchEngineHosts(): array /** * Format search engine version output * - * @param array $info + * @param array $info * @return string */ private function formatSearchEngineVersion(array $info): string @@ -549,7 +549,7 @@ private function formatSearchEngineVersion(array $info): string * Test Elasticsearch connection and return version info * * @param string $url - * @return array|bool + * @return array|false */ private function testElasticsearchConnection(string $url) { @@ -573,7 +573,7 @@ private function testElasticsearchConnection(string $url) * Try to connect using Magento's HTTP client * * @param string $url - * @return array|null + * @return array|null */ private function tryMagentoHttpClient(string $url): ?array { @@ -603,7 +603,7 @@ private function tryMagentoHttpClient(string $url): ?array /** * Get important PHP extensions * - * @return array + * @return array> */ private function getImportantPhpExtensions(): array { @@ -757,8 +757,8 @@ private function getSystemEnvironmentValue(string $name): ?string { // Use ini_get for certain system variables as a safer alternative if (in_array($name, ['memory_limit', 'max_execution_time'])) { - $value = ini_get($name); - if ($value !== false) { + $value = (string)ini_get($name); + if ($value !== '') { return $value; } } diff --git a/src/Console/Command/Theme/BuildCommand.php b/src/Console/Command/Theme/BuildCommand.php index 793d5ba..1d807f3 100644 --- a/src/Console/Command/Theme/BuildCommand.php +++ b/src/Console/Command/Theme/BuildCommand.php @@ -492,7 +492,7 @@ private function getServerVar(string $name): ?string private function setEnvVar(string $name, string $value): void { // Validate input parameters - if (empty($name) || !is_string($name)) { + if (empty($name) ) { return; } diff --git a/src/Console/Command/Theme/CleanCommand.php b/src/Console/Command/Theme/CleanCommand.php index 2d223aa..1ed6e0e 100644 --- a/src/Console/Command/Theme/CleanCommand.php +++ b/src/Console/Command/Theme/CleanCommand.php @@ -638,7 +638,7 @@ private function getServerVar(string $name): ?string */ private function setEnvVar(string $name, string $value): void { - if (empty($name) || !is_string($name)) { + if (empty($name) ) { return; } diff --git a/src/Model/TemplateEngine/Decorator/InspectorHints.php b/src/Model/TemplateEngine/Decorator/InspectorHints.php index 09b2b40..a544097 100644 --- a/src/Model/TemplateEngine/Decorator/InspectorHints.php +++ b/src/Model/TemplateEngine/Decorator/InspectorHints.php @@ -188,7 +188,7 @@ private function getParentBlockName(BlockInterface $block): string { if ($block instanceof AbstractBlock) { $parent = $block->getParentBlock(); - if ($parent && method_exists($parent, 'getNameInLayout')) { + if ($parent instanceof AbstractBlock) { return $parent->getNameInLayout() ?: ''; } } @@ -204,7 +204,7 @@ private function getParentBlockName(BlockInterface $block): string */ private function getBlockAlias(BlockInterface $block): string { - if ($block instanceof AbstractBlock && method_exists($block, 'getNameInLayout')) { + if ($block instanceof AbstractBlock) { return $block->getNameInLayout() ?: ''; } diff --git a/src/Model/TemplateEngine/Plugin/InspectorHints.php b/src/Model/TemplateEngine/Plugin/InspectorHints.php index 31e74cc..84d92a1 100644 --- a/src/Model/TemplateEngine/Plugin/InspectorHints.php +++ b/src/Model/TemplateEngine/Plugin/InspectorHints.php @@ -59,7 +59,7 @@ public function __construct( * @param TemplateEngineFactory $subject * @param TemplateEngineInterface $invocationResult * @return TemplateEngineInterface - * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings("PHPMD.UnusedFormalParameter") */ public function afterCreate( TemplateEngineFactory $subject, From e7319c46c0ed074ba6a7a473efb1097bf19fb41d Mon Sep 17 00:00:00 2001 From: Thomas Hauschild <7961978+Morgy93@users.noreply.github.com> Date: Wed, 21 Jan 2026 10:12:49 +0100 Subject: [PATCH 5/7] fix: simplify constructor by using property promotion --- .../Decorator/InspectorHintsFactory.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Model/TemplateEngine/Decorator/InspectorHintsFactory.php b/src/Model/TemplateEngine/Decorator/InspectorHintsFactory.php index 5360ad0..4002b97 100644 --- a/src/Model/TemplateEngine/Decorator/InspectorHintsFactory.php +++ b/src/Model/TemplateEngine/Decorator/InspectorHintsFactory.php @@ -11,14 +11,9 @@ */ class InspectorHintsFactory { - private ObjectManagerInterface $objectManager; - - /** - * @param ObjectManagerInterface $objectManager - */ - public function __construct(ObjectManagerInterface $objectManager) - { - $this->objectManager = $objectManager; + public function __construct( + private readonly ObjectManagerInterface $objectManager + ) { } /** From a832ecf1918851245345f1a7238d29330b20fadd Mon Sep 17 00:00:00 2001 From: Thomas Hauschild <7961978+Morgy93@users.noreply.github.com> Date: Wed, 21 Jan 2026 11:08:27 +0100 Subject: [PATCH 6/7] fix: improve docblocks and simplify create method --- .../TemplateEngine/Decorator/InspectorHintsFactory.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Model/TemplateEngine/Decorator/InspectorHintsFactory.php b/src/Model/TemplateEngine/Decorator/InspectorHintsFactory.php index 4002b97..9fcf0f0 100644 --- a/src/Model/TemplateEngine/Decorator/InspectorHintsFactory.php +++ b/src/Model/TemplateEngine/Decorator/InspectorHintsFactory.php @@ -11,6 +11,9 @@ */ class InspectorHintsFactory { + /** + * @param ObjectManagerInterface $objectManager + */ public function __construct( private readonly ObjectManagerInterface $objectManager ) { @@ -19,11 +22,13 @@ public function __construct( /** * Create InspectorHints instance * - * @param array $data + * @param array $data * @return InspectorHints */ public function create(array $data = []): InspectorHints { - return $this->objectManager->create(InspectorHints::class, $data); + /** @var InspectorHints $instance */ + $instance = $this->objectManager->create(InspectorHints::class, $data); + return $instance; } } From 15a7ecbcf29d511bab9201bff87ffbc45fa6f4a3 Mon Sep 17 00:00:00 2001 From: Thomas Hauschild <7961978+Morgy93@users.noreply.github.com> Date: Thu, 22 Jan 2026 09:30:30 +0100 Subject: [PATCH 7/7] fix: add missing use statement for InspectorHints --- src/Model/TemplateEngine/Decorator/InspectorHintsFactory.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Model/TemplateEngine/Decorator/InspectorHintsFactory.php b/src/Model/TemplateEngine/Decorator/InspectorHintsFactory.php index 9fcf0f0..c5fe32b 100644 --- a/src/Model/TemplateEngine/Decorator/InspectorHintsFactory.php +++ b/src/Model/TemplateEngine/Decorator/InspectorHintsFactory.php @@ -5,6 +5,7 @@ namespace OpenForgeProject\MageForge\Model\TemplateEngine\Decorator; use Magento\Framework\ObjectManagerInterface; +use OpenForgeProject\MageForge\Model\TemplateEngine\Decorator\InspectorHints; /** * Factory for InspectorHints decorator