The team parallelalready does what you want: it goes out of 0 if all jobs complete 0, and it goes out of non-zero if any one job goes out of non-zero. paralleloutput parameters are configurable, see section for details EXIT STATUS man parallel.
script || echo , , - ( bash 4.4.7 ubuntu):
#!/bin/bash
php_lint_file()
{
local php_file="$1"
php -l "$php_file" &> /dev/null
if [ "$?" -ne 0 ]
then
echo -e "[FAIL] $php_file"
return 1
fi
}
export -f php_lint_file
find . -path ./vendor -prune -o -name '*.php' | parallel -j 4 php_lint_file {}
if [ "$?" -ne 0 ]
then
exit 1
fi