Skip to content

Commit b59d3d2

Browse files
author
roadiz-ci
committed
chore: bumped
1 parent a89eec3 commit b59d3d2

76 files changed

Lines changed: 1643 additions & 980 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/run-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ubuntu-latest
2020
strategy:
2121
matrix:
22-
php-version: ['8.2', '8.3']
22+
php-version: ['8.3', '8.4']
2323
steps:
2424
- uses: shivammathur/setup-php@v2
2525
with:

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright © 2024 Ambroise Maupate
3+
Copyright © 2025 Ambroise Maupate
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

composer.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
}
1919
],
2020
"require": {
21-
"php": ">=8.2",
21+
"php": ">=8.3",
2222
"ext-json": "*",
2323
"ext-gd": "*",
2424
"ext-dom": "*",
@@ -27,30 +27,30 @@
2727
"ext-fileinfo": "*",
2828
"doctrine/orm": "~2.20.0",
2929
"enshrined/svg-sanitize": "^0.22",
30-
"intervention/image": "^2.5",
30+
"intervention/image": "^3.11",
3131
"league/flysystem": "^3.0",
32-
"monolog/monolog": "^1.24.0 || ^2.1.1",
33-
"symfony/asset": "6.4.*",
34-
"symfony/console": "6.4.*",
35-
"symfony/event-dispatcher": "6.4.*",
36-
"symfony/filesystem": "6.4.*",
37-
"symfony/finder": "6.4.*",
38-
"symfony/http-foundation": "6.4.*",
32+
"monolog/monolog": "^3.9",
33+
"symfony/asset": "7.3.*",
34+
"symfony/console": "7.3.*",
35+
"symfony/event-dispatcher": "7.3.*",
36+
"symfony/filesystem": ">=7.1",
37+
"symfony/finder": "7.3.*",
38+
"symfony/http-foundation": "7.3.*",
3939
"symfony/http-client-contracts": "^3.5",
40-
"symfony/options-resolver": "6.4.*",
41-
"symfony/serializer": "6.4.*",
42-
"twig/twig": "^3.16"
40+
"symfony/options-resolver": "7.3.*",
41+
"symfony/serializer": "7.3.*",
42+
"twig/twig": "^3.21"
4343
},
4444
"require-dev": {
45-
"api-platform/metadata": "~3.3.11",
45+
"api-platform/metadata": "^4.1.18",
4646
"doctrine/doctrine-bundle": "^2.8.1",
4747
"php-coveralls/php-coveralls": "^2.4",
4848
"phpstan/phpstan": "^1.5.3",
4949
"phpstan/phpdoc-parser": "<2",
5050
"phpstan/phpstan-doctrine": "^1.3",
51-
"phpunit/phpunit": "^9.5",
52-
"symfony/http-client": "6.4.*",
53-
"symfony/process": "6.4.*"
51+
"phpunit/phpunit": "^9.6",
52+
"symfony/http-client": "7.3.*",
53+
"symfony/process": "7.3.*"
5454
},
5555
"autoload": {
5656
"psr-4": {
@@ -70,8 +70,8 @@
7070
},
7171
"extra": {
7272
"branch-alias": {
73-
"dev-master": "2.5.x-dev",
74-
"dev-develop": "2.6.x-dev"
73+
"dev-master": "2.6.x-dev",
74+
"dev-develop": "2.7.x-dev"
7575
}
7676
}
7777
}

