11#! /usr/bin/bash
22
33# Script to Test and Lint
4- # - for the repository: macocci7/php-math-integer
54# requirement:
6- # - phpenv/phpenv
5+ # - https://github.com/jdx/mise installed
76# - PHP versions defined in ../PHP_VERSIONS installed
87
9- CMD=phpenv
8+ CMD=mise
109$CMD -v & > /dev/null
1110if [ $? -ne 0 ]; then
1211 echo " command [${CMD} ] not found!"
@@ -20,46 +19,13 @@ if [ $? -ne 0 ]; then
2019 exit 1
2120fi
2221
23- test_and_lint () {
22+ switch_version () {
2423 echo " ==========================================================="
25- echo " [PHP $1 ][phpenv local $1 ]"
26- phpenv local $1
27- if [ $? -ne 0 ]; then
28- echo " Failed to switch version to $i . skipped."
29- return 1
30- fi
31- echo " -----------------------------------------------------------"
32- echo " [PHP $1 ][php -v]"
33- php -v
34- echo " -----------------------------------------------------------"
35- echo " [PHP $1 ][parallel-lint]"
36- ./vendor/bin/parallel-lint src tests examples
37- # echo "-----------------------------------------------------------"
38- # echo "[PHP $1][neon-lint]"
39- # ./vendor/nette/neon/bin/neon-lint conf
40- echo " -----------------------------------------------------------"
41- echo " [PHP $1 ][phpcs]"
42- ./vendor/bin/phpcs --ignore=vendor \
43- --standard=phpcs.xml \
44- -p \
45- -s \
46- .
47- echo " -----------------------------------------------------------"
48- echo " [PHP $1 ][phpmd]"
49- ./vendor/bin/phpmd \
50- ./src/ ./examples/ ./tests/ text \
51- phpmd.xml
52- echo " -----------------------------------------------------------"
53- echo " [PHP $1 ][phpstan]"
54- ./vendor/bin/phpstan analyze -c phpstan.neon
55- echo " -----------------------------------------------------------"
56- echo " [PHP $1 ][phpunit]"
57- ./vendor/bin/phpunit ./tests/ \
58- --color=auto
59- echo " -----------------------------------------------------------"
24+ echo " [PHP $1 ][Switching PHP version to $1 ]"
25+ mise x php@$1 -- bash bin/TestAndLintSub.sh $1 ;
6026}
6127
62- echo " [[TesAndLint .sh]]"
28+ echo " [[TestAndLint .sh]]"
6329
6430SUPPORTED_PHP_VERSIONS=PHP_VERSIONS
6531if [ ! -f $SUPPORTED_PHP_VERSIONS ]; then
@@ -74,6 +40,6 @@ if [ ! -r $SUPPORTED_PHP_VERSIONS ]; then
7440fi
7541STR_CMD=' '
7642while read version ; do
77- STR_CMD=" $STR_CMD test_and_lint $version ;"
43+ STR_CMD=" $STR_CMD switch_version $version ;"
7844done < $SUPPORTED_PHP_VERSIONS
7945eval $STR_CMD
0 commit comments