Fix PHP-ALIAS-01 rule and resolve all fetch() aliasing violations

🤖 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 02:44:39 +00:00
parent 7d379b2402
commit 209dd72b03
20 changed files with 64 additions and 49 deletions

View File

@@ -103,9 +103,9 @@ class FieldAliasing_CodeQualityRule extends CodeQualityRule_Abstract
}
// Only check models - controllers are an escape hatch for custom responses
$extends = $metadata['extends'] ?? null;
$class_name = $metadata['class'] ?? null;
if ($extends !== 'Rsx_Model_Abstract') {
if (!$class_name || !\App\RSpade\Core\Manifest\Manifest::php_is_subclass_of($class_name, 'Rsx_Model_Abstract')) {
return;
}
@@ -176,20 +176,30 @@ class FieldAliasing_CodeQualityRule extends CodeQualityRule_Abstract
continue;
}
// Pattern: 'key' => ...
// Pattern: 'key' => ... (array construction) OR $data['key'] = ... (element assignment)
// We need to analyze what's on the right side
if (!preg_match("/['\"]([a-zA-Z_][a-zA-Z0-9_]*)['\"]\\s*=>/", $line, $key_match)) {
continue;
$key = null;
$value_part = null;
// Array construction: 'key' => value
if (preg_match("/['\"]([a-zA-Z_][a-zA-Z0-9_]*)['\"]\\s*=>/", $line, $key_match)) {
$key = $key_match[1];
$arrow_pos = strpos($line, '=>');
$value_part = trim(substr($line, $arrow_pos + 2));
}
// Element assignment: $data['key'] = value
elseif (preg_match("/\\$[a-zA-Z_][a-zA-Z0-9_]*\\[['\"]([a-zA-Z_][a-zA-Z0-9_]*)['\"]\\]\\s*=/", $line, $key_match)) {
$key = $key_match[1];
// Find the = that's NOT part of => or ==
if (preg_match("/\\]\\s*=(?![>=])/", $line, $eq_match, PREG_OFFSET_CAPTURE)) {
$eq_pos = $eq_match[0][1] + strlen($eq_match[0][0]) - 1;
$value_part = trim(substr($line, $eq_pos + 1));
}
}
$key = $key_match[1];
// Get the value part (everything after =>)
$arrow_pos = strpos($line, '=>');
if ($arrow_pos === false) {
if ($key === null || $value_part === null) {
continue;
}
$value_part = trim(substr($line, $arrow_pos + 2));
// Check for ternary operator
if ($this->is_ternary_expression($value_part)) {