1 | <?php |
||||
2 | |||||
3 | namespace EVB\Weather; |
||||
4 | |||||
5 | |||||
6 | /** |
||||
7 | * Wrapper class for basic curl_* functions |
||||
8 | */ |
||||
9 | class CurlWrapper |
||||
10 | { |
||||
11 | /** |
||||
12 | * Executes a curl request and returns the result |
||||
13 | * as a string. |
||||
14 | * |
||||
15 | * @param string $url |
||||
16 | * @return string |
||||
17 | */ |
||||
18 | public function fetch(string $url) : string |
||||
19 | { |
||||
20 | $session = \curl_init($url); |
||||
21 | |||||
22 | \curl_setopt($session, CURLOPT_RETURNTRANSFER, 1); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
23 | |||||
24 | $result = \curl_exec($session); |
||||
0 ignored issues
–
show
It seems like
$session 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
![]() |
|||||
25 | |||||
26 | \curl_close($session); |
||||
0 ignored issues
–
show
It seems like
$session 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
![]() |
|||||
27 | |||||
28 | if (!\is_string($result)) { |
||||
29 | $result = ""; |
||||
30 | } |
||||
31 | |||||
32 | return $result; |
||||
33 | } |
||||
34 | } |
||||
35 |