Skip to content

Commit 6cd3c40

Browse files
committed
refactor: ensure we have a proper curl handle before calling curl_close
1 parent 109d667 commit 6cd3c40

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

phpstan-baseline.neon

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ parameters:
6666
count: 1
6767
path: src/Runtime.php
6868

69+
-
70+
message: '#^Class CurlHandle not found\.$#'
71+
identifier: class.notFound
72+
count: 1
73+
path: src/RuntimeApiClient.php
74+
6975
-
7076
message: '#^Method Ymir\\Runtime\\RuntimeApiClient\:\:sendData\(\) has parameter \$data with no type specified\.$#'
7177
identifier: missingType.parameter

src/RuntimeApiClient.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ public function __construct(string $apiUrl, Logger $logger)
7171
*/
7272
public function __destruct()
7373
{
74-
curl_close($this->nextInvocationHandle);
74+
if ((\PHP_VERSION_ID < 80000 && is_resource($this->nextInvocationHandle)) || (\PHP_VERSION_ID >= 80000 && $this->nextInvocationHandle instanceof \CurlHandle)) {
75+
curl_close($this->nextInvocationHandle);
76+
}
7577
}
7678

7779
/**

0 commit comments

Comments
 (0)