PanovAlexey /
laravel-yandex-speller-package
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace CodeblogPro\YandexSpeller\Application\Services\YandexSpeller\Resolvers; |
||||
| 4 | |||||
| 5 | class CurlRequestContentResolver |
||||
| 6 | { |
||||
| 7 | /** |
||||
| 8 | * @param string $url |
||||
| 9 | * @param array $postData |
||||
| 10 | * @param array $optionsList |
||||
| 11 | * @return array |
||||
| 12 | */ |
||||
| 13 | public function handle(string $url, array $postData = [], array $optionsList = []): array |
||||
| 14 | { |
||||
| 15 | $curl = curl_init(); |
||||
| 16 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 17 | curl_setopt($curl, CURLOPT_URL, $url); |
||||
| 18 | |||||
| 19 | if (!empty($postData)) { |
||||
| 20 | curl_setopt($curl, CURLOPT_POST, 1); |
||||
| 21 | curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($postData)); |
||||
| 22 | } |
||||
| 23 | |||||
| 24 | if (!empty($optionsList)) { |
||||
| 25 | foreach ($optionsList as $optionKey => $optionValue) { |
||||
| 26 | curl_setopt($curl, $optionKey, $optionValue); |
||||
| 27 | } |
||||
| 28 | } |
||||
| 29 | |||||
| 30 | $result = [ |
||||
| 31 | 'result' => curl_exec($curl), |
||||
|
0 ignored issues
–
show
It seems like
$curl can also be of type false; however, parameter $ch of curl_exec() does only seem to accept resource, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 32 | 'errno' => curl_errno($curl), |
||||
|
0 ignored issues
–
show
It seems like
$curl can also be of type false; however, parameter $ch of curl_errno() does only seem to accept resource, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 33 | 'error' => curl_error($curl), |
||||
|
0 ignored issues
–
show
It seems like
$curl can also be of type false; however, parameter $ch of curl_error() does only seem to accept resource, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 34 | 'http_code' => curl_getinfo($curl, CURLINFO_HTTP_CODE), |
||||
|
0 ignored issues
–
show
It seems like
$curl can also be of type false; however, parameter $ch of curl_getinfo() does only seem to accept resource, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 35 | ]; |
||||
| 36 | |||||
| 37 | curl_close($curl); |
||||
|
0 ignored issues
–
show
It seems like
$curl can also be of type false; however, parameter $ch of curl_close() does only seem to accept resource, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 38 | |||||
| 39 | return $result; |
||||
| 40 | } |
||||
| 41 | } |
||||
| 42 |