Skip to content

Commit bca9ccd

Browse files
committed
Fix deprecations
1 parent eec319d commit bca9ccd

File tree

7 files changed

+53
-2
lines changed

7 files changed

+53
-2
lines changed

.php-cs-fixer.dist.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@
2323
'no_superfluous_phpdoc_tags' => false,
2424
// @todo: when we'll support only PHP 8.0 and upper, we can enable `parameters` for `trailing_comma_in_multiline` rule
2525
'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['array_destructuring', 'arrays', 'match'/* , 'parameters' */]],
26+
// @todo: when we'll support only PHP 8.0 and upper, we can enable this
27+
'get_class_to_class_keyword' => false,
2628
]);

src/Services/MeilisearchService.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Meilisearch\Bundle\Services;
66

77
use Doctrine\Common\Util\ClassUtils;
8+
use Doctrine\ORM\Mapping\LegacyReflectionFields;
89
use Doctrine\ORM\Proxy\DefaultProxyClassNameResolver;
910
use Doctrine\Persistence\ObjectManager;
1011
use Meilisearch\Bundle\Collection;
@@ -374,6 +375,11 @@ private static function resolveClass(object $object): string
374375
static $resolver;
375376

376377
$resolver ??= (function () {
378+
// Native lazy objects compatibility
379+
if (PHP_VERSION_ID >= 80400 && class_exists(LegacyReflectionFields::class)) {
380+
return fn (object $object) => get_class($object);
381+
}
382+
377383
// Doctrine ORM v3+ compatibility
378384
if (class_exists(DefaultProxyClassNameResolver::class)) {
379385
return fn (object $object) => DefaultProxyClassNameResolver::getClass($object);

tests/Integration/AggregatorTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Meilisearch\Bundle\Tests\Integration;
66

7+
use Doctrine\ORM\Mapping\LegacyReflectionFields;
78
use Doctrine\Persistence\Proxy;
89
use Meilisearch\Bundle\Exception\EntityNotFoundInObjectID;
910
use Meilisearch\Bundle\Exception\InvalidEntityForAggregator;
@@ -35,6 +36,10 @@ public function testConstructor(): void
3536

3637
public function testAggregatorProxyClass(): void
3738
{
39+
if (class_exists(LegacyReflectionFields::class)) {
40+
$this->markTestSkipped('Skipping, because proxies are not wrapped anymore with lazy native objects.');
41+
}
42+
3843
$this->entityManager->persist($post = new Post());
3944
$this->entityManager->flush();
4045
$postId = $post->getId();

tests/Kernel.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Doctrine\Bundle\DoctrineBundle\ConnectionFactory;
88
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
99
use Doctrine\ORM\Configuration;
10+
use Doctrine\ORM\Mapping\LegacyReflectionFields;
1011
use Meilisearch\Bundle\MeilisearchBundle;
1112
use Symfony\Bridge\Doctrine\ArgumentResolver\EntityValueResolver;
1213
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
@@ -29,7 +30,11 @@ public function registerBundles(): iterable
2930
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
3031
{
3132
if (PHP_VERSION_ID >= 80000) {
32-
$loader->load(__DIR__.'/config/config.yaml');
33+
if (class_exists(LegacyReflectionFields::class) && PHP_VERSION_ID >= 80400) {
34+
$loader->load(__DIR__.'/config/config.yaml');
35+
} else {
36+
$loader->load(__DIR__.'/config/config_old_proxy.yaml');
37+
}
3338
} else {
3439
$loader->load(__DIR__.'/config/config_php7.yaml');
3540
}

tests/baseline-ignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
%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.%
22
%Since symfony/var-exporter 7.3: The "Symfony\\Component\\VarExporter\\LazyGhostTrait" trait is deprecated, use native lazy objects instead.%
33
%Since symfony/var-exporter 7.3: Using ProxyHelper::generateLazyGhost\(\) is deprecated, use native lazy objects instead.%
4+
%Class "Doctrine\\ORM\\Proxy\\Autoloader" is deprecated. Use native lazy objects instead.%
5+
%Calling Doctrine\\ORM\\Configuration::setProxyDir is deprecated and will not be possible in Doctrine ORM 4.0%
6+
%Calling Doctrine\\ORM\\Configuration::getProxyDir is deprecated and will not be possible in Doctrine ORM 4.0%
7+
%Calling Doctrine\\ORM\\Configuration::setAutoGenerateProxyClasses is deprecated and will not be possible in Doctrine ORM 4.0%
8+
%Calling Doctrine\\ORM\\Configuration::getAutoGenerateProxyClasses is deprecated and will not be possible in Doctrine ORM 4.0%
9+
%Calling Doctrine\\ORM\\Configuration::setProxyNamespace is deprecated and will not be possible in Doctrine ORM 4.0%

tests/config/config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ doctrine:
1313
types:
1414
dummy_object_id: Meilisearch\Bundle\Tests\Dbal\Type\DummyObjectIdType
1515
orm:
16-
auto_generate_proxy_classes: true
16+
enable_native_lazy_objects: true
17+
auto_generate_proxy_classes: false
1718
report_fields_where_declared: true
1819
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
1920
auto_mapping: true

tests/config/config_old_proxy.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
framework:
2+
test: true
3+
secret: 67d829bf61dc5f87a73fd814e2c9f629
4+
http_method_override: false
5+
6+
doctrine:
7+
dbal:
8+
default_connection: default
9+
connections:
10+
default:
11+
driver: pdo_sqlite
12+
path: '%kernel.cache_dir%/test.sqlite'
13+
types:
14+
dummy_object_id: Meilisearch\Bundle\Tests\Dbal\Type\DummyObjectIdType
15+
orm:
16+
auto_generate_proxy_classes: true
17+
report_fields_where_declared: true
18+
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
19+
auto_mapping: true
20+
mappings:
21+
App:
22+
is_bundle: false
23+
type: attribute
24+
dir: '%kernel.project_dir%/tests/Entity'
25+
prefix: 'Meilisearch\Bundle\Tests\Entity'
26+
alias: App

0 commit comments

Comments
 (0)