Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow packages from "symfony/*" ^7 #2430

Merged
merged 1 commit into from
Dec 14, 2023
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: 5 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ jobs:
allowed-to-fail: false
symfony-require: 6.4.*
variant: symfony/symfony:"6.4.*"
- php-version: '8.2'
dependencies: highest
allowed-to-fail: false
symfony-require: 7.0.*
variant: symfony/symfony:"7.0.*"

steps:
- name: Checkout
Expand Down
56 changes: 28 additions & 28 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,44 +38,44 @@
"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",
"symfony/config": "^5.4 || ^6.2",
"symfony/console": "^5.4 || ^6.2",
"symfony/dependency-injection": "^5.4 || ^6.2",
"symfony/event-dispatcher": "^5.4 || ^6.2",
"symfony/filesystem": "^5.4 || ^6.2",
"symfony/finder": "^5.4 || ^6.2",
"symfony/form": "^5.4 || ^6.2",
"symfony/framework-bundle": "^5.4 || ^6.2",
"symfony/http-client": "^5.4 || ^6.2",
"symfony/http-foundation": "^5.4 || ^6.2",
"symfony/http-kernel": "^5.4 || ^6.2",
"symfony/mime": "^5.4 || ^6.2",
"symfony/options-resolver": "^5.4 || ^6.2",
"symfony/routing": "^5.4 || ^6.2",
"symfony/security-bundle": "^5.4 || ^6.2",
"symfony/security-core": "^5.4 || ^6.2",
"symfony/translation": "^5.4 || ^6.2",
"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/translation-contracts": "^2.0 || ^3.0",
"symfony/twig-bridge": "^5.4 || ^6.2",
"symfony/twig-bundle": "^5.4 || ^6.2",
"symfony/validator": "^5.4 || ^6.2",
"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",
"twig/string-extra": "^3.0",
"twig/twig": "^3.0"
},
"require-dev": {
"async-aws/simple-s3": "^1.0",
"aws/aws-sdk-php": "^3.0",
"dama/doctrine-test-bundle": "^7.0",
"dama/doctrine-test-bundle": "^8.0.1",
"doctrine/doctrine-bundle": "^2.7",
"doctrine/mongodb-odm": "^2.4",
"doctrine/orm": "^2.14",
"friendsofphp/php-cs-fixer": "^3.4",
"knplabs/knp-menu-bundle": "^3.0",
"liip/imagine-bundle": "^2.0",
"masterminds/html5": "^2.7",
"matthiasnoback/symfony-config-test": "^4.2",
"matthiasnoback/symfony-dependency-injection-test": "^4.0",
"matthiasnoback/symfony-config-test": "^4.2 || ^5.1",
"matthiasnoback/symfony-dependency-injection-test": "^4.0 || ^5.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
Expand All @@ -89,10 +89,10 @@
"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",
"symfony/messenger": "^5.4 || ^6.2",
"symfony/phpunit-bridge": "^6.2",
"symfony/security-csrf": "^5.4 || ^6.2",
"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",
"vimeo/psalm": "^5.0"
},
"conflict": {
Expand Down
4 changes: 4 additions & 0 deletions src/Admin/BaseMediaAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ protected function configurePersistentParameters(): array
$context = $request->query->get('context', $this->pool->getDefaultContext());
}

\assert(\is_string($context));
VincentLanglet marked this conversation as resolved.
Show resolved Hide resolved

$providers = $this->pool->getProvidersByContext($context);
$provider = $request->query->get('provider');

Expand Down Expand Up @@ -167,6 +169,8 @@ protected function alterNewInstance(object $object): void

$context = $request->query->get('context');

\assert(null === $context || \is_string($context));
VincentLanglet marked this conversation as resolved.
Show resolved Hide resolved

$object->setProviderName($providerName);
$object->setContext($context);

Expand Down
6 changes: 5 additions & 1 deletion src/Admin/GalleryAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ protected function alterNewInstance(object $object): void
return;
}

$object->setContext($this->getRequest()->query->get('context'));
$context = $this->getRequest()->query->get('context');

\assert(null === $context || \is_string($context));
VincentLanglet marked this conversation as resolved.
Show resolved Hide resolved

$object->setContext($context);
}

protected function configureFormFields(FormMapper $form): void
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/GalleryAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function listAction(Request $request): Response
}

$listMode = $request->query->get('_list_mode');
if (null !== $listMode) {
if (\is_string($listMode)) {
$this->admin->setListMode($listMode);
}

Expand Down
11 changes: 7 additions & 4 deletions src/Controller/MediaAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ public function createAction(Request $request): Response
if ($request->isMethod('get') && null === $request->query->get('provider')) {
$pool = $this->container->get('sonata.media.pool');
\assert($pool instanceof Pool);
$context = $request->query->get('context', $pool->getDefaultContext());
\assert(\is_string($context));
VincentLanglet marked this conversation as resolved.
Show resolved Hide resolved

return $this->render('@SonataMedia/MediaAdmin/select_provider.html.twig', [
'providers' => $pool->getProvidersByContext(
$request->query->get('context', $pool->getDefaultContext())
),
'providers' => $pool->getProvidersByContext($context),
'action' => 'create',
]);
}
Expand All @@ -66,7 +66,10 @@ public function listAction(Request $request): Response
return $preResponse;
}

$this->admin->setListMode($request->query->get('_list_mode', 'mosaic'));
$listMode = $request->query->get('_list_mode', 'mosaic');
VincentLanglet marked this conversation as resolved.
Show resolved Hide resolved
\assert(\is_string($listMode));

$this->admin->setListMode($listMode);

$datagrid = $this->admin->getDatagrid();

Expand Down
40 changes: 10 additions & 30 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ final class Configuration implements ConfigurationInterface
private const DB_DRIVERS = ['doctrine_orm', 'doctrine_mongodb', 'no_driver'];

/**
* @psalm-suppress PossiblyNullReference, UndefinedInterfaceMethod
*
* @see https://github.com/psalm/psalm-plugin-symfony/issues/174
* @psalm-suppress UndefinedInterfaceMethod
*/
public function getConfigTreeBuilder(): TreeBuilder
{
Expand Down Expand Up @@ -86,9 +84,7 @@ public function getConfigTreeBuilder(): TreeBuilder
}

/**
* @psalm-suppress PossiblyNullReference, UndefinedInterfaceMethod
*
* @see https://github.com/psalm/psalm-plugin-symfony/issues/174
* @psalm-suppress UndefinedInterfaceMethod
*/
private function addContextsSection(ArrayNodeDefinition $node): void
{
Expand Down Expand Up @@ -136,9 +132,7 @@ private function addContextsSection(ArrayNodeDefinition $node): void
}

/**
* @psalm-suppress PossiblyNullReference, UndefinedInterfaceMethod
*
* @see https://github.com/psalm/psalm-plugin-symfony/issues/174
* @psalm-suppress UndefinedInterfaceMethod
*/
private function addCdnSection(ArrayNodeDefinition $node): void
{
Expand Down Expand Up @@ -179,9 +173,7 @@ private function addCdnSection(ArrayNodeDefinition $node): void
}

/**
* @psalm-suppress PossiblyNullReference, UndefinedInterfaceMethod
*
* @see https://github.com/psalm/psalm-plugin-symfony/issues/174
* @psalm-suppress UndefinedInterfaceMethod
*/
private function addFilesystemSection(ArrayNodeDefinition $node): void
{
Expand Down Expand Up @@ -273,9 +265,7 @@ private function addFilesystemSection(ArrayNodeDefinition $node): void
}

/**
* @psalm-suppress PossiblyNullReference, UndefinedInterfaceMethod
*
* @see https://github.com/psalm/psalm-plugin-symfony/issues/174
* @psalm-suppress UndefinedInterfaceMethod
*/
private function addProvidersSection(ArrayNodeDefinition $node): void
{
Expand Down Expand Up @@ -401,9 +391,7 @@ private function addProvidersSection(ArrayNodeDefinition $node): void
}

/**
* @psalm-suppress PossiblyNullReference, UndefinedInterfaceMethod
*
* @see https://github.com/psalm/psalm-plugin-symfony/issues/174
* @psalm-suppress UndefinedInterfaceMethod
*/
private function addModelSection(ArrayNodeDefinition $node): void
{
Expand All @@ -422,9 +410,7 @@ private function addModelSection(ArrayNodeDefinition $node): void
}

/**
* @psalm-suppress PossiblyNullReference, UndefinedInterfaceMethod
*
* @see https://github.com/psalm/psalm-plugin-symfony/issues/174
* @psalm-suppress UndefinedInterfaceMethod
*/
private function addHttpClientSection(ArrayNodeDefinition $node): void
{
Expand All @@ -447,9 +433,7 @@ private function addHttpClientSection(ArrayNodeDefinition $node): void
}

/**
* @psalm-suppress PossiblyNullReference, UndefinedInterfaceMethod
*
* @see https://github.com/psalm/psalm-plugin-symfony/issues/174
* @psalm-suppress UndefinedInterfaceMethod
*/
private function addResizerSection(ArrayNodeDefinition $node): void
{
Expand Down Expand Up @@ -482,9 +466,7 @@ private function addResizerSection(ArrayNodeDefinition $node): void
}

