Completed
Push — master ( 955d05...19c28e )
by David
03:37
created

src/EmulatedHttpAsyncClient.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Http\Client\Common;
4
5
use Http\Client\HttpAsyncClient;
6
use Http\Client\HttpClient;
7
use Psr\Http\Client\ClientInterface;
8
9
/**
10
 * Emulates an async HTTP client.
11
 *
12
 * This should be replaced by an anonymous class in PHP 7.
13
 *
14
 * @author Márk Sági-Kazár <[email protected]>
15
 */
16
class EmulatedHttpAsyncClient implements HttpClient, HttpAsyncClient
17
{
18
    use HttpAsyncClientEmulator;
19
    use HttpClientDecorator;
20
21
    /**
22
     * @param HttpClient|ClientInterface $httpClient
23
     */
24 35
    public function __construct($httpClient)
25
    {
26 35
        if (!($httpClient instanceof HttpClient) && !($httpClient instanceof ClientInterface)) {
0 ignored issues
show
The class Psr\Http\Client\ClientInterface does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
27
            throw new \LogicException('Client must be an instance of Http\\Client\\HttpClient or Psr\\Http\\Client\\ClientInterface');
28
        }
29
30 35
        $this->httpClient = $httpClient;
31 35
    }
32
}
33