forked from ateli-development/actions-php-lint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
40 lines (30 loc) · 882 Bytes
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
set -e
echo " ************** MODIFIED FILES"
printf ${MODIFIED_FILES}
echo " ******************************"
PHP_FULL_VERSION=$(php -r 'echo phpversion();')
echo "## Running PHP Syntax Checker (lint) on ${DIR_TO_SCAN}"
echo "PHP Version : ${PHP_FULL_VERSION}"
ERROR=0
paths=(${MODIFIED_FILES//\n / })
for i in "${!paths[@]}"
do
if [[ ! ${paths[i]} =~ ^(.+)\.(php|phtml)$ ]] ; then
echo "skip: ${paths[i]} (this is not php)"
continue
fi
if [[ ${paths[i]} =~ ^((lib\/phpseclib\/)|(lib\/Zend)|(\/lib\/PEAR)|(\.phpstorm\.meta\.php)).* ]] ; then
echo "skip: ${paths[i]} (this is lib)"
continue
fi
if [ ! -f ${paths[i]} ] # file not exist
then
continue
fi
if ! php -d error_reporting="E_ALL & ~E_DEPRECATED" -l "${paths[i]}" # checking php syntax
then
ERROR=1
fi
done
exit "${ERROR}"