Skip to content

Conversation

@Morgy93
Copy link
Collaborator

@Morgy93 Morgy93 commented Jan 30, 2026

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 for ScopeConfigInterface with constructor injection, and updates corresponding usage in the isInspectorEnabled() method. [1] [2] [3]
  • CheckCommand.php: Injects ResourceConnection and ClientFactory via 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 the sanitizeTermValue and sanitizeAlphanumericValue methods to handle cases where preg_replace returns null, 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.

@Morgy93 Morgy93 requested a review from dermatz January 30, 2026 19:02
@Morgy93 Morgy93 enabled auto-merge (squash) January 30, 2026 19:04
@Morgy93 Morgy93 merged commit e24e138 into main Jan 30, 2026
12 checks passed
@Morgy93 Morgy93 deleted the fix-phpstan-8 branch January 30, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants