Created
June 23, 2017 05:39
-
-
Save jacks0n/56fd2d301c4faefc2eb8f10b25503869 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List all files with the wrong nameapace. | |
list_php_files_with_wrong_namespace() { | |
git ls-files --cached --modified '*.php' | while read PHP_FILE ; do | |
local EXPECTED_NAMESPACE="$( | |
echo "$PHP_FILE" | \ | |
sed -e 's/^src\///' -e 's/\//\\/g' -e 's/\.php$//' | \ | |
rev | cut -d'\' -f2- | rev | |
)" | |
local NAMESPACE="$(grep '^namespace ' "$PHP_FILE" | cut -d' ' -f2 | sed -e 's/;$//')" | |
if [[ "$NAMESPACE" != "$EXPECTED_NAMESPACE" ]] ; then | |
echo "$PHP_FILE" | |
echo "- Actual Namespace: $NAMESPACE" | |
echo "- Expected Namespace: $EXPECTED_NAMESPACE" | |
echo "\n" | |
fi | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment