File tree Expand file tree Collapse file tree 6 files changed +53
-7
lines changed Expand file tree Collapse file tree 6 files changed +53
-7
lines changed Original file line number Diff line number Diff line change 28
28
"psr-4" : {
29
29
"MeiliSearch\\ " : " src/" ,
30
30
"Meilisearch\\ " : " src/"
31
- }
31
+ },
32
+ "files" : [" src/polyfills.php" ]
32
33
},
33
34
"autoload-dev" : {
34
35
"psr-4" : {
Original file line number Diff line number Diff line change @@ -10,5 +10,7 @@ parameters:
10
10
paths :
11
11
- src
12
12
- tests
13
+ tips :
14
+ treatPhpDocTypesAsCertain : false
13
15
additionalConstructors :
14
16
- PHPUnit\Framework\TestCase::setUp
Original file line number Diff line number Diff line change @@ -29,12 +29,6 @@ public function getDocuments(?DocumentsQuery $options = null): DocumentsResults
29
29
if ($ options ->hasFilter ()) {
30
30
$ response = $ this ->http ->post (self ::PATH .'/ ' .$ this ->uid .'/documents/fetch ' , $ query );
31
31
} else {
32
- if (isset ($ query ['sort ' ])) {
33
- $ query ['sort ' ] = implode (', ' , $ query ['sort ' ]);
34
- }
35
- if (isset ($ query ['fields ' ])) {
36
- $ query ['fields ' ] = implode (', ' , $ query ['fields ' ]);
37
- }
38
32
$ response = $ this ->http ->get (self ::PATH .'/ ' .$ this ->uid .'/documents ' , $ query );
39
33
}
40
34
Original file line number Diff line number Diff line change @@ -165,6 +165,9 @@ private function buildQueryString(array $queryParams = []): string
165
165
if (\is_bool ($ value )) {
166
166
$ queryParams [$ key ] = $ value ? 'true ' : 'false ' ;
167
167
}
168
+ if (\is_array ($ value ) && array_is_list ($ value )) {
169
+ $ queryParams [$ key ] = implode (', ' , $ value );
170
+ }
168
171
}
169
172
170
173
return \count ($ queryParams ) > 0 ? '? ' .http_build_query ($ queryParams ) : '' ;
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ if (!function_exists ('array_is_list ' )) {
6
+ /**
7
+ * @param array<mixed, mixed> $array
8
+ *
9
+ * @see https://github.com/symfony/polyfill/blob/1.x/src/Php81/Php81.php
10
+ */
11
+ function array_is_list (array $ array ): bool
12
+ {
13
+ if ([] === $ array || $ array === array_values ($ array )) {
14
+ return true ;
15
+ }
16
+
17
+ $ nextKey = -1 ;
18
+
19
+ foreach ($ array as $ k => $ v ) {
20
+ if ($ k !== ++$ nextKey ) {
21
+ return false ;
22
+ }
23
+ }
24
+
25
+ return true ;
26
+ }
27
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Tests ;
6
+
7
+ use PHPUnit \Framework \Attributes \RequiresPhp ;
8
+
9
+ class PollyfillsTest extends TestCase
10
+ {
11
+ #[RequiresPhp('< 8.0 ' )]
12
+ public function testArrayIsList (): void
13
+ {
14
+ self ::assertTrue (array_is_list ([])); // @phpstan-ignore-line
15
+ self ::assertTrue (array_is_list (['foo ' , 'bar ' ])); // @phpstan-ignore-line
16
+ self ::assertFalse (array_is_list (['foo ' => 'bar ' ])); // @phpstan-ignore-line
17
+ self ::assertFalse (array_is_list ([0 => 'foo ' , 'foo ' => 'bar ' ])); // @phpstan-ignore-line
18
+ }
19
+ }
You can’t perform that action at this time.
0 commit comments