Skip to content
Open
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
14 changes: 14 additions & 0 deletions mago.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Mago configuration for MageForge
# https://mago.carthage.software/

[source]
paths = ["src/"]
includes = ["../../"]
extensions = ["php", "phtml"]

[parser]
enable-short-tags = false

[formatter]
inline-empty-constructor-braces = false
inline-empty-classlike-braces = false
2 changes: 1 addition & 1 deletion src/Block/Inspector.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(
private readonly State $state,
private readonly ScopeConfigInterface $scopeConfig,
private readonly DevHelper $devHelper,
array $data = []
array $data = [],
) {
parent::__construct($context, $data);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Console/Command/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected function isDebug(OutputInterface $output): bool
protected function handleInvalidThemeWithSuggestions(
string $invalidTheme,
ThemeSuggester $themeSuggester,
OutputInterface $output
OutputInterface $output,
): ?string {
$suggestions = $themeSuggester->findSimilarThemes($invalidTheme);

Expand Down Expand Up @@ -169,7 +169,7 @@ protected function handleInvalidThemeWithSuggestions(
label: 'Did you mean one of these themes?',
options: $options,
scroll: 10,
hint: 'Arrow keys to navigate, Enter to confirm'
hint: 'Arrow keys to navigate, Enter to confirm',
);

try {
Expand Down Expand Up @@ -375,7 +375,7 @@ private function sanitizeTermValue(string $value): ?string
if ($sanitized === null) {
return null;
}
return (strlen($sanitized) > 0 && strlen($sanitized) <= 50) ? $sanitized : null;
return strlen($sanitized) > 0 && strlen($sanitized) <= 50 ? $sanitized : null;
}

/**
Expand All @@ -402,7 +402,7 @@ private function sanitizeAlphanumericValue(string $value): ?string
if ($sanitized === null) {
return null;
}
return (strlen($sanitized) > 0 && strlen($sanitized) <= 255) ? $sanitized : null;
return strlen($sanitized) > 0 && strlen($sanitized) <= 255 ? $sanitized : null;
}

/**
Expand Down
38 changes: 17 additions & 21 deletions src/Console/Command/Dev/InspectorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(
private readonly State $state,
private readonly CacheManager $cacheManager,
private readonly ScopeConfigInterface $scopeConfig,
?string $name = null
?string $name = null,
) {
parent::__construct($name);
}
Expand All @@ -46,30 +46,29 @@ public function __construct(
*/
protected function configure(): void
{
$this->setName($this->getCommandName('theme', 'inspector'))
$this
->setName($this->getCommandName('theme', 'inspector'))
->setDescription('Manage MageForge Frontend Inspector (Actions: enable|disable|status)')
->addArgument(
self::ARGUMENT_ACTION,
InputArgument::REQUIRED,
'Action to perform: enable, disable, or status'
'Action to perform: enable, disable, or status',
)
->setHelp(
<<<HELP
The <info>%command.name%</info> command manages the MageForge Frontend Inspector:
->setHelp(<<<HELP
The <info>%command.name%</info> command manages the MageForge Frontend Inspector:

<info>php %command.full_name%</info> <comment>enable</comment>
Enable the inspector (requires developer mode)
<info>php %command.full_name%</info> <comment>enable</comment>
Enable the inspector (requires developer mode)

<info>php %command.full_name%</info> <comment>disable</comment>
Disable the inspector
<info>php %command.full_name%</info> <comment>disable</comment>
Disable the inspector

<info>php %command.full_name%</info> <comment>status</comment>
Show current inspector status
<info>php %command.full_name%</info> <comment>status</comment>
Show current inspector status

The inspector allows you to hover over frontend elements to see template paths,
block classes, modules, and other metadata. Activate with Ctrl+Shift+I.
HELP
);
The inspector allows you to hover over frontend elements to see template paths,
block classes, modules, and other metadata. Activate with Ctrl+Shift+I.
HELP);

parent::configure();
}
Expand All @@ -83,14 +82,11 @@ protected function configure(): void
*/
protected function executeCommand(InputInterface $input, OutputInterface $output): int
{
$action = strtolower((string)$input->getArgument(self::ARGUMENT_ACTION));
$action = strtolower((string) $input->getArgument(self::ARGUMENT_ACTION));

// Validate action
if (!in_array($action, ['enable', 'disable', 'status'], true)) {
$this->io->error(sprintf(
'Invalid action "%s". Use: enable, disable, or status',
$action
));
$this->io->error(sprintf('Invalid action "%s". Use: enable, disable, or status', $action));
return Cli::RETURN_FAILURE;
}

Expand Down
41 changes: 17 additions & 24 deletions src/Console/Command/Hyva/CompatibilityCheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CompatibilityCheckCommand extends AbstractCommand
* @param CompatibilityChecker $compatibilityChecker
*/
public function __construct(
private readonly CompatibilityChecker $compatibilityChecker
private readonly CompatibilityChecker $compatibilityChecker,
) {
parent::__construct();
}
Expand All @@ -50,32 +50,33 @@ public function __construct(
*/
protected function configure(): void
{
$this->setName($this->getCommandName('hyva', 'compatibility:check'))
$this
->setName($this->getCommandName('hyva', 'compatibility:check'))
->setDescription('Check modules for Hyvä theme compatibility issues')
->setAliases(['hyva:check'])
->addOption(
self::OPTION_SHOW_ALL,
'a',
InputOption::VALUE_NONE,
'Show all modules including compatible ones'
'Show all modules including compatible ones',
)
->addOption(
self::OPTION_THIRD_PARTY_ONLY,
't',
InputOption::VALUE_NONE,
'Check only third-party modules (exclude Magento_* modules)'
'Check only third-party modules (exclude Magento_* modules)',
)
->addOption(
self::OPTION_INCLUDE_VENDOR,
null,
InputOption::VALUE_NONE,
'Include Magento core modules (default: third-party modules only)'
'Include Magento core modules (default: third-party modules only)',
)
->addOption(
self::OPTION_DETAILED,
'd',
InputOption::VALUE_NONE,
'Show detailed file-level issues for incompatible modules'
'Show detailed file-level issues for incompatible modules',
);
}

Expand All @@ -89,7 +90,8 @@ protected function configure(): void
protected function executeCommand(InputInterface $input, OutputInterface $output): int
{
// Check if we're in interactive mode (no options provided)
$hasOptions = $input->getOption(self::OPTION_SHOW_ALL)
$hasOptions =
$input->getOption(self::OPTION_SHOW_ALL)
|| $input->getOption(self::OPTION_THIRD_PARTY_ONLY)
|| $input->getOption(self::OPTION_INCLUDE_VENDOR)
|| $input->getOption(self::OPTION_DETAILED);
Expand Down Expand Up @@ -142,10 +144,7 @@ private function runInteractiveMode(InputInterface $input, OutputInterface $outp
$scope = $scopePrompt->prompt();

// Detailed view confirmation
$detailedPrompt = new ConfirmPrompt(
label: 'Show detailed file-level issues?',
default: false,
);
$detailedPrompt = new ConfirmPrompt(label: 'Show detailed file-level issues?', default: false);

$detailed = $detailedPrompt->prompt();

Expand Down Expand Up @@ -221,9 +220,8 @@ private function runScan(
bool $includeVendor,
bool $detailed,
bool $incompatibleOnly,
OutputInterface $output
OutputInterface $output,
): int {

// Determine filter logic:
// - thirdPartyOnly: Only scan non-Magento_* modules (default behavior)
// - includeVendor: Also scan Magento_* core modules
Expand All @@ -237,7 +235,7 @@ private function runScan(
$output,
$showAll,
$scanThirdPartyOnly,
$excludeVendor
$excludeVendor,
);

// Determine display mode:
Expand Down Expand Up @@ -266,9 +264,7 @@ private function runScan(
$this->io->newLine();

// Return appropriate exit code
return $results['summary']['criticalIssues'] > 0
? Cli::RETURN_FAILURE
: Cli::RETURN_SUCCESS;
return $results['summary']['criticalIssues'] > 0 ? Cli::RETURN_FAILURE : Cli::RETURN_SUCCESS;
}

/**
Expand All @@ -289,10 +285,7 @@ private function displayResults(array $results, bool $showAll): void
return;
}

$this->io->table(
['Module', 'Status', 'Issues'],
$tableData
);
$this->io->table(['Module', 'Status', 'Issues'], $tableData);
}

/**
Expand Down Expand Up @@ -327,7 +320,7 @@ private function displayDetailedIssues(array $results): void
$color,
$symbol,
$issue['line'],
$issue['description']
$issue['description'],
));
}
}
Expand Down Expand Up @@ -367,15 +360,15 @@ private function displaySummary(array $results): void
$this->io->writeln(sprintf(
'<fg=red>⚠</> Found <fg=red;options=bold>%d critical compatibility issue(s)</> in %d scanned modules.',
$summary['criticalIssues'],
$summary['total']
$summary['total'],
));
$this->io->writeln('These modules require modifications to work with Hyvä themes.');
} elseif ($summary['warningIssues'] > 0) {
$this->io->newLine();
$this->io->writeln(sprintf(
'<fg=yellow>ℹ</> Found <fg=yellow;options=bold>%d warning(s)</> in %d scanned modules.',
$summary['warningIssues'],
$summary['total']
$summary['total'],
));
$this->io->writeln('Review these modules for potential compatibility issues.');
} else {
Expand Down
Loading