Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
1 change: 0 additions & 1 deletion src/Console/Command/Dev/InspectorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,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
8 changes: 6 additions & 2 deletions src/Model/TemplateEngine/Decorator/InspectorHints.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -184,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() ?: '';
}
}
Expand All @@ -200,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() ?: '';
}

Expand Down
14 changes: 7 additions & 7 deletions src/Model/TemplateEngine/Decorator/InspectorHintsFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@
*/
class InspectorHintsFactory
{
private ObjectManagerInterface $objectManager;

/**
* @param ObjectManagerInterface $objectManager
*/
public function __construct(ObjectManagerInterface $objectManager)
{
$this->objectManager = $objectManager;
public function __construct(
private readonly ObjectManagerInterface $objectManager
) {
}

/**
* Create InspectorHints instance
*
* @param array $data
* @param array<string, mixed> $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;
}
}
2 changes: 1 addition & 1 deletion src/Model/TemplateEngine/Plugin/InspectorHints.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
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
2 changes: 1 addition & 1 deletion src/Service/StaticContentCleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading