fix: update phpstan level to 8 and improve commands #119
+32
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request improves dependency injection usage, error handling, and input sanitization across several console commands. The main focus is on replacing direct usage of Magento's ObjectManager with constructor-injected dependencies, which enhances code testability and maintainability. Additionally, it improves validation and error reporting in theme-related commands.
Dependency Injection Improvements:
InspectorCommand.php: Replaces direct ObjectManager usage forScopeConfigInterfacewith constructor injection, and updates corresponding usage in theisInspectorEnabled()method. [1] [2] [3]CheckCommand.php: InjectsResourceConnectionandClientFactoryvia the constructor, removing ObjectManager calls in methods that require database and HTTP client access. Updates affected methods to use the injected dependencies. [1] [2] [3] [4]Input Validation and Error Handling:
BuildCommand.php: Adds a check for a missing theme path and reports an error if the path is not found, preventing further execution.WatchCommand.php: Adds error reporting if no suitable builder is found for the given theme, returning a failure status.Sanitization Enhancements:
BuildCommand.php&CleanCommand.php: Improves thesanitizeTermValueandsanitizeAlphanumericValuemethods to handle cases wherepreg_replacereturnsnull, ensuring robust input validation. [1] [2] [3] [4]Static Analysis Configuration:
phpstan.neon: Increases the PHPStan analysis level from 7 to 8, enforcing stricter static analysis.