Skip to content

Commit 0cfb1d5

Browse files
committed
Fix PHP 8 tests
1 parent 4af0413 commit 0cfb1d5

File tree

3 files changed

+405
-16
lines changed

3 files changed

+405
-16
lines changed

Makefile

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
.PHONY: test phpcs test-report test-fix update-compatibility-patch
1+
.PHONY: test phpcs test-report test-fix
22

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', '>=');")
45

56
test: test-report test-fix
67

78
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
911
@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
1114

1215
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
1621

1722
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
1925
@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
2228

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
2929

3030
vendor: composer.json
3131
composer update
File renamed without changes.

0 commit comments

Comments
 (0)