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 committed Mar 6, 2023
2 parents 385ea1a + ce31e67 commit 6e594c8
Show file tree
Hide file tree
Showing 29 changed files with 98 additions and 37 deletions.
20 changes: 10 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"homepage": "https://docs.sonata-project.org/projects/SonataMediaBundle",
"require": {
"php": "^7.4 || ^8.0",
"doctrine/persistence": "^2.0 || ^3.0",
"doctrine/persistence": "^3.0.2",
"imagine/imagine": "^1.3",
"knplabs/gaufrette": "^0.10",
"knplabs/gaufrette": "^0.10 || ^0.11",
"nyholm/psr7": "^1.4",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",
Expand Down Expand Up @@ -67,9 +67,9 @@
"async-aws/simple-s3": "^1.0",
"aws/aws-sdk-php": "^3.0",
"dama/doctrine-test-bundle": "^6.7",
"doctrine/doctrine-bundle": "^2.3.2",
"doctrine/mongodb-odm": "^2.2",
"doctrine/orm": "^2.9",
"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",
Expand All @@ -82,8 +82,8 @@
"phpstan/phpstan-strict-rules": "^1.0",
"phpstan/phpstan-symfony": "^1.0",
"phpunit/phpunit": "^9.5",
"psalm/plugin-phpunit": "^0.17",
"psalm/plugin-symfony": "^3.0",
"psalm/plugin-phpunit": "^0.18",
"psalm/plugin-symfony": "^4.0 || ^5.0",
"rector/rector": "^0.15",
"sonata-project/admin-bundle": "^4.9",
"sonata-project/block-bundle": "^4.11",
Expand All @@ -93,13 +93,13 @@
"symfony/messenger": "^4.4 || ^5.4 || ^6.0",
"symfony/phpunit-bridge": "^6.1",
"symfony/security-csrf": "^4.4 || ^5.4 || ^6.0",
"vimeo/psalm": "^4.7.2"
"vimeo/psalm": "^4.7.2 || ^5.0"
},
"conflict": {
"async-aws/simple-s3": "<1.0",
"aws/aws-sdk-php": "<3.0",
"doctrine/mongodb-odm": "<2.2",
"doctrine/orm": "<2.9",
"doctrine/mongodb-odm": "<2.4",
"doctrine/orm": "<2.14",
"knplabs/knp-menu-bundle": "<3.0",
"liip/imagine-bundle": "<2.0",
"sonata-project/admin-bundle": "<4.9",
Expand Down
2 changes: 1 addition & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<psalm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" errorLevel="2" findUnusedPsalmSuppress="true" resolveFromConfigFile="true" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd">
<psalm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" errorLevel="2" findUnusedPsalmSuppress="true" resolveFromConfigFile="true" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" findUnusedBaselineEntry="true" findUnusedCode="false">
<projectFiles>
<directory name="src"/>
<directory name="tests"/>
Expand Down
2 changes: 2 additions & 0 deletions src/Form/DataTransformer/ProviderDataTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function __construct(Pool $pool, string $class, array $options = [])
* @phpstan-param MediaInterface|null $value
* @phpstan-return MediaInterface|null
*/
#[\ReturnTypeWillChange]
public function transform($value)
{
if (null === $value) {
Expand All @@ -80,6 +81,7 @@ public function transform($value)
* @phpstan-param MediaInterface|null $value
* @phpstan-return MediaInterface|null
*/
#[\ReturnTypeWillChange]
public function reverseTransform($value)
{
if (!$value instanceof MediaInterface) {
Expand Down
3 changes: 3 additions & 0 deletions src/Form/Type/MediaType.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* @psalm-suppress MissingTemplateParam https://github.com/phpstan/phpstan-symfony/issues/320
*/
final class MediaType extends AbstractType implements LoggerAwareInterface
{
use LoggerAwareTrait;
Expand Down
3 changes: 3 additions & 0 deletions src/Model/Gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ public function removeGalleryItem(GalleryItemInterface $galleryItem): void
}
}

/**
* @psalm-suppress RedundantCondition https://github.com/vimeo/psalm/issues/9449
*/
public function reorderGalleryItems(): void
{
$iterator = $this->getGalleryItems()->getIterator();
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/doctrine/BaseGallery.mongodb.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mongo-mapping xmlns="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd">
<doctrine-mongo-mapping xmlns="https://doctrine-project.org/schemas/odm/doctrine-mongo-mapping" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping https://www.doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd">
<mapped-superclass name="Sonata\MediaBundle\Document\BaseGallery">
<field name="name" field-name="name" type="string"/>
<field name="context" field-name="context" type="string"/>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/doctrine/BaseGallery.orm.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<doctrine-mapping xmlns="https://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<mapped-superclass name="Sonata\MediaBundle\Entity\BaseGallery">
<field name="name" type="string" column="name" length="255"/>
<field name="context" type="string" column="context" length="64"/>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/doctrine/BaseGalleryItem.mongodb.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mongo-mapping xmlns="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd">
<doctrine-mongo-mapping xmlns="https://doctrine-project.org/schemas/odm/doctrine-mongo-mapping" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping https://www.doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd">
<mapped-superclass name="Sonata\MediaBundle\Document\BaseGalleryItem">
<field name="position" type="int"/>
<field name="enabled" type="boolean"/>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/doctrine/BaseGalleryItem.orm.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<doctrine-mapping xmlns="https://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<mapped-superclass name="Sonata\MediaBundle\Entity\BaseGalleryItem">
<field name="position" type="integer" column="position"/>
<field name="enabled" type="boolean" column="enabled"/>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/doctrine/BaseMedia.mongodb.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mongo-mapping xmlns="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd">
<doctrine-mongo-mapping xmlns="https://doctrine-project.org/schemas/odm/doctrine-mongo-mapping" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping https://www.doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd">
<mapped-superclass name="Sonata\MediaBundle\Document\BaseMedia">
<field name="name" field-name="name" type="string"/>
<field name="description" field-name="description" type="string"/>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/doctrine/BaseMedia.orm.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<doctrine-mapping xmlns="https://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<mapped-superclass name="Sonata\MediaBundle\Entity\BaseMedia">
<field name="name" column="name" type="string" length="255"/>
<field name="description" column="description" type="text" nullable="true" length="1024"/>
Expand Down
1 change: 1 addition & 0 deletions src/Validator/Constraints/ValidMediaFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function validatedBy(): string
/**
* @return string|string[]
*/
#[\ReturnTypeWillChange]
public function getTargets()
{
return self::CLASS_CONSTRAINT;
Expand Down
23 changes: 16 additions & 7 deletions tests/App/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Security\Http\Authentication\AuthenticatorManager;

final class AppKernel extends Kernel
Expand Down Expand Up @@ -79,27 +80,35 @@ public function getProjectDir(): string
*/
protected function configureRoutes($routes): void
{
$routes->import(__DIR__.'/Resources/config/routing/routes.yaml');
$routes->import(__DIR__.'/config/routes.yaml');
}

/**
* @psalm-suppress DeprecatedClass
*/
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
{
$loader->load(__DIR__.'/Resources/config/config.yaml');
$loader->load(__DIR__.'/config/config.yaml');

if (class_exists(AuthenticatorManager::class)) {
$loader->load(__DIR__.'/Resources/config/config_symfony_v5.yaml');
if (class_exists(IsGranted::class)) {
$loader->load(__DIR__.'/config/config_symfony_v6.yaml');
} elseif (class_exists(AuthenticatorManager::class)) {
$loader->load(__DIR__.'/config/config_symfony_v5.yaml');
} else {
$loader->load(__DIR__.'/Resources/config/config_symfony_v4.yaml');
$loader->load(__DIR__.'/config/config_symfony_v4.yaml');
}

if (class_exists(HttpCacheHandler::class)) {
$loader->load(__DIR__.'/Resources/config/config_sonata_block_v4.yaml');
$loader->load(__DIR__.'/config/config_sonata_block_v4.yaml');
}

$loader->load(__DIR__.'/Resources/config/services.php');
if (version_compare(\PHP_VERSION, '8.0.0', '>=')) {
$loader->load(__DIR__.'/config/config_php8.yaml');
} else {
$loader->load(__DIR__.'/config/config_php7.yaml');
}

$loader->load(__DIR__.'/config/services.php');
$container->setParameter('app.base_dir', $this->getBaseDir());
}

Expand Down
6 changes: 6 additions & 0 deletions tests/App/Entity/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@

namespace Sonata\MediaBundle\Tests\App\Entity;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Sonata\ClassificationBundle\Entity\BaseCategory;

/**
* @ORM\Entity
* @ORM\Table(name="classification__category")
*/
#[ORM\Entity]
#[ORM\Table(name: 'classification__category')]
class Category extends BaseCategory
{
/**
Expand All @@ -29,6 +32,9 @@ class Category extends BaseCategory
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
#[ORM\Id]
#[ORM\Column(type: Types::INTEGER)]
#[ORM\GeneratedValue]
protected $id;

public function setId(?int $id): void
Expand Down
6 changes: 6 additions & 0 deletions tests/App/Entity/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,25 @@

namespace Sonata\MediaBundle\Tests\App\Entity;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Sonata\ClassificationBundle\Entity\BaseContext;

/**
* @ORM\Entity
* @ORM\Table(name="classification__context")
*/
#[ORM\Entity]
#[ORM\Table(name: 'classification__context')]
class Context extends BaseContext
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="string")
*/
#[ORM\Id]
#[ORM\Column(type: Types::STRING)]
#[ORM\GeneratedValue]
protected ?string $id = null;
}
6 changes: 6 additions & 0 deletions tests/App/Entity/Gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Sonata\MediaBundle\Tests\App\Entity;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Sonata\MediaBundle\Entity\BaseGallery;
use Sonata\MediaBundle\Model\GalleryItemInterface;
Expand All @@ -23,6 +24,8 @@
*
* @phpstan-extends BaseGallery<GalleryItemInterface>
*/
#[ORM\Entity]
#[ORM\Table(name: 'media__gallery')]
class Gallery extends BaseGallery
{
/**
Expand All @@ -32,6 +35,9 @@ class Gallery extends BaseGallery
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
#[ORM\Id]
#[ORM\Column(type: Types::INTEGER)]
#[ORM\GeneratedValue]
protected $id;

public function getId()
Expand Down
6 changes: 6 additions & 0 deletions tests/App/Entity/GalleryItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@

namespace Sonata\MediaBundle\Tests\App\Entity;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Sonata\MediaBundle\Entity\BaseGalleryItem;

/**
* @ORM\Entity
* @ORM\Table(name="media__gallery_item")
*/
#[ORM\Entity]
#[ORM\Table(name: 'media__gallery_item')]
class GalleryItem extends BaseGalleryItem
{
/**
Expand All @@ -29,6 +32,9 @@ class GalleryItem extends BaseGalleryItem
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
#[ORM\Id]
#[ORM\Column(type: Types::INTEGER)]
#[ORM\GeneratedValue]
protected $id;

public function getId()
Expand Down
6 changes: 6 additions & 0 deletions tests/App/Entity/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@

namespace Sonata\MediaBundle\Tests\App\Entity;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Sonata\MediaBundle\Entity\BaseMedia;

/**
* @ORM\Entity
* @ORM\Table(name="media__media")
*/
#[ORM\Entity]
#[ORM\Table(name: 'media__media')]
class Media extends BaseMedia
{
/**
Expand All @@ -29,6 +32,9 @@ class Media extends BaseMedia
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
#[ORM\Id]
#[ORM\Column(type: Types::INTEGER)]
#[ORM\GeneratedValue]
protected $id;

public function setId(int $id): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ security:

twig:
exception_controller: null
paths:
- '%kernel.project_dir%/Resources/views'
strict_variables: true

sonata_media:
Expand Down Expand Up @@ -77,13 +75,3 @@ doctrine:
dbal:
driver: pdo_sqlite
path: "%app.base_dir%sonata_media_test.db3"
orm:
entity_managers:
default:
mappings:
SonataMediaBundle: null
SonataMediaTest:
type: annotation
dir: "%kernel.project_dir%/Entity"
is_bundle: false
prefix: Sonata\MediaBundle\Tests\App\Entity
11 changes: 11 additions & 0 deletions tests/App/config/config_php7.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
doctrine:
orm:
entity_managers:
default:
mappings:
SonataMediaBundle: null
SonataMediaTest:
type: annotation
dir: "%kernel.project_dir%/Entity"
is_bundle: false
prefix: Sonata\MediaBundle\Tests\App\Entity
11 changes: 11 additions & 0 deletions tests/App/config/config_php8.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
doctrine:
orm:
entity_managers:
default:
mappings:
SonataMediaBundle: null
SonataMediaTest:
type: attribute
dir: "%kernel.project_dir%/Entity"
is_bundle: false
prefix: Sonata\MediaBundle\Tests\App\Entity
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions tests/App/config/config_symfony_v6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
framework:
session:
storage_factory_id: session.storage.factory.mock_file
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/Metadata/AmazonMetadataBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function testAmazon(array $settings, array $mediaAttributes, array $expec
}

/**
* @phpstan-return iterable<array{AmazonSettings, array<string, mixed>}>
* @phpstan-return iterable<array{AmazonSettings, array<string, string|int>, array<string, mixed>}>
*/
public function provider(): iterable
{
Expand Down

0 comments on commit 6e594c8

Please sign in to comment.