Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/_static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ jobs:
static-check:
name: Run Static Analysis
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [ "8.1", "8.5" ] # Deprecation warnings only show starting PHP 8.5
steps:
- uses: actions/checkout@v6

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.1"
php-version: ${{ matrix.php-version }}
tools: composer

- name: Install dependencies
Expand Down
10 changes: 5 additions & 5 deletions src/Dependency/DependencyChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ public static function isImageMagickPolicyAllowed(): void
{
self::isImageMagickAvailable();

$imagick = new Imagick();
try {
$imagick->readImage(
/** @phpstan-ignore-next-line */
TestingUtilities::getV1DataDir() . "/products/expense_receipts/default_sample.jpg"
);
$writer = new Imagick();
$writer->newImage(1, 1, 'white');
$writer->setImageFormat('pdf');
$reader = new Imagick();
$reader->readImageBlob($writer->getImageBlob());
} catch (Exception) {
throw new MindeeUnhandledException(
"To enable full support of PDF features, you need "
Expand Down
3 changes: 0 additions & 3 deletions src/Input/UrlInputSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,12 @@ private function downloadFile(

if ($response === false) {
$error = curl_error($ch);
curl_close($ch);
throw new MindeeSourceException(
'Failed to download file: ' . $error,
ErrorCode::NETWORK_ERROR
);
}

curl_close($ch);

if ($httpCode >= 200 && $httpCode < 300) {
return $response;
}
Expand Down
10 changes: 2 additions & 8 deletions src/V1/Http/BaseEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,10 @@ protected function initCurlSessionGet(string $queueId): array
CurlSslConfig::apply($ch);
curl_setopt($ch, CURLOPT_USERAGENT, getUserAgent());

$resp = [
return [
'data' => curl_exec($ch),
'code' => curl_getinfo($ch, CURLINFO_HTTP_CODE),
];
curl_close($ch);

return $resp;
}

/**
Expand All @@ -75,12 +72,9 @@ public function setFinalCurlOpts(
}
CurlSslConfig::apply($ch);
curl_setopt($ch, CURLOPT_USERAGENT, getUserAgent());
$resp = [
return [
'data' => curl_exec($ch),
'code' => curl_getinfo($ch, CURLINFO_HTTP_CODE),
];
curl_close($ch);

return $resp;
}
}
18 changes: 3 additions & 15 deletions src/V2/Http/MindeeApiV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,10 @@ private function sendGetRequest(string $url): array
/** @var CurlHandle $ch */
$ch = $this->initChannel();
curl_setopt($ch, CURLOPT_URL, $url);
$resp = [
return [
'data' => curl_exec($ch),
'code' => curl_getinfo($ch, CURLINFO_HTTP_CODE),
];
curl_close($ch);

return $resp;
}

/**
Expand Down Expand Up @@ -357,7 +354,6 @@ private function documentEnqueuePost(
if (!empty($curlError)) {
throw new MindeeException("cURL error:\n$curlError");
}
curl_close($ch);

return $resp;
}
Expand Down Expand Up @@ -409,7 +405,6 @@ public function reqPostRagDocument(
'code' => curl_getinfo($ch, CURLINFO_HTTP_CODE),
];
$curlError = curl_error($ch);
curl_close($ch);

if (!empty($curlError)) {
throw new MindeeException("cURL error:\n$curlError");
Expand Down Expand Up @@ -437,13 +432,10 @@ private function sendPatchRequest(string $url, array $body): array
'Authorization: ' . $this->apiKey,
'Content-Type: application/json',
]);
$resp = [
return [
'data' => curl_exec($ch),
'code' => curl_getinfo($ch, CURLINFO_HTTP_CODE),
];
curl_close($ch);

return $resp;
}

/**
Expand All @@ -457,13 +449,10 @@ private function sendDeleteRequest(string $url): array
$ch = $this->initChannel();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
$resp = [
return [
'data' => curl_exec($ch),
'code' => curl_getinfo($ch, CURLINFO_HTTP_CODE),
];
curl_close($ch);

return $resp;
}

/**
Expand Down Expand Up @@ -538,7 +527,6 @@ public function reqGetSearch(BaseSearchParameters $params): BaseResponse
'data' => curl_exec($ch),
'code' => curl_getinfo($ch, CURLINFO_HTTP_CODE),
];
curl_close($ch);
return $this->deserializeResponse($params->getResponseClass(), $resp);
}
}
2 changes: 1 addition & 1 deletion tests/pdffeatures.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<phpunit bootstrap="../vendor/autoload.php">
<phpunit bootstrap="../vendor/autoload.php" convertDeprecationsToExceptions="true">
<testsuites>
<testsuite name="main">
<directory suffix="TestPdf.php">.</directory>
Expand Down
Loading