Skip to content

Commit 1b16382

Browse files
Merge #259
259: Fix deprecations r=brunoocasali a=norkunas # Pull Request ## Related issue Fixes #258 ## What does this PR do? - Fixes deprecations ## PR checklist Please check if your PR fulfills the following requirements: - [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)? - [x] Have you read the contributing guidelines? - [x] Have you made sure that the title is accurate and descriptive of the changes? Co-authored-by: Tomas <[email protected]>
2 parents e4411ca + 3d9752d commit 1b16382

18 files changed

+29
-99
lines changed

.php-cs-fixer.dist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
'import_functions' => false,
1717
'import_constants' => false,
1818
],
19+
'no_superfluous_phpdoc_tags' => false,
1920
]
2021
)
2122
->setRiskyAllowed(true)

config/services.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
class="Meilisearch\Bundle\EventListener\DoctrineEventSubscriber"
1313
public="true">
1414
<argument type="service" id="search.service"/>
15-
<argument type="collection"/> <!-- doctrine subscribed events -->
16-
<tag name="doctrine.event_subscriber"/>
17-
<tag name="doctrine_mongodb.odm.event_subscriber"/>
1815
</service>
1916

2017
<service id="search.client" class="Meilisearch\Client" public="true" lazy="true">

src/Collection.php

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ final class Collection implements \ArrayAccess, \Countable, \IteratorAggregate
1717
*/
1818
private array $items;
1919

20-
/**
21-
* @param mixed $items
22-
*/
2320
public function __construct($items = [])
2421
{
2522
$this->items = $this->getArrayableItems($items);
@@ -30,12 +27,6 @@ public function all(): array
3027
return $this->items;
3128
}
3229

