Skip to content

Commit

Permalink
PCBC-1010: use explicit nullable types where applicable
Browse files Browse the repository at this point in the history
Otherwise PHP 8.4 will emit deprecation warning
  • Loading branch information
avsej committed Oct 2, 2024
1 parent 166e242 commit 6c788db
Show file tree
Hide file tree
Showing 59 changed files with 454 additions and 300 deletions.
2 changes: 1 addition & 1 deletion Couchbase/AnalyticsOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public static function getTranscoder(?AnalyticsOptions $options): Transcoder
return $options->transcoder;
}

public static function export(?AnalyticsOptions $options, string $scopeName = null, string $bucketName = null): array
public static function export(?AnalyticsOptions $options, ?string $scopeName = null, ?string $bucketName = null): array
{
if ($options == null) {
return [
Expand Down
8 changes: 4 additions & 4 deletions Couchbase/BinaryCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function name(): string
* @throws CouchbaseException
* @since 4.0.0
*/
public function append(string $id, string $value, AppendOptions $options = null): MutationResult
public function append(string $id, string $value, ?AppendOptions $options = null): MutationResult
{
$response = Extension\documentAppend(
$this->core,
Expand All @@ -105,7 +105,7 @@ public function append(string $id, string $value, AppendOptions $options = null)
* @throws CouchbaseException
* @since 4.0.0
*/
public function prepend(string $id, string $value, PrependOptions $options = null): MutationResult
public function prepend(string $id, string $value, ?PrependOptions $options = null): MutationResult
{
$response = Extension\documentPrepend(
$this->core,
Expand All @@ -131,7 +131,7 @@ public function prepend(string $id, string $value, PrependOptions $options = nul
* @throws CouchbaseException
* @since 4.0.0
*/
public function increment(string $id, IncrementOptions $options = null): CounterResult
public function increment(string $id, ?IncrementOptions $options = null): CounterResult
{
$response = Extension\documentIncrement(
$this->core,
Expand All @@ -156,7 +156,7 @@ public function increment(string $id, IncrementOptions $options = null): Counter
* @throws CouchbaseException
* @since 4.0.0
*/
public function decrement(string $id, DecrementOptions $options = null): CounterResult
public function decrement(string $id, ?DecrementOptions $options = null): CounterResult
{
$response = Extension\documentDecrement(
$this->core,
Expand Down
8 changes: 4 additions & 4 deletions Couchbase/BinaryCollectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ interface BinaryCollectionInterface
{
public function name(): string;

public function append(string $id, string $value, AppendOptions $options = null): MutationResult;
public function append(string $id, string $value, ?AppendOptions $options = null): MutationResult;

public function prepend(string $id, string $value, PrependOptions $options = null): MutationResult;
public function prepend(string $id, string $value, ?PrependOptions $options = null): MutationResult;

public function increment(string $id, IncrementOptions $options = null): CounterResult;
public function increment(string $id, ?IncrementOptions $options = null): CounterResult;

public function decrement(string $id, DecrementOptions $options = null): CounterResult;
public function decrement(string $id, ?DecrementOptions $options = null): CounterResult;
}
4 changes: 2 additions & 2 deletions Couchbase/Bucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function name(): string
* @return ViewResult
* @since 4.0.0
*/
public function viewQuery(string $designDoc, string $viewName, ViewOptions $options = null): ViewResult
public function viewQuery(string $designDoc, string $viewName, ?ViewOptions $options = null): ViewResult
{
$opts = ViewOptions::export($options);
$namespace = $opts["namespace"];
Expand Down Expand Up @@ -195,7 +195,7 @@ public function ping($services = null, $reportId = null)
* @deprecated - see cluster->diagnostics
* @since 4.0.0
*/
public function diagnostics(string $reportId = null)
public function diagnostics(?string $reportId = null)
{
if ($reportId == null) {
$reportId = uniqid();
Expand Down
2 changes: 1 addition & 1 deletion Couchbase/BucketInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ public function scope(string $name): ScopeInterface;

public function name(): string;

public function viewQuery(string $designDoc, string $viewName, ViewOptions $options = null): ViewResult;
public function viewQuery(string $designDoc, string $viewName, ?ViewOptions $options = null): ViewResult;
}
8 changes: 4 additions & 4 deletions Couchbase/Cluster.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function query(string $statement, ?QueryOptions $options = null): QueryRe
* @throws CouchbaseException
* @since 4.0.0
*/
public function analyticsQuery(string $statement, AnalyticsOptions $options = null): AnalyticsResult
public function analyticsQuery(string $statement, ?AnalyticsOptions $options = null): AnalyticsResult
{
$result = Extension\analyticsQuery($this->core, $statement, AnalyticsOptions::export($options));

Expand All @@ -202,7 +202,7 @@ public function analyticsQuery(string $statement, AnalyticsOptions $options = nu
* @return SearchResult
* @since 4.0.0
*/
public function searchQuery(string $indexName, SearchQuery $query, SearchOptions $options = null): SearchResult
public function searchQuery(string $indexName, SearchQuery $query, ?SearchOptions $options = null): SearchResult
{
$result = Extension\searchQuery($this->core, $indexName, json_encode($query), SearchOptions::export($options));

Expand All @@ -222,7 +222,7 @@ public function searchQuery(string $indexName, SearchQuery $query, SearchOptions
* @throws InvalidArgumentException
* @since 4.1.7
*/
public function search(string $indexName, SearchRequest $request, SearchOptions $options = null): SearchResult
public function search(string $indexName, SearchRequest $request, ?SearchOptions $options = null): SearchResult
{
$exportedRequest = SearchRequest::export($request);
$exportedOptions = SearchOptions::export($options);
Expand Down Expand Up @@ -329,7 +329,7 @@ public function ping($services = null, $reportId = null)
*
* @since 4.0.0
*/
public function diagnostics(string $reportId = null)
public function diagnostics(?string $reportId = null)
{
if ($reportId == null) {
$reportId = uniqid();
Expand Down
4 changes: 2 additions & 2 deletions Couchbase/ClusterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function bucket(string $name): BucketInterface;

public function query(string $statement, ?QueryOptions $options = null): QueryResult;

public function analyticsQuery(string $statement, AnalyticsOptions $options = null): AnalyticsResult;
public function analyticsQuery(string $statement, ?AnalyticsOptions $options = null): AnalyticsResult;

public function searchQuery(string $indexName, SearchQuery $query, SearchOptions $options = null): SearchResult;
public function searchQuery(string $indexName, SearchQuery $query, ?SearchOptions $options = null): SearchResult;
}
40 changes: 20 additions & 20 deletions Couchbase/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function name(): string
* @throws CouchbaseException
* @since 4.0.0
*/
public function get(string $id, GetOptions $options = null): GetResult
public function get(string $id, ?GetOptions $options = null): GetResult
{
$response = Extension\documentGet(
$this->core,
Expand All @@ -137,7 +137,7 @@ public function get(string $id, GetOptions $options = null): GetResult
* @throws CouchbaseException
* @since 4.0.0
*/
public function exists(string $id, ExistsOptions $options = null): ExistsResult
public function exists(string $id, ?ExistsOptions $options = null): ExistsResult
{
$response = Extension\documentExists(
$this->core,
Expand All @@ -164,7 +164,7 @@ public function exists(string $id, ExistsOptions $options = null): ExistsResult
* @throws CouchbaseException
* @since 4.0.0
*/
public function getAndLock(string $id, int $lockTimeSeconds, GetAndLockOptions $options = null): GetResult
public function getAndLock(string $id, int $lockTimeSeconds, ?GetAndLockOptions $options = null): GetResult
{
$response = Extension\documentGetAndLock(
$this->core,
Expand All @@ -191,7 +191,7 @@ public function getAndLock(string $id, int $lockTimeSeconds, GetAndLockOptions $
* @throws CouchbaseException
* @since 4.0.0
*/
public function getAndTouch(string $id, $expiry, GetAndTouchOptions $options = null): GetResult
public function getAndTouch(string $id, $expiry, ?GetAndTouchOptions $options = null): GetResult
{
if ($expiry instanceof DateTimeInterface) {
$expirySeconds = $expiry->getTimestamp();
Expand Down Expand Up @@ -223,7 +223,7 @@ public function getAndTouch(string $id, $expiry, GetAndTouchOptions $options = n
* @throws TimeoutException
* @since 4.0.1
*/
public function getAnyReplica(string $id, GetAnyReplicaOptions $options = null): GetReplicaResult
public function getAnyReplica(string $id, ?GetAnyReplicaOptions $options = null): GetReplicaResult
{
$response = Extension\documentGetAnyReplica(
$this->core,
Expand All @@ -248,7 +248,7 @@ public function getAnyReplica(string $id, GetAnyReplicaOptions $options = null):
* @throws TimeoutException
* @since 4.0.0
*/
public function getAllReplicas(string $id, GetAllReplicasOptions $options = null): array
public function getAllReplicas(string $id, ?GetAllReplicasOptions $options = null): array
{
$responses = Extension\documentGetAllReplicas(
$this->core,
Expand Down Expand Up @@ -278,7 +278,7 @@ function (array $response) use ($options) {
* @throws CouchbaseException
* @since 4.0.0
*/
public function upsert(string $id, $value, UpsertOptions $options = null): MutationResult
public function upsert(string $id, $value, ?UpsertOptions $options = null): MutationResult
{
$encoded = UpsertOptions::encodeDocument($options, $value);
$response = Extension\documentUpsert(
Expand Down Expand Up @@ -307,7 +307,7 @@ public function upsert(string $id, $value, UpsertOptions $options = null): Mutat
* @throws CouchbaseException
* @since 4.0.0
*/
public function insert(string $id, $value, InsertOptions $options = null): MutationResult
public function insert(string $id, $value, ?InsertOptions $options = null): MutationResult
{
$encoded = InsertOptions::encodeDocument($options, $value);
$response = Extension\documentInsert(
Expand Down Expand Up @@ -337,7 +337,7 @@ public function insert(string $id, $value, InsertOptions $options = null): Mutat
* @throws CouchbaseException
* @since 4.0.0
*/
public function replace(string $id, $value, ReplaceOptions $options = null): MutationResult
public function replace(string $id, $value, ?ReplaceOptions $options = null): MutationResult
{
$encoded = ReplaceOptions::encodeDocument($options, $value);
$response = Extension\documentReplace(
Expand Down Expand Up @@ -366,7 +366,7 @@ public function replace(string $id, $value, ReplaceOptions $options = null): Mut
* @throws DocumentNotFoundException
* @since 4.0.0
*/
public function remove(string $id, RemoveOptions $options = null): MutationResult
public function remove(string $id, ?RemoveOptions $options = null): MutationResult
{
$response = Extension\documentRemove(
$this->core,
Expand Down Expand Up @@ -394,7 +394,7 @@ public function remove(string $id, RemoveOptions $options = null): MutationResul
* @throws CouchbaseException
* @since 4.0.0
*/
public function unlock(string $id, string $cas, UnlockOptions $options = null): Result
public function unlock(string $id, string $cas, ?UnlockOptions $options = null): Result
{
$response = Extension\documentUnlock(
$this->core,
Expand All @@ -421,7 +421,7 @@ public function unlock(string $id, string $cas, UnlockOptions $options = null):
* @throws CouchbaseException
* @since 4.0.0
*/
public function touch(string $id, $expiry, TouchOptions $options = null): MutationResult
public function touch(string $id, $expiry, ?TouchOptions $options = null): MutationResult
{
if ($expiry instanceof DateTimeInterface) {
$expirySeconds = $expiry->getTimestamp();
Expand Down Expand Up @@ -453,7 +453,7 @@ public function touch(string $id, $expiry, TouchOptions $options = null): Mutati
* @throws CouchbaseException
* @since 4.0.0
*/
public function lookupIn(string $id, array $specs, LookupInOptions $options = null): LookupInResult
public function lookupIn(string $id, array $specs, ?LookupInOptions $options = null): LookupInResult
{
$encoded = array_map(
function (LookupInSpec $item) {
Expand Down Expand Up @@ -489,7 +489,7 @@ function (LookupInSpec $item) {
* @throws CouchbaseException
* @since 4.1.6
*/
public function lookupInAnyReplica(string $id, array $specs, LookupInAnyReplicaOptions $options = null): LookupInReplicaResult
public function lookupInAnyReplica(string $id, array $specs, ?LookupInAnyReplicaOptions $options = null): LookupInReplicaResult
{
$encoded = array_map(
function (LookupInSpec $item) {
Expand Down Expand Up @@ -526,7 +526,7 @@ function (LookupInSpec $item) {
* @throws CouchbaseException
* @since 4.1.6
*/
public function lookupInAllReplicas(string $id, array $specs, LookupInAllReplicasOptions $options = null): array
public function lookupInAllReplicas(string $id, array $specs, ?LookupInAllReplicasOptions $options = null): array
{
$encoded = array_map(
function (LookupInSpec $item) {
Expand Down Expand Up @@ -568,7 +568,7 @@ function (array $response) use ($options) {
* @throws CouchbaseException
* @since 4.0.0
*/
public function mutateIn(string $id, array $specs, MutateInOptions $options = null): MutateInResult
public function mutateIn(string $id, array $specs, ?MutateInOptions $options = null): MutateInResult
{
$encoded = array_map(
function (MutateInSpec $item) use ($options) {
Expand Down Expand Up @@ -598,7 +598,7 @@ function (MutateInSpec $item) use ($options) {
* @return array<GetResult> array of GetResult, one for each of the entries
* @since 4.0.0
*/
public function getMulti(array $ids, GetOptions $options = null): array
public function getMulti(array $ids, ?GetOptions $options = null): array
{
$responses = Extension\documentGetMulti(
$this->core,
Expand Down Expand Up @@ -630,7 +630,7 @@ function (array $response) use ($options) {
* @throws InvalidArgumentException
* @since 4.1.6
*/
public function scan(ScanType $scanType, ScanOptions $options = null): ScanResults
public function scan(ScanType $scanType, ?ScanOptions $options = null): ScanResults
{
if ($scanType instanceof RangeScan) {
$type = RangeScan::export($scanType);
Expand Down Expand Up @@ -664,7 +664,7 @@ public function scan(ScanType $scanType, ScanOptions $options = null): ScanResul
* @throws UnsupportedOperationException
* @since 4.0.0
*/
public function removeMulti(array $entries, RemoveOptions $options = null): array
public function removeMulti(array $entries, ?RemoveOptions $options = null): array
{
$responses = Extension\documentRemoveMulti(
$this->core,
Expand Down Expand Up @@ -693,7 +693,7 @@ function (array $response) {
* @throws InvalidArgumentException
* @since 4.0.0
*/
public function upsertMulti(array $entries, UpsertOptions $options = null): array
public function upsertMulti(array $entries, ?UpsertOptions $options = null): array
{
$encodedEntries = array_map(
function (array $entry) use ($options) {
Expand Down
28 changes: 14 additions & 14 deletions Couchbase/CollectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,33 @@ public function scopeName(): string;

public function name(): string;

public function get(string $id, GetOptions $options = null): GetResult;
public function get(string $id, ?GetOptions $options = null): GetResult;

public function exists(string $id, ExistsOptions $options = null): ExistsResult;
public function exists(string $id, ?ExistsOptions $options = null): ExistsResult;

public function getAndLock(string $id, int $lockTimeSeconds, GetAndLockOptions $options = null): GetResult;
public function getAndLock(string $id, int $lockTimeSeconds, ?GetAndLockOptions $options = null): GetResult;

public function getAndTouch(string $id, $expiry, GetAndTouchOptions $options = null): GetResult;
public function getAndTouch(string $id, $expiry, ?GetAndTouchOptions $options = null): GetResult;

public function getAnyReplica(string $id, GetAnyReplicaOptions $options = null): GetReplicaResult;
public function getAnyReplica(string $id, ?GetAnyReplicaOptions $options = null): GetReplicaResult;

public function getAllReplicas(string $id, GetAllReplicasOptions $options = null): array;
public function getAllReplicas(string $id, ?GetAllReplicasOptions $options = null): array;

public function upsert(string $id, $value, UpsertOptions $options = null): MutationResult;
public function upsert(string $id, $value, ?UpsertOptions $options = null): MutationResult;

public function insert(string $id, $value, InsertOptions $options = null): MutationResult;
public function insert(string $id, $value, ?InsertOptions $options = null): MutationResult;

public function replace(string $id, $value, ReplaceOptions $options = null): MutationResult;
public function replace(string $id, $value, ?ReplaceOptions $options = null): MutationResult;

public function remove(string $id, RemoveOptions $options = null): MutationResult;
public function remove(string $id, ?RemoveOptions $options = null): MutationResult;

public function unlock(string $id, string $cas, UnlockOptions $options = null): Result;
public function unlock(string $id, string $cas, ?UnlockOptions $options = null): Result;

public function touch(string $id, $expiry, TouchOptions $options = null): MutationResult;
public function touch(string $id, $expiry, ?TouchOptions $options = null): MutationResult;

public function lookupIn(string $id, array $specs, LookupInOptions $options = null): LookupInResult;
public function lookupIn(string $id, array $specs, ?LookupInOptions $options = null): LookupInResult;

public function mutateIn(string $id, array $specs, MutateInOptions $options = null): MutateInResult;
public function mutateIn(string $id, array $specs, ?MutateInOptions $options = null): MutateInResult;

public function binary(): BinaryCollectionInterface;
}
2 changes: 1 addition & 1 deletion Couchbase/Exception/CouchbaseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CouchbaseException extends Exception
{
private ?array $context;

public function __construct($message = "", $code = 0, Throwable $previous = null, array $context = null)
public function __construct($message = "", $code = 0, ?Throwable $previous = null, ?array $context = null)
{
parent::__construct($message, $code, $previous);
$this->context = $context;
Expand Down
4 changes: 2 additions & 2 deletions Couchbase/GeoDistanceSearchQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class GeoDistanceSearchQuery implements JsonSerializable, SearchQuery
*
* @since 4.0.0
*/
public function __construct(float $longitude, float $latitude, string $distance = null)
public function __construct(float $longitude, float $latitude, ?string $distance = null)
{
$this->longitude = $longitude;
$this->latitude = $latitude;
Expand All @@ -59,7 +59,7 @@ public function __construct(float $longitude, float $latitude, string $distance
* @return GeoDistanceSearchQuery
* @since 4.1.7
*/
public static function build(float $longitude, float $latitude, string $distance = null): GeoDistanceSearchQuery
public static function build(float $longitude, float $latitude, ?string $distance = null): GeoDistanceSearchQuery
{
return new GeoDistanceSearchQuery($longitude, $latitude, $distance);
}
Expand Down
Loading

0 comments on commit 6c788db

Please sign in to comment.