Skip to content

Commit

Permalink
feat: replace @method in traits with abstract defs
Browse files Browse the repository at this point in the history
  • Loading branch information
taka-oyama committed Jul 17, 2023
1 parent bf87274 commit 35e195b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 22 deletions.
8 changes: 5 additions & 3 deletions src/Concerns/ManagesDataDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
use function json_encode;
use function trigger_deprecation;

/**
* @method Database getSpannerDatabase()
*/
trait ManagesDataDefinitions
{
/**
* @return Database
*/
abstract public function getSpannerDatabase(): Database;

/**
* @deprecated use runDdlBatch() instead
* @param string $ddl
Expand Down
8 changes: 5 additions & 3 deletions src/Concerns/ManagesMutations.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
use Illuminate\Database\Events\TransactionCommitted;
use Illuminate\Support\Arr;

/**
* @method Database|Transaction getDatabaseContext()
*/
trait ManagesMutations
{
/**
* @return Database|Transaction
*/
abstract protected function getDatabaseContext(): Database|Transaction;

/**
* @param string $table
* @param array $dataSet
Expand Down
10 changes: 6 additions & 4 deletions src/Concerns/ManagesPartitionedDml.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@

use Google\Cloud\Spanner\Database;

/**
* @method Database getSpannerDatabase()
*/
trait ManagesPartitionedDml
{
/**
* @return Database
*/
abstract public function getSpannerDatabase(): Database;

/**
* Run an SQL statement as partitioned DML and get the number of rows affected.
*
* @param string $query
* @param array<mixed> $bindings
* @param array<array-key, mixed> $bindings
* @return int
*/
public function runPartitionedDml($query, $bindings = [])
Expand Down
9 changes: 5 additions & 4 deletions src/Concerns/ManagesSessionPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@
use ReflectionException;
use ReflectionObject;

/**
* @property Database|null $spannerDatabase
* @method Database getSpannerDatabase()
*/
trait ManagesSessionPool
{
use EmulatorTrait;

/**
* @return Database
*/
abstract public function getSpannerDatabase(): Database;

/**
* @return void
*/
Expand Down
13 changes: 6 additions & 7 deletions src/Concerns/ManagesStaleReads.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,20 @@

use Colopl\Spanner\TimestampBound\TimestampBoundInterface;
use Generator;
use Throwable;

trait ManagesStaleReads
{
/**
* @param string $query
* @param array<string, mixed> $bindings
* @param array<array-key, mixed> $bindings
* @param TimestampBoundInterface|null $timestampBound
* @return Generator<int, list<mixed>|null>
*/
public function cursorWithTimestampBound($query, $bindings = [], TimestampBoundInterface $timestampBound = null): Generator
{
return $this->run($query, $bindings, function ($query, $bindings) use ($timestampBound) {
if ($this->pretending()) {
return call_user_func(function() {
return call_user_func(static function() {
yield from [];
});
}
Expand All @@ -50,10 +49,10 @@ public function cursorWithTimestampBound($query, $bindings = [], TimestampBoundI
}

/**
* @param string $query
* @param array $bindings
* @param string $query
* @param array<array-key, mixed> $bindings
* @param TimestampBoundInterface|null $timestampBound
* @return array
* @return list<array<mixed>>
*/
public function selectWithTimestampBound($query, $bindings = [], TimestampBoundInterface $timestampBound = null): array
{
Expand All @@ -64,7 +63,7 @@ public function selectWithTimestampBound($query, $bindings = [], TimestampBoundI

/**
* @param string $query
* @param array<mixed> $bindings
* @param array<array-key, mixed> $bindings
* @param TimestampBoundInterface|null $timestampBound
* @return array<mixed>|null
*/
Expand Down
1 change: 0 additions & 1 deletion src/Concerns/ManagesTransactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Closure;
use Exception;
use Google\Cloud\Core\Exception\AbortedException;
use Google\Cloud\Core\Exception\NotFoundException;
use Google\Cloud\Spanner\Database;
use Google\Cloud\Spanner\Transaction;
use Throwable;
Expand Down

0 comments on commit 35e195b

Please sign in to comment.