Skip to content

Commit fa34cd8

Browse files
authored
fix: run mago format (#146)
* fix: run mago format * feat: add mago configuration file * fix: correct phpcs enable comment syntax * fix: remove unnecessary string concatenation in warning * fix: remove unnecessary string concatenation in warning
1 parent cb90564 commit fa34cd8

38 files changed

Lines changed: 279 additions & 439 deletions

mago.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Mago configuration for MageForge
2+
# https://mago.carthage.software/
3+
4+
[source]
5+
paths = ["src/"]
6+
includes = ["../../"]
7+
extensions = ["php", "phtml"]
8+
9+
[parser]
10+
enable-short-tags = false
11+
12+
[formatter]
13+
inline-empty-constructor-braces = false
14+
inline-empty-classlike-braces = false

src/Block/Inspector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(
3232
private readonly State $state,
3333
private readonly ScopeConfigInterface $scopeConfig,
3434
private readonly DevHelper $devHelper,
35-
array $data = []
35+
array $data = [],
3636
) {
3737
parent::__construct($context, $data);
3838
}

src/Console/Command/AbstractCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ protected function isDebug(OutputInterface $output): bool
134134
protected function handleInvalidThemeWithSuggestions(
135135
string $invalidTheme,
136136
ThemeSuggester $themeSuggester,
137-
OutputInterface $output
137+
OutputInterface $output,
138138
): ?string {
139139
$suggestions = $themeSuggester->findSimilarThemes($invalidTheme);
140140

@@ -169,7 +169,7 @@ protected function handleInvalidThemeWithSuggestions(
169169
label: 'Did you mean one of these themes?',
170170
options: $options,
171171
scroll: 10,
172-
hint: 'Arrow keys to navigate, Enter to confirm'
172+
hint: 'Arrow keys to navigate, Enter to confirm',
173173
);
174174

175175
try {
@@ -375,7 +375,7 @@ private function sanitizeTermValue(string $value): ?string
375375
if ($sanitized === null) {
376376
return null;
377377
}
378-
return (strlen($sanitized) > 0 && strlen($sanitized) <= 50) ? $sanitized : null;
378+
return strlen($sanitized) > 0 && strlen($sanitized) <= 50 ? $sanitized : null;
379379
}
380380

381381
/**
@@ -402,7 +402,7 @@ private function sanitizeAlphanumericValue(string $value): ?string
402402
if ($sanitized === null) {
403403
return null;
404404
}
405-
return (strlen($sanitized) > 0 && strlen($sanitized) <= 255) ? $sanitized : null;
405+
return strlen($sanitized) > 0 && strlen($sanitized) <= 255 ? $sanitized : null;
406406
}
407407

408408
/**

src/Console/Command/Dev/InspectorCommand.php

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(
3434
private readonly State $state,
3535
private readonly CacheManager $cacheManager,
3636
private readonly ScopeConfigInterface $scopeConfig,
37-
?string $name = null
37+
?string $name = null,
3838
) {
3939
parent::__construct($name);
4040
}
@@ -46,30 +46,29 @@ public function __construct(
4646
*/
4747
protected function configure(): void
4848
{
49-
$this->setName($this->getCommandName('theme', 'inspector'))
49+
$this
50+
->setName($this->getCommandName('theme', 'inspector'))
5051
->setDescription('Manage MageForge Frontend Inspector (Actions: enable|disable|status)')
5152
->addArgument(
5253
self::ARGUMENT_ACTION,
5354
InputArgument::REQUIRED,
54-
'Action to perform: enable, disable, or status'
55+
'Action to perform: enable, disable, or status',
5556
)
56-
->setHelp(
57-
<<<HELP
58-
The <info>%command.name%</info> command manages the MageForge Frontend Inspector:
57+
->setHelp(<<<HELP
58+
The <info>%command.name%</info> command manages the MageForge Frontend Inspector:
5959
60-
<info>php %command.full_name%</info> <comment>enable</comment>
61-
Enable the inspector (requires developer mode)
60+
<info>php %command.full_name%</info> <comment>enable</comment>
61+
Enable the inspector (requires developer mode)
6262
63-
<info>php %command.full_name%</info> <comment>disable</comment>
64-
Disable the inspector
63+
<info>php %command.full_name%</info> <comment>disable</comment>
64+
Disable the inspector
6565
66-
<info>php %command.full_name%</info> <comment>status</comment>
67-
Show current inspector status
66+
<info>php %command.full_name%</info> <comment>status</comment>
67+
Show current inspector status
6868
69-
The inspector allows you to hover over frontend elements to see template paths,
70-
block classes, modules, and other metadata. Activate with Ctrl+Shift+I.
71-
HELP
72-
);
69+
The inspector allows you to hover over frontend elements to see template paths,
70+
block classes, modules, and other metadata. Activate with Ctrl+Shift+I.
71+
HELP);
7372

7473
parent::configure();
7574
}
@@ -83,14 +82,11 @@ protected function configure(): void
8382
*/
8483
protected function executeCommand(InputInterface $input, OutputInterface $output): int
8584
{
86-
$action = strtolower((string)$input->getArgument(self::ARGUMENT_ACTION));
85+
$action = strtolower((string) $input->getArgument(self::ARGUMENT_ACTION));
8786

8887
// Validate action
8988
if (!in_array($action, ['enable', 'disable', 'status'], true)) {
90-
$this->io->error(sprintf(
91-
'Invalid action "%s". Use: enable, disable, or status',
92-
$action
93-
));
89+
$this->io->error(sprintf('Invalid action "%s". Use: enable, disable, or status', $action));
9490
return Cli::RETURN_FAILURE;
9591
}
9692

src/Console/Command/Hyva/CompatibilityCheckCommand.php

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class CompatibilityCheckCommand extends AbstractCommand
3838
* @param CompatibilityChecker $compatibilityChecker
3939
*/
4040
public function __construct(
41-
private readonly CompatibilityChecker $compatibilityChecker
41+
private readonly CompatibilityChecker $compatibilityChecker,
4242
) {
4343
parent::__construct();
4444
}
@@ -50,32 +50,33 @@ public function __construct(
5050
*/
5151
protected function configure(): void
5252
{
53-
$this->setName($this->getCommandName('hyva', 'compatibility:check'))
53+
$this
54+
->setName($this->getCommandName('hyva', 'compatibility:check'))
5455
->setDescription('Check modules for Hyvä theme compatibility issues')
5556
->setAliases(['hyva:check'])
5657
->addOption(
5758
self::OPTION_SHOW_ALL,
5859
'a',
5960
InputOption::VALUE_NONE,
60-
'Show all modules including compatible ones'
61+
'Show all modules including compatible ones',
6162
)
6263
->addOption(
6364
self::OPTION_THIRD_PARTY_ONLY,
6465
't',
6566
InputOption::VALUE_NONE,
66-
'Check only third-party modules (exclude Magento_* modules)'
67+
'Check only third-party modules (exclude Magento_* modules)',
6768
)
6869
->addOption(
6970
self::OPTION_INCLUDE_VENDOR,
7071
null,
7172
InputOption::VALUE_NONE,
72-
'Include Magento core modules (default: third-party modules only)'
73+
'Include Magento core modules (default: third-party modules only)',
7374
)
7475
->addOption(
7576
self::OPTION_DETAILED,
7677
'd',
7778
InputOption::VALUE_NONE,
78-
'Show detailed file-level issues for incompatible modules'
79+
'Show detailed file-level issues for incompatible modules',
7980
);
8081
}
8182

@@ -89,7 +90,8 @@ protected function configure(): void
8990
protected function executeCommand(InputInterface $input, OutputInterface $output): int
9091
{
9192
// Check if we're in interactive mode (no options provided)
92-
$hasOptions = $input->getOption(self::OPTION_SHOW_ALL)
93+
$hasOptions =
94+
$input->getOption(self::OPTION_SHOW_ALL)
9395
|| $input->getOption(self::OPTION_THIRD_PARTY_ONLY)
9496
|| $input->getOption(self::OPTION_INCLUDE_VENDOR)
9597
|| $input->getOption(self::OPTION_DETAILED);
@@ -142,10 +144,7 @@ private function runInteractiveMode(InputInterface $input, OutputInterface $outp
142144
$scope = $scopePrompt->prompt();
143145

144146
// Detailed view confirmation
145-
$detailedPrompt = new ConfirmPrompt(
146-
label: 'Show detailed file-level issues?',
147-
default: false,
148-
);
147+
$detailedPrompt = new ConfirmPrompt(label: 'Show detailed file-level issues?', default: false);
149148

150149
$detailed = $detailedPrompt->prompt();
151150

@@ -221,9 +220,8 @@ private function runScan(
221220
bool $includeVendor,
222221
bool $detailed,
223222
bool $incompatibleOnly,
224-
OutputInterface $output
223+
OutputInterface $output,
225224
): int {
226-
227225
// Determine filter logic:
228226
// - thirdPartyOnly: Only scan non-Magento_* modules (default behavior)
229227
// - includeVendor: Also scan Magento_* core modules
@@ -237,7 +235,7 @@ private function runScan(
237235
$output,
238236
$showAll,
239237
$scanThirdPartyOnly,
240-
$excludeVendor
238+
$excludeVendor,
241239
);
242240

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

268266
// Return appropriate exit code
269-
return $results['summary']['criticalIssues'] > 0
270-
? Cli::RETURN_FAILURE
271-
: Cli::RETURN_SUCCESS;
267+
return $results['summary']['criticalIssues'] > 0 ? Cli::RETURN_FAILURE : Cli::RETURN_SUCCESS;
272268
}
273269

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

292-
$this->io->table(
293-
['Module', 'Status', 'Issues'],
294-
$tableData
295-
);
288+
$this->io->table(['Module', 'Status', 'Issues'], $tableData);
296289
}
297290

298291
/**
@@ -327,7 +320,7 @@ private function displayDetailedIssues(array $results): void
327320
$color,
328321
$symbol,
329322
$issue['line'],
330-
$issue['description']
323+
$issue['description'],
331324
));
332325
}
333326
}
@@ -367,15 +360,15 @@ private function displaySummary(array $results): void
367360
$this->io->writeln(sprintf(
368361
'<fg=red>⚠</> Found <fg=red;options=bold>%d critical compatibility issue(s)</> in %d scanned modules.',
369362
$summary['criticalIssues'],
370-
$summary['total']
363+
$summary['total'],
371364
));
372365
$this->io->writeln('These modules require modifications to work with Hyvä themes.');
373366
} elseif ($summary['warningIssues'] > 0) {
374367
$this->io->newLine();
375368
$this->io->writeln(sprintf(
376369
'<fg=yellow>ℹ</> Found <fg=yellow;options=bold>%d warning(s)</> in %d scanned modules.',
377370
$summary['warningIssues'],
378-
$summary['total']
371+
$summary['total'],
379372
));
380373
$this->io->writeln('Review these modules for potential compatibility issues.');
381374
} else {

0 commit comments

Comments
 (0)