Skip to content

Fix deprecations in tests #390

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

Merged
merged 2 commits into from
Jul 13, 2025
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
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
- trying
- staging
- main
schedule:
- cron: '0 3 * * 1'

env:
fail-fast: true
Expand Down
2 changes: 2 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@
'no_superfluous_phpdoc_tags' => false,
// @todo: when we'll support only PHP 8.0 and upper, we can enable `parameters` for `trailing_comma_in_multiline` rule
'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['array_destructuring', 'arrays', 'match'/* , 'parameters' */]],
// @todo: when we'll support only PHP 8.0 and upper, we can enable this
'get_class_to_class_keyword' => false,
]);
6 changes: 6 additions & 0 deletions src/Services/MeilisearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Meilisearch\Bundle\Services;

use Doctrine\Common\Util\ClassUtils;
use Doctrine\ORM\Mapping\LegacyReflectionFields;
use Doctrine\ORM\Proxy\DefaultProxyClassNameResolver;
use Doctrine\Persistence\ObjectManager;
use Meilisearch\Bundle\Collection;
Expand Down Expand Up @@ -374,6 +375,11 @@ private static function resolveClass(object $object): string
static $resolver;

$resolver ??= (function () {
// Native lazy objects compatibility
if (PHP_VERSION_ID >= 80400 && class_exists(LegacyReflectionFields::class)) {
return fn (object $object) => \get_class($object);
}

// Doctrine ORM v3+ compatibility
if (class_exists(DefaultProxyClassNameResolver::class)) {
return fn (object $object) => DefaultProxyClassNameResolver::getClass($object);
Expand Down
5 changes: 5 additions & 0 deletions tests/Integration/AggregatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Meilisearch\Bundle\Tests\Integration;

use Doctrine\ORM\Mapping\LegacyReflectionFields;
use Doctrine\Persistence\Proxy;
use Meilisearch\Bundle\Exception\EntityNotFoundInObjectID;
use Meilisearch\Bundle\Exception\InvalidEntityForAggregator;
Expand Down Expand Up @@ -35,6 +36,10 @@ public function testConstructor(): void

public function testAggregatorProxyClass(): void
{
if (class_exists(LegacyReflectionFields::class)) {
$this->markTestSkipped('Skipping, because proxies are not wrapped anymore with lazy native objects.');
}

$this->entityManager->persist($post = new Post());
$this->entityManager->flush();
$postId = $post->getId();
Expand Down
7 changes: 6 additions & 1 deletion tests/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Doctrine\Bundle\DoctrineBundle\ConnectionFactory;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\Mapping\LegacyReflectionFields;
use Meilisearch\Bundle\MeilisearchBundle;
use Symfony\Bridge\Doctrine\ArgumentResolver\EntityValueResolver;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
Expand All @@ -29,7 +30,11 @@ public function registerBundles(): iterable
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
{
if (PHP_VERSION_ID >= 80000) {
$loader->load(__DIR__.'/config/config.yaml');
if (class_exists(LegacyReflectionFields::class) && PHP_VERSION_ID >= 80400) {
$loader->load(__DIR__.'/config/config.yaml');
} else {
$loader->load(__DIR__.'/config/config_old_proxy.yaml');
}
} else {
$loader->load(__DIR__.'/config/config_php7.yaml');
}
Expand Down
6 changes: 6 additions & 0 deletions tests/baseline-ignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
%Method "ArrayAccess::offsetGet\(\)" might add "mixed" as a native return type declaration in the future. Do the same in implementation "Meilisearch\\Contracts\\Data" now to avoid errors or add an explicit @return annotation to suppress this message.%
%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::setProxyNamespace is deprecated and will not be possible in Doctrine ORM 4.0%
3 changes: 2 additions & 1 deletion tests/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ doctrine:
types:
dummy_object_id: Meilisearch\Bundle\Tests\Dbal\Type\DummyObjectIdType
orm:
auto_generate_proxy_classes: true
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
Expand Down
26 changes: 26 additions & 0 deletions tests/config/config_old_proxy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
framework:
test: true
secret: 67d829bf61dc5f87a73fd814e2c9f629
http_method_override: false

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:
auto_generate_proxy_classes: true
report_fields_where_declared: true
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
Loading