diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml
index 15deb843c..0316e945e 100644
--- a/.github/workflows/dependabot-auto-merge.yml
+++ b/.github/workflows/dependabot-auto-merge.yml
@@ -13,7 +13,7 @@ jobs:
steps:
- name: Dependabot metadata
id: dependabot-metadata
- uses: dependabot/fetch-metadata@v2.2.0
+ uses: dependabot/fetch-metadata@v2.3.0
- name: Approve and label updates
run: |
diff --git a/.github/workflows/pre-commit-auto-update.yml b/.github/workflows/pre-commit-auto-update.yml
index 726704f50..26ad84a13 100644
--- a/.github/workflows/pre-commit-auto-update.yml
+++ b/.github/workflows/pre-commit-auto-update.yml
@@ -38,7 +38,7 @@ jobs:
with:
commit-message: Update pre-commit dependencies
labels: cleanup-no-release-required, dependencies, github_actions
- title: Update pre-commit dependencies
+ title: ⬆ Update pre-commit dependencies
body: |
```diff
${{ steps.gather-changes.outputs.changes }}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7674b80db..c3398c40b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,10 @@ backwards-incompatible changes that will affect existing usage.
+## 11.0.2 - 2025-02-18
+
+- Fix CI (PHPUnit) ([#918](https://github.com/php-curl-class/php-curl-class/pull/918))
+
## 11.0.1 - 2025-01-13
- Increase Psalm strictness ([#909](https://github.com/php-curl-class/php-curl-class/pull/909))
diff --git a/composer.json b/composer.json
index 8eb824cf5..0e7a8bbc2 100644
--- a/composer.json
+++ b/composer.json
@@ -29,7 +29,8 @@
"phpcsstandards/phpcsutils": "@alpha",
"phpstan/phpstan": "*",
"phpunit/phpunit": "*",
- "squizlabs/php_codesniffer": "*"
+ "squizlabs/php_codesniffer": "*",
+ "vimeo/psalm": ">=5.26.1"
},
"suggest": {
"ext-mbstring": "*"
diff --git a/scripts/make_release_requirements.txt b/scripts/make_release_requirements.txt
index 73dcd7ed8..133b5a34f 100644
--- a/scripts/make_release_requirements.txt
+++ b/scripts/make_release_requirements.txt
@@ -12,7 +12,7 @@ cffi==1.16.0
# pynacl
charset-normalizer==3.3.2
# via requests
-cryptography==43.0.1
+cryptography==44.0.1
# via pyjwt
deprecated==1.2.14
# via pygithub
@@ -24,7 +24,7 @@ idna==3.7
# via requests
pycparser==2.22
# via cffi
-pygithub==2.5.0
+pygithub==2.6.0
# via -r scripts/make_release_requirements.in
pyjwt[crypto]==2.8.0
# via pygithub
diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php
index d71118f1c..047391194 100644
--- a/src/Curl/Curl.php
+++ b/src/Curl/Curl.php
@@ -6,7 +6,7 @@
class Curl extends BaseCurl
{
- public const VERSION = '11.0.1';
+ public const VERSION = '11.0.2';
public const DEFAULT_TIMEOUT = 30;
public $curl = null;
@@ -328,7 +328,7 @@ public function download($url, $mixed_filename)
// Attempt to resume download only when a temporary download file exists and is not empty.
if (is_file($download_filename) && $filesize = filesize($download_filename)) {
$first_byte_position = $filesize;
- $range = $first_byte_position . '-';
+ $range = (string)$first_byte_position . '-';
$this->setRange($range);
$this->fileHandle = fopen($download_filename, 'ab');
} else {
@@ -385,7 +385,7 @@ public function fastDownload($url, $filename, $connections = 4)
}
// Divide chunk_size across the number of connections.
- $chunk_size = ceil($content_length / $connections);
+ $chunk_size = (int)ceil($content_length / $connections);
// Keep track of file name parts.
$part_file_names = [];
@@ -399,9 +399,9 @@ public function fastDownload($url, $filename, $connections = 4)
if ($part_number === $connections) {
$range_end = '';
}
- $range = $range_start . '-' . $range_end;
+ $range = (string)$range_start . '-' . (string)$range_end;
- $part_file_name = $filename . '.part' . $part_number;
+ $part_file_name = $filename . '.part' . (string)$part_number;
// Save the file name of this part.
$part_file_names[] = $part_file_name;
@@ -1294,13 +1294,13 @@ public function diagnose($return = false)
$response_headers_count = count($this->responseHeaders);
echo
- 'Request contained ' . $request_options_count . ' ' . (
+ 'Request contained ' . (string)$request_options_count . ' ' . (
$request_options_count === 1 ? 'option:' : 'options:'
) . "\n";
if ($request_options_count) {
$i = 1;
foreach ($this->options as $option => $value) {
- echo ' ' . $i . ' ';
+ echo ' ' . (string)$i . ' ';
$this->displayCurlOptionValue($option, $value);
$i += 1;
}
@@ -1308,13 +1308,13 @@ public function diagnose($return = false)
echo
'Sent an HTTP ' . $request_method . ' request to "' . $request_url . '".' . "\n" .
- 'Request contained ' . $request_headers_count . ' ' . (
+ 'Request contained ' . (string)$request_headers_count . ' ' . (
$request_headers_count === 1 ? 'header:' : 'headers:'
) . "\n";
if ($request_headers_count) {
$i = 1;
foreach ($this->requestHeaders as $key => $value) {
- echo ' ' . $i . ' ' . $key . ': ' . $value . "\n";
+ echo ' ' . (string)$i . ' ' . $key . ': ' . $value . "\n";
$i += 1;
}
}
@@ -1346,13 +1346,13 @@ public function diagnose($return = false)
}
echo
- 'Response contains ' . $response_headers_count . ' ' . (
+ 'Response contains ' . (string)$response_headers_count . ' ' . (
$response_headers_count === 1 ? 'header:' : 'headers:'
) . "\n";
if ($this->responseHeaders !== null) {
$i = 1;
foreach ($this->responseHeaders as $key => $value) {
- echo ' ' . $i . ' ' . $key . ': ' . $value . "\n";
+ echo ' ' . (string)$i . ' ' . $key . ': ' . $value . "\n";
$i += 1;
}
}
@@ -1409,12 +1409,13 @@ public function diagnose($return = false)
$messages_count = count($messages);
if ($messages_count) {
echo
- 'Found ' . $messages_count . ' ' . ($messages_count === 1 ? 'message' : 'messages') .
+ 'Found ' . (string)$messages_count . ' ' .
+ ($messages_count === 1 ? 'message' : 'messages') .
' in response:' . "\n";
$i = 1;
foreach ($messages as $message) {
- echo ' ' . $i . ' ' . $message . "\n";
+ echo ' ' . (string)$i . ' ' . $message . "\n";
$i += 1;
}
}
@@ -1713,7 +1714,7 @@ public function displayCurlOptionValue($option, $value = null)
if (is_string($value)) {
echo ' "' . $value . '"' . "\n";
} elseif (is_int($value)) {
- echo ' ' . $value;
+ echo ' ' . (string)$value;
$bit_flag_lookups = [
'CURLOPT_HTTPAUTH' => 'CURLAUTH_',
diff --git a/src/Curl/MultiCurl.php b/src/Curl/MultiCurl.php
index f6c00a8c8..d84c09bfd 100644
--- a/src/Curl/MultiCurl.php
+++ b/src/Curl/MultiCurl.php
@@ -111,7 +111,7 @@ public function addDownload($url, $mixed_filename)
// Attempt to resume download only when a temporary download file exists and is not empty.
if (is_file($download_filename) && $filesize = filesize($download_filename)) {
$first_byte_position = $filesize;
- $range = $first_byte_position . '-';
+ $range = (string)$first_byte_position . '-';
$curl->setRange($range);
$curl->fileHandle = fopen($download_filename, 'ab');
@@ -587,7 +587,7 @@ public function setRateLimit($rate_limit)
$interval_seconds = $interval * 3600;
}
- $this->rateLimit = $max_requests . '/' . $interval . $unit;
+ $this->rateLimit = (string)$max_requests . '/' . (string)$interval . $unit;
$this->rateLimitEnabled = true;
$this->maxRequests = $max_requests;
$this->interval = $interval;
diff --git a/tests/.pre-commit-config.yaml b/tests/.pre-commit-config.yaml
index c17742696..953ea36ae 100644
--- a/tests/.pre-commit-config.yaml
+++ b/tests/.pre-commit-config.yaml
@@ -12,18 +12,18 @@
# $ pre-commit autoupdate --config="tests/.pre-commit-config.yaml"
repos:
- repo: https://github.com/psf/black
- rev: 24.10.0
+ rev: 25.1.0
hooks:
- id: black
name: black
entry: black
- repo: https://github.com/pycqa/flake8
- rev: 7.1.1
+ rev: 7.1.2
hooks:
- id: flake8
args: ["--config", "tests/setup.cfg"]
- repo: https://github.com/pycqa/isort
- rev: 5.13.2
+ rev: 6.0.0
hooks:
- id: isort
name: isort
diff --git a/tests/PHPCurlClass/PHPCurlClassTest.php b/tests/PHPCurlClass/PHPCurlClassTest.php
index 857b01975..4991d646b 100644
--- a/tests/PHPCurlClass/PHPCurlClassTest.php
+++ b/tests/PHPCurlClass/PHPCurlClassTest.php
@@ -3186,24 +3186,14 @@ public function testCookieJarAfterClose()
$this->assertNotEmpty($cookies);
}
- /**
- * @requires PHPUnit < 10
- * @expectedException \PHPUnit\Framework\Error\Warning
- */
- public function testRequiredOptionCurlOptReturnTransferEmitsWarning()
- {
- $this->expectWarning(\PHPUnit\Framework\Error\Warning::class);
-
- $curl = new Curl();
- $curl->setOpt(CURLOPT_RETURNTRANSFER, false);
- }
-
/**
* @requires PHPUnit >= 10
*/
+ #[RequiresPhpunit('>= 10')]
public function testRequiredOptionCurlOptReturnTransferEmitsWarningPHPUnit10Plus()
{
set_error_handler(static function (int $errno, string $errstr): never {
+ restore_error_handler();
throw new \Exception($errstr, $errno);
}, E_USER_WARNING);
@@ -3211,8 +3201,6 @@ public function testRequiredOptionCurlOptReturnTransferEmitsWarningPHPUnit10Plus
$curl = new Curl();
$curl->setOpt(CURLOPT_RETURNTRANSFER, false);
-
- restore_error_handler();
}
public function testRequestMethodSuccessiveGetRequests()
@@ -3966,7 +3954,7 @@ public function testMock()
$curl->expects($this->once())
->method('getRawResponse')
- ->will($this->returnValue('[]'));
+ ->willReturn('[]');
$this->assertEquals('[]', $curl->getRawResponse());
}
diff --git a/tests/psalm.xml b/tests/psalm.xml
index d56152c69..c1a61e7fe 100644
--- a/tests/psalm.xml
+++ b/tests/psalm.xml
@@ -1,6 +1,7 @@
-
+
-
-
+
+
+
-
-
+
+
+
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/psalm_7.4.xml b/tests/psalm_7.4.xml
new file mode 100644
index 000000000..fc7304663
--- /dev/null
+++ b/tests/psalm_7.4.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/run.sh b/tests/run.sh
index 9b9822576..fd8240039 100755
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -2,25 +2,17 @@
set -x
+errors=()
+
if [[ "${CI}" == "true" ]]; then
composer self-update
-
- # TODO: Add "vimeo/psalm" back into composer.json under "require-dev" when
- # vimeo/psalm supports PHP 8.4 (https://github.com/vimeo/psalm/issues/11107):
- # "require-dev": {
- # "vimeo/psalm": ">=5.26.1"
- # },
- #
- # TODO: Remove this workaround that only installs vimeo/psalm on PHP < 8.4 when
- # vimeo/psalm supports PHP 8.4 (https://github.com/vimeo/psalm/issues/11107):
- if [[ $(echo "${CI_PHP_VERSION} < 8.4" | bc -l) -eq 1 ]]; then
- composer require --dev "vimeo/psalm:>=5.26.1"
- fi
-
composer install --prefer-source --no-interaction
+ if [[ "${?}" -ne 0 ]]; then
+ echo "Error: composer install failed"
+ errors+=("composer install failed")
+ fi
fi
-
# Use composer's phpunit and phpcs by adding composer bin directory to the path environment variable.
export PATH="${PWD}/vendor/bin:${PATH}"
@@ -34,8 +26,6 @@ echo "CI_PHP_FUTURE_RELEASE: ${CI_PHP_FUTURE_RELEASE}"
php -r "var_dump(phpversion());"
php -r "var_dump(curl_version());"
-errors=()
-
source "run_syntax_check.sh"
source "run_coding_standards_check.sh"
@@ -46,6 +36,8 @@ source "run_static_analysis_check_phpstan.sh"
source "run_static_analysis_check_psalm.sh"
+set +x
+
source "display_errors.inc.sh"
if [[ "${CI_PHP_FUTURE_RELEASE}" != "true" ]]; then
diff --git a/tests/run_phpunit.sh b/tests/run_phpunit.sh
index 01b8bd2b7..d30f8ff48 100755
--- a/tests/run_phpunit.sh
+++ b/tests/run_phpunit.sh
@@ -57,6 +57,14 @@ phpunit_v10_shim() {
remove_expectWarning
}
+phpunit_v11_shim() {
+ :;
+}
+
+phpunit_v12_shim() {
+ remove_expectWarning
+}
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "${SCRIPT_DIR}"
@@ -101,6 +109,12 @@ elif [[ "${phpunit_version}" == "9."* ]]; then
elif [[ "${phpunit_version}" == "10."* ]]; then
phpunit_v10_shim
phpunit_args=" --display-incomplete --display-skipped --display-deprecations --display-errors --display-notices --display-warnings --fail-on-risky ${extra_args}"
+elif [[ "${phpunit_version}" == "11."* ]]; then
+ phpunit_v11_shim
+ phpunit_args=" --display-incomplete --display-skipped --display-deprecations --display-errors --display-notices --display-warnings --fail-on-risky ${extra_args}"
+elif [[ "${phpunit_version}" == "12."* ]]; then
+ phpunit_v12_shim
+ phpunit_args=" --display-incomplete --display-skipped --display-deprecations --display-errors --display-notices --display-warnings --fail-on-risky ${extra_args}"
fi
# Run tests.
diff --git a/tests/run_static_analysis_check_psalm.sh b/tests/run_static_analysis_check_psalm.sh
index 9cfae3716..d351d4c91 100755
--- a/tests/run_static_analysis_check_psalm.sh
+++ b/tests/run_static_analysis_check_psalm.sh
@@ -10,16 +10,17 @@ pushd ..
set -x
-# TODO: Remove exclusion that skips running psalm on PHP 8.4 when psalm
-# supports PHP 8.4 (https://github.com/vimeo/psalm/issues/11107).
-if [[ $(echo "${CI_PHP_VERSION} < 8.4" | bc -l) -eq 1 ]]; then
- vendor/bin/psalm --config="tests/psalm.xml"
- if [[ "${?}" -ne 0 ]]; then
- echo "Error: psalm static analysis check failed"
- errors+=("psalm static analysis check failed")
- fi
+vendor/bin/psalm --version
+
+if [[ $(echo "${CI_PHP_VERSION} == 7.4" | bc -l) -eq 1 ]]; then
+ vendor/bin/psalm --config="tests/psalm_7.4.xml"
else
- echo "Skipped running psalm check"
+ vendor/bin/psalm --config="tests/psalm.xml"
+fi
+
+if [[ "${?}" -ne 0 ]]; then
+ echo "Error: psalm static analysis check failed"
+ errors+=("psalm static analysis check failed")
fi
popd