@@ -104,12 +104,12 @@ class DatastoreClient
104104 /**
105105 * @var Operation
106106 */
107- protected $ operation ;
107+ protected Operation $ operation ;
108108
109109 /**
110110 * @var EntityMapper
111111 */
112- private $ entityMapper ;
112+ private EntityMapper $ entityMapper ;
113113
114114 /**
115115 * @var GapicDatastoreClient
@@ -234,7 +234,7 @@ public function __construct(array $config = [])
234234 );
235235 }
236236
237- $ this ->projectId = $ this ->detectProjectId ($ gapicOptions );
237+ $ this ->projectId = ( string ) $ this ->detectProjectId ($ gapicOptions );
238238 $ this ->gapicClient = $ this ->getGapicClient ($ gapicOptions );
239239
240240 // The second parameter here should change to a variable
@@ -286,7 +286,7 @@ public function __construct(array $config = [])
286286 * }
287287 * @return Key
288288 */
289- public function key ($ kind , $ identifier = null , array $ options = [])
289+ public function key (string $ kind , $ identifier = null , array $ options = []): Key
290290 {
291291 return $ this ->operation ->key ($ kind , $ identifier , $ options );
292292 }
@@ -334,7 +334,7 @@ public function key($kind, $identifier = null, array $options = [])
334334 * }
335335 * @return Key[]
336336 */
337- public function keys ($ kind , array $ options = [])
337+ public function keys (string $ kind , array $ options = []): array
338338 {
339339 return $ this ->operation ->keys ($ kind , $ options );
340340 }
@@ -457,7 +457,7 @@ public function keys($kind, array $options = [])
457457 * }
458458 * @return EntityInterface
459459 */
460- public function entity ($ key = null , array $ entity = [], array $ options = [])
460+ public function entity (Key | string | null $ key = null , array $ entity = [], array $ options = []): EntityInterface
461461 {
462462 return $ this ->operation ->entity ($ key , $ entity , $ options );
463463 }
@@ -478,7 +478,7 @@ public function entity($key = null, array $entity = [], array $options = [])
478478 * **Defaults to** `false`.
479479 * @return GeoPoint
480480 */
481- public function geoPoint ($ latitude , $ longitude , $ allowNull = false )
481+ public function geoPoint (float $ latitude , float $ longitude , bool $ allowNull = false ): GeoPoint
482482 {
483483 return new GeoPoint ($ latitude , $ longitude , $ allowNull );
484484 }
@@ -499,7 +499,7 @@ public function geoPoint($latitude, $longitude, $allowNull = false)
499499 * @param string|resource|StreamInterface $value The value to store in a blob.
500500 * @return Blob
501501 */
502- public function blob ($ value )
502+ public function blob (mixed $ value ): Blob
503503 {
504504 return new Blob ($ value );
505505 }
@@ -516,7 +516,7 @@ public function blob($value)
516516 * @param string $value
517517 * @return Int64
518518 */
519- public function int64 ($ value )
519+ public function int64 (string $ value ): Int64
520520 {
521521 return new Int64 ($ value );
522522 }
@@ -535,7 +535,7 @@ public function int64($value)
535535 * @param string|int $cursorValue
536536 * @return Cursor
537537 */
538- public function cursor ($ cursorValue )
538+ public function cursor (string | int $ cursorValue ): Cursor
539539 {
540540 return new Cursor ($ cursorValue );
541541 }
@@ -560,7 +560,7 @@ public function cursor($cursorValue)
560560 * @param array $options [optional] Configuration options.
561561 * @return Key
562562 */
563- public function allocateId (Key $ key , array $ options = [])
563+ public function allocateId (Key $ key , array $ options = []): Key
564564 {
565565 $ res = $ this ->allocateIds ([$ key ], $ options );
566566 return $ res [0 ];
@@ -594,7 +594,7 @@ public function allocateId(Key $key, array $options = [])
594594 * }.
595595 * @return Key[]
596596 */
597- public function allocateIds (array $ keys , array $ options = [])
597+ public function allocateIds (array $ keys , array $ options = []): array
598598 {
599599 return $ this ->operation ->allocateIds ($ keys , $ options );
600600 }
@@ -620,7 +620,7 @@ public function allocateIds(array $keys, array $options = [])
620620 * @return Transaction
621621 * @codingStandardsIgnoreEnd
622622 */
623- public function transaction (array $ options = [])
623+ public function transaction (array $ options = []): Transaction
624624 {
625625 $ transaction = $ this ->operation ->beginTransaction ([
626626 // if empty, force request to encode as {} rather than [].
@@ -659,7 +659,7 @@ public function transaction(array $options = [])
659659 * @return ReadOnlyTransaction
660660 * @codingStandardsIgnoreEnd
661661 */
662- public function readOnlyTransaction (array $ options = [])
662+ public function readOnlyTransaction (array $ options = []): ReadOnlyTransaction
663663 {
664664 $ transaction = $ this ->operation ->beginTransaction ([
665665 // if empty, force request to encode as {} rather than [].
@@ -696,7 +696,7 @@ public function readOnlyTransaction(array $options = [])
696696 * @return string The entity version.
697697 * @throws DomainException If a conflict occurs, fail.
698698 */
699- public function insert (EntityInterface $ entity , array $ options = [])
699+ public function insert (EntityInterface $ entity , array $ options = []): string
700700 {
701701 $ res = $ this ->insertBatch ([$ entity ], $ options );
702702 return $ this ->parseSingleMutationResult ($ res );
@@ -727,7 +727,7 @@ public function insert(EntityInterface $entity, array $options = [])
727727 * @param array $options [optional] Configuration options.
728728 * @return array [Response Body](https://cloud.google.com/datastore/reference/rest/v1/projects/commit#response-body)
729729 */
730- public function insertBatch (array $ entities , array $ options = [])
730+ public function insertBatch (array $ entities , array $ options = []): array
731731 {
732732 $ entities = $ this ->operation ->allocateIdsToEntities ($ entities );
733733 $ mutations = [];
@@ -773,7 +773,7 @@ public function insertBatch(array $entities, array $options = [])
773773 * @return string The entity version.
774774 * @throws DomainException If a conflict occurs, fail.
775775 */
776- public function update (EntityInterface $ entity , array $ options = [])
776+ public function update (EntityInterface $ entity , array $ options = []): string
777777 {
778778 $ res = $ this ->updateBatch ([$ entity ], $ options );
779779 return $ this ->parseSingleMutationResult ($ res );
@@ -814,7 +814,7 @@ public function update(EntityInterface $entity, array $options = [])
814814 * }
815815 * @return array [Response Body](https://cloud.google.com/datastore/reference/rest/v1/projects/commit#response-body)
816816 */
817- public function updateBatch (array $ entities , array $ options = [])
817+ public function updateBatch (array $ entities , array $ options = []): array
818818 {
819819 $ options += [
820820 'allowOverwrite ' => false
@@ -860,7 +860,7 @@ public function updateBatch(array $entities, array $options = [])
860860 * @return string The entity version.
861861 * @throws DomainException If a conflict occurs, fail.
862862 */
863- public function upsert (EntityInterface $ entity , array $ options = [])
863+ public function upsert (EntityInterface $ entity , array $ options = []): string
864864 {
865865 $ res = $ this ->upsertBatch ([$ entity ], $ options );
866866 return $ this ->parseSingleMutationResult ($ res );
@@ -903,7 +903,7 @@ public function upsert(EntityInterface $entity, array $options = [])
903903 * @param array $options [optional] Configuration Options.
904904 * @return array [Response Body](https://cloud.google.com/datastore/reference/rest/v1/projects/commit#response-body)
905905 */
906- public function upsertBatch (array $ entities , array $ options = [])
906+ public function upsertBatch (array $ entities , array $ options = []): array
907907 {
908908 $ entities = $ this ->operation ->allocateIdsToEntities ($ entities );
909909 $ mutations = [];
@@ -941,7 +941,7 @@ public function upsertBatch(array $entities, array $options = [])
941941 * @return string The updated entity version number.
942942 * @throws DomainException If a conflict occurs, fail.
943943 */
944- public function delete (Key $ key , array $ options = [])
944+ public function delete (Key $ key , array $ options = []): string
945945 {
946946 $ res = $ this ->deleteBatch ([$ key ], $ options );
947947 return $ this ->parseSingleMutationResult ($ res );
@@ -976,7 +976,7 @@ public function delete(Key $key, array $options = [])
976976 * }
977977 * @return array [Response Body](https://cloud.google.com/datastore/reference/rest/v1/projects/commit#response-body)
978978 */
979- public function deleteBatch (array $ keys , array $ options = [])
979+ public function deleteBatch (array $ keys , array $ options = []): array
980980 {
981981 $ options += [
982982 'baseVersion ' => null
@@ -1033,7 +1033,7 @@ public function deleteBatch(array $keys, array $options = [])
10331033 * }
10341034 * @return EntityInterface|null
10351035 */
1036- public function lookup (Key $ key , array $ options = [])
1036+ public function lookup (Key $ key , array $ options = []): ? EntityInterface
10371037 {
10381038 $ res = $ this ->lookupBatch ([$ key ], $ options );
10391039
@@ -1100,7 +1100,7 @@ public function lookup(Key $key, array $options = [])
11001100 * {@see \Google\Cloud\Datastore\Entity}. Members of `missing` and
11011101 * `deferred` will be instance of {@see \Google\Cloud\Datastore\Key}.
11021102 */
1103- public function lookupBatch (array $ keys , array $ options = [])
1103+ public function lookupBatch (array $ keys , array $ options = []): array
11041104 {
11051105 return $ this ->operation ->lookup ($ keys , $ options );
11061106 }
@@ -1119,7 +1119,7 @@ public function lookupBatch(array $keys, array $options = [])
11191119 * @param array $query [Query](https://cloud.google.com/datastore/reference/rest/v1/projects/runQuery#query)
11201120 * @return Query
11211121 */
1122- public function query (array $ query = [])
1122+ public function query (array $ query = []): Query
11231123 {
11241124 return new Query ($ this ->entityMapper , [
11251125 'query ' => $ query
@@ -1139,7 +1139,7 @@ public function query(array $query = [])
11391139 * @param array $query [Query](https://cloud.google.com/datastore/reference/rest/v1/projects/runQuery#query)
11401140 * @return AggregationQuery
11411141 */
1142- public function aggregationQuery (array $ query = [])
1142+ public function aggregationQuery (array $ query = []): AggregationQuery
11431143 {
11441144 return new AggregationQuery ($ this ->query ($ query ));
11451145 }
@@ -1212,7 +1212,7 @@ public function aggregationQuery(array $query = [])
12121212 * }
12131213 * @return GqlQuery
12141214 */
1215- public function gqlQuery ($ query , array $ options = [])
1215+ public function gqlQuery (string $ query , array $ options = []): GqlQuery
12161216 {
12171217 return new GqlQuery ($ this ->entityMapper , $ query , $ options );
12181218 }
@@ -1294,7 +1294,7 @@ public function runQuery(QueryInterface $query, array $options = [])
12941294 * }
12951295 * @return AggregationQueryResult
12961296 */
1297- public function runAggregationQuery (AggregationQuery $ query , array $ options = [])
1297+ public function runAggregationQuery (AggregationQuery $ query , array $ options = []): AggregationQueryResult
12981298 {
12991299 return $ this ->operation ->runAggregationQuery ($ query , $ options );
13001300 }
@@ -1308,7 +1308,7 @@ public function runAggregationQuery(AggregationQuery $query, array $options = []
13081308 * @throws DomainException
13091309 * @codingStandardsIgnoreEnd
13101310 */
1311- private function parseSingleMutationResult (array $ res )
1311+ private function parseSingleMutationResult (array $ res ): string
13121312 {
13131313 $ mutationResult = $ res ['mutationResults ' ][0 ];
13141314
0 commit comments