Framework pull: auto-revert use statement changes before update

Class override system: .upstream file handling and restore logic
Php_Fixer: Redirect use statements to correct manifest FQCN
Fix: Only match PHP files in __find_class_fqcn_in_manifest
Complete Php_Fixer use statement redirection implementation (checkpoint 2)
WIP: Php_Fixer use statement redirection for class overrides (checkpoint)

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-12-10 07:04:05 +00:00
parent 0a479ed5a2
commit f02a04f37a
6 changed files with 307 additions and 51 deletions

View File

@@ -216,6 +216,77 @@ if [ -n "$UPSTREAM_FILES" ]; then
done
fi
# Step 3: Restore files with ONLY use statement changes
# When classes are overridden in rsx/, Php_Fixer updates use statements in system/ files
# to point to the Rsx\ namespace. These changes should be reverted before framework update.
# We only auto-revert files where ALL changes are use statement modifications.
echo " Checking for auto-fixable use statement changes..."
MODIFIED_SYSTEM_FILES=$(git diff --name-only -- . ":(exclude)rsx" 2>/dev/null | grep "\.php$" || true)
USE_STMT_REVERTED=0
if [ -n "$MODIFIED_SYSTEM_FILES" ]; then
while IFS= read -r modified_file; do
if [ -z "$modified_file" ] || [ ! -f "$modified_file" ]; then
continue
fi
# Get the diff for this file, check if ALL changed lines are use statements
# Changed lines start with + or - (excluding the diff header lines +++ and ---)
DIFF_CONTENT=$(git diff -- "$modified_file" 2>/dev/null || true)
if [ -z "$DIFF_CONTENT" ]; then
continue
fi
# Extract changed lines (+ or - at start, not +++ or ---)
# Then check if all of them are use statements or empty
ALL_USE_STATEMENTS=true
while IFS= read -r line; do
# Skip diff metadata lines
case "$line" in
"+++"*|"---"*|"@@"*|"diff "*|"index "*) continue ;;
esac
# Check lines that start with + or - (actual changes)
case "$line" in
"+"*|"-"*)
# Remove the leading +/- and trim whitespace
content="${line#[+-]}"
content=$(echo "$content" | sed 's/^[[:space:]]*//')
# Empty lines are OK
if [ -z "$content" ]; then
continue
fi
# Use statements are OK (with or without leading backslash)
if echo "$content" | grep -qE "^use[[:space:]]+(\\\\)?[A-Za-z]"; then
continue
fi
# Any other change means this file has non-use-statement modifications
ALL_USE_STATEMENTS=false
break
;;
esac
done <<< "$DIFF_CONTENT"
# If all changes were use statements, revert the file
if [ "$ALL_USE_STATEMENTS" = true ]; then
if git checkout HEAD -- "$modified_file" 2>/dev/null; then
echo " ✓ Reverted use statements: $modified_file"
USE_STMT_REVERTED=$((USE_STMT_REVERTED + 1))
fi
fi
done <<< "$MODIFIED_SYSTEM_FILES"
fi
if [ "$USE_STMT_REVERTED" -gt 0 ]; then
echo " ✓ Reverted $USE_STMT_REVERTED file(s) with use statement changes"
fi
echo " ✓ Override cleanup complete"
echo ""