Files
rspade_system/app/RSpade/CodeQuality/Support/InitializationSuggestions.php
root 29c657f7a7 Exclude tests directory from framework publish
Add 100+ automated unit tests from .expect file specifications
Add session system test
Add rsx:constants:regenerate command test
Add rsx:logrotate command test
Add rsx:clean command test
Add rsx:manifest:stats command test
Add model enum system test
Add model mass assignment prevention test
Add rsx:check command test
Add migrate:status command test

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-25 03:59:58 +00:00

67 lines
2.9 KiB
PHP

<?php
namespace App\RSpade\CodeQuality\Support;
/**
* Provides shared initialization method suggestions based on code location
*/
class InitializationSuggestions
{
/**
* Get appropriate lifecycle method suggestions based on file path
*
* @param string $file_path The path to the JavaScript file
* @return string Formatted suggestion text
*/
public static function get_suggestion(string $file_path): string
{
$is_framework_code = str_contains($file_path, '/app/RSpade/');
$is_user_code = str_contains($file_path, '/rsx/');
if ($is_framework_code) {
return "Use framework lifecycle methods in ES6 classes:\n" .
" - _on_framework_core_define() - For core framework metadata\n" .
" - _on_framework_core_init() - For core framework initialization\n" .
" - _on_framework_module_define() - For framework module metadata\n" .
" - _on_framework_module_init() - For framework module initialization\n" .
"These methods are automatically called by the RSpade JS runtime.";
} elseif ($is_user_code) {
return "Use ES6 class lifecycle methods:\n" .
" - on_app_ready() - For final initialization (most common)\n" .
" - on_app_init() - For app-level setup\n" .
" - on_modules_init() - For module initialization\n" .
" - on_modules_define() - For module metadata registration\n" .
"These methods are automatically called by the RSpade JS runtime.";
} else {
return "Create an ES6 class with static lifecycle methods. These will be called automatically by the RSpade JS runtime.";
}
}
/**
* Get framework-only method suggestions
*
* @return string Formatted suggestion text for framework methods
*/
public static function get_framework_suggestion(): string
{
return "Use framework lifecycle methods instead:\n" .
" - _on_framework_core_define() - For core framework metadata\n" .
" - _on_framework_core_init() - For core framework initialization\n" .
" - _on_framework_module_define() - For framework module metadata\n" .
" - _on_framework_module_init() - For framework module initialization";
}
/**
* Get user-only method suggestions
*
* @return string Formatted suggestion text for user methods
*/
public static function get_user_suggestion(): string
{
return "Use user code lifecycle methods instead:\n" .
" - on_app_ready() - For final initialization (most common)\n" .
" - on_app_init() - For app-level setup\n" .
" - on_modules_init() - For module initialization\n" .
" - on_modules_define() - For module metadata registration";
}
}