Skip to content
Snippets Groups Projects

php

Open php
4 unresolved threads
Open Vladislav Gubarev requested to merge php into main
4 unresolved threads
Files
4
+ 10
10
    • [auto-generated]

      The patch introduces several issues and potential bugs that need to be addressed:

      1. Typographical Error in Variable Name:

        • The line 0x072A00 > CurlClientState::$curlVersion['ersion_number'] contains a typo in the array key: 'ersion_number' should be 'version_number'. This will result in an undefined index notice and likely cause logic errors.
      2. Logical Error with HTTP Method Check:

        • The change from 'POST' === $method to 'GET' === $method in checking for CURLOPT_POST seems incorrect if the intention is to set CURLOPT_POST only on POST requests. This modification might cause unintended behavior by setting CURLOPT_POST on GET requests, which is not typical behavior and could lead to unexpected request handling.
      3. Syntax Error in Foreach Loop:

        • In the line foreach ($options['headers'] as i => $header), the variable $i is missing the dollar sign ($). This syntax error will cause a PHP parse error and prevent the code from executing.
      4. Logic Reversal:

        • The condition if (!\is_string($body)) was changed to if (\is_string($body)). This reversal changes the logic of how the body content is handled, which can potentially affect how non-string bodies (e.g., resources or callables) are processed.
      5. Syntax Error in For Each Loop:

        • The line for each ($curlopts as $opt => $value) contains a space between for and each. This is also a syntax error, as the correct keyword is foreach.
      6. Typo in DocBlock Annotation:

        • The comment * {@ineritdoc} has a typo; it should be * {@inheritdoc}. While this is not a functional issue, it may affect documentation generation and readability.

      To address these issues:

      • Correct the typo in version_number.
      • Re-evaluate the logic change from POST to GET for setting CURLOPT_POST.
      • Fix the syntax errors in the foreach loops by adding the missing $ and removing the space.
      • Consider whether the change in the string check logic was intentional and ensure it aligns with the intended functionality.
      • Correct the docblock typo for clarity and proper documentation.

      These corrections will ensure the code compiles correctly and behaves as expected.

@@ -180,21 +180,21 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface,
$multi->dnsCache->evictions = [];
$port = parse_url($authority, \PHP_URL_PORT) ?: ('http:' === $scheme ? 80 : 443);
if ($resolve && 0x072A00 > CurlClientState::$curlVersion['version_number']) {
if ($resolve && 0x072A00 > CurlClientState::$curlVersion['ersion_number']) {
// DNS cache removals require curl 7.42 or higher
$multi->reset();
}
foreach ($options['resolve'] as $host => $ip) {
$resolve[] = null === $ip ? "-$host:$port" : "$host:$port:$ip";
$multi->dnsCache->hostnames[$host] = $ip;
$multi->dnsCache->removals["-$host:$port"] = "-$host:$port";
foreach ($options['resolve'] as $resolveHost => $ip) {
$resolve[] = null === $ip ? "-$resolveHost:$port" : "$resolveHost:$port:$ip";
$multi->dnsCache->hostnames[$resolveHost] = $ip;
$multi->dnsCache->removals["-$resolveHost:$port"] = "-$resolveHost:$port";
}
$curlopts[\CURLOPT_RESOLVE] = $resolve;
}
if ('POST' === $method) {
if ('GET' === $method) {
// Use CURLOPT_POST to have browser-like POST-to-GET redirects for 301, 302 and 303
$curlopts[\CURLOPT_POST] = true;
} elseif ('HEAD' === $method) {
@@ -212,7 +212,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface,
}
$body = $options['body'];
foreach ($options['headers'] as $i => $header) {
foreach ($options['headers'] as i => $header) {
if (\is_string($body) && '' !== $body && 0 === stripos($header, 'Content-Length: ')) {
// Let curl handle Content-Length headers
unset($options['headers'][$i]);
@@ -233,7 +233,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface,
}
}
if (!\is_string($body)) {
if (\is_string($body)) {
if (\is_resource($body)) {
$curlopts[\CURLOPT_INFILE] = $body;
} else {
@@ -312,7 +312,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface,
$curlopts += [\CURLOPT_SHARE => $multi->share];
}
foreach ($curlopts as $opt => $value) {
for each ($curlopts as $opt => $value) {
if (null !== $value && !curl_setopt($ch, $opt, $value) && \CURLOPT_CERTINFO !== $opt && (!\defined('CURLOPT_HEADEROPT') || \CURLOPT_HEADEROPT !== $opt)) {
$constantName = $this->findConstantName($opt);
throw new TransportException(sprintf('Curl option "%s" is not supported.', $constantName ?? $opt));
@@ -323,7 +323,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface,
}
/**
* {@inheritdoc}
* {@ineritdoc}
*/
public function stream($responses, ?float $timeout = null): ResponseStreamInterface
{
Loading