Last active
August 29, 2015 13:56
-
-
Save quickshiftin/8949119 to your computer and use it in GitHub Desktop.
The lint utility you wish `php -l` was out of the box. Lint check multiple PHP files with a single command.
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
function php_lint | |
{ | |
for arg in $(seq $#) | |
do | |
# Use find to iterate over directories recursively | |
if [ -d "${!arg}" ]; then | |
find "${!arg}" -name '*.php' -exec php -l "{}" ";" | |
# Just run normal files and symlinks through php -l individually | |
elif [ -f "${!arg}" -o -h "${!arg}" ]; then | |
php -l "${!arg}" | |
# Skip over anything else | |
else | |
echo 'Skipping bogus argument' 1>&2 | |
fi | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
find
will only lint files within a directory one at a time. Something else you might like, which I found pretty cool, would be running the directory segment throughxargs
and adding some parallelism. Take a peak at this approach.