diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4557343e..1c9f0bfa 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,9 +11,6 @@ on: schedule: - cron: '0 3 * * 1' -env: - fail-fast: true - jobs: integration-tests: # Will not run if the event is a PR to bump-meilisearch-v* (so a pre-release PR) @@ -30,8 +27,9 @@ jobs: MEILI_NO_ANALYTICS: true strategy: matrix: - php-version: ['7.4', '8.1', '8.2', '8.3', '8.4'] - sf-version: ['5.4', '6.4', '7.0', '7.1', '7.2', '7.3'] + php-version: [ '7.4', '8.1', '8.2', '8.3', '8.4' ] + sf-version: [ '5.4', '6.4', '7.0', '7.1', '7.2', '7.3' ] + dependencies: [ 'default' ] exclude: - php-version: '7.4' sf-version: '6.4' @@ -39,6 +37,8 @@ jobs: sf-version: '7.0' - php-version: '7.4' sf-version: '7.1' + - php-version: '7.4' + sf-version: '7.2' - php-version: '7.4' sf-version: '7.3' - php-version: '8.1' @@ -47,6 +47,8 @@ jobs: sf-version: '7.0' - php-version: '8.1' sf-version: '7.1' + - php-version: '8.1' + sf-version: '7.2' - php-version: '8.1' sf-version: '7.3' - php-version: '8.2' @@ -55,14 +57,24 @@ jobs: sf-version: '5.4' - php-version: '8.4' sf-version: '5.4' + include: - php-version: '7.4' - sf-version: '7.2' - - php-version: '8.0' - sf-version: '7.2' - - php-version: '8.1' - sf-version: '7.2' + sf-version: '5.4' + dependencies: 'lowest' + - php-version: '7.4' + sf-version: '5.4' + dependencies: 'highest' + - php-version: '8.4' + sf-version: '6.4' + dependencies: 'lowest' + - php-version: '8.4' + sf-version: '6.4' + dependencies: 'highest' + - php-version: '8.4' + sf-version: '7.3' + dependencies: 'highest' - name: integration-tests (PHP ${{ matrix.php-version }}) (Symfony ${{ matrix.sf-version }}.*) + name: integration-tests (PHP ${{ matrix.php-version }}) (Symfony ${{ matrix.sf-version }}.*)${{ matrix.dependencies != 'default' && format(' ({0})', matrix.dependencies) || '' }} steps: - name: Checkout code uses: actions/checkout@v5 @@ -73,7 +85,7 @@ jobs: php-version: ${{ matrix.php-version }} tools: composer, flex - - name: Validate composer.json and composer.lock + - name: Validate composer.json run: composer validate - name: Remove doctrine/annotations @@ -85,7 +97,8 @@ jobs: env: SYMFONY_REQUIRE: ${{ matrix.sf-version }}.* with: - dependency-versions: 'highest' + composer-options: --no-interaction --no-progress --prefer-dist --dev + dependency-versions: "${{ matrix.dependencies }}" - name: Run test suite run: composer test:unit -- --coverage-clover coverage.xml @@ -93,7 +106,7 @@ jobs: - name: Upload coverage file uses: actions/upload-artifact@v4 with: - name: 'phpunit-${{ matrix.php-version }}-${{ matrix.sf-version }}-coverage' + name: "phpunit-${{ matrix.php-version }}-${{ matrix.sf-version }}-${{ matrix.dependencies }}-coverage" path: 'coverage.xml' code-style: diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index de29a333..adef17be 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -13,7 +13,7 @@ ->setFinder($finder) ->setRules([ '@Symfony' => true, - '@PHP80Migration:risky' => true, + '@PHP8x0Migration:risky' => true, 'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'], 'global_namespace_import' => [ 'import_classes' => false, diff --git a/composer.json b/composer.json index 47c04655..58979bce 100644 --- a/composer.json +++ b/composer.json @@ -20,8 +20,8 @@ "require": { "php": "^7.4|^8.0", "ext-json": "*", - "doctrine/doctrine-bundle": "^2.10", - "meilisearch/meilisearch-php": "^1.0.0", + "doctrine/doctrine-bundle": "^2.10 || ^3.0", + "meilisearch/meilisearch-php": "^1.16", "symfony/config": "^5.4 || ^6.0 || ^7.0", "symfony/dependency-injection": "^5.4.17 || ^6.0 || ^7.0", "symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0", @@ -34,21 +34,22 @@ "doctrine/annotations": "^2.0.0", "doctrine/orm": "^2.12 || ^3.0", "matthiasnoback/symfony-config-test": "^4.3 || ^5.2", - "matthiasnoback/symfony-dependency-injection-test": "^4.3 || ^5.0", - "nyholm/psr7": "^1.8.1", - "php-cs-fixer/shim": "^3.58.1", + "matthiasnoback/symfony-dependency-injection-test": "^4.3 || ^5.1", + "nikic/php-parser": "^5.6.2", + "nyholm/psr7": "^1.8.2", + "php-cs-fixer/shim": "^3.88.2", "phpmd/phpmd": "^2.15", - "phpstan/extension-installer": "^1.4.1", - "phpstan/phpstan": "^1.11.4", - "phpstan/phpstan-doctrine": "^1.4.3", - "phpstan/phpstan-phpunit": "^1.4.0", - "phpstan/phpstan-symfony": "^1.4.4", - "phpunit/php-code-coverage": "^9.2.31", + "phpstan/extension-installer": "^1.4.3", + "phpstan/phpstan": "^2.1.31", + "phpstan/phpstan-doctrine": "^2.0.10", + "phpstan/phpstan-phpunit": "^2.0.7", + "phpstan/phpstan-symfony": "^2.0.8", + "phpunit/php-code-coverage": "^9.2.32", "symfony/doctrine-bridge": "^5.4.19 || ^6.0.7 || ^7.0", "symfony/filesystem": "^5.4 || ^6.0 || ^7.0", "symfony/framework-bundle": "^5.4.17 || ^6.0 || ^7.0", - "symfony/http-client": "^5.4 || ^6.0 || ^7.0", - "symfony/phpunit-bridge": "^6.4 || ^7.0", + "symfony/http-client": "^5.4.47 || ^6.4.15 || ^7.1.8", + "symfony/phpunit-bridge": "^7.3", "symfony/yaml": "^5.4 || ^6.0 || ^7.0" }, "autoload": { diff --git a/phpstan.neon.dist b/phpstan.dist.neon similarity index 52% rename from phpstan.neon.dist rename to phpstan.dist.neon index 28e5679a..5c8c9244 100644 --- a/phpstan.neon.dist +++ b/phpstan.dist.neon @@ -7,3 +7,4 @@ parameters: - tests ignoreErrors: - '#Call to static method getClass\(\) on an unknown class Doctrine\\Common\\Util\\ClassUtils#' + - '#Parameter \#1 \$array of function array_unique expects an array of values castable to string, list\|Meilisearch\\Bundle\\Entity\\Aggregator> given#' diff --git a/src/Engine.php b/src/Engine.php index 50b54528..937c6962 100644 --- a/src/Engine.php +++ b/src/Engine.php @@ -111,7 +111,7 @@ public function clear(string $indexUid): array /** * Delete an index and its content. */ - public function delete(string $indexUid): ?array + public function delete(string $indexUid): array { return $this->client->deleteIndex($indexUid); } diff --git a/src/Services/MeilisearchService.php b/src/Services/MeilisearchService.php index 9f0130d9..ad85706c 100644 --- a/src/Services/MeilisearchService.php +++ b/src/Services/MeilisearchService.php @@ -137,12 +137,12 @@ public function clear(string $className): array return $this->engine->clear($this->searchableAs($className)); } - public function deleteByIndexName(string $indexName): ?array + public function deleteByIndexName(string $indexName): array { return $this->engine->delete($indexName); } - public function delete(string $className): ?array + public function delete(string $className): array { $this->assertIsSearchable($className); diff --git a/tests/Kernel.php b/tests/Kernel.php index 28b72424..da870126 100644 --- a/tests/Kernel.php +++ b/tests/Kernel.php @@ -5,8 +5,8 @@ namespace Meilisearch\Bundle\Tests; use Doctrine\Bundle\DoctrineBundle\ConnectionFactory; +use Doctrine\Bundle\DoctrineBundle\Dbal\BlacklistSchemaAssetFilter; use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; -use Doctrine\ORM\Configuration; use Doctrine\ORM\Mapping\LegacyReflectionFields; use Meilisearch\Bundle\MeilisearchBundle; use Symfony\Bridge\Doctrine\ArgumentResolver\EntityValueResolver; @@ -29,18 +29,30 @@ public function registerBundles(): iterable protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void { + $loader->load(__DIR__.'/config/framework.yaml'); + + $doctrineBundleV3 = !class_exists(BlacklistSchemaAssetFilter::class); + if (PHP_VERSION_ID >= 80000) { - if (class_exists(LegacyReflectionFields::class) && PHP_VERSION_ID >= 80400) { - $loader->load(__DIR__.'/config/config.yaml'); + if ($doctrineBundleV3) { + $loader->load(__DIR__.'/config/doctrine.yaml'); + } elseif (class_exists(LegacyReflectionFields::class) && PHP_VERSION_ID >= 80400) { + $loader->load(__DIR__.'/config/doctrine_v2.yaml'); } else { - $loader->load(__DIR__.'/config/config_old_proxy.yaml'); + $loader->load(__DIR__.'/config/doctrine_old_proxy.yaml'); } } else { - $loader->load(__DIR__.'/config/config_php7.yaml'); + $container->prependExtensionConfig('framework', [ + 'annotations' => true, + 'serializer' => ['enable_annotations' => true], + 'router' => ['utf8' => true], + ]); + + $loader->load(__DIR__.'/config/doctrine_php7.yaml'); } $loader->load(__DIR__.'/config/meilisearch.yaml'); - if (\defined(ConnectionFactory::class.'::DEFAULT_SCHEME_MAP')) { + if (\defined(ConnectionFactory::class.'::DEFAULT_SCHEME_MAP') && !$doctrineBundleV3) { $container->prependExtensionConfig('doctrine', [ 'orm' => [ 'report_fields_where_declared' => true, @@ -49,15 +61,6 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa ]); } - // @phpstan-ignore-next-line - if (method_exists(Configuration::class, 'setLazyGhostObjectEnabled') && Kernel::VERSION_ID >= 60100) { - $container->prependExtensionConfig('doctrine', [ - 'orm' => [ - 'enable_lazy_ghost_objects' => true, - ], - ]); - } - if (class_exists(EntityValueResolver::class)) { $container->prependExtensionConfig('doctrine', [ 'orm' => [ diff --git a/tests/baseline-ignore b/tests/baseline-ignore index 7a70d53c..efbcd39c 100644 --- a/tests/baseline-ignore +++ b/tests/baseline-ignore @@ -2,10 +2,17 @@ %Since symfony/var-exporter 7.3: The "Symfony\\Component\\VarExporter\\LazyGhostTrait" trait is deprecated, use native lazy objects instead.% %Since symfony/var-exporter 7.3: Using ProxyHelper::generateLazyGhost\(\) is deprecated, use native lazy objects instead.% %Class "Doctrine\\ORM\\Proxy\\Autoloader" is deprecated. Use native lazy objects instead.% -%Calling Doctrine\\ORM\\Configuration::setProxyDir is deprecated and will not be possible in Doctrine ORM 4.0% -%Calling Doctrine\\ORM\\Configuration::getProxyDir is deprecated and will not be possible in Doctrine ORM 4.0% -%Calling Doctrine\\ORM\\Configuration::setAutoGenerateProxyClasses is deprecated and will not be possible in Doctrine ORM 4.0% -%Calling Doctrine\\ORM\\Configuration::getAutoGenerateProxyClasses is deprecated and will not be possible in Doctrine ORM 4.0% +%Calling Doctrine\\ORM\\Configuration::(setProxyDir|getProxyDir) is deprecated and will not be possible in Doctrine ORM 4.0% +%Calling Doctrine\\ORM\\Configuration::(setAutoGenerateProxyClasses|getAutoGenerateProxyClasses) is deprecated and will not be possible in Doctrine ORM 4.0% %Calling Doctrine\\ORM\\Configuration::setProxyNamespace is deprecated and will not be possible in Doctrine ORM 4.0% %Since doctrine/doctrine-bundle 2.16: Not setting "doctrine.orm.enable_native_lazy_objects" to true is deprecated% -%The "report_fields_where_declared" configuration option is deprecated and will be removed in DoctrineBundle 3.0. When using ORM 3, report_fields_where_declared will always be true.% +%The "report_fields_where_declared" configuration option is deprecated and will be removed in DoctrineBundle 3.0.% +%Implicitly marking parameter \$.+ as nullable is deprecated% +%The "Doctrine\\Bundle\\DoctrineBundle\\CacheWarmer\\DoctrineMetadataCacheWarmer::doWarmUp\(\)" method will require a new "string|null \$buildDir" argument in the next major version of its parent class "Symfony\\Bundle\\FrameworkBundle\\CacheWarmer\\AbstractPhpFileCacheWarmer", not defining it is deprecated% +%Constant E_STRICT is deprecated% +%Method "ArrayAccess::(offsetExists|offsetGet|offsetSet|offsetUnset)\(\)" might add ".+" as a native return type declaration in the future. Do the same in implementation "(Doctrine\\Common\\Collections\\.+|Doctrine\\ORM\\PersistentCollection)" now to avoid errors or add an explicit @return annotation to suppress this message% +%Method "Countable::count\(\)" might add "int" as a native return type declaration in the future. Do the same in implementation "Doctrine\\Common\\Collections\\.+" now to avoid errors or add an explicit @return annotation to suppress this message% +%Method "IteratorAggregate::getIterator\(\)" might add "\\Traversable" as a native return type declaration in the future\. Do the same in implementation "Doctrine\\Common\\Collections\\.+" now to avoid errors or add an explicit @return annotation to suppress this message% +%Return type of Doctrine\\Common\\Collections\\(ArrayCollection|AbstractLazyCollection)::count\(\) should either be compatible with Countable::count\(\): int, or the \#\[\\ReturnTypeWillChange\] attribute should be used to temporarily suppress the notice% +%Return type of Doctrine\\Common\\Collections\\(ArrayCollection|AbstractLazyCollection)::getIterator\(\) should either be compatible with IteratorAggregate::getIterator\(\): Traversable, or the \#\[\\ReturnTypeWillChange\] attribute should be used to temporarily suppress the notice% +%Return type of Doctrine\\Common\\Collections\\(ArrayCollection|AbstractLazyCollection)::(offsetExists|offsetGet|offsetSet|offsetUnset)\(\$offset.*\) should either be compatible with ArrayAccess::(offsetExists|offsetGet|offsetSet|offsetUnset)\(mixed \$offset.*\): .+, or the \#\[\\ReturnTypeWillChange\] attribute should be used to temporarily suppress the notice% diff --git a/tests/config/doctrine.yaml b/tests/config/doctrine.yaml new file mode 100644 index 00000000..ddadaa05 --- /dev/null +++ b/tests/config/doctrine.yaml @@ -0,0 +1,19 @@ +doctrine: + dbal: + default_connection: default + connections: + default: + driver: pdo_sqlite + path: '%kernel.cache_dir%/test.sqlite' + types: + dummy_object_id: Meilisearch\Bundle\Tests\Dbal\Type\DummyObjectIdType + orm: + naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware + auto_mapping: true + mappings: + App: + is_bundle: false + type: attribute + dir: '%kernel.project_dir%/tests/Entity' + prefix: 'Meilisearch\Bundle\Tests\Entity' + alias: App diff --git a/tests/config/config_old_proxy.yaml b/tests/config/doctrine_old_proxy.yaml similarity index 82% rename from tests/config/config_old_proxy.yaml rename to tests/config/doctrine_old_proxy.yaml index 87de9ee1..55a89891 100644 --- a/tests/config/config_old_proxy.yaml +++ b/tests/config/doctrine_old_proxy.yaml @@ -1,8 +1,3 @@ -framework: - test: true - secret: 67d829bf61dc5f87a73fd814e2c9f629 - http_method_override: false - doctrine: dbal: default_connection: default @@ -14,7 +9,6 @@ doctrine: dummy_object_id: Meilisearch\Bundle\Tests\Dbal\Type\DummyObjectIdType orm: auto_generate_proxy_classes: true - report_fields_where_declared: true naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware auto_mapping: true mappings: diff --git a/tests/config/config_php7.yaml b/tests/config/doctrine_php7.yaml similarity index 76% rename from tests/config/config_php7.yaml rename to tests/config/doctrine_php7.yaml index 7f690a23..ee4a73a5 100644 --- a/tests/config/config_php7.yaml +++ b/tests/config/doctrine_php7.yaml @@ -1,13 +1,3 @@ -framework: - test: true - secret: 67d829bf61dc5f87a73fd814e2c9f629 - http_method_override: false - annotations: true - serializer: - enable_annotations: true - router: - utf8: true - doctrine: dbal: default_connection: default diff --git a/tests/config/config.yaml b/tests/config/doctrine_v2.yaml similarity index 83% rename from tests/config/config.yaml rename to tests/config/doctrine_v2.yaml index 5302d56e..7abc037c 100644 --- a/tests/config/config.yaml +++ b/tests/config/doctrine_v2.yaml @@ -1,8 +1,3 @@ -framework: - test: true - secret: 67d829bf61dc5f87a73fd814e2c9f629 - http_method_override: false - doctrine: dbal: default_connection: default @@ -15,7 +10,6 @@ doctrine: orm: enable_native_lazy_objects: true auto_generate_proxy_classes: false - report_fields_where_declared: true naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware auto_mapping: true mappings: diff --git a/tests/config/framework.yaml b/tests/config/framework.yaml new file mode 100644 index 00000000..f94709a2 --- /dev/null +++ b/tests/config/framework.yaml @@ -0,0 +1,4 @@ +framework: + test: true + secret: 67d829bf61dc5f87a73fd814e2c9f629 + http_method_override: false