From 816ac3088adddcf02d8e5b4e8d1b6e67173dba25 Mon Sep 17 00:00:00 2001 From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com> Date: Tue, 27 Oct 2026 15:47:34 +0100 Subject: [PATCH] :recycle: update deprecated syntaxes + add checks --- .github/workflows/_static-analysis.yml | 5 ++++- src/Dependency/DependencyChecker.php | 10 +++++----- src/Input/UrlInputSource.php | 3 --- src/V1/Http/BaseEndpoint.php | 10 ++-------- src/V2/Http/MindeeApiV2.php | 18 +++--------------- tests/pdffeatures.xml | 2 +- 6 files changed, 15 insertions(+), 33 deletions(-) diff --git a/.github/workflows/_static-analysis.yml b/.github/workflows/_static-analysis.yml index 8d86e043..6b2185ff 100644 --- a/.github/workflows/_static-analysis.yml +++ b/.github/workflows/_static-analysis.yml @@ -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 diff --git a/src/Dependency/DependencyChecker.php b/src/Dependency/DependencyChecker.php index 87cc8e12..2cf6ae7f 100644 --- a/src/Dependency/DependencyChecker.php +++ b/src/Dependency/DependencyChecker.php @@ -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 " diff --git a/src/Input/UrlInputSource.php b/src/Input/UrlInputSource.php index fb81f20c..1f4074c7 100644 --- a/src/Input/UrlInputSource.php +++ b/src/Input/UrlInputSource.php @@ -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; } diff --git a/src/V1/Http/BaseEndpoint.php b/src/V1/Http/BaseEndpoint.php index 570ff2d0..fe0267a8 100644 --- a/src/V1/Http/BaseEndpoint.php +++ b/src/V1/Http/BaseEndpoint.php @@ -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; } /** @@ -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; } } diff --git a/src/V2/Http/MindeeApiV2.php b/src/V2/Http/MindeeApiV2.php index 40fe056e..148daef0 100644 --- a/src/V2/Http/MindeeApiV2.php +++ b/src/V2/Http/MindeeApiV2.php @@ -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; } /** @@ -357,7 +354,6 @@ private function documentEnqueuePost( if (!empty($curlError)) { throw new MindeeException("cURL error:\n$curlError"); } - curl_close($ch); return $resp; } @@ -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"); @@ -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; } /** @@ -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; } /** @@ -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); } } diff --git a/tests/pdffeatures.xml b/tests/pdffeatures.xml index dd66c121..743c2301 100644 --- a/tests/pdffeatures.xml +++ b/tests/pdffeatures.xml @@ -1,5 +1,5 @@ - + .