Skip to content

Commit 96e2dde

Browse files
authored
Merge pull request hkulekci#35 from NiCr42/use-php-feature-constructor-property-promotion
Use php feature constructor property promotion
2 parents 5627d6e + 46c3a43 commit 96e2dde

28 files changed

+91
-137
lines changed

src/Config.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,11 @@
1010

1111
class Config
1212
{
13-
protected string $host;
1413

15-
protected string $port;
1614
protected ?string $apiKey = null;
1715

18-
public function __construct($host, $port = 6333)
16+
public function __construct(protected string $host, protected int $port = 6333)
1917
{
20-
$this->host = $host;
21-
$this->port = $port;
2218
}
2319

2420
public function getDomain(): string

src/Endpoints/AbstractEndpoint.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,10 @@
1515

1616
abstract class AbstractEndpoint
1717
{
18-
protected HttpClientInterface $client;
19-
2018
protected ?string $collectionName = null;
2119

22-
public function __construct(HttpClientInterface $client)
20+
public function __construct(protected HttpClientInterface $client)
2321
{
24-
$this->client = $client;
2522
}
2623

2724
public function setCollectionName(?string $collectionName): static

src/Http/GuzzleClient.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@
1818

1919
class GuzzleClient implements HttpClientInterface
2020
{
21-
protected Config $config;
2221
protected Client $client;
2322

24-
public function __construct(Config $config)
23+
public function __construct(protected Config $config)
2524
{
26-
$this->config = $config;
2725
$this->client = new Client([
2826
'base_uri' => $this->config->getDomain(),
2927
'http_errors' => true,

src/Models/Filter/Condition/AbstractCondition.php

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

99
class AbstractCondition
1010
{
11-
protected string $key;
12-
13-
public function __construct(string $key)
11+
public function __construct(protected string $key)
1412
{
15-
$this->key = $key;
1613
}
1714
}

src/Models/Filter/Condition/FullTextMatch.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@
88

99
class FullTextMatch extends AbstractCondition implements ConditionInterface
1010
{
11-
protected string $text;
12-
13-
public function __construct(string $key, string $text)
11+
public function __construct(string $key, protected string $text)
1412
{
1513
parent::__construct($key);
16-
$this->text = $text;
1714
}
1815

1916
public function toArray(): array

src/Models/Filter/Condition/GeoBoundingBox.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
class GeoBoundingBox extends AbstractCondition implements ConditionInterface
1212
{
1313
protected const CONDITIONS = ['bottom_right', 'top_left'];
14-
protected array $boundingBox;
1514

16-
public function __construct(string $key, array $boundingBox)
15+
public function __construct(string $key, protected array $boundingBox)
1716
{
1817
parent::__construct($key);
1918
Assert::keysExists(
@@ -25,7 +24,6 @@ public function __construct(string $key, array $boundingBox)
2524
Assert::allKeyExists(array_values($boundingBox), 'lat', 'All geo locations need to provide "lat" key');
2625
Assert::allKeyExists(array_values($boundingBox), 'lon', 'All geo locations need to provide "lon" key');
2726

28-
$this->boundingBox = $boundingBox;
2927
}
3028

3129
public function toArray(): array

src/Models/Filter/Condition/GeoRadius.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@
77
namespace Qdrant\Models\Filter\Condition;
88

99
use Qdrant\Domain\Assert;
10-
use Qdrant\Exception\InvalidArgumentException;
1110

1211
class GeoRadius extends AbstractCondition implements ConditionInterface
1312
{
1413
protected const CONDITIONS = ['center', 'radius'];
15-
protected array $radius;
1614

17-
public function __construct(string $key, array $radius)
15+
public function __construct(string $key, protected array $radius)
1816
{
1917
parent::__construct($key);
2018
Assert::keysExists(
@@ -23,7 +21,6 @@ public function __construct(string $key, array $radius)
2321

2422
Assert::keysExists($radius['center'], ['lat', 'lon'], 'Radius center parameter expected lat and lon');
2523

26-
$this->radius = $radius;
2724
}
2825

2926
public function toArray(): array

src/Models/Filter/Condition/HasId.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@
88

99
class HasId implements ConditionInterface
1010
{
11-
protected array $ids;
12-
13-
public function __construct(array $ids)
11+
public function __construct(protected array $ids)
1412
{
15-
$this->ids = $ids;
1613
}
1714

1815
public function toArray(): array

src/Models/Filter/Condition/MatchAny.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@
88

99
class MatchAny extends AbstractCondition implements ConditionInterface
1010
{
11-
protected array $values = [];
12-
13-
public function __construct(string $key, array $values)
11+
public function __construct(string $key, protected array $values = [])
1412
{
1513
parent::__construct($key);
16-
$this->values = $values;
1714
}
1815

1916
public function toArray(): array

src/Models/Filter/Condition/MatchBool.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@
88

99
class MatchBool extends AbstractCondition implements ConditionInterface
1010
{
11-
protected bool $value;
12-
13-
public function __construct(string $key, bool $value)
11+
public function __construct(string $key, protected bool $value)
1412
{
1513
parent::__construct($key);
16-
$this->value = $value;
1714
}
1815

1916
public function toArray(): array

0 commit comments

Comments
 (0)