Skip to content

Commit

Permalink
Merge 4.x into 5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
SonataCI authored Dec 8, 2024
2 parents 8a55a51 + 38f4cc2 commit cd1a5fe
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 56 deletions.
54 changes: 27 additions & 27 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
],
"homepage": "https://docs.sonata-project.org/projects/SonataMediaBundle",
"require": {
"php": "^8.0",
"php": "^8.1",
"doctrine/persistence": "^3.0.2",
"imagine/imagine": "^1.3",
"knplabs/gaufrette": "^0.10 || ^0.11",
Expand All @@ -38,28 +38,28 @@
"sonata-project/doctrine-extensions": "^1.13 || ^2.0",
"sonata-project/form-extensions": "^1.4 || ^2.0",
"sonata-project/twig-extensions": "^1.3 || ^2.0",
"symfony/asset": "^5.4 || ^6.2 || ^7.0",
"symfony/config": "^5.4 || ^6.2 || ^7.0",
"symfony/console": "^5.4 || ^6.2 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.2 || ^7.0",
"symfony/event-dispatcher": "^5.4 || ^6.2 || ^7.0",
"symfony/filesystem": "^5.4 || ^6.2 || ^7.0",
"symfony/finder": "^5.4 || ^6.2 || ^7.0",
"symfony/form": "^5.4 || ^6.2 || ^7.0",
"symfony/framework-bundle": "^5.4 || ^6.2 || ^7.0",
"symfony/http-client": "^5.4 || ^6.2 || ^7.0",
"symfony/http-foundation": "^5.4 || ^6.2 || ^7.0",
"symfony/http-kernel": "^5.4 || ^6.2 || ^7.0",
"symfony/mime": "^5.4 || ^6.2 || ^7.0",
"symfony/options-resolver": "^5.4 || ^6.2 || ^7.0",
"symfony/routing": "^5.4 || ^6.2 || ^7.0",
"symfony/security-bundle": "^5.4 || ^6.2 || ^7.0",
"symfony/security-core": "^5.4 || ^6.2 || ^7.0",
"symfony/translation": "^5.4 || ^6.2 || ^7.0",
"symfony/asset": "^6.4 || ^7.1",
"symfony/config": "^6.4 || ^7.1",
"symfony/console": "^6.4 || ^7.1",
"symfony/dependency-injection": "^6.4 || ^7.1",
"symfony/event-dispatcher": "^6.4 || ^7.1",
"symfony/filesystem": "^6.4 || ^7.1",
"symfony/finder": "^6.4 || ^7.1",
"symfony/form": "^6.4 || ^7.1",
"symfony/framework-bundle": "^6.4 || ^7.1",
"symfony/http-client": "^6.4 || ^7.1",
"symfony/http-foundation": "^6.4 || ^7.1",
"symfony/http-kernel": "^6.4 || ^7.1",
"symfony/mime": "^6.4 || ^7.1",
"symfony/options-resolver": "^6.4 || ^7.1",
"symfony/routing": "^6.4 || ^7.1",
"symfony/security-bundle": "^6.4 || ^7.1",
"symfony/security-core": "^6.4 || ^7.1",
"symfony/translation": "^6.4 || ^7.1",
"symfony/translation-contracts": "^2.0 || ^3.0",
"symfony/twig-bridge": "^5.4 || ^6.2 || ^7.0",
"symfony/twig-bundle": "^5.4 || ^6.2 || ^7.0",
"symfony/validator": "^5.4 || ^6.2 || ^7.0",
"symfony/twig-bridge": "^6.4 || ^7.1",
"symfony/twig-bundle": "^6.4 || ^7.1",
"symfony/validator": "^6.4 || ^7.1",
"twig/string-extra": "^3.0",
"twig/twig": "^3.0"
},
Expand All @@ -86,14 +86,14 @@
"psalm/plugin-phpunit": "^0.18",
"psalm/plugin-symfony": "^5.0",
"rector/rector": "^1.1",
"sonata-project/admin-bundle": "^4.28",
"sonata-project/admin-bundle": "^4.34",
"sonata-project/block-bundle": "^4.11 || ^5.0",
"sonata-project/classification-bundle": "^4.0",
"sonata-project/doctrine-orm-admin-bundle": "^4.0",
"symfony/browser-kit": "^5.4 || ^6.2 || ^7.0",
"symfony/messenger": "^5.4 || ^6.2 || ^7.0",
"symfony/phpunit-bridge": "^6.2 || ^7.0",
"symfony/security-csrf": "^5.4 || ^6.2 || ^7.0",
"symfony/browser-kit": "^6.4 || ^7.1",
"symfony/messenger": "^6.4 || ^7.1",
"symfony/phpunit-bridge": "^6.4 || ^7.1",
"symfony/security-csrf": "^6.4 || ^7.1",
"vimeo/psalm": "^5.0"
},
"conflict": {
Expand Down
4 changes: 4 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

use Rector\Config\RectorConfig;
use Rector\Php70\Rector\FunctionLike\ExceptionHandlerTypehintRector;
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\NarrowUnusedSetUpDefinedPropertyRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
Expand All @@ -40,6 +42,8 @@
$rectorConfig->importShortClasses(false);
$rectorConfig->skip([
ExceptionHandlerTypehintRector::class,
ReadOnlyPropertyRector::class,
NullToStrictStringFuncCallArgRector::class,
PreferPHPUnitThisCallRector::class,
NarrowUnusedSetUpDefinedPropertyRector::class,
]);
Expand Down
5 changes: 1 addition & 4 deletions src/Filesystem/Replicate.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,11 @@

final class Replicate implements Adapter, FileFactory, StreamFactory, MetadataSupporter
{
private LoggerInterface $logger;

public function __construct(
private Adapter $primary,
private Adapter $secondary,
?LoggerInterface $logger = null,
private LoggerInterface $logger = new NullLogger(),
) {
$this->logger = $logger ?? new NullLogger();
}

public function delete($key): bool
Expand Down
5 changes: 1 addition & 4 deletions src/Metadata/AmazonMetadataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,15 @@ final class AmazonMetadataBuilder implements MetadataBuilderInterface
'reduced' => self::STORAGE_REDUCED,
];

private MimeTypesInterface $mimeTypes;

/**
* @param array<string, mixed> $settings
*
* @phpstan-param AmazonSettings $settings
*/
public function __construct(
private array $settings,
?MimeTypesInterface $mimeTypes = null,
private MimeTypesInterface $mimeTypes = new MimeTypes(),
) {
$this->mimeTypes = $mimeTypes ?? new MimeTypes();
}

public function get(MediaInterface $media, string $filename): array
Expand Down
9 changes: 1 addition & 8 deletions src/Model/NoDriverGalleryManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,9 @@ public function getTableName(): string
}

