I am trying to use the PHPCompatibility standard for PHP CodeSniffer to test a specific set of files.
I'm currently using find
to do this.
find ./path1 ./path2 ./path3 ./path4 \
-type f \
-name '*.php' \
-not -path './path4/dontwantthis/*' \
-exec ./vendor/bin/phpcs \
--standard=PHPCompatibility --runtime-set testVersion 5.6 {} \;
However, this is really slow and inefficient because the startup for the script runs for every single file.
The phpcs script takes in a path like ./vendor/bin/phpcs --standard=PHPCompatibility --runtime-set testVersion 5.6 <path-of-your-php-files>
and I'd like to find a way to replicate the find
stuff with a globbing pattern in place of the <path-of-your-php-files>
One of the major problems I was having was including ./path4/*.php
while also excluding ./path4/dontwantthis/*
End your -exec
option with +
instead of \;
. That tells find
to run the command once with all the filenames, rather than separately for each filename.
find ./path1 ./path2 ./path3 ./path4 \
-type f \
-name '*.php' \
-not -path './path4/dontwantthis/*' \
-exec ./vendor/bin/phpcs \
--standard=PHPCompatibility --runtime-set testVersion 5.6 {} +