/**
* @psalm-suppress PossiblyNullReference, UndefinedInterfaceMethod
*
* @see https://github.com/psalm/psalm-plugin-symfony/issues/174
* @psalm-suppress UndefinedInterfaceMethod
*/
private function addAdapterSection(ArrayNodeDefinition $node): void
{
Expand All @@ -500,9 +482,7 @@ private function addAdapterSection(ArrayNodeDefinition $node): void
}

/**
* @psalm-suppress PossiblyNullReference, UndefinedInterfaceMethod
*
* @see https://github.com/psalm/psalm-plugin-symfony/issues/174
* @psalm-suppress UndefinedInterfaceMethod
*/
private function addMessengerSection(ArrayNodeDefinition $node): void
{
Expand Down
2 changes: 1 addition & 1 deletion src/Filesystem/Replicate.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function exists($key): bool
* @param string $key
* @param string $content
*
* @return int|bool
* @return bool
*/
public function write($key, $content)
{
Expand Down
8 changes: 2 additions & 6 deletions src/Form/DataTransformer/ProviderDataTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,11 @@ public function __construct(
/**
* @param mixed $value
*
* @return mixed
*
* @phpstan-param MediaInterface|null $value
* @phpstan-return MediaInterface|null
*/
#[\ReturnTypeWillChange]
public function transform($value)
public function transform($value): mixed
{
if (null === $value) {
return new $this->class();
Expand All @@ -70,13 +68,11 @@ public function transform($value)
/**
* @param mixed $value
*
* @return mixed
*
* @phpstan-param MediaInterface|null $value
* @phpstan-return MediaInterface|null
*/
#[\ReturnTypeWillChange]
public function reverseTransform($value)
public function reverseTransform($value): mixed
{
if (!$value instanceof MediaInterface) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/Form/Type/MediaType.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function configureOptions(OptionsResolver $resolver): void
->setAllowedValues('context', array_keys($this->pool->getContexts()));
}

public function getParent(): ?string
public function getParent(): string
{
return FormType::class;
}
Expand Down
32 changes: 32 additions & 0 deletions src/Messenger/BackwardCompatibleMessageHandlerInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Sonata\MediaBundle\Messenger;

use Symfony\Component\Messenger\Handler\MessageHandlerInterface;

// `Symfony\Component\Messenger\Handler\MessageHandlerInterface` was removed in "symfony/messenger" 7.
// @todo: Remove this interface when dropping support for "symfony/messenger" < 7.
/** @psalm-suppress UndefinedClass */
if (interface_exists(MessageHandlerInterface::class)) {
class_alias(MessageHandlerInterface::class, __NAMESPACE__.'\BackwardCompatibleMessageHandlerInterface');
} else {
/**
* @internal
*
* @psalm-suppress UnrecognizedStatement
*/
interface BackwardCompatibleMessageHandlerInterface
{
}
}
7 changes: 4 additions & 3 deletions src/Messenger/GenerateThumbnailsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@
use Sonata\MediaBundle\Model\MediaManagerInterface;
use Sonata\MediaBundle\Provider\Pool;
use Sonata\MediaBundle\Thumbnail\GenerableThumbnailInterface;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
use Symfony\Component\Messenger\Exception\UnrecoverableMessageHandlingException;
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;

/**
* @author Jordi Sala Morales <[email protected]>
*
* @psalm-suppress DeprecatedInterface
* NEXT_MAJOR: Stop implementing `BackwardCompatibleMessageHandlerInterface`.
*/
final class GenerateThumbnailsHandler implements MessageHandlerInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a BC break for non SF 7 users.

We should use something like
https://github.com/sonata-project/SonataAdminBundle/blob/4.x/src/ArgumentResolver/CompatibleValueResolverInterface.php

if (interface_exists(MessageHandlerInterface::class)) {
    /** @internal */
    interface CompatibleMessageHandlerInterface extends MessageHandlerInterface
    {
    }
} else {
    /** @internal */
    interface CompatibleMessageHandlerInterface
    {
    }
}

and use it here:

final class GenerateThumbnailsHandler implements CompatibleMessageHandlerInterface

#[AsMessageHandler]
final class GenerateThumbnailsHandler implements BackwardCompatibleMessageHandlerInterface
{
public function __construct(
private GenerableThumbnailInterface $thumbnail,
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/Metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getDescription(): ?string
return $this->description;
}

public function getImage(): ?string
public function getImage(): string
{
return $this->image;
}
Expand Down
5 changes: 1 addition & 4 deletions src/Validator/Constraints/ValidMediaFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@ public function validatedBy(): string
return 'sonata.media.validator.format';
}

/**
* @return string|string[]
*/
#[\ReturnTypeWillChange]
public function getTargets()
public function getTargets(): string
{
return self::CLASS_CONSTRAINT;
}
Expand Down
Loading