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

/**
* @param Context $context
* @param State $state
* @param ScopeConfigInterface $scopeConfig
* @param DevHelper $devHelper
* @param array<string, mixed> $data
*/
public function __construct(
Context $context,
private readonly State $state,
Expand Down
4 changes: 2 additions & 2 deletions src/Console/Command/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ abstract class AbstractCommand extends Command
protected SymfonyStyle $io;

/**
* @var array
* @var array<string, string|null>
*/
private array $originalEnv = [];

/**
* @var array
* @var array<string, string|null>
*/
private array $secureEnvStorage = [];

Expand Down
10 changes: 10 additions & 0 deletions src/Console/Command/Hyva/CompatibilityCheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ class CompatibilityCheckCommand extends AbstractCommand
private const SCOPE_THIRD_PARTY = 'third-party';
private const SCOPE_ALL = 'all';

/** @var array<string, string|null> */
private array $originalEnv = [];

/** @var array<string, string|null> */
private array $secureEnvStorage = [];

public function __construct(
Expand Down Expand Up @@ -245,6 +248,9 @@ private function runScan(

/**
* Display compatibility check results
*
* @param array<string, mixed> $results
* @param bool $showAll
*/
private function displayResults(array $results, bool $showAll): void
{
Expand All @@ -265,6 +271,8 @@ private function displayResults(array $results, bool $showAll): void

/**
* Display detailed file-level issues
*
* @param array<string, mixed> $results
*/
private function displayDetailedIssues(array $results): void
{
Expand Down Expand Up @@ -303,6 +311,8 @@ private function displayDetailedIssues(array $results): void

/**
* Display summary statistics
*
* @param array<string, mixed> $results
*/
private function displaySummary(array $results): void
{
Expand Down
13 changes: 9 additions & 4 deletions src/Console/Command/Theme/BuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
*/
class BuildCommand extends AbstractCommand
{
/** @var array<string, string|null> */
private array $originalEnv = [];

/** @var array<string, string|null> */
private array $secureEnvStorage = [];

/**
Expand Down Expand Up @@ -136,7 +139,7 @@ private function displayAvailableThemes(SymfonyStyle $io): int
/**
* Process theme building
*
* @param array $themeCodes
* @param array<string> $themeCodes
* @param SymfonyStyle $io
* @param OutputInterface $output
* @param bool $isVerbose
Expand Down Expand Up @@ -247,7 +250,7 @@ private function validateAndCorrectTheme(
* @param SymfonyStyle $io
* @param OutputInterface $output
* @param bool $isVerbose
* @param array $successList
* @param array<string> $successList
* @return bool
*/
private function buildValidatedTheme(
Expand Down Expand Up @@ -287,7 +290,7 @@ private function buildValidatedTheme(
* @param SymfonyStyle $io
* @param OutputInterface $output
* @param bool $isVerbose
* @param array $successList
* @param array<string> $successList
* @return bool
*/
private function processTheme(
Expand All @@ -312,7 +315,7 @@ private function processTheme(
* Display build summary
*
* @param SymfonyStyle $io
* @param array $successList
* @param array<string> $successList
* @param float $duration
*/
private function displayBuildSummary(SymfonyStyle $io, array $successList, float $duration): void
Expand Down Expand Up @@ -386,6 +389,8 @@ private function getSecureEnvironmentValue(string $name): ?string

/**
* Cache and filter environment variables safely
*
* @return array<string, string|null>
*/
private function getCachedEnvironmentVariables(): array
{
Expand Down
31 changes: 18 additions & 13 deletions src/Console/Command/Theme/CleanCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
*/
class CleanCommand extends AbstractCommand
{
/** @var array<string, string|null>|null */
private static ?array $cachedEnv = null;
/** @var array<string, string|null> */
private array $originalEnv = [];
/** @var array<string, string|null> */
private array $secureEnvStorage = [];

/**
Expand Down Expand Up @@ -96,7 +99,7 @@ protected function executeCommand(InputInterface $input, OutputInterface $output
*
* @param InputInterface $input
* @param OutputInterface $output
* @return array|null Array of theme codes or null to exit
* @return array<string>|null Array of theme codes or null to exit
*/
private function resolveThemeCodes(InputInterface $input, OutputInterface $output): ?array
{
Expand All @@ -117,7 +120,7 @@ private function resolveThemeCodes(InputInterface $input, OutputInterface $outpu
/**
* Get all theme codes
*
* @return array|null
* @return array<string>|null
*/
private function getAllThemeCodes(): ?array
{
Expand All @@ -138,7 +141,7 @@ private function getAllThemeCodes(): ?array
* Select themes interactively
*
* @param OutputInterface $output
* @return array|null
* @return array<string>|null
*/
private function selectThemesInteractively(OutputInterface $output): ?array
{
Expand All @@ -156,7 +159,7 @@ private function selectThemesInteractively(OutputInterface $output): ?array
/**
* Display available themes for non-interactive environments
*
* @param array $themes
* @param array<mixed> $themes
* @return void
*/
private function displayAvailableThemes(array $themes): void
Expand All @@ -181,9 +184,9 @@ private function displayAvailableThemes(array $themes): void
/**
* Prompt user to select themes
*
* @param array $options
* @param array $themes
* @return array|null
* @param array<string> $options
* @param array<mixed> $themes
* @return array<string>|null
*/
private function promptForThemes(array $options, array $themes): ?array
{
Expand Down Expand Up @@ -219,10 +222,10 @@ private function promptForThemes(array $options, array $themes): ?array
/**
* Process cleaning for all selected themes
*
* @param array $themeCodes
* @param array<string> $themeCodes
* @param bool $dryRun
* @param OutputInterface $output
* @return array [totalCleaned, failedThemes]
* @return array<int, mixed> [totalCleaned, failedThemes]
*/
private function processThemes(array $themeCodes, bool $dryRun, OutputInterface $output): array
{
Expand Down Expand Up @@ -257,7 +260,7 @@ private function processThemes(array $themeCodes, bool $dryRun, OutputInterface
* Validate theme exists
*
* @param string $themeName
* @param array &$failedThemes
* @param array<string> $failedThemes
* @param OutputInterface $output
* @return string|null Theme code if valid or corrected, null if invalid
*/
Expand Down Expand Up @@ -364,9 +367,9 @@ private function displayThemeResult(string $themeName, int $cleaned, bool $dryRu
/**
* Display summary of cleaning operation
*
* @param array $themeCodes
* @param array<string> $themeCodes
* @param int $totalCleaned
* @param array $failedThemes
* @param array<string> $failedThemes
* @param bool $dryRun
* @return void
*/
Expand Down Expand Up @@ -411,7 +414,7 @@ private function displaySingleThemeSummary(string $themeCode, int $totalCleaned,
*
* @param int $totalThemes
* @param int $totalCleaned
* @param array $failedThemes
* @param array<string> $failedThemes
* @param bool $dryRun
* @return void
*/
Expand Down Expand Up @@ -543,6 +546,8 @@ private function getSecureEnvironmentValue(string $name): ?string

/**
* Cache and filter environment variables safely
*
* @return array<string, string|null>
*/
private function getCachedEnvironmentVariables(): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Model/TemplateEngine/Decorator/InspectorHints.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(
*
* @param BlockInterface $block
* @param string $templateFile
* @param array $dictionary
* @param array<string, mixed> $dictionary
* @return string
*/
public function render(BlockInterface $block, $templateFile, array $dictionary = []): string
Expand Down
2 changes: 1 addition & 1 deletion src/Model/ThemeList.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(
/**
* Get all themes
*
* @return array
* @return array<mixed>
*/
public function getAllThemes(): array
{
Expand Down
14 changes: 13 additions & 1 deletion src/Service/Hyva/CompatibilityChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(
* @param bool $showAll Whether to show all modules (including compatible ones)
* @param bool $thirdPartyOnly Whether to scan only third-party modules (excludes Magento_* modules)
* @param bool $excludeVendor Whether to exclude modules from the vendor/ directory (true = exclude, false = include)
* @return array Results with structure: ['modules' => [], 'summary' => [], 'hasIncompatibilities' => bool]
* @return array<string, mixed> Results with structure: ['modules' => [], 'summary' => [], 'hasIncompatibilities' => bool]
*/
public function check(
SymfonyStyle $io,
Expand Down Expand Up @@ -126,6 +126,10 @@ private function isMagentoModule(string $moduleName): bool

/**
* Format results for display
*
* @param array<string, mixed> $results
* @param bool $showAll
* @return array<int, array<int, string>>
*/
public function formatResultsForDisplay(array $results, bool $showAll = false): array
{
Expand All @@ -149,6 +153,8 @@ public function formatResultsForDisplay(array $results, bool $showAll = false):

/**
* Get status display string with colors
*
* @param array<string, mixed> $moduleData
*/
private function getStatusDisplay(array $moduleData): string
{
Expand All @@ -169,6 +175,8 @@ private function getStatusDisplay(array $moduleData): string

/**
* Get issues display string
*
* @param array<string, mixed> $moduleData
*/
private function getIssuesDisplay(array $moduleData): string
{
Expand All @@ -195,6 +203,10 @@ private function getIssuesDisplay(array $moduleData): string

/**
* Get detailed file issues for a module
*
* @param string $moduleName
* @param array<string, mixed> $moduleData
* @return array<int, array<string, mixed>>
*/
public function getDetailedIssues(string $moduleName, array $moduleData): array
{
Expand Down
6 changes: 5 additions & 1 deletion src/Service/Hyva/IncompatibilityDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function __construct(
/**
* Detect incompatibilities in a file
*
* @return array Array of issues with keys: pattern, description, severity, line
* @return array<int, array<string, mixed>> Array of issues with keys: pattern, description, severity, line
*/
public function detectInFile(string $filePath): array
{
Expand Down Expand Up @@ -142,6 +142,10 @@ private function mapExtensionToType(string $extension): string

/**
* Scan content lines for pattern matches
*
* @param array<int, string> $lines
* @param array<int, array<string, mixed>> $patterns
* @return array<int, array<string, mixed>>
*/
private function scanContentForPatterns(array $lines, array $patterns): array
{
Expand Down
8 changes: 6 additions & 2 deletions src/Service/Hyva/ModuleScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(
/**
* Scan a module directory for compatibility issues
*
* @return array Array with structure: ['files' => [], 'totalIssues' => int, 'criticalIssues' => int]
* @return array<string, mixed> Array with structure: ['files' => [], 'totalIssues' => int, 'criticalIssues' => int]
*/
public function scanModule(string $modulePath): array
{
Expand Down Expand Up @@ -65,6 +65,8 @@ public function scanModule(string $modulePath): array

/**
* Recursively find all relevant files in a directory
*
* @return array<int, string>
*/
private function findRelevantFiles(string $directory): array
{
Expand Down Expand Up @@ -109,7 +111,7 @@ private function findRelevantFiles(string $directory): array
/**
* Check if module has Hyvä compatibility package based on composer data
*
* @param array $composerData Parsed composer.json data
* @param array<string, mixed> $composerData Parsed composer.json data
*/
private function isHyvaCompatibilityPackage(array $composerData): bool
{
Expand Down Expand Up @@ -165,6 +167,8 @@ public function hasHyvaCompatibilityPackage(string $modulePath): bool

/**
* Get module info from composer.json
*
* @return array<string, mixed>
*/
public function getModuleInfo(string $modulePath): array
{
Expand Down
8 changes: 8 additions & 0 deletions src/Service/StandardThemeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ public function __construct(
) {
}

/**
* @param string $themeCode
* @param SymfonyStyle $io
* @param OutputInterface $output
* @param bool $isVerbose
* @param array<string> $successList
* @return bool
*/
public function build(
string $themeCode,
SymfonyStyle $io,
Expand Down
4 changes: 4 additions & 0 deletions src/Service/ThemeBuilder/BuilderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class BuilderFactory
{
/** @var array<string, BuilderInterface> */
private array $builders = [];

public function addBuilder(BuilderInterface $builder): void
Expand All @@ -22,6 +23,9 @@ public function create(string $type): BuilderInterface
return $this->builders[$type];
}

/**
* @return array<string>
*/
public function getAvailableBuilders(): array
{
return array_keys($this->builders);
Expand Down
Loading
Loading