Completed
Push — master ( 8bc9d2...ec70be )
by Márk
01:58
created

src/Exception/BadResponseException.php (1 issue)

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
namespace GuzzleHttp\Exception;
3
4
use Psr\Http\Message\RequestInterface;
5
use Psr\Http\Message\ResponseInterface;
6
7
/**
8
 * Exception when an HTTP error occurs (4xx or 5xx error)
9
 */
10
class BadResponseException extends RequestException
11
{
12
    public function __construct(
13
        $message,
14
        RequestInterface $request,
15
        ResponseInterface $response = null,
16
        \Exception $previous = null,
17
        array $handlerContext = []
18
    ) {
19
        if (null === $response) {
20
            @trigger_error(
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
21
                'Instantiating the ' . __CLASS__ . ' class without a Response is deprecated since version 6.3 and will be removed in 7.0.',
22
                E_USER_DEPRECATED
23
            );
24
        }
25
        parent::__construct($message, $request, $response, $previous, $handlerContext);
26
    }
27
}
28