Skip to content

Commit 937157e

Browse files
JulesEfreiEpx-jules
authored andcommitted
chore: fix deprecated and typos
1 parent 73d4ce1 commit 937157e

File tree

6 files changed

+19
-21
lines changed

6 files changed

+19
-21
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"scripts": {
4040
"typesenseServer": [
4141
"Composer\\Config::disableProcessTimeout",
42-
"docker run -i -p 8108:8108 -v/tmp/typesense-server-data-1c/:/data typesense/typesense:27.1 --data-dir /data --api-key=123 --listen-port 8108 --enable-cors"
42+
"docker run -i -p 8108:8108 -v/tmp/typesense-server-data-1c/:/data typesense/typesense:29.0 --data-dir /data --api-key=123 --listen-port 8108 --enable-cors"
4343
]
4444
},
4545
"config": {

src/EventListener/TypesenseIndexer.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use ACSEO\TypesenseBundle\Manager\CollectionManager;
88
use ACSEO\TypesenseBundle\Manager\DocumentManager;
99
use ACSEO\TypesenseBundle\Transformer\DoctrineToTypesenseTransformer;
10-
use Doctrine\Common\Util\ClassUtils;
1110
use Doctrine\Persistence\Event\LifecycleEventArgs;
1211

1312
class TypesenseIndexer
@@ -140,26 +139,28 @@ private function resetDocuments()
140139

141140
private function entityIsNotManaged($entity)
142141
{
143-
$entityClassname = ClassUtils::getClass($entity);
142+
$entityClassname = get_class($entity);
144143

145144
return !in_array($entityClassname, array_values($this->managedClassNames), true);
146145
}
147146

148147
private function getCollectionName($entity)
149148
{
150-
$entityClassname = ClassUtils::getClass($entity);
149+
$entityClassname = get_class($entity);
151150

152151
return array_search($entityClassname, $this->managedClassNames, true);
153152
}
154153

155154
private function getCollectionKey($entity)
156155
{
157-
$entityClassname = ClassUtils::getClass($entity);
156+
$entityClassname = get_class($entity);
158157

159158
foreach ($this->collectionManager->getCollectionDefinitions() as $key => $def) {
160159
if ($def['entity'] === $entityClassname) {
161160
return $key;
162161
}
163162
}
163+
164+
return null;
164165
}
165166
}

src/Finder/TypesenseQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class TypesenseQuery
88
{
99
private $searchParameters;
1010

11-
public function __construct(string $q = null, string $queryBy = null)
11+
public function __construct(?string $q = null, ?string $queryBy = null)
1212
{
1313
$this->searchParameters = [];
1414
if ($q !== null) {

src/Transformer/DoctrineToTypesenseTransformer.php

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

55
namespace ACSEO\TypesenseBundle\Transformer;
66

7-
use App\Doctrine\Entity\Site\Site;
87
use Doctrine\Common\Collections\Collection;
9-
use Doctrine\Common\Util\ClassUtils;
10-
use Doctrine\ORM\PersistentCollection;
118
use Symfony\Component\DependencyInjection\ContainerInterface;
129
use Symfony\Component\PropertyAccess\Exception\RuntimeException;
1310
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
@@ -33,7 +30,7 @@ public function __construct(array $collectionDefinitions, PropertyAccessorInterf
3330

3431
public function convert($entity): array
3532
{
36-
$entityClass = ClassUtils::getClass($entity);
33+
$entityClass = get_class($entity);
3734

3835
// See : https://github.com/acseo/TypesenseBundle/pull/91
3936
// Allow subclasses to be recognized as a parent class

tests/Functional/TypesenseInteractionsTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use Doctrine\ORM\Query;
2121
use Doctrine\ORM\Configuration;
2222
use Doctrine\ORM\EntityManager;
23-
use Doctrine\ORM\Event\LifecycleEventArgs;
23+
use Doctrine\Persistence\Event\LifecycleEventArgs;
2424
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
2525
use Symfony\Component\Console\Application;
2626
use Symfony\Component\Console\Tester\CommandTester;
@@ -33,8 +33,8 @@
3333
*/
3434
class TypesenseInteractionsTest extends KernelTestCase
3535
{
36-
public const NB_BOOKS = 5;
37-
public const BOOK_TITLES = [
36+
public const int NB_BOOKS = 5;
37+
public const array BOOK_TITLES = [
3838
'Total Khéops',
3939
'Chourmo',
4040
'Solea',
@@ -95,7 +95,7 @@ public function testImportCommand($nbBooks, $maxPerPage = null, $firstPage = nul
9595
);
9696
}
9797

98-
public function importCommandProvider()
98+
public function importCommandProvider(): array
9999
{
100100
return [
101101
"insert 10 books one by one" => [
@@ -105,7 +105,7 @@ public function importCommandProvider()
105105
42, 10
106106
],
107107
"insert 130 books 100 per 100" => [
108-
130, null //100 is by defaut
108+
130, null //100 is by default
109109
],
110110
"insert 498 books 50 per 50, from page 8 to 10 and expect 148 inserted" => [
111111
498, 50, 8, 10, 148
@@ -129,12 +129,12 @@ public function testSearchByAuthor($nbBooks)
129129
$bookFinder = new CollectionFinder($collectionClient, $em, $bookDefinition);
130130
$query = new TypesenseQuery('Nicolas', 'author');
131131

132-
$query->maxHits($nbBooks < 250 ? $nbBooks : 250);
133-
$query->perPage($nbBooks < 250 ? $nbBooks : 250);
132+
$query->maxHits(min($nbBooks, 250));
133+
$query->perPage(min($nbBooks, 250));
134134

135135
$results = $bookFinder->rawQuery($query)->getResults();
136136

137-
self::assertCount(($nbBooks < 250 ? $nbBooks : 250), $results, "result doesn't contains ".$nbBooks.' elements');
137+
self::assertCount((min($nbBooks, 250)), $results, "result doesn't contains ".$nbBooks.' elements');
138138
self::assertArrayHasKey('document', $results[0], "First item does not have the key 'document'");
139139
self::assertArrayHasKey('highlights', $results[0], "First item does not have the key 'highlights'");
140140
self::assertArrayHasKey('text_match', $results[0], "First item does not have the key 'text_match'");
@@ -284,7 +284,7 @@ private function importCommandTester($options): CommandTester
284284
return new CommandTester($application->find('typesense:import'));
285285
}
286286

287-
private function getCollectionDefinitions($entityClass)
287+
private function getCollectionDefinitions($entityClass): array
288288
{
289289
return [
290290
'books' => [
@@ -343,7 +343,7 @@ private function getCollectionDefinitions($entityClass)
343343
];
344344
}
345345

346-
private function getMockedBooks($options)
346+
private function getMockedBooks($options): array
347347
{
348348
$author = new Author('Nicolas Potier', 'France');
349349
$books = [];

tests/Unit/Finder/TypesenseQueryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function testSimpleQuery()
2121

2222
public function testComplexQuery()
2323
{
24-
$query = (new TypesenseQuery('search term', 'search field'))
24+
$query = new TypesenseQuery('search term', 'search field')
2525
->prefix(false)
2626
->filterBy('filter term')
2727
->sortBy('sort term')

0 commit comments

Comments
 (0)