Skip to content

Commit

Permalink
Handle a possible curl init error
Browse files Browse the repository at this point in the history
Signed-off-by: William Desportes <williamdes@wdes.fr>
  • Loading branch information
williamdes committed Mar 11, 2021
1 parent 129c131 commit f3e3230
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 25 deletions.
25 changes: 0 additions & 25 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -50,36 +50,11 @@ parameters:
count: 1
path: src/Controller/Component/GithubApiComponent.php

-
message: "#^Parameter \\#1 \\$ch of function curl_setopt expects resource, resource\\|false given\\.$#"
count: 5
path: src/Controller/Component/GithubApiComponent.php

-
message: "#^Parameter \\#1 \\$ch of function curl_exec expects resource, resource\\|false given\\.$#"
count: 1
path: src/Controller/Component/GithubApiComponent.php

-
message: "#^Parameter \\#1 \\$ch of function curl_error expects resource, resource\\|false given\\.$#"
count: 1
path: src/Controller/Component/GithubApiComponent.php

-
message: "#^Parameter \\#1 \\$ch of function curl_close expects resource, resource\\|false given\\.$#"
count: 3
path: src/Controller/Component/GithubApiComponent.php

-
message: "#^Parameter \\#1 \\$json of function json_decode expects string, string\\|true given\\.$#"
count: 1
path: src/Controller/Component/GithubApiComponent.php

-
message: "#^Parameter \\#1 \\$ch of function curl_getinfo expects resource, resource\\|false given\\.$#"
count: 1
path: src/Controller/Component/GithubApiComponent.php

-
message: "#^Method App\\\\Controller\\\\Component\\\\GithubApiComponent\\:\\:createIssue\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
count: 1
Expand Down
5 changes: 5 additions & 0 deletions src/Controller/Component/GithubApiComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ public function sendRequest(
): array {
Log::debug('Request-url: ' . $url);
$curlHandle = curl_init($url);
if ($curlHandle === false) {
Log::error('Curl init error for: ' . $url);

return ['', 0];
}
curl_setopt($curlHandle, CURLOPT_CUSTOMREQUEST, $method);
$header = ['Accept: application/json'];
if ($access_token !== '') {
Expand Down

0 comments on commit f3e3230

Please sign in to comment.