|
1 |
| -.PHONY: test phpcs test-report test-fix update-compatibility-patch |
| 1 | +.PHONY: test phpcs test-report test-fix |
2 | 2 |
|
3 |
| -PHP_74_OR_NEWER:=$(shell php -r "echo (int) version_compare(PHP_VERSION, '7.4', '>=');") |
| 3 | +PHP_74:=$(shell php -r "echo (int) (version_compare(PHP_VERSION, '7.4', '>=') && version_compare(PHP_VERSION, '8.0', '<'));") |
| 4 | +PHP_80:=$(shell php -r "echo (int) version_compare(PHP_VERSION, '8.0', '>=');") |
4 | 5 |
|
5 | 6 | test: test-report test-fix
|
6 | 7 |
|
7 | 8 | phpcs:
|
8 |
| - @if [ $(PHP_74_OR_NEWER) -eq 1 ]; then git apply tests/php-compatibility.patch; fi |
| 9 | + @if [ $(PHP_74) -eq 1 ]; then git apply tests/php74-compatibility.patch; fi |
| 10 | + @if [ $(PHP_80) -eq 1 ]; then git apply tests/php80-compatibility.patch; fi |
9 | 11 | @vendor/bin/phpcs src
|
10 |
| - @if [ $(PHP_74_OR_NEWER) -eq 1 ]; then git apply -R tests/php-compatibility.patch; fi |
| 12 | + @if [ $(PHP_74) -eq 1 ]; then git apply -R tests/php74-compatibility.patch; fi |
| 13 | + @if [ $(PHP_80) -eq 1 ]; then git apply -R tests/php80-compatibility.patch; fi |
11 | 14 |
|
12 | 15 | test-report: vendor
|
13 |
| - @if [ $(PHP_74_OR_NEWER) -eq 1 ]; then git apply tests/php-compatibility.patch; fi |
14 |
| - @vendor/bin/phpcs `find tests/input/* | sort` --report=summary --report-file=phpcs.log; diff -u tests/expected_report.txt phpcs.log; if [ $$? -ne 0 ]; then if [ $(PHP_74_OR_NEWER) -eq 1 ]; then git apply -R tests/php-compatibility.patch; fi; exit 1; fi |
15 |
| - @if [ $(PHP_74_OR_NEWER) -eq 1 ]; then git apply -R tests/php-compatibility.patch; fi |
| 16 | + @if [ $(PHP_74) -eq 1 ]; then git apply tests/php74-compatibility.patch; fi |
| 17 | + @if [ $(PHP_80) -eq 1 ]; then git apply tests/php80-compatibility.patch; fi |
| 18 | + @vendor/bin/phpcs `find tests/input/* | sort` --report=summary --report-file=phpcs.log; diff -u tests/expected_report.txt phpcs.log; if [ $$? -ne 0 ]; then if [ $(PHP_74) -eq 1 ]; then git apply -R tests/php74-compatibility.patch; elif [ $(PHP_80) -eq 1 ]; then git apply -R tests/php80-compatibility.patch; fi; exit 1; fi |
| 19 | + @if [ $(PHP_74) -eq 1 ]; then git apply -R tests/php74-compatibility.patch; fi |
| 20 | + @if [ $(PHP_80) -eq 1 ]; then git apply -R tests/php80-compatibility.patch; fi |
16 | 21 |
|
17 | 22 | test-fix: vendor
|
18 |
| - @if [ $(PHP_74_OR_NEWER) -eq 1 ]; then git apply tests/php-compatibility.patch; fi |
| 23 | + @if [ $(PHP_74) -eq 1 ]; then git apply tests/php74-compatibility.patch; fi |
| 24 | + @if [ $(PHP_80) -eq 1 ]; then git apply tests/php80-compatibility.patch; fi |
19 | 25 | @cp -R tests/input/ tests/input2/
|
20 |
| - @vendor/bin/phpcbf tests/input2; diff -u tests/input2 tests/fixed; if [ $$? -ne 0 ]; then rm -rf tests/input2/ && if [ $(PHP_74_OR_NEWER) -eq 1 ]; then git apply -R tests/php-compatibility.patch; fi; exit 1; fi |
21 |
| - @rm -rf tests/input2/ && if [ $(PHP_74_OR_NEWER) -eq 1 ]; then git apply -R tests/php-compatibility.patch; fi |
| 26 | + @vendor/bin/phpcbf tests/input2; diff -u tests/input2 tests/fixed; if [ $$? -ne 0 ]; then rm -rf tests/input2/ && if [ $(PHP_74) -eq 1 ]; then git apply -R tests/php74-compatibility.patch; elif [ $(PHP_80) -eq 1 ]; then git apply -R tests/php80-compatibility.patch; fi; exit 1; fi |
| 27 | + @rm -rf tests/input2/ && if [ $(PHP_74) -eq 1 ]; then git apply -R tests/php74-compatibility.patch; elif [ $(PHP_80) -eq 1 ]; then git apply -R tests/php80-compatibility.patch; fi |
22 | 28 |
|
23 |
| -update-compatibility-patch: |
24 |
| - @git apply tests/php-compatibility.patch |
25 |
| - @printf "Please open your editor and apply your changes\n" |
26 |
| - @until [ "$${compatibility_resolved}" == "y" ]; do read -p "Have finished your changes (y|n)? " compatibility_resolved; done && compatibility_resolved= |
27 |
| - @git diff -- tests/expected_report.txt tests/fixed > .tmp-patch && mv .tmp-patch tests/php-compatibility.patch && git apply -R tests/php-compatibility.patch |
28 |
| - @git commit -m 'Update compatibility patch' tests/php-compatibility.patch |
29 | 29 |
|
30 | 30 | vendor: composer.json
|
31 | 31 | composer update
|
|
0 commit comments