/**
* Do not add return typehint to this method, it forces a dependency with
* Doctrine DBAL that we do not want here. This method will probably be
* deprecated on sonata-project/doctrine-extensions because it is only for
* Doctrine ORM.
*
* TODO: Remove this with the drop of sonata-project/doctrine-extensions < 2.
*
* @psalm-suppress MissingReturnType
*/
public function getConnection() // @phpstan-ignore-line
public function getConnection(): never
{
throw new NoDriverException();
}
Expand Down
9 changes: 1 addition & 8 deletions src/Model/NoDriverMediaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,9 @@ public function getTableName(): string
}

/**
* Do not add return typehint to this method, it forces a dependency with
* Doctrine DBAL that we do not want here. This method will probably be
* deprecated on sonata-project/doctrine-extensions because it is only for
* Doctrine ORM.
*
* TODO: Remove this with the drop of sonata-project/doctrine-extensions < 2.
*
* @psalm-suppress MissingReturnType
*/
public function getConnection() // @phpstan-ignore-line
public function getConnection(): never
{
throw new NoDriverException();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/DailyMotionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private function fixBinaryContent(MediaInterface $media): void
return;
}

if (1 === preg_match('{^(?:https?://)?www.dailymotion.com/video/(?<video_id>[0-9a-zA-Z]*)}', $media->getBinaryContent(), $matches)) {
if (1 === preg_match('{^(?:https?://)?www.dailymotion.com/video/(?<video_id>[0-9a-zA-Z]*)}', (string) $media->getBinaryContent(), $matches)) {
$media->setBinaryContent($matches['video_id']);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/FileProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public function validate(ErrorElement $errorElement, MediaInterface $media): voi

if (
'' !== $media->getBinaryContent()->getFilename()
&& !\in_array(strtolower($media->getBinaryContent()->getMimeType()), $this->allowedMimeTypes, true)
&& !\in_array(strtolower((string) $media->getBinaryContent()->getMimeType()), $this->allowedMimeTypes, true)
) {
$errorElement
->with('binaryContent')
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/VimeoProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected function fixBinaryContent(MediaInterface $media): void
return;
}

if (1 === preg_match('{vimeo\.com/(?:video/|)(?<video_id>\d+)}', $media->getBinaryContent(), $matches)) {
if (1 === preg_match('{vimeo\.com/(?:video/|)(?<video_id>\d+)}', (string) $media->getBinaryContent(), $matches)) {
$media->setBinaryContent($matches['video_id']);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Provider/YouTubeProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,13 @@ private function fixBinaryContent(MediaInterface $media): void
return;
}

if (11 === \strlen($media->getBinaryContent())) {
if (11 === \strlen((string) $media->getBinaryContent())) {
return;
}

if (1 === preg_match(
'{^(?:https?://)?(?:www\.)?(?:m\.)?(?:youtu\.be/|youtube\.com/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)/))(?<video_id>[^\#\?&\'>]+)}',
$media->getBinaryContent(),
(string) $media->getBinaryContent(),
$matches
)) {
$media->setBinaryContent($matches['video_id']);
Expand Down

0 comments on commit cd1a5fe

Please sign in to comment.