Skip to content

Commit

Permalink
Merge pull request #61 from adrmrn/php84-compatibility
Browse files Browse the repository at this point in the history
Make package compatible with PHP 8.4
  • Loading branch information
hkulekci authored Nov 30, 2024
2 parents 0a92196 + 14b073d commit 9be8fa3
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 21 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- php-version: '8.1'
- php-version: '8.2'
- php-version: '8.3'
- php-version: '8.4'
services:
qdrant:
image: qdrant/qdrant
Expand Down
4 changes: 2 additions & 2 deletions src/Endpoints/Collections/Points.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function search(SearchRequest $searchParams, array $queryParams = []): Re
/**
* @throws InvalidArgumentException
*/
public function scroll(Filter|ScrollRequest $scrollParams = null, array $queryParams = []): Response
public function scroll(Filter|ScrollRequest|null $scrollParams = null, array $queryParams = []): Response
{
$body = [];
if ($scrollParams instanceof Filter) {
Expand Down Expand Up @@ -133,7 +133,7 @@ public function id(int|string $id, array $queryParams = []): Response
/**
* @throws InvalidArgumentException
*/
public function count(Filter $filter = null, $exact = false): Response
public function count(?Filter $filter = null, $exact = false): Response
{
$body = [
'exact' => $exact,
Expand Down
5 changes: 3 additions & 2 deletions src/Endpoints/Collections/Points/Payload.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ public function clear(array $points): Response
* @param array $points
* @param array $keys
* @param Filter|null $filter
* @param array $queryParams
* @return Response
* @throws InvalidArgumentException
*/
public function delete(array $points, array $keys, Filter $filter = null, array $queryParams = []): Response
public function delete(array $points, array $keys, ?Filter $filter = null, array $queryParams = []): Response
{
$data = [
'points' => $points,
Expand Down Expand Up @@ -75,4 +76,4 @@ public function set(array $points, array $payload, array $queryParams = []): Res
)
);
}
}
}
4 changes: 2 additions & 2 deletions src/Endpoints/Collections/Snapshots.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function download(string $snapshotName): Response
/**
* @throws InvalidArgumentException
*/
public function recover(bool $wait = null): Response
public function recover(?bool $wait = null): Response
{
return $this->client->execute(
$this->createRequest(
Expand All @@ -77,4 +77,4 @@ public function recover(bool $wait = null): Response
)
);
}
}
}
4 changes: 2 additions & 2 deletions src/Http/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class Builder
{
protected ?ClientInterface $client;
public function __construct(ClientInterface $client = null) {
public function __construct(?ClientInterface $client = null) {
$this->client = $client ?: Psr18ClientDiscovery::find();
}

Expand All @@ -26,4 +26,4 @@ public function build(Config $config): Transport
$config
);
}
}
}
2 changes: 1 addition & 1 deletion src/Models/MultiVectorStruct.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function getName(): ?string
return array_key_first($this->vectors);
}

public function toSearchArray(string $name = null): array
public function toSearchArray(?string $name = null): array
{
// Throw an error if no name is given
if ($name === null) {
Expand Down
4 changes: 2 additions & 2 deletions src/Models/Request/CreateCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CreateCollection implements RequestModel

protected ?QuantizationConfig $quantizationConfig = null;

public function addVector(VectorParams $vectorParams, string $name = null): CreateCollection
public function addVector(VectorParams $vectorParams, ?string $name = null): CreateCollection
{
if ($name !== null) {
$this->vectors[$name] = $vectorParams->toArray();
Expand Down Expand Up @@ -150,4 +150,4 @@ public function toArray(): array

return $data;
}
}
}
4 changes: 2 additions & 2 deletions src/Models/Request/CreateIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CreateIndex implements RequestModel
protected string $fieldName;
protected ?array $fieldSchema;

public function __construct(string $fieldName, array|string $fieldSchema = null)
public function __construct(string $fieldName, array|string|null $fieldSchema = null)
{
if (is_string($fieldSchema)) {
$this->fieldSchema = [
Expand All @@ -31,4 +31,4 @@ public function toArray(): array
'field_schema' => $this->fieldSchema
]);
}
}
}
4 changes: 2 additions & 2 deletions src/Models/VectorStruct.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function getName(): ?string
return $this->name;
}

public function toSearchArray(string $name = null): array
public function toSearchArray(?string $name = null): array
{
if ($this->isNamed()) {
return [
Expand All @@ -46,4 +46,4 @@ public function toArray(): array
}
return $this->vector;
}
}
}
4 changes: 2 additions & 2 deletions src/Models/VectorStructInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ public function getName(): ?string;
* @param string|null $name
* @return array
*/
public function toSearchArray(string $name = null): array;
public function toSearchArray(?string $name = null): array;

/**
* Convert this vector an array for Point and PointsBatch.
*
* @return array
*/
public function toArray(): array;
}
}
4 changes: 2 additions & 2 deletions src/Qdrant.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(private readonly Transport $transport)
{
}

public function collections(string $collectionName = null): Collections
public function collections(?string $collectionName = null): Collections
{
return (new Collections($this))->setCollectionName($collectionName);
}
Expand Down Expand Up @@ -60,4 +60,4 @@ public function execute(RequestInterface $request): Response

return new Response($res);
}
}
}
4 changes: 2 additions & 2 deletions tests/Integration/AbstractIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private static function sampleCollectionOption(): CreateCollection
->addVector(new VectorParams(3, VectorParams::DISTANCE_COSINE), 'text');
}

protected function createCollections($name, CreateCollection $withConfiguration = null): void
protected function createCollections($name, ?CreateCollection $withConfiguration = null): void
{
$this->collections = new Collections($this->client);
$response = $this->collections->setCollectionName($name)
Expand All @@ -55,4 +55,4 @@ public function getCollections(string $collectionsName): Collections

return $this->collections;
}
}
}

0 comments on commit 9be8fa3

Please sign in to comment.