Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates MageForge’s PHP code to satisfy PHPStan level 9 by tightening runtime type checks around decoded JSON / CLI inputs and by adding PHPStan-specific type aliases for Hyvä compatibility scanning results.
Changes:
- Raised PHPStan config from level 8 to level 9 and adjusted code to comply.
- Added explicit
is_array/is_stringguards for JSON-decoded data and Symfony Console inputs/options. - Introduced PHPStan type aliases (
@phpstan-type,@phpstan-import-type) to better describe Hyvä scan/check result shapes.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Service/ThemeBuilder/TailwindCSS/Builder.php | Adds safe guards around decoded composer.json for theme detection. |
| src/Service/ThemeBuilder/HyvaThemes/Builder.php | Adds safe guards around decoded composer.json for Hyvä theme detection. |
| src/Service/Hyva/ModuleScanner.php | Adds PHPStan type aliases and strengthens composer.json parsing guards. |
| src/Service/Hyva/IncompatibilityDetector.php | Defines ScanIssue shape and tightens PHPStan annotations for pattern scanning. |
| src/Service/Hyva/CompatibilityChecker.php | Adds PHPStan result shapes and updates annotations for formatted/detailed output. |
| src/Model/ThemeList.php | Adds stronger typing around Magento theme list items (but currently has an unused import). |
| src/Console/Command/Theme/WatchCommand.php | Validates prompt result is a string before use. |
| src/Console/Command/Theme/TokensCommand.php | Validates CLI arg/prompt result types before use. |
| src/Console/Command/Theme/CleanCommand.php | Casts options to bool and adds PHPStan/docblock typing to reduce mixed usage. |
| src/Console/Command/Theme/BuildCommand.php | Adds PHPStan-friendly annotations/casts and minor formatting fixes. |
| src/Console/Command/System/VersionCommand.php | Adds guards for JSON-decoded version/tag fields. |
| src/Console/Command/System/CheckCommand.php | Adds stronger typing/guards for decoded JSON/config values and minor arithmetic simplification. |
| src/Console/Command/Hyva/CompatibilityCheckCommand.php | Adds PHPStan type imports and casts prompt/options to bool. |
| src/Console/Command/Dev/InspectorCommand.php | Ensures action arg is a string before strtolower. |
| src/Console/Command/AbstractCommand.php | Improves prompt return typing and refactors vendor theme resolution formatting. |
| src/Block/Inspector.php | Ensures config value is a non-empty string before returning it. |
| phpstan.neon | Bumps PHPStan analysis level to 9. |
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
Updates the codebase to satisfy stricter PHPStan analysis (level 9) by tightening runtime type checks and adding PHPStan-specific type annotations across CLI commands and Hyvä compatibility services.
Changes:
- Bump PHPStan configuration from level 8 to level 9.
- Add/adjust runtime type-guards and casts for user input, JSON decoding, and config reads to satisfy stricter static analysis.
- Introduce PHPStan type aliases/imports for Hyvä compatibility scanning and results shaping.
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Service/ThemeBuilder/TailwindCSS/Builder.php | Harden composer.json detection with array/string checks. |
| src/Service/ThemeBuilder/HyvaThemes/Builder.php | Add array/string guards to composer.json detection. |
| src/Service/Hyva/ModuleScanner.php | Add PHPStan type aliases and runtime type checks for composer/require parsing. |
| src/Service/Hyva/IncompatibilityDetector.php | Define PHPStan ScanIssue shape and tighten internal param/return typing. |
| src/Service/Hyva/CompatibilityChecker.php | Add PHPStan type aliases for results and adjust result structure typing. |
| src/Model/ThemeList.php | Add concrete Theme typing/cast for getAllThemes(). |
| src/Console/Command/Theme/WatchCommand.php | Validate prompt result is a string before using it as a theme code. |
| src/Console/Command/Theme/TokensCommand.php | Ensure CLI arg/prompt outputs are treated as nullable strings safely. |
| src/Console/Command/Theme/CleanCommand.php | Cast CLI options/args to expected types and refine return shape annotations. |
| src/Console/Command/Theme/BuildCommand.php | Add argument typing hints and minor formatting fixes. |
| src/Console/Command/System/VersionCommand.php | Add array/string guards around decoded JSON reads. |
| src/Console/Command/System/CheckCommand.php | Add type assertions/guards for decoded JSON/config reads and minor arithmetic refactor. |
| src/Console/Command/Hyva/CompatibilityCheckCommand.php | Cast prompt/options to bool and add PHPStan param typing. |
| src/Console/Command/Dev/InspectorCommand.php | Ensure action argument is string before normalizing. |
| src/Console/Command/AbstractCommand.php | Normalize prompt return typing and minor formatting tweaks in vendor-theme resolution. |
| src/Block/Inspector.php | Ensure config value is a non-empty string before returning. |
| phpstan.neon | Increase level from 8 to 9. |
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates MageForge’s codebase and PHPStan configuration to pass PHPStan level 9 by tightening runtime type checks and adding PHPStan-specific type annotations across commands and Hyvä compatibility services.
Changes:
- Bumps PHPStan strictness from level 8 to level 9 and adjusts code accordingly.
- Adds defensive type checks (e.g.,
is_array/is_string/(bool)casts) around decoded JSON, CLI input options/arguments, and prompt results. - Introduces richer PHPStan type aliases for Hyvä compatibility scanning results to improve static analysis.
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Service/ThemeBuilder/TailwindCSS/Builder.php | Makes theme detection PHPStan-safe by validating decoded composer.json structure/types. |
| src/Service/ThemeBuilder/HyvaThemes/Builder.php | Adds array/string guards in composer.json-based Hyvä detection. |
| src/Service/Hyva/ModuleScanner.php | Adds PHPStan type aliases and hardens composer.json parsing/require handling. |
| src/Service/Hyva/IncompatibilityDetector.php | Adds PHPStan ScanIssue type and tightens pattern/return annotations. |
| src/Service/Hyva/CompatibilityChecker.php | Adds PHPStan-imported types and removes overly defensive runtime checks in favor of typed structures. |
| src/Model/ThemeList.php | Narrows the documented return type of getAllThemes() (but needs correction re: array keys). |
| src/Console/Command/Theme/WatchCommand.php | Ensures prompt result is a string before using it as a theme code. |
| src/Console/Command/Theme/TokensCommand.php | Validates themeCode argument type and ensures prompt result is string-or-null. |
| src/Console/Command/Theme/CleanCommand.php | Adds casts and PHPStan annotations for arguments/options and return shapes. |
| src/Console/Command/Theme/BuildCommand.php | Adds PHPStan annotations and minor formatting tweaks. |
| src/Console/Command/System/VersionCommand.php | Hardens JSON decoding results before accessing version/tag_name. |
| src/Console/Command/System/CheckCommand.php | Adds type assertions/guards in several config-reading paths and simplifies disk size math. |
| src/Console/Command/Hyva/CompatibilityCheckCommand.php | Adds PHPStan imported types and casts CLI options/prompt results to bool. |
| src/Console/Command/Dev/InspectorCommand.php | Ensures the action argument is a string before strtolower(). |
| src/Console/Command/AbstractCommand.php | Ensures theme selection result is a string and refactors vendor theme resolution formatting. |
| src/Block/Inspector.php | Ensures config theme value is a non-empty string before returning it. |
| phpstan.neon | Increases PHPStan level to 9. |
You can also share your feedback on Copilot code review. Take the survey.
Updates the code to pass phpstan level 9