src/AbstractDocumentFinder.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
abstract class AbstractDocumentFinder implements DocumentFinderInterface
88
{
9+
#[\Override]
910
public function findVideosWithFilename(string $fileName): iterable
1011
{
1112
$basename = pathinfo($fileName);
@@ -24,6 +25,7 @@ public function findVideosWithFilename(string $fileName): iterable
2425
return $this->findAllByFilenames($sourcesDocsName);
2526
}
2627

28+
#[\Override]
2729
public function findAudiosWithFilename(string $fileName): iterable
2830
{
2931
$basename = pathinfo($fileName);
@@ -40,6 +42,7 @@ public function findAudiosWithFilename(string $fileName): iterable
4042
return $this->findAllByFilenames($sourcesDocsName);
4143
}
4244

45+
#[\Override]
4346
public function findPicturesWithFilename(string $fileName): iterable
4447
{
4548
$pathInfo = pathinfo($fileName);
@@ -60,9 +63,7 @@ public function findPicturesWithFilename(string $fileName): iterable
6063
// remove current extension from list
6164
$extensionsList = array_diff($extensionsList, [$currentExtension]);
6265
// list sources paths for extensions
63-
$sourcesDocsName = array_values(array_map(function ($extension) use ($basename) {
64-
return $basename.'.'.$extension;
65-
}, $extensionsList));
66+
$sourcesDocsName = array_values(array_map(fn ($extension) => $basename.'.'.$extension, $extensionsList));
6667

6768
return $this->findAllByFilenames($sourcesDocsName);
6869
}

src/ArrayDocumentFinder.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ final class ArrayDocumentFinder extends AbstractDocumentFinder
1515
/**
1616
* @var ArrayCollection<int, DocumentInterface>
1717
*/
18-
private ArrayCollection $documents;
18+
private readonly ArrayCollection $documents;
1919

2020
public function __construct()
2121
{
@@ -27,24 +27,23 @@ public function __construct()
2727
*
2828
* @return ArrayCollection<int, DocumentInterface>
2929
*/
30+
#[\Override]
3031
public function findAllByFilenames(array $fileNames): ArrayCollection
3132
{
3233
return $this->documents->filter(
33-
function (DocumentInterface $document) use ($fileNames) {
34-
return in_array($document->getFilename(), $fileNames);
35-
}
34+
fn (DocumentInterface $document) => in_array($document->getFilename(), $fileNames)
3635
);
3736
}
3837

38+
#[\Override]
3939
public function findOneByFilenames(array $fileNames): ?DocumentInterface
4040
{
4141
return $this->documents->filter(
42-
function (DocumentInterface $document) use ($fileNames) {
43-
return in_array($document->getFilename(), $fileNames);
44-
}
42+
fn (DocumentInterface $document) => in_array($document->getFilename(), $fileNames)
4543
)->first() ?: null;
4644
}
4745

46+
#[\Override]
4847
public function findOneByHashAndAlgorithm(string $hash, string $algorithm): ?DocumentInterface
4948
{
5049
return null;

src/AverageColorResolver.php

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,16 @@
44

55
namespace RZ\Roadiz\Documents;
66

7-
use Intervention\Image\Image;
7+
use Intervention\Image\Interfaces\ImageInterface;
88

99
final readonly class AverageColorResolver
1010
{
11-
public function getAverageColor(Image $image): string
11+
/**
12+
* Get the average color of an image by resampling the image to 1x1 pixel and pick this pixel color.
13+
* Then only use the RGB channels by picking only the 7 first hex chars to get rid of alpha channel.
14+
*/
15+
public function getAverageColor(ImageInterface $image): string
1216
{
13-
$colorArray = $this->getAverageColorAsArray($image);
14-
15-
return sprintf(
16-
'#%02x%02x%02x',
17-
$colorArray[0],
18-
$colorArray[1],
19-
$colorArray[2]
20-
);
21-
}
22-
23-
public function getAverageColorAsArray(Image $image): array
24-
{
25-
$image->resize(1, 1);
26-
/** @var array $array */
27-
$array = $image->pickColor(0, 0);
28-
29-
return $array;
17+
return substr($image->resize(1, 1)->pickColor(0, 0)->toHex('#'), 0, 7);
3018
}
3119
}

src/Console/DocumentAverageColorCommand.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
namespace RZ\Roadiz\Documents\Console;
66

7-
use Intervention\Image\Exception\NotReadableException;
7+
use Intervention\Image\Exceptions\DecoderException;
8+
use League\Flysystem\FilesystemException;
89
use RZ\Roadiz\Documents\AverageColorResolver;
910
use RZ\Roadiz\Documents\Models\AdvancedDocumentInterface;
1011
use RZ\Roadiz\Documents\Models\DocumentInterface;
@@ -16,13 +17,15 @@ class DocumentAverageColorCommand extends AbstractDocumentCommand
1617
{
1718
protected SymfonyStyle $io;
1819

20+
#[\Override]
1921
protected function configure(): void
2022
{
2123
$this->setName('documents:color')
2224
->setDescription('Fetch every document medium color and write it in database.')
2325
;
2426
}
2527

28+
#[\Override]
2629
protected function execute(InputInterface $input, OutputInterface $output): int
2730
{
2831
$this->io = new SymfonyStyle($input, $output);
@@ -43,11 +46,11 @@ private function updateDocumentColor(DocumentInterface $document): void
4346
return;
4447
}
4548
try {
46-
$mediumColor = (new AverageColorResolver())->getAverageColor($this->imageManager->make(
49+
$mediumColor = (new AverageColorResolver())->getAverageColor($this->imageManager->read(
4750
$this->documentsStorage->readStream($mountPath)
4851
));
4952
$document->setImageAverageColor($mediumColor);
50-
} catch (NotReadableException $exception) {
53+
} catch (DecoderException|FilesystemException) {
5154
/*
5255
* Do nothing
5356
* just return 0 width and height

src/Console/DocumentClearFolderCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class DocumentClearFolderCommand extends AbstractDocumentCommand
1717
{
1818
protected SymfonyStyle $io;
1919

20+
#[\Override]
2021
protected function configure(): void
2122
{
2223
$this->setName('documents:clear-folder')
@@ -34,6 +35,7 @@ protected function getDocumentQueryBuilder(FolderInterface $folder): QueryBuilde
3435
->setParameter(':folderId', $folder);
3536
}
3637

38+
#[\Override]
3739
protected function execute(InputInterface $input, OutputInterface $output): int
3840
{
3941
$this->io = new SymfonyStyle($input, $output);

src/Console/DocumentDownscaleCommand.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
namespace RZ\Roadiz\Documents\Console;
66

77
use Doctrine\Persistence\ManagerRegistry;
8-
use Intervention\Image\Exception\NotReadableException;
8+
use Intervention\Image\Exceptions\DecoderException;
99
use Intervention\Image\ImageManager;
10+
use League\Flysystem\FilesystemException;
1011
use League\Flysystem\FilesystemOperator;
1112
use RZ\Roadiz\Documents\DownscaleImageManager;
1213
use RZ\Roadiz\Documents\Events\CachePurgeAssetsRequestEvent;
@@ -36,6 +37,7 @@ public function __construct(
3637
parent::__construct($managerRegistry, $imageManager, $documentsStorage, $name);
3738
}
3839

40+
#[\Override]
3941
protected function configure(): void
4042
{
4143
$this->setName('documents:downscale')
@@ -45,6 +47,7 @@ protected function configure(): void
4547
->setDescription('Downscale every document according to max pixel size defined in configuration.');
4648
}
4749

50+
#[\Override]
4851
protected function execute(InputInterface $input, OutputInterface $output): int
4952
{
5053
$io = new SymfonyStyle($input, $output);
@@ -133,7 +136,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
133136
foreach ($documents as $document) {
134137
try {
135138
$this->downscaler->processDocumentFromExistingRaw($document);
136-
} catch (NotReadableException $exception) {
139+
} catch (DecoderException|FilesystemException $exception) {
137140
$io->error($exception->getMessage().' - '.(string) $document);
138141
}
139142
$io->progressAdvance();

src/Console/DocumentDuplicatesCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ class DocumentDuplicatesCommand extends AbstractDocumentCommand
1414
{
1515
protected SymfonyStyle $io;
1616

17+
#[\Override]
1718
protected function configure(): void
1819
{
1920
$this->setName('documents:duplicates')
2021
->setDescription('Find duplicated documents based on their file hash.')
2122
;
2223
}
2324

25+
#[\Override]
2426
protected function execute(InputInterface $input, OutputInterface $output): int
2527
{
2628
$this->io = new SymfonyStyle($input, $output);

0 commit comments

Comments
 (0)