# Run PHP auto-fixing first
if command -v composer &> /dev/null; then
  # Get list of staged PHP files
  files=$(git diff --cached --name-only --diff-filter=d | grep '\.php$' || true)
  
  if [ -n "$files" ]; then
    composer lint:fix
    # Only re-stage the files that were originally staged
    echo "$files" | xargs git add
    # Then run the check
    composer lint
  fi
else
  echo "Composer is not installed. Skipping PHP linting."
fi