Skip to content

fix(phpcs): refactor environment variable handling in commands#135

Merged
Morgy93 merged 5 commits intomainfrom
fix-phpcs-1
Feb 14, 2026
Merged

fix(phpcs): refactor environment variable handling in commands#135
Morgy93 merged 5 commits intomainfrom
fix-phpcs-1

Conversation

@Morgy93
Copy link
Copy Markdown
Collaborator

@Morgy93 Morgy93 commented Feb 14, 2026

This pull request refactors environment variable handling across several console command classes to centralize and secure the logic in the AbstractCommand base class. The main improvements include removing duplicated environment management code from child classes and enhancing the safety and consistency of environment variable access, sanitization, and mutation. Additionally, some minor formatting changes improve code readability.

Centralization and Security of Environment Variable Handling:

  • Refactored environment variable logic to AbstractCommand:

    • All logic for getting, setting, sanitizing, and caching environment variables has been moved to AbstractCommand, with improved validation and sanitization routines. Methods such as getEnvVar, setEnvVar, and related helpers are now only present and maintained in the base class. (src/Console/Command/AbstractCommand.php [1] [2] [3] [4]
    • Methods for managing the prompt environment (setPromptEnvironment, resetPromptEnvironment) and detecting interactive terminals (isInteractiveTerminal) are now protected in the base class for reuse. (src/Console/Command/AbstractCommand.php [1] [2] [3]
  • Removed redundant code from child command classes:

    • Deleted all per-class environment variable storage, caching, and helper methods from BuildCommand, CleanCommand, and CompatibilityCheckCommand, relying on the base class implementation instead. (src/Console/Command/Theme/BuildCommand.php [1] [2]; src/Console/Command/Theme/CleanCommand.php [3]; src/Console/Command/Hyva/CompatibilityCheckCommand.php [4] [5]

Code Quality and Readability Improvements:

  • Improved output formatting for theme build progress:
    • Enhanced the formatting of progress messages in the theme build process for better readability. (src/Console/Command/Theme/BuildCommand.php [1] [2]

These changes make environment variable management more secure and maintainable, reduce code duplication, and improve the clarity of command output.

@Morgy93 Morgy93 requested a review from Copilot February 14, 2026 07:52
@Morgy93 Morgy93 changed the title feat: refactor environment variable handling in commands fix: refactor environment variable handling in commands Feb 14, 2026
@Morgy93 Morgy93 changed the title fix: refactor environment variable handling in commands fix(phpcs): refactor environment variable handling in commands Feb 14, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request refactors environment variable handling by consolidating duplicated code from three child command classes (BuildCommand, CleanCommand, CompatibilityCheckCommand) into the AbstractCommand base class. The changes aim to improve code maintainability, enhance security through better sanitization, and eliminate code duplication.

Changes:

  • Centralized environment variable management (get, set, sanitize, cache) in AbstractCommand with enhanced validation and sanitization routines
  • Removed duplicated environment variable code from BuildCommand, CleanCommand, and CompatibilityCheckCommand
  • Improved code formatting for multi-line method signatures and sprintf calls in BuildCommand and CleanCommand

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
src/Console/Command/AbstractCommand.php Added comprehensive environment variable handling methods with sanitization; changed visibility of prompt-related methods to protected for child class access
src/Console/Command/Theme/BuildCommand.php Removed duplicated environment variable code; improved formatting of multi-line sprintf calls
src/Console/Command/Theme/CleanCommand.php Removed duplicated environment variable code; reformatted displayMultiThemeSummary method signature
src/Console/Command/Hyva/CompatibilityCheckCommand.php Removed duplicated environment variable and prompt management code

Comment thread src/Console/Command/Hyva/CompatibilityCheckCommand.php Outdated
Comment thread src/Console/Command/AbstractCommand.php
Comment thread src/Console/Command/AbstractCommand.php Outdated
Comment thread src/Console/Command/Theme/CleanCommand.php
Comment thread src/Console/Command/AbstractCommand.php
Comment thread src/Console/Command/AbstractCommand.php
Copilot AI review requested due to automatic review settings February 14, 2026 09:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread src/Console/Command/AbstractCommand.php
@Morgy93 Morgy93 merged commit 9c01ce5 into main Feb 14, 2026
18 checks passed
@Morgy93 Morgy93 deleted the fix-phpcs-1 branch February 14, 2026 09: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.

2 participants