Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9807f87
feat: remove continue-on-error from PHPStan step
Morgy93 Jan 21, 2026
6feb082
fix: downgrade phpstan level to 5
Morgy93 Jan 21, 2026
a5ce1ef
fix: remove unused constants and simplify returns
Morgy93 Jan 21, 2026
60d240c
fix: update return types and simplify conditions
Morgy93 Jan 21, 2026
e7319c4
fix: simplify constructor by using property promotion
Morgy93 Jan 21, 2026
a832ecf
fix: improve docblocks and simplify create method
Morgy93 Jan 21, 2026
4c2fd38
Merge branch 'main' into fix-phpstan-5
dermatz Jan 21, 2026
4c0241e
Merge branch 'main' into fix-phpstan-5
dermatz Jan 21, 2026
bf88c63
Merge branch 'main' into fix-phpstan-5
dermatz Jan 21, 2026
53f8d47
Merge branch 'main' into fix-phpstan-5
dermatz Jan 21, 2026
6fa7535
Merge branch 'main' into fix-phpstan-5
dermatz Jan 21, 2026
971c95d
Merge branch 'main' into fix-phpstan-5
Morgy93 Jan 22, 2026
d3b19ec
Merge branch 'main' into fix-phpstan-5
dermatz Jan 22, 2026
696b992
Merge branch 'main' into fix-phpstan-5
dermatz Jan 22, 2026
15a7ecb
fix: add missing use statement for InspectorHints
Morgy93 Jan 22, 2026
5b213b8
fix: update Magento download method and config
Morgy93 Jan 29, 2026
ea51a01
fix: remove packagist disable command from PHPStan
Morgy93 Jan 29, 2026
604fa51
fix: refactor InspectorHints and factory for clarity
Morgy93 Jan 29, 2026
9d8a769
fix: extract random generator for PHPStan compliance
Morgy93 Jan 29, 2026
fa62051
fix: refactor constructors for property promotion
Morgy93 Jan 29, 2026
ce72138
fix: simplify random generator usage for PHPStan
Morgy93 Jan 29, 2026
3d1b9d7
#84 - Enable verbose PHPStan output and add bleedingEdge config for d…
Morgy93 Jan 29, 2026
3b0d5ae
#84 - Add PHP config check and clear PHPStan cache in CI
Morgy93 Jan 29, 2026
8145b05
#84 - Debug: Show actual file content in CI vendor directory
Morgy93 Jan 29, 2026
cc7d94b
#84 - Workaround PHPStan 2.x bug: Remove readonly from factory property
Morgy93 Jan 29, 2026
488ccc1
fix: remove InspectorHintsFactory class
Morgy93 Jan 29, 2026
2632e49
fix: remove bleedingEdge configuration from phpstan
Morgy93 Jan 29, 2026
4a1dbd1
Merge branch 'main' into fix-phpstan-5
Morgy93 Jan 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,12 @@ jobs:
key: ${{ runner.os }}-composer-2.4.8-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-2.4.8

- name: Clone Magento
- name: Download Magento
run: |
git clone --depth=1 --branch=2.4.8 https://github.com/magento/magento2.git magento2
composer create-project \
--repository-url=https://mirror.mage-os.org/ \
magento/project-community-edition \
magento2

- name: Install Magento
working-directory: magento2
Expand Down Expand Up @@ -109,11 +112,9 @@ jobs:
composer update --with-dependencies

# Enable module
bin/magento module:enable OpenForgeProject_MageForge
bin/magento setup:upgrade

- 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
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
parameters:
level: 6
level: 5
paths:
- src
22 changes: 3 additions & 19 deletions src/Block/Inspector.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,13 @@ class Inspector extends Template
{
private const XML_PATH_INSPECTOR_ENABLED = 'dev/mageforge_inspector/enabled';

private State $state;

private ScopeConfigInterface $scopeConfig;

private DevHelper $devHelper;

/**
* @param Context $context
* @param State $state
* @param ScopeConfigInterface $scopeConfig
* @param DevHelper $devHelper
* @param array $data
*/
public function __construct(
Context $context,
State $state,
ScopeConfigInterface $scopeConfig,
DevHelper $devHelper,
private readonly State $state,
private readonly ScopeConfigInterface $scopeConfig,
private readonly DevHelper $devHelper,
array $data = []
) {
$this->state = $state;
$this->scopeConfig = $scopeConfig;
$this->devHelper = $devHelper;
parent::__construct($context, $data);
}

Expand Down
22 changes: 3 additions & 19 deletions src/Console/Command/Dev/InspectorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,12 @@ class InspectorCommand extends AbstractCommand
private const XML_PATH_INSPECTOR_ENABLED = 'dev/mageforge_inspector/enabled';
private const ARGUMENT_ACTION = 'action';

private WriterInterface $configWriter;

private State $state;

private CacheManager $cacheManager;

/**
* @param WriterInterface $configWriter
* @param State $state
* @param CacheManager $cacheManager
* @param string|null $name
*/
public function __construct(
WriterInterface $configWriter,
State $state,
CacheManager $cacheManager,
private readonly WriterInterface $configWriter,
private readonly State $state,
private readonly CacheManager $cacheManager,
?string $name = null
) {
$this->configWriter = $configWriter;
$this->state = $state;
$this->cacheManager = $cacheManager;
parent::__construct($name);
}

Expand Down Expand Up @@ -116,7 +101,6 @@ protected function executeCommand(InputInterface $input, OutputInterface $output
'enable' => $this->enableInspector(),
'disable' => $this->disableInspector(),
'status' => $this->showStatus(),
default => Cli::RETURN_FAILURE,
};
}

Expand Down
16 changes: 8 additions & 8 deletions src/Console/Command/System/CheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ private function getMysqlVersionViaPdo(): ?string
/**
* Get database configuration from environment variables
*
* @return array
* @return array<string, string>
*/
private function getDatabaseConfig(): array
{
Expand Down Expand Up @@ -500,7 +500,7 @@ private function checkSearchEngineConnections(): ?string
/**
* Get potential search engine hosts
*
* @return array
* @return string[]
*/
private function getSearchEngineHosts(): array
{
Expand Down Expand Up @@ -531,7 +531,7 @@ private function getSearchEngineHosts(): array
/**
* Format search engine version output
*
* @param array $info
* @param array<string, mixed> $info
* @return string
*/
private function formatSearchEngineVersion(array $info): string
Expand All @@ -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<string, mixed>|false
*/
private function testElasticsearchConnection(string $url)
{
Expand All @@ -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<string, mixed>|null
*/
private function tryMagentoHttpClient(string $url): ?array
{
Expand Down Expand Up @@ -603,7 +603,7 @@ private function tryMagentoHttpClient(string $url): ?array
/**
* Get important PHP extensions
*
* @return array
* @return array<int, array<int, string>>
*/
private function getImportantPhpExtensions(): array
{
Expand Down Expand Up @@ -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;
}
}
Expand Down
1 change: 0 additions & 1 deletion src/Console/Command/System/VersionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Command/Theme/BuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Console/Command/Theme/CleanCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Console/Command/Theme/TokensCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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");
Expand Down
27 changes: 10 additions & 17 deletions src/Model/TemplateEngine/Decorator/InspectorHints.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace OpenForgeProject\MageForge\Model\TemplateEngine\Decorator;

use Magento\Framework\App\ObjectManager;
use Magento\Framework\Math\Random;
use Magento\Framework\View\Element\AbstractBlock;
use Magento\Framework\View\Element\BlockInterface;
Expand All @@ -17,28 +16,18 @@
*/
class InspectorHints implements TemplateEngineInterface
{
private TemplateEngineInterface $subject;

private bool $showBlockHints;

private ?Random $random = null;

private string $magentoRoot;

/**
* @param TemplateEngineInterface $subject
* @param bool $showBlockHints
* @param Random|null $random
* @param Random $random
*/
public function __construct(
TemplateEngineInterface $subject,
bool $showBlockHints,
?Random $random = null
private readonly TemplateEngineInterface $subject,
private readonly bool $showBlockHints,
private readonly Random $random
) {
$this->subject = $subject;
$this->showBlockHints = $showBlockHints;
$this->random = $random ?? ObjectManager::getInstance()->get(Random::class);

// Get Magento root directory - try multiple strategies
// 1. Try from BP constant (most reliable)
if (defined('BP')) {
Expand All @@ -62,6 +51,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;
Expand Down Expand Up @@ -189,7 +182,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() ?: '';
}
}
Expand All @@ -205,7 +198,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() ?: '';
}

Expand Down
34 changes: 0 additions & 34 deletions src/Model/TemplateEngine/Decorator/InspectorHintsFactory.php

This file was deleted.

34 changes: 6 additions & 28 deletions src/Model/TemplateEngine/Plugin/InspectorHints.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,13 @@ class InspectorHints
{
private const XML_PATH_INSPECTOR_ENABLED = 'dev/mageforge_inspector/enabled';

private ScopeConfigInterface $scopeConfig;

private StoreManagerInterface $storeManager;

private DevHelper $devHelper;

private InspectorHintsFactory $inspectorHintsFactory;

private State $state;

/**
* @param ScopeConfigInterface $scopeConfig
* @param StoreManagerInterface $storeManager
* @param DevHelper $devHelper
* @param InspectorHintsFactory $inspectorHintsFactory
* @param State $state
*/
public function __construct(
ScopeConfigInterface $scopeConfig,
StoreManagerInterface $storeManager,
DevHelper $devHelper,
InspectorHintsFactory $inspectorHintsFactory,
State $state
private readonly ScopeConfigInterface $scopeConfig,
private readonly StoreManagerInterface $storeManager,
private readonly DevHelper $devHelper,
private readonly InspectorHintsFactory $inspectorHintsFactory,
private readonly State $state
) {
$this->scopeConfig = $scopeConfig;
$this->storeManager = $storeManager;
$this->devHelper = $devHelper;
$this->inspectorHintsFactory = $inspectorHintsFactory;
$this->state = $state;
}

/**
Expand All @@ -59,7 +37,7 @@ public function __construct(
* @param TemplateEngineFactory $subject
* @param TemplateEngineInterface $invocationResult
* @return TemplateEngineInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
*/
public function afterCreate(
TemplateEngineFactory $subject,
Expand Down
5 changes: 1 addition & 4 deletions src/Model/ThemePath.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
}

Expand Down
3 changes: 1 addition & 2 deletions src/Service/Hyva/CompatibilityChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
}

Expand Down
Loading
Loading