Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix CI (PHPUnit) #918

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 2 composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"phpstan/phpstan": "*",
"phpunit/phpunit": "*",
"squizlabs/php_codesniffer": "*",
"vimeo/psalm": ">=5.26.1"
"vimeo/psalm": ">=5.26.1,<6.7"
},
"suggest": {
"ext-mbstring": "*"
Expand Down
27 changes: 14 additions & 13 deletions 27 src/Curl/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 = [];
Expand All @@ -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;
Expand Down Expand Up @@ -1294,27 +1294,27 @@ 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;
}
}

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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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_',
Expand Down
4 changes: 2 additions & 2 deletions 4 src/Curl/MultiCurl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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;
Expand Down
18 changes: 3 additions & 15 deletions 18 tests/PHPCurlClass/PHPCurlClassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3186,33 +3186,21 @@ 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);

$this->expectExceptionMessage('CURLOPT_RETURNTRANSFER is a required option');

$curl = new Curl();
$curl->setOpt(CURLOPT_RETURNTRANSFER, false);

restore_error_handler();
}

public function testRequestMethodSuccessiveGetRequests()
Expand Down Expand Up @@ -3966,7 +3954,7 @@ public function testMock()

$curl->expects($this->once())
->method('getRawResponse')
->will($this->returnValue('[]'));
->willReturn('[]');

$this->assertEquals('[]', $curl->getRawResponse());
}
Expand Down
1 change: 1 addition & 0 deletions 1 tests/psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<!-- TODO: Use errorLevel="1" -->
<psalm
ensureOverrideAttribute="false"
errorLevel="4"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand Down
2 changes: 2 additions & 0 deletions 2 tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,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
Expand Down
14 changes: 14 additions & 0 deletions 14 tests/run_phpunit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down Expand Up @@ -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.
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.