#!/bin/bash

echo 'Printing phpcs warnings for only Changed Files';

branch_name="$1"
files=$(git --no-pager diff --name-only "$branch_name")

# Filter out files that do not exist
files=$(echo "$files" | xargs -I{} sh -c '[ -f "{}" ] && echo "{}"')

# Pass files to phpcs
vendor/bin/phpcs $files
