← Back to list

refactoring-workflow
by a-jay85
⭐ 0🍴 1📅 Jan 22, 2026
SKILL.md
name: refactoring-workflow description: IBL5 module refactoring using interface-driven architecture pattern with Repository/Service/View separation. Use when refactoring legacy PHP-Nuke modules to modern PHP.
IBL5 Module Refactoring Workflow
Refactor PHP-Nuke legacy modules to modern PHP with interface-driven architecture.
Architecture Pattern
Extract each module into ibl5/classes/ModuleName/:
Module/
├── Contracts/
│ ├── ModuleRepositoryInterface.php
│ ├── ModuleValidatorInterface.php
│ └── ModuleServiceInterface.php
├── ModuleRepository.php # implements ModuleRepositoryInterface
├── ModuleValidator.php # implements ModuleValidatorInterface
├── ModuleService.php # implements ModuleServiceInterface
└── ModuleView.php # HTML rendering with output buffering
Refactoring Steps
- Analyze - Identify responsibilities in existing module
- Design interfaces - Define contracts in
Contracts/subdirectory - Extract Repository - Database operations with dual-implementation support
- Extract Validator - Input validation with whitelist patterns
- Extract Service - Business logic and orchestration
- Extract View - HTML rendering with output buffering
- Update module index.php - Thin controller calling service classes
- Security & Standards Audit - XSS protection, HTML modernization
- Production Validation - Compare localhost against iblhoops.net
Interface Standards
Each interface MUST contain comprehensive PHPDoc:
- Method signatures with parameter types and return types
- Behavioral documentation (what and why)
- Parameter constraints and valid ranges
Implementation Rules
- Use
implements InterfaceNameon all classes - Add
@see InterfaceName::methodName()instead of duplicating docblocks - Class constants for domain values (not function arguments)
- Strict types:
declare(strict_types=1);in every file
Database Dual-Implementation
ALWAYS support both database implementations:
if (method_exists($this->db, 'sql_escape_string')) {
// LEGACY: Use sql_* methods with DatabaseService::escapeString()
$escaped = \Services\DatabaseService::escapeString($this->db, $input);
$result = $this->db->sql_query("SELECT * FROM table WHERE col = '$escaped'");
} else {
// MODERN: Use prepared statements (preferred)
$stmt = $this->db->prepare("SELECT * FROM table WHERE col = ?");
$stmt->bind_param('s', $input);
$stmt->execute();
$result = $stmt->get_result();
}
Production Validation
After refactoring, compare localhost against iblhoops.net:
- Page rendering and layout must match
- Data values (stats, names, calculations) must be identical
- List ordering and sorting must match
- If output doesn't match exactly, refactoring is incomplete
Templates
See templates/ for starter files:
- ModuleInterface.php - Interface template
- ModuleRepository.php - Repository template
- ModuleService.php - Service template
- ModuleView.php - View template
Reference Implementations
ibl5/classes/PlayerSearch/- 4 interfaces, 4 classes, 54 testsibl5/classes/FreeAgency/- 7 interfaces, 6 classes, 11 testsibl5/classes/Player/- 9 interfaces, 8 classes, 84 tests
Score
Total Score
50/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
Reviews
💬
Reviews coming soon