From 671fa60eaebfeb498988cd26f46b98b9777df6ac Mon Sep 17 00:00:00 2001 From: roadiz-ci Date: Fri, 19 Apr 2024 09:50:25 +0000 Subject: [PATCH] Merge branch hotfix/v2.2.15 --- .github/workflows/run-test.yml | 2 +- .travis.yml | 19 ------------------- composer.json | 8 ++++---- phpstan.neon | 2 ++ src/AbstractDocumentFinder.php | 5 ++++- src/DocumentArchiver.php | 14 +++++++++++--- src/DownscaleImageManager.php | 2 +- src/Models/AdvancedDocumentInterface.php | 13 +------------ src/Models/DocumentInterface.php | 2 +- src/Viewers/SvgDocumentViewer.php | 2 +- 10 files changed, 26 insertions(+), 43 deletions(-) delete mode 100644 .travis.yml diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml index 01c564c..b33d114 100644 --- a/.github/workflows/run-test.yml +++ b/.github/workflows/run-test.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-version: ['8.0', '8.1'] + php-version: ['8.1', '8.2', '8.3'] steps: - uses: shivammathur/setup-php@v2 with: diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 61a6d14..0000000 --- a/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -language: php -sudo: required -php: - - 7.4 - - 8.0 - - 8.1 - - nightly -env: - - XDEBUG_MODE=coverage -install: - - curl -s http://getcomposer.org/installer | php - - php composer.phar install --dev --no-interaction -script: - - vendor/bin/phpcs --report=full --report-file=./report.txt -p ./src - - vendor/bin/atoum -d tests - - vendor/bin/phpstan analyse -c phpstan.neon -jobs: - allow_failures: - - php: nightly diff --git a/composer.json b/composer.json index a3378da..3e27fae 100644 --- a/composer.json +++ b/composer.json @@ -18,14 +18,14 @@ } ], "require": { - "php": ">=8.0", + "php": ">=8.1", "ext-json": "*", "ext-gd": "*", "ext-dom": "*", "ext-zip": "*", "ext-simplexml": "*", "ext-fileinfo": "*", - "doctrine/orm": "<2.17", + "doctrine/orm": "~2.17.0", "enshrined/svg-sanitize": "^0.15", "guzzlehttp/guzzle": "^7.2.0", "guzzlehttp/psr7": "^2.0", @@ -62,8 +62,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.1.x-dev", - "dev-develop": "2.2.x-dev" + "dev-master": "2.2.x-dev", + "dev-develop": "2.3.x-dev" } } } diff --git a/phpstan.neon b/phpstan.neon index 273466e..f4a94cf 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -17,6 +17,8 @@ parameters: - '#Doctrine\\ORM\\Mapping\\GeneratedValue constructor expects#' - '#type mapping mismatch: property can contain Doctrine\\Common\\Collections\\Collection]+> but database expects Doctrine\\Common\\Collections\\Collection&iterable<[^\>]+>#' - '#should return Doctrine\\Common\\Collections\\Collection]+Interface> but returns Doctrine\\Common\\Collections\\Collection]+>#' + - '#but returns Doctrine\\Common\\Collections\\ReadableCollection]+>#' + - '#does not accept Doctrine\\Common\\Collections\\ReadableCollection]+>#' reportUnmatchedIgnoredErrors: false checkMissingIterableValueType: false checkGenericClassInNonGenericObjectType: false diff --git a/src/AbstractDocumentFinder.php b/src/AbstractDocumentFinder.php index e16a500..ff42399 100644 --- a/src/AbstractDocumentFinder.php +++ b/src/AbstractDocumentFinder.php @@ -53,7 +53,10 @@ public function findPicturesWithFilename(string $fileName): iterable { $pathInfo = pathinfo($fileName); $basename = $pathInfo['filename']; - $currentExtension = $pathInfo['extension']; + $currentExtension = $pathInfo['extension'] ?? null; + if (null === $currentExtension) { + return []; + } $extensionsList = [ 'jpg', 'gif', diff --git a/src/DocumentArchiver.php b/src/DocumentArchiver.php index f89813f..2ab4782 100644 --- a/src/DocumentArchiver.php +++ b/src/DocumentArchiver.php @@ -24,13 +24,13 @@ public function __construct(FilesystemOperator $documentsStorage) } /** - * @param array $documents + * @param iterable $documents * @param string $name * @param bool $keepFolders * @return string Zip file path * @throws FilesystemException */ - public function archive(array $documents, string $name, bool $keepFolders = true): string + public function archive(iterable $documents, string $name, bool $keepFolders = true): string { $filename = (new AsciiSlugger())->slug($name . ' ' . date('YmdHis'), '_') . '.zip'; $tmpFileName = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $filename; @@ -60,8 +60,16 @@ public function archive(array $documents, string $name, bool $keepFolders = true return $tmpFileName; } + /** + * @param iterable $documents + * @param string $name + * @param bool $keepFolders + * @param bool $unlink + * @return BinaryFileResponse + * @throws FilesystemException + */ public function archiveAndServe( - array $documents, + iterable $documents, string $name, bool $keepFolders = true, bool $unlink = true diff --git a/src/DownscaleImageManager.php b/src/DownscaleImageManager.php index 2807840..aea311c 100644 --- a/src/DownscaleImageManager.php +++ b/src/DownscaleImageManager.php @@ -97,7 +97,7 @@ public function processDocumentFromExistingRaw(?DocumentInterface $document = nu null !== $this->createDocumentFromImage($document, $processImage, true) && null !== $this->logger ) { - $this->logger->info('Document has been downscaled.', ['path' => $documentPath]); + $this->logger->info('Document has been downscaled.', ['path' => $documentPath, 'entity' => $document]); } } } diff --git a/src/Models/AdvancedDocumentInterface.php b/src/Models/AdvancedDocumentInterface.php index 6755df5..f86ca2b 100644 --- a/src/Models/AdvancedDocumentInterface.php +++ b/src/Models/AdvancedDocumentInterface.php @@ -4,19 +4,8 @@ namespace RZ\Roadiz\Documents\Models; -interface AdvancedDocumentInterface extends DocumentInterface, SizeableInterface +interface AdvancedDocumentInterface extends DocumentInterface, SizeableInterface, DisplayableInterface { - /** - * @return string|null - */ - public function getImageAverageColor(): ?string; - - /** - * @param string|null $imageAverageColor - * @return $this - */ - public function setImageAverageColor(?string $imageAverageColor): static; - /** * @return int|null */ diff --git a/src/Models/DocumentInterface.php b/src/Models/DocumentInterface.php index 3936b4f..1f990bf 100644 --- a/src/Models/DocumentInterface.php +++ b/src/Models/DocumentInterface.php @@ -156,7 +156,7 @@ public function setRawDocument(?DocumentInterface $rawDocument = null): static; public function isRaw(): bool; /** - * @param boolean $raw the raw + * @param bool $raw the raw * @return $this */ public function setRaw(bool $raw): static; diff --git a/src/Viewers/SvgDocumentViewer.php b/src/Viewers/SvgDocumentViewer.php index 8133ffd..15746a0 100644 --- a/src/Viewers/SvgDocumentViewer.php +++ b/src/Viewers/SvgDocumentViewer.php @@ -32,7 +32,7 @@ class SvgDocumentViewer * @param FilesystemOperator $documentsStorage * @param DocumentInterface $document * @param array $attributes - * @param boolean $asObject Default false + * @param bool $asObject Default false * @param string $imageUrl Only needed if you set $asObject to true. */ public function __construct(