Skip to content

Commit 31a65e2

Browse files
committed
Remove void return type when running tests on PHP 7.0
The void return type was implemented in PHP 7.1 and PHP 7.0 treats the void return type as a class name. Errors: 1) CurlTest\CurlTest::testExtensionsLoaded TypeError: Return value of CurlTest\CurlTest::setUp() must be an instance of CurlTest\void, none returned /home/runner/work/php-curl-class/php-curl-class/tests/PHPCurlClass/PHPCurlClassTest.php:18 2) CurlTest\CurlTest::testCaseInsensitiveArrayGet TypeError: Return value of CurlTest\CurlTest::setUp() must be an instance of CurlTest\void, none returned /home/runner/work/php-curl-class/php-curl-class/tests/PHPCurlClass/PHPCurlClassTest.php:18 3) CurlTest\CurlTest::testCaseInsensitiveArraySet TypeError: Return value of CurlTest\CurlTest::setUp() must be an instance of CurlTest\void, none returned /home/runner/work/php-curl-class/php-curl-class/tests/PHPCurlClass/PHPCurlClassTest.php:18 [...]
1 parent 860645c commit 31a65e2

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

tests/ci.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ phpunit_v8_1_shim() {
2424
remove_expectWarning
2525
}
2626

27+
php_v7_0_shim() {
28+
# -protected function setUp(): void
29+
# +protected function setUp()
30+
find='protected function setUp(): void'
31+
replace='protected function setUp()'
32+
sed -i'' -e"s/${find}/${replace}/" "./PHPCurlClass/PHP"*
33+
}
34+
2735
set -x
2836

2937
composer self-update
@@ -76,6 +84,10 @@ elif [[ "${phpunit_version}" == "8.1."* ]]; then
7684
phpunit_v8_1_shim
7785
fi
7886

87+
if [[ "${CI_PHP_VERSION}" == "7.0" ]]; then
88+
php_v7_0_shim
89+
fi
90+
7991
# Run tests.
8092
"${phpunit_to_use}" --version
8193
"${phpunit_to_use}" \

tests/run.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ phpunit_v8_1_shim() {
2424
remove_expectWarning
2525
}
2626

27+
php_v7_0_shim() {
28+
# -protected function setUp(): void
29+
# +protected function setUp()
30+
find='protected function setUp(): void'
31+
replace='protected function setUp()'
32+
sed -i'' -e"s/${find}/${replace}/" "./PHPCurlClass/PHP"*
33+
}
34+
2735
set -x
2836

2937
# Use composer's phpunit and phpcs by adding composer bin directory to the path environment variable.
@@ -73,6 +81,10 @@ elif [[ "${phpunit_version}" == "8.1."* ]]; then
7381
phpunit_v8_1_shim
7482
fi
7583

84+
if [[ "${CI_PHP_VERSION}" == "7.0" ]]; then
85+
php_v7_0_shim
86+
fi
87+
7688
# Run tests.
7789
extra_args="${@}"
7890
"${phpunit_to_use}" --version

0 commit comments

Comments
 (0)