Skip to content

Commit 0a4a5fa

Browse files
authored
feat: update phpstan level and add type hints (#116)
1 parent ae9ca01 commit 0a4a5fa

File tree

14 files changed

+86
-27
lines changed

14 files changed

+86
-27
lines changed

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
parameters:
2-
level: 5
2+
level: 6
33
paths:
44
- src

src/Block/Inspector.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ class Inspector extends Template
1919
{
2020
private const XML_PATH_INSPECTOR_ENABLED = 'dev/mageforge_inspector/enabled';
2121

22+
/**
23+
* @param Context $context
24+
* @param State $state
25+
* @param ScopeConfigInterface $scopeConfig
26+
* @param DevHelper $devHelper
27+
* @param array<string, mixed> $data
28+
*/
2229
public function __construct(
2330
Context $context,
2431
private readonly State $state,

src/Console/Command/AbstractCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ abstract class AbstractCommand extends Command
3030
protected SymfonyStyle $io;
3131

3232
/**
33-
* @var array
33+
* @var array<string, string|null>
3434
*/
3535
private array $originalEnv = [];
3636

3737
/**
38-
* @var array
38+
* @var array<string, string|null>
3939
*/
4040
private array $secureEnvStorage = [];
4141

src/Console/Command/Hyva/CompatibilityCheckCommand.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ class CompatibilityCheckCommand extends AbstractCommand
3434
private const SCOPE_THIRD_PARTY = 'third-party';
3535
private const SCOPE_ALL = 'all';
3636

37+
/** @var array<string, string|null> */
3738
private array $originalEnv = [];
39+
40+
/** @var array<string, string|null> */
3841
private array $secureEnvStorage = [];
3942

4043
public function __construct(
@@ -245,6 +248,9 @@ private function runScan(
245248

246249
/**
247250
* Display compatibility check results
251+
*
252+
* @param array<string, mixed> $results
253+
* @param bool $showAll
248254
*/
249255
private function displayResults(array $results, bool $showAll): void
250256
{
@@ -265,6 +271,8 @@ private function displayResults(array $results, bool $showAll): void
265271

266272
/**
267273
* Display detailed file-level issues
274+
*
275+
* @param array<string, mixed> $results
268276
*/
269277
private function displayDetailedIssues(array $results): void
270278
{
@@ -303,6 +311,8 @@ private function displayDetailedIssues(array $results): void
303311

304312
/**
305313
* Display summary statistics
314+
*
315+
* @param array<string, mixed> $results
306316
*/
307317
private function displaySummary(array $results): void
308318
{

src/Console/Command/Theme/BuildCommand.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
*/
2424
class BuildCommand extends AbstractCommand
2525
{
26+
/** @var array<string, string|null> */
2627
private array $originalEnv = [];
28+
29+
/** @var array<string, string|null> */
2730
private array $secureEnvStorage = [];
2831

2932
/**
@@ -136,7 +139,7 @@ private function displayAvailableThemes(SymfonyStyle $io): int
136139
/**
137140
* Process theme building
138141
*
139-
* @param array $themeCodes
142+
* @param array<string> $themeCodes
140143
* @param SymfonyStyle $io
141144
* @param OutputInterface $output
142145
* @param bool $isVerbose
@@ -247,7 +250,7 @@ private function validateAndCorrectTheme(
247250
* @param SymfonyStyle $io
248251
* @param OutputInterface $output
249252
* @param bool $isVerbose
250-
* @param array $successList
253+
* @param array<string> $successList
251254
* @return bool
252255
*/
253256
private function buildValidatedTheme(
@@ -287,7 +290,7 @@ private function buildValidatedTheme(
287290
* @param SymfonyStyle $io
288291
* @param OutputInterface $output
289292
* @param bool $isVerbose
290-
* @param array $successList
293+
* @param array<string> $successList
291294
* @return bool
292295
*/
293296
private function processTheme(
@@ -312,7 +315,7 @@ private function processTheme(
312315
* Display build summary
313316
*
314317
* @param SymfonyStyle $io
315-
* @param array $successList
318+
* @param array<string> $successList
316319
* @param float $duration
317320
*/
318321
private function displayBuildSummary(SymfonyStyle $io, array $successList, float $duration): void
@@ -386,6 +389,8 @@ private function getSecureEnvironmentValue(string $name): ?string
386389

387390
/**
388391
* Cache and filter environment variables safely
392+
*
393+
* @return array<string, string|null>
389394
*/
390395
private function getCachedEnvironmentVariables(): array
391396
{

src/Console/Command/Theme/CleanCommand.php

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@
2121
*/
2222
class CleanCommand extends AbstractCommand
2323
{
24+
/** @var array<string, string|null>|null */
2425
private static ?array $cachedEnv = null;
26+
/** @var array<string, string|null> */
2527
private array $originalEnv = [];
28+
/** @var array<string, string|null> */
2629
private array $secureEnvStorage = [];
2730

2831
/**
@@ -96,7 +99,7 @@ protected function executeCommand(InputInterface $input, OutputInterface $output
9699
*
97100
* @param InputInterface $input
98101
* @param OutputInterface $output
99-
* @return array|null Array of theme codes or null to exit
102+
* @return array<string>|null Array of theme codes or null to exit
100103
*/
101104
private function resolveThemeCodes(InputInterface $input, OutputInterface $output): ?array
102105
{
@@ -117,7 +120,7 @@ private function resolveThemeCodes(InputInterface $input, OutputInterface $outpu
117120
/**
118121
* Get all theme codes
119122
*
120-
* @return array|null
123+
* @return array<string>|null
121124
*/
122125
private function getAllThemeCodes(): ?array
123126
{
@@ -138,7 +141,7 @@ private function getAllThemeCodes(): ?array
138141
* Select themes interactively
139142
*
140143
* @param OutputInterface $output
141-
* @return array|null
144+
* @return array<string>|null
142145
*/
143146
private function selectThemesInteractively(OutputInterface $output): ?array
144147
{
@@ -156,7 +159,7 @@ private function selectThemesInteractively(OutputInterface $output): ?array
156159
/**
157160
* Display available themes for non-interactive environments
158161
*
159-
* @param array $themes
162+
* @param array<mixed> $themes
160163
* @return void
161164
*/
162165
private function displayAvailableThemes(array $themes): void
@@ -181,9 +184,9 @@ private function displayAvailableThemes(array $themes): void
181184
/**
182185
* Prompt user to select themes
183186
*
184-
* @param array $options
185-
* @param array $themes
186-
* @return array|null
187+
* @param array<string> $options
188+
* @param array<mixed> $themes
189+
* @return array<string>|null
187190
*/
188191
private function promptForThemes(array $options, array $themes): ?array
189192
{
@@ -219,10 +222,10 @@ private function promptForThemes(array $options, array $themes): ?array
219222
/**
220223
* Process cleaning for all selected themes
221224
*
222-
* @param array $themeCodes
225+
* @param array<string> $themeCodes
223226
* @param bool $dryRun
224227
* @param OutputInterface $output
225-
* @return array [totalCleaned, failedThemes]
228+
* @return array<int, mixed> [totalCleaned, failedThemes]
226229
*/
227230
private function processThemes(array $themeCodes, bool $dryRun, OutputInterface $output): array
228231
{
@@ -257,7 +260,7 @@ private function processThemes(array $themeCodes, bool $dryRun, OutputInterface
257260
* Validate theme exists
258261
*
259262
* @param string $themeName
260-
* @param array &$failedThemes
263+
* @param array<string> $failedThemes
261264
* @param OutputInterface $output
262265
* @return string|null Theme code if valid or corrected, null if invalid
263266
*/
@@ -364,9 +367,9 @@ private function displayThemeResult(string $themeName, int $cleaned, bool $dryRu
364367
/**
365368
* Display summary of cleaning operation
366369
*
367-
* @param array $themeCodes
370+
* @param array<string> $themeCodes
368371
* @param int $totalCleaned
369-
* @param array $failedThemes
372+
* @param array<string> $failedThemes
370373
* @param bool $dryRun
371374
* @return void
372375
*/
@@ -411,7 +414,7 @@ private function displaySingleThemeSummary(string $themeCode, int $totalCleaned,
411414
*
412415
* @param int $totalThemes
413416
* @param int $totalCleaned
414-
* @param array $failedThemes
417+
* @param array<string> $failedThemes
415418
* @param bool $dryRun
416419
* @return void
417420
*/
@@ -543,6 +546,8 @@ private function getSecureEnvironmentValue(string $name): ?string
543546

544547
/**
545548
* Cache and filter environment variables safely
549+
*
550+
* @return array<string, string|null>
546551
*/
547552
private function getCachedEnvironmentVariables(): array
548553
{

src/Model/TemplateEngine/Decorator/InspectorHints.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(
4444
*
4545
* @param BlockInterface $block
4646
* @param string $templateFile
47-
* @param array $dictionary
47+
* @param array<string, mixed> $dictionary
4848
* @return string
4949
*/
5050
public function render(BlockInterface $block, $templateFile, array $dictionary = []): string

src/Model/ThemeList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function __construct(
2121
/**
2222
* Get all themes
2323
*
24-
* @return array
24+
* @return array<mixed>
2525
*/
2626
public function getAllThemes(): array
2727
{

src/Service/Hyva/CompatibilityChecker.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct(
3131
* @param bool $showAll Whether to show all modules (including compatible ones)
3232
* @param bool $thirdPartyOnly Whether to scan only third-party modules (excludes Magento_* modules)
3333
* @param bool $excludeVendor Whether to exclude modules from the vendor/ directory (true = exclude, false = include)
34-
* @return array Results with structure: ['modules' => [], 'summary' => [], 'hasIncompatibilities' => bool]
34+
* @return array<string, mixed> Results with structure: ['modules' => [], 'summary' => [], 'hasIncompatibilities' => bool]
3535
*/
3636
public function check(
3737
SymfonyStyle $io,
@@ -126,6 +126,10 @@ private function isMagentoModule(string $moduleName): bool
126126

127127
/**
128128
* Format results for display
129+
*
130+
* @param array<string, mixed> $results
131+
* @param bool $showAll
132+
* @return array<int, array<int, string>>
129133
*/
130134
public function formatResultsForDisplay(array $results, bool $showAll = false): array
131135
{
@@ -149,6 +153,8 @@ public function formatResultsForDisplay(array $results, bool $showAll = false):
149153

150154
/**
151155
* Get status display string with colors
156+
*
157+
* @param array<string, mixed> $moduleData
152158
*/
153159
private function getStatusDisplay(array $moduleData): string
154160
{
@@ -169,6 +175,8 @@ private function getStatusDisplay(array $moduleData): string
169175

170176
/**
171177
* Get issues display string
178+
*
179+
* @param array<string, mixed> $moduleData
172180
*/
173181
private function getIssuesDisplay(array $moduleData): string
174182
{
@@ -195,6 +203,10 @@ private function getIssuesDisplay(array $moduleData): string
195203

196204
/**
197205
* Get detailed file issues for a module
206+
*
207+
* @param string $moduleName
208+
* @param array<string, mixed> $moduleData
209+
* @return array<int, array<string, mixed>>
198210
*/
199211
public function getDetailedIssues(string $moduleName, array $moduleData): array
200212
{

src/Service/Hyva/IncompatibilityDetector.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function __construct(
102102
/**
103103
* Detect incompatibilities in a file
104104
*
105-
* @return array Array of issues with keys: pattern, description, severity, line
105+
* @return array<int, array<string, mixed>> Array of issues with keys: pattern, description, severity, line
106106
*/
107107
public function detectInFile(string $filePath): array
108108
{
@@ -142,6 +142,10 @@ private function mapExtensionToType(string $extension): string
142142

143143
/**
144144
* Scan content lines for pattern matches
145+
*
146+
* @param array<int, string> $lines
147+
* @param array<int, array<string, mixed>> $patterns
148+
* @return array<int, array<string, mixed>>
145149
*/
146150
private function scanContentForPatterns(array $lines, array $patterns): array
147151
{

0 commit comments

Comments
 (0)