33-
/**
34-
* @param mixed $key
35-
* @param mixed $default
36-
*
37-
* @return mixed
38-
*/
3930
public function get($key, $default = null)
4031
{
4132
if (array_key_exists($key, $this->items)) {
@@ -151,10 +142,6 @@ public function unique($key = null, bool $strict = false)
151142

152143
/**
153144
* Get the first item from the collection passing the given truth test.
154-
*
155-
* @param mixed $default
156-
*
157-
* @return mixed
158145
*/
159146
public function first(callable $callback = null, $default = null)
160147
{
@@ -181,27 +168,18 @@ public function first(callable $callback = null, $default = null)
181168
* Get the first item by the given key value pair.
182169
*
183170
* @param string $key
184-
* @param mixed $operator
185-
* @param mixed $value
186-
*
187-
* @return mixed
188171
*/
189172
public function firstWhere($key, $operator = null, $value = null)
190173
{
191174
return $this->first($this->operatorForWhere(...func_get_args()));
192175
}
193176

194-
/**
195-
* @param mixed $offset
196-
*/
197177
public function offsetExists($offset): bool
198178
{
199179
return isset($this->items[$offset]);
200180
}
201181

202182
/**
203-
* @param mixed $offset
204-
*
205183
* @return mixed
206184
*/
207185
#[\ReturnTypeWillChange]
@@ -210,10 +188,6 @@ public function offsetGet($offset)
210188
return $this->items[$offset];
211189
}
212190

213-
/**
214-
* @param mixed $offset
215-
* @param mixed $value
216-
*/
217191
public function offsetSet($offset, $value): void
218192
{
219193
if (is_null($offset)) {
@@ -223,9 +197,6 @@ public function offsetSet($offset, $value): void
223197
}
224198
}
225199

226-
/**
227-
* @param mixed $offset
228-
*/
229200
public function offsetUnset($offset): void
230201
{
231202
unset($this->items[$offset]);
@@ -241,9 +212,6 @@ public function getIterator(): \ArrayIterator
241212
return new \ArrayIterator($this->items);
242213
}
243214

244-
/**
245-
* @param mixed $items
246-
*/
247215
private function getArrayableItems($items): array
248216
{
249217
if (is_array($items)) {
@@ -269,9 +237,6 @@ private function getArrayableItems($items): array
269237
return (array) $items;
270238
}
271239

272-
/**
273-
* @param mixed $value
274-
*/
275240
private function useAsCallable($value): bool
276241
{
277242
return !is_string($value) && is_callable($value);
@@ -292,11 +257,7 @@ private function valueRetriever($value)
292257
}
293258

294259
/**
295-
* @param mixed $target
296260
* @param string|array|int|null $key
297-
* @param mixed $default
298-
*
299-
* @return mixed
300261
*/
301262
private static function getDeepData($target, $key, $default = null)
302263
{
@@ -358,9 +319,6 @@ public static function arrayCollapse(iterable $array): array
358319
return array_merge([], ...$results);
359320
}
360321

361-
/**
362-
* @param mixed $value
363-
*/
364322
public static function accessible($value): bool
365323
{
366324
return is_array($value) || $value instanceof \ArrayAccess;
@@ -381,10 +339,7 @@ private static function existsInArray($array, $key): bool
381339
return array_key_exists($key, $array);
382340
}
383341

384-
/**
385-
* @param mixed $value
386-
*/
387-
private function operatorForWhere(string $key, ?string $operator = null, $value = null): \Closure
342+
private function operatorForWhere(string $key, string $operator = null, $value = null): \Closure
388343
{
389344
if (1 === func_num_args()) {
390345
$value = true;

src/DependencyInjection/MeilisearchExtension.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
*/
2020
final class MeilisearchExtension extends Extension
2121
{
22-
/**
23-
* {@inheritdoc}
24-
*/
2522
public function load(array $configs, ContainerBuilder $container): void
2623
{
2724
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../../config'));
@@ -39,7 +36,12 @@ public function load(array $configs, ContainerBuilder $container): void
3936
$container->setParameter('meili_symfony_version', MeilisearchBundle::qualifiedVersion());
4037

4138
if (\count($doctrineEvents = $config['doctrineSubscribedEvents']) > 0) {
42-
$container->getDefinition('search.search_indexer_subscriber')->setArgument(1, $doctrineEvents);
39+
$subscriber = $container->getDefinition('search.search_indexer_subscriber');
40+
41+
foreach ($doctrineEvents as $event) {
42+
$subscriber->addTag('doctrine.event_listener', ['event' => $event]);
43+
$subscriber->addTag('doctrine_mongodb.odm.event_listener', ['event' => $event]);
44+
}
4345
} else {
4446
$container->removeDefinition('search.search_indexer_subscriber');
4547
}

src/EventListener/DoctrineEventSubscriber.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,16 @@
44

55
namespace Meilisearch\Bundle\EventListener;
66

7-
use Doctrine\Common\EventSubscriber;
87
use Doctrine\Persistence\Event\LifecycleEventArgs;
98
use Meilisearch\Bundle\SearchService;
109

11-
final class DoctrineEventSubscriber implements EventSubscriber
10+
final class DoctrineEventSubscriber
1211
{
1312
private SearchService $searchService;
14-
private array $subscribedEvents;
1513

16-
public function __construct(SearchService $searchService, array $subscribedEvents)
14+
public function __construct(SearchService $searchService)
1715
{
1816
$this->searchService = $searchService;
19-
$this->subscribedEvents = $subscribedEvents;
20-
}
21-
22-
public function getSubscribedEvents(): array
23-
{
24-
return $this->subscribedEvents;
2517
}
2618

2719
public function postUpdate(LifecycleEventArgs $args): void

src/Model/Aggregator.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,7 @@ public static function getEntityClassFromObjectID(string $objectId): string
7878
throw new EntityNotFoundInObjectID("Entity class from ObjectID $objectId not found.");
7979
}
8080

81-
/**
82-
* {@inheritdoc}
83-
*/
84-
public function normalize(NormalizerInterface $normalizer, ?string $format = null, array $context = []): array
81+
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = []): array
8582
{
8683
return array_merge(['objectID' => $this->objectID], $normalizer->normalize($this->entity, $format, $context));
8784
}

src/SearchableEntity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(
4343
string $indexUid,
4444
$entity,
4545
ClassMetadata $entityMetadata,
46-
?NormalizerInterface $normalizer = null,
46+
NormalizerInterface $normalizer = null,
4747
array $extra = []
4848
) {
4949
$this->indexUid = $indexUid;

src/Services/MeilisearchService.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ public function __construct(NormalizerInterface $normalizer, Engine $engine, arr
4646
$this->setIndexIfMapping();
4747
}
4848

49-
/**
50-
* {@inheritdoc}
51-
*/
5249
public function isSearchable($className): bool
5350
{
5451
if (is_object($className)) {
@@ -68,9 +65,6 @@ public function getConfiguration(): Collection
6865
return $this->configuration;
6966
}
7067

71-
/**
72-
* {@inheritdoc}
73-
*/
7468
public function searchableAs(string $className): string
7569
{
7670
$indexes = new Collection($this->getConfiguration()->get('indices'));
@@ -185,9 +179,6 @@ public function search(
185179
return $results;
186180
}
187181

188-
/**
189-
* {@inheritdoc}
190-
*/
191182
public function rawSearch(
192183
string $className,
193184
string $query = '',

tests/Entity/Link.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,6 @@ public function setIsSponsored(bool $isSponsored): Link
9191
return $this;
9292
}
9393

94-
/**
95-
* {@inheritDoc}
96-
*/
9794
public function normalize(NormalizerInterface $normalizer, $format = null, array $context = []): array
9895
{
9996
if (Searchable::NORMALIZATION_FORMAT === $format) {

tests/Entity/Page.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Page
2727
#[ORM\Id]
2828
#[ORM\GeneratedValue(strategy: 'NONE')]
2929
#[ORM\Column(type: Types::OBJECT)]
30-
private $id = null;
30+
private $id;
3131

3232
/**
3333
* @ORM\Column(type="string", nullable=true)

tests/Entity/Tag.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ public function setPublic(bool $public): Tag
8888
}
8989

9090
/**
91-
* {@inheritDoc}
92-
*
9391
* @throws ExceptionInterface
9492
*/
9593
public function normalize(NormalizerInterface $normalizer, $format = null, array $context = []): array

tests/Integration/EventListener/DoctrineEventSubscriberTest.php

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

55
namespace Meilisearch\Bundle\Tests\Integration\EventListener;
66

7-
use Doctrine\ORM\Event\LifecycleEventArgs;
7+
use Doctrine\Persistence\Event\LifecycleEventArgs;
88
use Meilisearch\Bundle\EventListener\DoctrineEventSubscriber;
99
use Meilisearch\Bundle\Tests\BaseKernelTestCase;
1010
use Meilisearch\Bundle\Tests\Entity\Page;
@@ -35,7 +35,7 @@ public function testPostPersist(): void
3535

3636
$eventArgs = new LifecycleEventArgs($post, $this->entityManager);
3737

38-
$subscriber = new DoctrineEventSubscriber($this->searchService, []);
38+
$subscriber = new DoctrineEventSubscriber($this->searchService);
3939
$subscriber->postPersist($eventArgs);
4040

4141
$this->waitForAllTasks();
@@ -53,7 +53,7 @@ public function testPostPersistWithObjectId(): void
5353

5454
$eventArgs = new LifecycleEventArgs($page, $this->entityManager);
5555

56-
$subscriber = new DoctrineEventSubscriber($this->searchService, []);
56+
$subscriber = new DoctrineEventSubscriber($this->searchService);
5757
$subscriber->postPersist($eventArgs);
5858

5959
$this->waitForAllTasks();
@@ -74,7 +74,7 @@ public function testPostUpdate(): void
7474

7575
$eventArgs = new LifecycleEventArgs($post, $this->entityManager);
7676

77-
$subscriber = new DoctrineEventSubscriber($this->searchService, []);
77+
$subscriber = new DoctrineEventSubscriber($this->searchService);
7878
$subscriber->postUpdate($eventArgs);
7979

8080
$this->waitForAllTasks();
@@ -92,7 +92,7 @@ public function testPostUpdateWithObjectId(): void
9292

9393
$eventArgs = new LifecycleEventArgs($page, $this->entityManager);
9494

95-
$subscriber = new DoctrineEventSubscriber($this->searchService, []);
95+
$subscriber = new DoctrineEventSubscriber($this->searchService);
9696
$subscriber->postUpdate($eventArgs);
9797

9898
$this->waitForAllTasks();
@@ -113,7 +113,7 @@ public function testPreRemove(): void
113113

114114
$eventArgs = new LifecycleEventArgs($post, $this->entityManager);
115115

116-
$subscriber = new DoctrineEventSubscriber($this->searchService, []);
116+
$subscriber = new DoctrineEventSubscriber($this->searchService);
117117
$subscriber->postPersist($eventArgs);
118118

119119
$this->waitForAllTasks();
@@ -138,7 +138,7 @@ public function testPreRemoveWithObjectId(): void
138138

139139
$eventArgs = new LifecycleEventArgs($page, $this->entityManager);
140140

141-
$subscriber = new DoctrineEventSubscriber($this->searchService, []);
141+
$subscriber = new DoctrineEventSubscriber($this->searchService);
142142
$subscriber->postPersist($eventArgs);
143143

144144
$this->waitForAllTasks();

tests/Integration/SearchTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ class SearchTest extends BaseKernelTestCase
2929
protected Indexes $index;
3030

3131
/**
32-
* {@inheritDoc}
33-
*
3432
* @throws ApiException
3533
* @throws \Exception
3634
*/

tests/Kernel.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
class Kernel extends HttpKernel
1818
{
1919
/**
20-
* {@inheritDoc}
21-
*
2220
* @return array<int, BundleInterface>
2321
*/
2422
public function registerBundles(): array

tests/Unit/ConfigurationTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ class ConfigurationTest extends KernelTestCase
1414
{
1515
/**
1616
* @dataProvider dataTestConfigurationTree
17-
*
18-
* @param mixed $inputConfig
19-
* @param mixed $expectedConfig
2017
*/
2118
public function testConfigurationTree($inputConfig, $expectedConfig): void
2219
{

tests/baseline-ignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@
33
%The "Symfony\\Component\\HttpClient\\HttplugClient" class implements "Http\\Message\\RequestFactory" that is deprecated since version 1.1, use Psr\\Http\\Message\\RequestFactoryInterface instead.%
44
%The "Symfony\\Component\\HttpClient\\HttplugClient" class implements "Http\\Message\\StreamFactory" that is deprecated since version 1.1, use Psr\\Http\\Message\\StreamFactoryInterface instead.%
55
%The "Symfony\\Component\\HttpClient\\HttplugClient" class implements "Http\\Message\\UriFactory" that is deprecated since version 1.1, use Psr\\Http\\Message\\UriFactoryInterface instead.%
6+
%Doctrine\\DBAL\\Platforms\\AbstractPlatform::usesSequenceEmulatedIdentityColumns is deprecated. \(AbstractPlatform.php:\d+ called by ClassMetadataFactory.php:\d+, https://github.com/doctrine/dbal/pull/5513, package doctrine/dbal\)%
7+
%Column::setCustomSchemaOptions\(\) is deprecated. Use setPlatformOptions\(\) instead. \(Column.php:\d+ called by Column.php:\d+, https://github.com/doctrine/dbal/pull/5476, package doctrine/dbal\)%
8+
%SqlitePlatform::canEmulateSchemas\(\) is deprecated. \(SqlitePlatform.php:\d+ called by SchemaTool.php:\d+, https://github.com/doctrine/dbal/pull/4805, package doctrine/dbal\)%
9+
%Doctrine\\DBAL\\Schema\\Table::getPrimaryKeyColumns is deprecated. Use getPrimaryKey\(\) and Index::getColumns\(\) instead. \(Table.php:\d+ called by Table.php:\d+, https://github.com/doctrine/dbal/pull/5731, package doctrine/dbal\)%
10+
%The annotation mapping driver is deprecated and will be removed in Doctrine ORM 3.0, please migrate to the attribute or XML driver. \(AnnotationDriver.php:\d+ called by getDoctrine_Orm_DefaultAnnotationMetadataDriverService.php:20, https://github.com/doctrine/orm/issues/10098, package doctrine/orm\)%

tests/config/config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ doctrine:
1212
path: '%kernel.cache_dir%/test.sqlite'
1313
orm:
1414
auto_generate_proxy_classes: true
15-
naming_strategy: doctrine.orm.naming_strategy.underscore
15+
validate_xml_mapping: true
16+
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
1617
auto_mapping: true
1718
mappings:
1819
App:

0 commit comments

Comments
 (0)