Skip to content

Commit 3e00bfb

Browse files
committed
update test and fix CS
1 parent ad9603b commit 3e00bfb

11 files changed

+49
-15
lines changed

src/Collection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function map(callable $callback)
6565
*
6666
* @return static
6767
*/
68-
public function filter(?callable $callback = null)
68+
public function filter(callable $callback = null)
6969
{
7070
if (null !== $callback) {
7171
return new self(array_filter($this->items, $callback, ARRAY_FILTER_USE_BOTH));
@@ -143,7 +143,7 @@ public function unique($key = null, bool $strict = false)
143143
/**
144144
* Get the first item from the collection passing the given truth test.
145145
*/
146-
public function first(?callable $callback = null, $default = null)
146+
public function first(callable $callback = null, $default = null)
147147
{
148148
if (is_null($callback)) {
149149
if (empty($this->items)) {
@@ -339,7 +339,7 @@ private static function existsInArray($array, $key): bool
339339
return array_key_exists($key, $array);
340340
}
341341

342-
private function operatorForWhere(string $key, ?string $operator = null, $value = null): \Closure
342+
private function operatorForWhere(string $key, string $operator = null, $value = null): \Closure
343343
{
344344
if (1 === func_num_args()) {
345345
$value = true;

src/Exception/InvalidIndiceException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
final class InvalidIndiceException extends \InvalidArgumentException
88
{
9-
public function __construct(string $indice, $code = 0, ?\Throwable $previous = null)
9+
public function __construct(string $indice, $code = 0, \Throwable $previous = null)
1010
{
1111
parent::__construct(sprintf('Meilisearch index for "%s" was not found.', $indice), $code, $previous);
1212
}

src/Model/Aggregator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static function getEntityClassFromObjectID(string $objectId): string
7373
throw new EntityNotFoundInObjectID("Entity class from ObjectID $objectId not found.");
7474
}
7575

76-
public function normalize(NormalizerInterface $normalizer, ?string $format = null, array $context = []): array
76+
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = []): array
7777
{
7878
return array_merge(['objectID' => $this->objectID], $normalizer->normalize($this->entity, $format, $context));
7979
}

src/SearchableEntity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(
3838
string $indexUid,
3939
$entity,
4040
ClassMetadata $entityMetadata,
41-
?NormalizerInterface $normalizer = null,
41+
NormalizerInterface $normalizer = null,
4242
array $extra = []
4343
) {
4444
$this->indexUid = $indexUid;

src/Services/MeilisearchService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ final class MeilisearchService implements SearchService
4242
private array $classToSerializerGroup;
4343
private array $indexIfMapping;
4444

45-
public function __construct(NormalizerInterface $normalizer, Engine $engine, array $configuration, ?PropertyAccessorInterface $propertyAccessor = null)
45+
public function __construct(NormalizerInterface $normalizer, Engine $engine, array $configuration, PropertyAccessorInterface $propertyAccessor = null)
4646
{
4747
$this->normalizer = $normalizer;
4848
$this->engine = $engine;

src/Services/SettingsUpdater.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(SearchService $searchService, Client $searchClient,
3333
* @param non-empty-string $indice
3434
* @param positive-int|null $responseTimeout
3535
*/
36-
public function update(string $indice, ?int $responseTimeout = null): void
36+
public function update(string $indice, int $responseTimeout = null): void
3737
{
3838
$index = (new Collection($this->configuration->get('indices')))->firstWhere('prefixed_name', $indice);
3939

src/Services/UnixTimestampNormalizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ final class UnixTimestampNormalizer implements NormalizerInterface
1111
/**
1212
* @param \DateTimeInterface $object
1313
*/
14-
public function normalize($object, ?string $format = null, array $context = []): int
14+
public function normalize($object, string $format = null, array $context = []): int
1515
{
1616
return $object->getTimestamp();
1717
}
1818

1919
/**
2020
* @param mixed $data
2121
*/
22-
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
22+
public function supportsNormalization($data, string $format = null, array $context = []): bool
2323
{
2424
return $data instanceof \DateTimeInterface && true === ($context['meilisearch'] ?? null);
2525
}

tests/BaseKernelTestCase.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Meilisearch\Bundle\SearchableEntity;
1111
use Meilisearch\Bundle\SearchService;
1212
use Meilisearch\Bundle\Tests\Entity\Comment;
13+
use Meilisearch\Bundle\Tests\Entity\ExternalLink;
1314
use Meilisearch\Bundle\Tests\Entity\Image;
1415
use Meilisearch\Bundle\Tests\Entity\Link;
1516
use Meilisearch\Bundle\Tests\Entity\ObjectId\DummyObjectId;
@@ -42,7 +43,7 @@ protected function setUp(): void
4243
$this->cleanUp();
4344
}
4445

45-
protected function createPost(?int $id = null): Post
46+
protected function createPost(int $id = null): Post
4647
{
4748
$post = new Post();
4849
$post->setTitle('Test Post');
@@ -83,7 +84,7 @@ protected function createSearchablePost(): SearchableEntity
8384
);
8485
}
8586

86-
protected function createComment(?int $id = null): Comment
87+
protected function createComment(int $id = null): Comment
8788
{
8889
$post = new Post(['title' => 'What a post!']);
8990
$comment = new Comment();
@@ -101,7 +102,7 @@ protected function createComment(?int $id = null): Comment
101102
return $comment;
102103
}
103104

104-
protected function createImage(?int $id = null): Image
105+
protected function createImage(int $id = null): Image
105106
{
106107
$image = new Image();
107108
$image->setUrl('https://docs.meilisearch.com/logo.png');
@@ -148,7 +149,7 @@ protected function createTag(array $properties = []): Tag
148149

149150
protected function createLink(array $properties = []): Link
150151
{
151-
$link = new Link();
152+
$link = new ExternalLink();
152153
$link->setName('Meilisearch Test Link');
153154

154155
if (count($properties) > 0) {

tests/Entity/ExternalLink.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Meilisearch\Bundle\Tests\Entity;
6+
7+
use Doctrine\ORM\Mapping as ORM;
8+
9+
/**
10+
* @ORM\Entity
11+
*/
12+
#[ORM\Entity]
13+
class ExternalLink extends Link
14+
{
15+
}

tests/Entity/InternalLink.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Meilisearch\Bundle\Tests\Entity;
6+
7+
use Doctrine\ORM\Mapping as ORM;
8+
9+
/**
10+
* @ORM\Entity
11+
*/
12+
#[ORM\Entity]
13+
class InternalLink extends Link
14+
{
15+
}

tests/Entity/Link.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
* @ORM\Entity
1515
*/
1616
#[ORM\Entity]
17-
class Link implements NormalizableInterface
17+
#[ORM\InheritanceType('JOINED')]
18+
#[ORM\DiscriminatorColumn(name: 'type', type: 'integer')]
19+
#[ORM\DiscriminatorMap([1 => ExternalLink::class, 2 => InternalLink::class])]
20+
abstract class Link implements NormalizableInterface
1821
{
1922
/**
2023
* @ORM\Id

0 commit comments

Comments
 (0)