Fix MODEL-REL-01 and MODEL-ENUMS-01 false positives in code quality rules

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-12-26 03:25:02 +00:00
parent 209dd72b03
commit 051ab489d0
2 changed files with 80 additions and 8 deletions

View File

@@ -106,8 +106,26 @@ class ModelRelations_CodeQualityRule extends CodeQualityRule_Abstract
$relationship_methods = [];
$complex_relationships = [];
// Track multi-line comment state
$in_multiline_comment = false;
// Parse each method to find relationships
foreach ($lines as $i => $line) {
// Track multi-line comment state
// Check for comment start (but not if it's closed on same line)
if (preg_match('#/\*#', $line) && !preg_match('#/\*.*\*/#', $line)) {
$in_multiline_comment = true;
}
// Check for comment end
if (preg_match('#\*/#', $line)) {
$in_multiline_comment = false;
continue; // Skip the closing line too
}
// Skip lines inside multi-line comments
if ($in_multiline_comment) {
continue;
}
// Look for public non-static function declarations
if (preg_match('/public\s+(?!static\s+)function\s+(\w+)\s*\(/', $line, $func_match)) {
$method_name = $func_match[1];