Skip to content

Commit

Permalink
Support Symfony 7 (FriendsOfSymfony#1938)
Browse files Browse the repository at this point in the history
* Update dependencies

* add php 8.3

* add symfony 7 to tests

* exclude php 7.4 from tests for symfony 7

* Exclude all php versions prior to 8.2 for Symfony 7. Minimum supported Symfony 7 php version is 8.2 https://symfony.com/releases/7.0

* Require minimum doctrine/phpcr-odm 1.5.3. This is the lowest version with support for php 8.*

* Exclude php 8.3 symfony 7 lowest dependencies from CI. Higher doctrine/phpcr-odm version should be used for php 8.3

* Revert "Exclude php 8.3 symfony 7 lowest dependencies from CI. Higher doctrine/phpcr-odm version should be used for php 8.3"

This reverts commit 22c8a4c.

* Run cs fixer

* fix code style

* fix a suddenly excluded case

* Lock to symfony/console@^6.1 because of issue with doctrine/phpcr-odm as described in FriendsOfSymfony#1933 (comment)

* run cs fixer

* Bump jms/serializer-bundle to v5

* Remove jms/serializer-bundle v3 support because php 7.2 has reached an end of life https://www.php.net/supported-versions.php

* add php 8.3 to phpstan

* Update all Symfony references to ^6.3

* Add symfony/console 7.0 to dependencies.

* Normalize continuous integration matrix.

* Normalize continuous integration matrix.

* update gitignore

* fix gitignore

* fix typo

* Replace php-cs-fixer with a shim version. It allows us to lock with any desired version without the need to update the rest of dependencies.

* Run php-cs-fixer with locked version 3.8.0.

* Add support for doctrine/phpcr-odm 2-beta release.

* Cs fixer fix

* Bump knplabs/knp-components

* Fix php cs fixer version.

* CS Fixer fixes with version 3.8.0.

* Add symfony/stopwatch because it's required by project

* Bumb jackalope/jackalope-doctrine-dbal to RC-1

* Normalize composer

* Disable symfony testing with php 8.2 and 8.3

* minimum stability RC

* [cs] Fix composer.json

* [phpunit] Fix 'framework.annotations' error

* [phpunit] Fix 'getAliasNamespace' error

* [phpunit] Not use CodeExtension anymore

* [phpunit] Variable 'profile_type' does not exist

* Make use of 'AsMessageHandler' attribute in favor of MessageHandlerInterface + dropped support for SF 4.4 (as AsMessageHandler is available in SF 5.4)

* [phpstan] Excluded AsyncPersistPageHandler as attributes are not supported

* [phpstan] Fix ContainerAwareInterface not found

---------

Co-authored-by: Liakhovskyi Vladyslav <vlad@revotale.com>
Co-authored-by: Liakhovskyi Vladyslav <rusted@revotale.com>
  • Loading branch information
3 people authored and 7ochem committed Apr 18, 2024
1 parent 6906b04 commit b6c3b16
Show file tree
Hide file tree
Showing 56 changed files with 147 additions and 206 deletions.
39 changes: 24 additions & 15 deletions .github/workflows/continuous-integration.yaml
Expand Up @@ -40,24 +40,24 @@ jobs:
- '7.4'
- '8.1'
- '8.2'
- '8.3'
symfony:
- '4.4.*'
- '5.4.*'
- '6.2.*'
- '6.3.*'
- '7.0.*'
elasticsearch:
- '7.11.0'
dependencies:
- 'highest'
include:
- php: '7.4'
elasticsearch: '7.0.0'
dependencies: 'lowest'
symfony: '4.4.*'
exclude:
- php: '7.4'
symfony: '6.2.*'
dependencies: 'highest'
elasticsearch: '7.11.0'
symfony: '7.0.*'
- php: '7.4'
symfony: '6.3.*'
- php: '8.0'
symfony: '7.0.*'
- php: '8.1'
symfony: '7.0.*'
fail-fast: false
steps:
- name: 'Checkout'
Expand Down Expand Up @@ -103,20 +103,29 @@ jobs:
- '7.4'
- '8.1'
- '8.2'
- '8.3'
symfony:
- '4.4.*'
- '5.4.*'
- '6.2.*'
- '6.3.*'
- '7.0.*'
dependencies:
- 'highest'
include:
- php: '7.4'
dependencies: 'lowest'
symfony: '4.4.*'
symfony: '5.4.*'
exclude:
- php: '7.4'
symfony: '6.2.*'
dependencies: 'highest'
symfony: '7.0.*'
- php: '7.4'
symfony: '6.3.*'
- php: '8.0'
symfony: '7.0.*'
- php: '8.1'
symfony: '7.0.*'
- php: '8.1'
symfony: '4.4.*'

fail-fast: false
steps:
- name: 'Checkout'
Expand Down
37 changes: 20 additions & 17 deletions composer.json
Expand Up @@ -34,38 +34,41 @@
"pagerfanta/pagerfanta": "^2.4 || ^3.0 || ^4.0",
"psr/log": "^1.0 || ^2.0 || ^3.0",
"ruflin/elastica": "^7.1",
"symfony/console": "^4.4 || ^5.4 || ^6.2",
"symfony/dependency-injection": "^4.4 || ^5.4 || ^6.2",
"symfony/framework-bundle": "^4.4 || ^5.4 || ^6.2",
"symfony/property-access": "^4.4 || ^5.4 || ^6.2"
"symfony/console": "^5.4 || ^6.3 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.3 || ^7.0",
"symfony/framework-bundle": "^5.4 || ^6.3 || ^7.0",
"symfony/property-access": "^5.4 || ^6.3 || ^7.0",
"symfony/stopwatch": "^5.4 || ^6.3 || ^7.0"
},
"require-dev": {
"doctrine/doctrine-bundle": "^2.1.1",
"doctrine/mongodb-odm": "^2.2",
"doctrine/orm": "^2.8",
"doctrine/phpcr-odm": "^1.4",
"doctrine/phpcr-odm": "^1.5.3 || ^2.0.0-beta2",
"ergebnis/composer-normalize": "^2.28",
"friendsofphp/php-cs-fixer": "^3.0",
"jackalope/jackalope-doctrine-dbal": "^1.2",
"jackalope/jackalope-doctrine-dbal": "^1.2 || ^2.0.0-RC1",
"jms/serializer": "^3.8",
"jms/serializer-bundle": "^3.5 || ^4.0",
"knplabs/knp-components": "^2.4 || ^3.0",
"jms/serializer-bundle": "^4.0 || ^5.0",
"knplabs/knp-components": "^2.4 || ^3.0 || ^4.0",
"php-cs-fixer/shim": "3.8.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.4",
"phpstan/phpstan-phpunit": "^1.1",
"phpstan/phpstan-symfony": "^1.2",
"phpunit/phpunit": "^9.5",
"symfony/expression-language": "^4.4 || ^5.4 || ^6.2",
"symfony/messenger": "^4.4 || ^5.4 || ^6.2",
"symfony/serializer": "^4.4 || ^5.4 || ^6.2",
"symfony/twig-bundle": "^4.4 || ^5.4 || ^6.2",
"symfony/web-profiler-bundle": "^4.4 || ^5.4 || ^6.2",
"symfony/yaml": "^4.4 || ^5.4 || ^6.2"
"symfony/expression-language": "^5.4 || ^6.3 || ^7.0",
"symfony/messenger": "^5.4 || ^6.3 || ^7.0",
"symfony/serializer": "^5.4 || ^6.3 || ^7.0",
"symfony/twig-bundle": "^5.4 || ^6.3 || ^7.0",
"symfony/web-profiler-bundle": "^5.4 || ^6.3 || ^7.0",
"symfony/yaml": "^5.4 || ^6.3 || ^7.0"
},
"suggest": {
"enqueue/elastica-bundle": "For populating Elasticsearch indexes asynchronously and using significanly less resources. Uses Enqueue.",
"symfony/messenger": "For populating Elasticsearch indexes asynchronously and using significanly less resources."
},
"minimum-stability": "RC",
"prefer-stable": true,
"autoload": {
"psr-4": {
"FOS\\ElasticaBundle\\": "src/"
Expand All @@ -78,8 +81,8 @@
},
"config": {
"allow-plugins": {
"phpstan/extension-installer": true,
"ergebnis/composer-normalize": true
"ergebnis/composer-normalize": true,
"phpstan/extension-installer": true
}
},
"extra": {
Expand Down
2 changes: 2 additions & 0 deletions phpstan.dist.neon
Expand Up @@ -8,6 +8,8 @@ parameters:
paths:
- src
# - tests
excludePaths:
- src/Message/Handler/AsyncPersistPageHandler.php
ignoreErrors:
- message: /Trying to mock an undefined method/
path: tests/
Expand Down
1 change: 1 addition & 0 deletions src/Configuration/ConfigManager.php
Expand Up @@ -18,6 +18,7 @@ class ConfigManager implements ManagerInterface
{
/**
* @var IndexConfig[]
*
* @phpstan-var array<string, IndexConfigInterface>
*/
private $indexes = [];
Expand Down
1 change: 1 addition & 0 deletions src/Configuration/IndexConfigInterface.php
Expand Up @@ -69,6 +69,7 @@ public function getNumericDetection(): ?bool;

/**
* @return string|bool|null
*
* @phpstan-return ?TDynamic
*/
public function getDynamic();
Expand Down
6 changes: 6 additions & 0 deletions src/Configuration/IndexConfigTrait.php
Expand Up @@ -48,21 +48,27 @@ trait IndexConfigTrait
* An array of settings sent to ElasticSearch when creating the index.
*
* @var array
*
* @phpstan-var TSettings
*
* @phpstan-ignore-next-line Ignored because of a bug in PHPStan (https://github.com/phpstan/phpstan/issues/5091)
*/
private $settings;

/**
* @var array
*
* @phpstan-var TConfig
*
* @phpstan-ignore-next-line Ignored because of a bug in PHPStan (https://github.com/phpstan/phpstan/issues/5091)
*/
private $config;

/**
* @var array
*
* @phpstan-var TMapping
*
* @phpstan-ignore-next-line Ignored because of a bug in PHPStan (https://github.com/phpstan/phpstan/issues/5091)
*/
private $mapping;
Expand Down
2 changes: 2 additions & 0 deletions src/Configuration/Source/ContainerSource.php
Expand Up @@ -25,6 +25,7 @@ class ContainerSource implements SourceInterface
* The internal container representation of information.
*
* @var array
*
* @phpstan-var list<TConfig>
*/
private $configArray;
Expand All @@ -41,6 +42,7 @@ public function __construct(array $configArray)
* Should return all configuration available from the data source.
*
* @return IndexConfig[]
*
* @phpstan-return array<string, IndexConfig>
*/
public function getConfiguration(): array
Expand Down
1 change: 1 addition & 0 deletions src/Configuration/Source/SourceInterface.php
Expand Up @@ -23,6 +23,7 @@ interface SourceInterface
* Should return all configuration available from the data source.
*
* @return \FOS\ElasticaBundle\Configuration\IndexConfig[]
*
* @phpstan-return array<string, IndexConfigInterface>
*/
public function getConfiguration(): array;
Expand Down
2 changes: 2 additions & 0 deletions src/Configuration/Source/TemplateContainerSource.php
Expand Up @@ -25,6 +25,7 @@ class TemplateContainerSource implements SourceInterface
* The internal container representation of information.
*
* @var array
*
* @phpstan-var list<TConfig>
*/
private $configArray;
Expand All @@ -41,6 +42,7 @@ public function __construct(array $configArray)
* Should return all configuration available from the data source.
*
* @return IndexTemplateConfig[]
*
* @phpstan-return array<string, IndexTemplateConfig>
*/
public function getConfiguration(): array
Expand Down
3 changes: 3 additions & 0 deletions src/Configuration/TypeConfig.php
Expand Up @@ -21,12 +21,14 @@ class TypeConfig
{
/**
* @var array
*
* @phpstan-var TElasticConfig
*/
private $config;

/**
* @var array
*
* @phpstan-var TMapping
*/
private $mapping;
Expand All @@ -38,6 +40,7 @@ class TypeConfig

/**
* @param TMapping $mapping
*
* @phpstan-param TElasticConfig $config
*/
public function __construct(string $name, array $mapping, array $config = [])
Expand Down
6 changes: 0 additions & 6 deletions src/DataCollector/ElasticaDataCollector.php
Expand Up @@ -39,17 +39,11 @@ public function collect(Request $request, Response $response, ?\Throwable $excep
$this->data['queries'] = $this->logger->getQueries();
}

/**
* @return mixed
*/
public function getQueryCount()
{
return $this->data['nb_queries'];
}

/**
* @return mixed
*/
public function getQueries()
{
return $this->data['queries'];
Expand Down
4 changes: 3 additions & 1 deletion src/DependencyInjection/FOSElasticaExtension.php
Expand Up @@ -41,6 +41,7 @@ class FOSElasticaExtension extends Extension
* An array of indexes as configured by the extension.
*
* @var array
*
* @phpstan-var array<string, TIndexConfig>
*/
private $indexConfigs = [];
Expand All @@ -49,6 +50,7 @@ class FOSElasticaExtension extends Extension
* An array of index templates as configured by the extension.
*
* @var array
*
* @phpstan-var array<string, TIndexTemplateConfig>
*/
private $indexTemplateConfigs = [];
Expand Down Expand Up @@ -721,7 +723,7 @@ private function loadSerializer(array $config, ContainerBuilder $container): voi
$serializer = $container->getDefinition('fos_elastica.serializer_callback_prototype');
$serializer->setClass($config['callback_class']);

if (\is_subclass_of($config['callback_class'], ContainerAwareInterface::class)) {
if (\class_exists('Symfony\Component\DependencyInjection\ContainerAwareInterface') && \is_subclass_of($config['callback_class'], ContainerAwareInterface::class)) {
$serializer->addMethodCall('setContainer', [new Reference('service_container')]);
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/Doctrine/AbstractElasticaToModelTransformer.php
Expand Up @@ -144,9 +144,6 @@ public function hybridTransform(array $elasticaObjects)
return $result;
}

/**
* {@inheritdoc}
*/
public function getIdentifierField(): string
{
return $this->options['identifier'];
Expand Down
3 changes: 0 additions & 3 deletions src/Doctrine/MongoDBPagerProvider.php
Expand Up @@ -37,9 +37,6 @@ public function __construct(
$this->registerListenersService = $registerListenersService;
}

/**
* {@inheritdoc}
*/
public function provide(array $options = []): PagerInterface
{
$options = \array_replace($this->baseOptions, $options);
Expand Down
3 changes: 0 additions & 3 deletions src/Doctrine/ORMPagerProvider.php
Expand Up @@ -41,9 +41,6 @@ public function __construct(
$this->registerListenersService = $registerListenersService;
}

/**
* {@inheritdoc}
*/
public function provide(array $options = []): PagerInterface
{
$options = \array_replace($this->baseOptions, $options);
Expand Down
5 changes: 1 addition & 4 deletions src/Doctrine/PHPCRPagerProvider.php
Expand Up @@ -55,9 +55,6 @@ public function __construct(ManagerRegistry $doctrine, RegisterListenersService
$this->registerListenersService = $registerListenersService;
}

/**
* {@inheritdoc}
*/
public function provide(array $options = []): PagerInterface
{
$options = \array_replace($this->baseOptions, $options);
Expand All @@ -73,7 +70,7 @@ public function provide(array $options = []): PagerInterface
$repository = $manager->getRepository($this->objectClass);

$adapter = new QueryAdapter(
\call_user_func([$repository, $options['query_builder_method']], static::ENTITY_ALIAS)
\call_user_func([$repository, $options['query_builder_method']], self::ENTITY_ALIAS)
);

$pager = new PagerfantaPager(new Pagerfanta($adapter));
Expand Down
10 changes: 6 additions & 4 deletions src/Doctrine/RepositoryManager.php
Expand Up @@ -35,9 +35,6 @@ public function __construct(ManagerRegistry $managerRegistry, RepositoryManagerI
$this->repositoryManager = $repositoryManager;
}

/**
* {@inheritdoc}
*/
public function addIndex(string $indexName, FinderInterface $finder, ?string $repositoryName = null): void
{
throw new \LogicException(__METHOD__.' should not be called. Call addIndex on the main repository manager');
Expand All @@ -58,7 +55,12 @@ public function getRepository(string $entityName): Repository
$realEntityName = $entityName;
if (false !== \strpos($entityName, ':')) {
[$namespaceAlias, $simpleClassName] = \explode(':', $entityName);
$realEntityName = $this->managerRegistry->getAliasNamespace($namespaceAlias).'\\'.$simpleClassName;
// @link https://github.com/doctrine/persistence/pull/204
if (\method_exists($this->managerRegistry, 'getAliasNamespace')) {
$realEntityName = $this->managerRegistry->getAliasNamespace($namespaceAlias).'\\'.$simpleClassName;
} else {
$realEntityName = $simpleClassName.'::class';
}
}

if (isset($this->entities[$realEntityName])) {
Expand Down
2 changes: 0 additions & 2 deletions src/Elastica/Client.php
Expand Up @@ -50,8 +50,6 @@ class Client extends BaseClient
private $stopwatch;

/**
* {@inheritdoc}
*
* @param array<mixed> $data
* @param array<mixed> $query
*/
Expand Down
3 changes: 1 addition & 2 deletions src/Event/AbstractIndexPopulateEvent.php
Expand Up @@ -37,6 +37,7 @@ abstract class AbstractIndexPopulateEvent extends AbstractIndexEvent

/**
* @var array
*
* @phpstan-var TOptions
*/
protected $options;
Expand Down Expand Up @@ -67,8 +68,6 @@ public function getOptions(): array

/**
* @throws \InvalidArgumentException if option does not exist
*
* @return mixed
*/
public function getOption(string $name)
{
Expand Down

0 comments on commit b6c3b16

Please sign in to comment.