This document contains issue templates for major initiatives identified in the codebase review. Copy these into GitHub issues.
Labels: enhancement, code-quality, good-first-issue
Milestone: 2025
Assignee: TBD
Add return type declarations and parameter type hints throughout the codebase to improve code quality, IDE support, and reduce runtime errors.
Most methods lack return type declarations:
public function getMODX()
{
// ...
}All methods should have proper type declarations:
public function getMODX(): ?\MODX\Revolution\modX
{
// ...
}src/Application.php- All methodssrc/Command/BaseCmd.php- All methodssrc/Command/ProcessorCmd.php- All methods- All command classes in
src/Command/ - All configuration classes in
src/Configuration/ - API classes in
src/API/
- Better IDE autocompletion and inline documentation
- Reduced runtime type errors
- Improved code maintainability
- Better static analysis support (PHPStan/Psalm)
Phase 1: Core classes (1 week)
- Application.php
- BaseCmd.php
- ProcessorCmd.php
- ListProcessor.php
Phase 2: Command classes (1 week)
- All commands in src/Command/
Phase 3: Supporting classes (1 week)
- Configuration classes
- API classes
- Formatters, SSH, Alias classes
- All public methods have return type declarations
- All protected methods have return type declarations
- Parameters have type hints where applicable
- PHPDoc blocks updated to match type declarations
- All tests pass
- No breaking changes to public API
2-3 weeks
Labels: enhancement, code-quality, tooling
Milestone: 2025
Assignee: TBD
Add PHPStan for static analysis to catch bugs before runtime and improve code quality.
No static analysis tool configured. Potential type errors and bugs go undetected until runtime.
PHPStan configured and running at level 5-6, integrated into CI/CD pipeline.
-
Add PHPStan to composer.json dev dependencies
composer require --dev phpstan/phpstan
-
Create
phpstan.neonconfigurationparameters: level: 5 paths: - src excludePaths: - src/Xdom.php
-
Add composer scripts
"scripts": { "analyse": "phpstan analyse", "analyse:baseline": "phpstan analyse --generate-baseline" }
-
Fix identified issues at level 5
-
Gradually increase to level 6+
-
Add to CI/CD pipeline
- PHPStan installed and configured
- Running at minimum level 5
- All identified issues at level 5 fixed
- Composer script added for easy execution
- Documentation updated
- CI/CD integration (if applicable)
1 week
Labels: enhancement, refactoring, maintainability
Milestone: 2025
Assignee: TBD
Move hardcoded field mappings from ProcessorCmd to a centralized configuration system for better maintainability and extensibility.
Field mappings are hardcoded in ProcessorCmd::prePopulateFromExisting() (lines 187-207):
$defaultMappings = array(
'modChunk' => array('name' => 'name', 'description' => 'description', ...),
'modTemplate' => array('templatename' => 'templatename', ...),
// ...
);- Hard to maintain
- Cannot be customized per instance
- Not extensible for custom MODX objects
- Mixed concerns (logic + data)
Field mappings should be:
- Stored in configuration files (JSON/YAML)
- Loadable from instance-specific configs
- Extensible for custom objects
- Overridable in custom commands
- Create
src/Configuration/FieldMappings.phpclass - Create
config/field-mappings.jsonwith default mappings - Support instance-specific overrides in
.modx/field-mappings.json - Update
ProcessorCmdto use configuration - Add documentation for custom field mappings
config/
└── field-mappings.json # Default mappings
~/.modx/
└── field-mappings.json # User overrides
project/
└── modx-cli.yml
└── field_mappings: # Project-specific
- FieldMappings configuration class created
- Default mappings in JSON/YAML file
- Support for instance-specific overrides
- ProcessorCmd refactored to use configuration
- Backward compatibility maintained
- Documentation added
- Tests updated
1-2 weeks
Labels: enhancement, architecture, documentation
Milestone: Q2 2025
Assignee: TBD
Create a central registry for command metadata to enable better organization, documentation generation, and command discovery.
Command metadata is scattered across individual command classes with no central registry.
Centralized metadata registry supporting:
- Command categories and tags
- Version requirements
- Related commands
- Auto-generated documentation
- Command aliases
-
Command Discovery: Find all commands in a category
modx list --category=resource
-
Auto-Documentation: Generate reference docs
modx docs:generate
-
Command Aliases: Support shortcuts
modx r:l # Alias for resource:list
- Create
src/Registry/CommandMetadata.php - Create
src/Registry/MetadataRegistry.php - Add metadata to existing commands via attributes or annotations
- Implement registry loading and querying
- Update
listcommand to use metadata - Create documentation generation command
#[CommandMetadata(
category: 'resource',
tags: ['content', 'crud'],
minModxVersion: '3.0.0',
aliases: ['r:l']
)]
class GetList extends ListProcessor
{
// ...
}- CommandMetadata class created
- MetadataRegistry implemented
- Metadata added to core commands
- list command enhanced with filtering
- Documentation generation working
- Tests added
2 weeks
Labels: enhancement, maintainability, i18n-prep
Milestone: Q1 2025
Assignee: TBD
Centralize error messages to improve consistency and prepare for future internationalization.
Error messages are hardcoded throughout command classes:
$this->error('Something went wrong while executing the processor');
$this->error('Unable to init the command!');- Inconsistent messaging
- Hard to translate
- Difficult to maintain
- Duplication across commands
Centralized, templated error messages:
$this->error(ErrorMessages::PROCESSOR_FAILED);
$this->error(ErrorMessages::format('RESOURCE_NOT_FOUND', ['id' => $id]));- Create
src/Messages/ErrorMessages.php - Create
src/Messages/MessageFormatter.phpfor templating - Define common error messages as constants
- Refactor commands to use centralized messages
- Support message parameters/templating
namespace MODX\CLI\Messages;
class ErrorMessages
{
const PROCESSOR_FAILED = 'processor_failed';
const RESOURCE_NOT_FOUND = 'resource_not_found';
const COMMAND_INIT_FAILED = 'command_init_failed';
private static $messages = [
'processor_failed' => 'Something went wrong while executing the processor',
'resource_not_found' => 'Resource with ID {id} not found',
'command_init_failed' => 'Unable to initialize the command',
];
public static function get(string $key): string
{
return self::$messages[$key] ?? $key;
}
public static function format(string $key, array $params): string
{
$message = self::get($key);
foreach ($params as $k => $v) {
$message = str_replace("{{$k}}", $v, $message);
}
return $message;
}
}- ErrorMessages class created
- MessageFormatter implemented
- All common errors centralized
- Commands refactored to use centralized messages
- Support for message templating
- Documentation added
- Tests updated
3-5 days
Labels: bug, enhancement, cross-platform
Milestone: Q1 2025
Assignee: TBD
Add proper support for Windows configuration paths to make MODX CLI fully cross-platform.
Configuration path detection may not work correctly on Windows systems.
Proper configuration path resolution on Windows:
C:\Users\{username}\.modx\for user config- Project-relative paths working correctly
- Path separator handling
- Research Windows config path conventions
- Update
src/Configuration/Base.php::getConfigPath() - Add Windows-specific path handling
- Test on Windows environment
- Update installation documentation
- Linux/Mac:
~/.modx/ - Windows:
%USERPROFILE%\.modx\or%APPDATA%\modx-cli\
src/Configuration/Base.php
- Windows config path properly detected
- Path separators handled correctly
- Tests pass on Windows
- Documentation updated for Windows users
- Cross-platform CI tests added (if applicable)
2-3 days
Labels: enhancement, feature, logging
Milestone: Q2 2025
Assignee: TBD
Implement a comprehensive logging system with PSR-3 interface, log levels, rotation, and file output.
Limited logging capabilities, mostly console output.
Full-featured logging system:
- PSR-3 compliant
- Log levels (DEBUG, INFO, WARNING, ERROR)
- File and console output
- Log rotation
- Configurable verbosity
-
Log Levels
modx resource:list --log-level=debug
-
File Logging
modx resource:list --log-file=operations.log
-
Verbosity Control
modx resource:list -v # Verbose modx resource:list -vv # Very verbose modx resource:list -q # Quiet
- Install PSR-3 logger (Monolog)
- Create
src/Logging/Logger.phpwrapper - Add global verbosity options to Application
- Integrate with BaseCmd
- Add log file configuration
- Implement log rotation
- PSR-3 logger integrated
- Log levels implemented
- File logging working
- Verbosity flags functional
- Log rotation configured
- Documentation added
- Tests added
1-2 weeks
Labels: enhancement, modernization, breaking-change
Milestone: Q2-Q3 2025
Assignee: TBD
Upgrade minimum PHP version from 7.4 to 8.0 or 8.1 to leverage modern PHP features.
Minimum PHP 7.4 requirement limits use of modern features.
- Named arguments
- Constructor property promotion
- Union types
- Match expressions
- Nullsafe operator
- Better performance
- Better type system
Phase 1: Preparation
- Add PHP 8.0 to test matrix
- Fix any PHP 8.x compatibility issues
- Update all dependencies for PHP 8.x
Phase 2: PHP 8.0 Features
- Use constructor property promotion
- Replace
strposwithstr_contains,str_starts_with - Use named arguments where beneficial
- Add union types
Phase 3: PHP 8.1+ Features (if moving to 8.1)
- Use enums for constants
- Implement readonly properties
- Use
neverreturn type - First-class callable syntax
- Update
composer.json:"php": ">=8.0" - May require MODX 3.x update
- User systems must have PHP 8.0+
Need to create comprehensive guide for users including:
- PHP upgrade instructions
- Compatibility checks
- Fallback options
- Minimum PHP version updated
- All PHP 8.x features utilized appropriately
- All tests pass on PHP 8.x
- Dependencies updated
- Migration guide created
- CHANGELOG updated
- Major version bump
4-6 weeks
Labels: enhancement, feature, architecture
Milestone: Q3 2025
Assignee: TBD
Design and implement a plugin architecture for third-party extensibility.
Extensions must be added via composer or manual file inclusion. No standardized plugin system.
Full plugin system supporting:
- Plugin discovery and loading
- Plugin lifecycle hooks
- Plugin management commands
- Plugin marketplace integration
-
Install Plugin
modx plugin:install vendor/plugin-name
-
List Plugins
modx plugin:list
-
Enable/Disable
modx plugin:enable plugin-name modx plugin:disable plugin-name
plugins/
└── vendor/
└── plugin-name/
├── plugin.json # Metadata
├── src/
│ └── Plugin.php # Entry point
└── commands/ # Plugin commands
- Design plugin interface and lifecycle
- Create plugin discovery mechanism
- Implement plugin loader
- Add plugin management commands
- Create plugin development guide
- Build example plugins
- Plugin interface defined
- Plugin discovery working
- Plugin lifecycle implemented
- Management commands created
- Documentation complete
- Example plugins created
- Tests added
4-6 weeks
Labels: enhancement, feature, performance
Milestone: Q3 2025
Assignee: TBD
Add support for streaming output for long-running commands with progress bars and real-time updates.
Commands wait until completion before showing output, making long operations appear hung.
Real-time progress feedback:
- Progress bars for operations
- Streaming output for logs
- Async command execution
- Cancelable operations
-
Package Installation
Installing package... [==============> ] 65% - Copying files... -
Cache Clearing
Clearing cache... ✓ Cleared resource cache (120 items) ✓ Cleared template cache (45 items) ⏳ Clearing db cache... -
Resource Crawling
Crawling resources... [====================] 100% - 150/150 resources
- Add Symfony ProgressBar component
- Implement streaming output handler
- Add progress tracking to long operations
- Support async execution
- Add cancellation handling (Ctrl+C)
- Progress bars implemented
- Streaming output working
- Async execution supported
- Graceful cancellation
- Applied to long-running commands
- Documentation added
- Tests added
2-3 weeks
- ✅ Configure PHP_CodeSniffer
- ✅ Review and prioritize TODOs
- ✅ Create GitHub issues
- #1: Add PHP Type Declarations
- #2: Add Static Analysis (PHPStan)
- #3: Centralize Field Mappings
- #5: Centralize Error Messages
- #6: Windows Configuration Path Support
- #4: Command Metadata Registry
- #7: Enhanced Logging System
- #8: PHP 8.x Upgrade (Preparation)
- #8: PHP 8.x Upgrade (Implementation)
- #9: Plugin Architecture
- #10: Command Output Streaming
- Each issue should be created in GitHub with appropriate labels and milestones
- Assign to team members based on expertise and availability
- Link related issues using "Related to #X" or "Blocks #X"
- Update this document as issues are created with issue numbers