39
39
use Google \Cloud \Spanner \Transaction ;
40
40
use Illuminate \Contracts \Support \Arrayable ;
41
41
use Illuminate \Database \Connection as BaseConnection ;
42
+ use Illuminate \Database \Query \Expression ;
42
43
use Illuminate \Database \Query \Grammars \Grammar as BaseQueryGrammar ;
43
44
use Illuminate \Database \QueryException ;
44
45
use Illuminate \Support \Arr ;
@@ -240,15 +241,23 @@ protected function getDefaultPostProcessor(): QueryProcessor
240
241
}
241
242
242
243
/**
243
- * @inheritDoc OVERRIDDEN for return type change
244
+ * OVERRIDDEN for return type change
245
+ *
246
+ * {@inheritDoc}
247
+ *
248
+ * @param Closure|QueryBuilder|Expression|string $table
249
+ * @return QueryBuilder
244
250
*/
245
251
public function table ($ table , $ as = null ): QueryBuilder
246
252
{
247
253
return $ this ->query ()->from ($ table , $ as );
248
254
}
249
255
250
256
/**
251
- * @inheritDoc OVERRIDDEN for return type change
257
+ * OVERRIDDEN for return type change
258
+ *
259
+ * {@inheritDoc}
260
+ *
252
261
* @return QueryBuilder
253
262
*/
254
263
public function query (): QueryBuilder
@@ -257,7 +266,9 @@ public function query(): QueryBuilder
257
266
}
258
267
259
268
/**
260
- * @inheritDoc
269
+ * {@inheritDoc}
270
+ * @param array<array-key, mixed> $bindings
271
+ * @return array<array-key, mixed>
261
272
*/
262
273
public function select ($ query , $ bindings = [], $ useReadPdo = true ): array
263
274
{
@@ -267,6 +278,9 @@ public function select($query, $bindings = [], $useReadPdo = true): array
267
278
/**
268
279
* {@inheritDoc}
269
280
* @return Generator<int, array<array-key, mixed>>
281
+ * @param array<array-key, mixed> $bindings
282
+ * @return Generator<int, array<array-key, mixed>>
283
+ * @phpstan-ignore method.childReturnType
270
284
*/
271
285
public function cursor ($ query , $ bindings = [], $ useReadPdo = true ): Generator
272
286
{
@@ -281,6 +295,7 @@ public function cursor($query, $bindings = [], $useReadPdo = true): Generator
281
295
*/
282
296
public function selectWithOptions (string $ query , array $ bindings , array $ options ): array
283
297
{
298
+ /** @var array<int, array<array-key, mixed>> */
284
299
return $ this ->run ($ query , $ bindings , function ($ query , $ bindings ) use ($ options ): array {
285
300
return !$ this ->pretending ()
286
301
? iterator_to_array ($ this ->executeQuery ($ query , $ bindings , $ options ))
@@ -304,28 +319,32 @@ public function cursorWithOptions(string $query, array $bindings, array $options
304
319
}
305
320
306
321
/**
307
- * @inheritDoc
322
+ * {@inheritDoc}
323
+ * @param array<array-key, mixed> $bindings
308
324
*/
309
325
public function statement ($ query , $ bindings = []): bool
310
326
{
311
327
// is SELECT query
312
328
if (0 === stripos (ltrim ($ query ), 'select ' )) {
313
- return $ this ->select ($ query , $ bindings ) !== null ;
329
+ $ this ->select ($ query , $ bindings );
330
+ return true ;
314
331
}
315
332
316
333
// is DML query
317
334
if (0 === stripos (ltrim ($ query ), 'insert ' ) ||
318
335
0 === stripos (ltrim ($ query ), 'update ' ) ||
319
336
0 === stripos (ltrim ($ query ), 'delete ' )) {
320
- return $ this ->affectingStatement ($ query , $ bindings ) !== null ;
337
+ $ this ->affectingStatement ($ query , $ bindings );
338
+ return true ;
321
339
}
322
340
323
341
// is DDL Query
324
342
return $ this ->runDdlBatch ([$ query ]) !== null ;
325
343
}
326
344
327
345
/**
328
- * @inheritDoc
346
+ * {@inheritDoc}
347
+ * @param array<array-key, mixed> $bindings
329
348
*/
330
349
public function affectingStatement ($ query , $ bindings = []): int
331
350
{
@@ -378,8 +397,8 @@ public function getDatabaseName()
378
397
379
398
/**
380
399
* @internal
381
- * @inheritDoc
382
- * @return void
400
+ * { @inheritDoc}
401
+ * @return never
383
402
*/
384
403
public function setDatabaseName ($ database )
385
404
{
@@ -388,9 +407,8 @@ public function setDatabaseName($database)
388
407
389
408
/**
390
409
* @internal
391
- * @inheritDoc
392
- * @return void
393
- * @internal
410
+ * {@inheritDoc}
411
+ * @return never
394
412
*/
395
413
public function getPdo ()
396
414
{
@@ -399,9 +417,8 @@ public function getPdo()
399
417
400
418
/**
401
419
* @internal
402
- * @inheritDoc
403
- * @return void
404
- * @internal
420
+ * {@inheritDoc}
421
+ * @return never
405
422
*/
406
423
public function getReadPdo ()
407
424
{
@@ -419,7 +436,9 @@ public function getDoctrineConnection()
419
436
}
420
437
421
438
/**
422
- * @inheritDoc
439
+ * {@inheritDoc}
440
+ * @param array<array-key, mixed> $bindings
441
+ * @return array<array-key, mixed>
423
442
*/
424
443
public function prepareBindings (array $ bindings )
425
444
{
@@ -457,7 +476,7 @@ protected function prepareBinding(BaseQueryGrammar $grammar, mixed $value): mixe
457
476
}
458
477
459
478
/**
460
- * @inheritDoc
479
+ * { @inheritDoc}
461
480
* @param scalar|list<mixed>|Nested|null $value
462
481
*/
463
482
public function escape ($ value , $ binary = false )
@@ -508,7 +527,8 @@ protected function escapeString($value)
508
527
}
509
528
510
529
/**
511
- * @inheritDoc
530
+ * {@inheritDoc}
531
+ * @param array<array-key, mixed> $bindings
512
532
*/
513
533
protected function runQueryCallback ($ query , $ bindings , Closure $ callback )
514
534
{
@@ -596,6 +616,7 @@ protected function executeQuery(string $query, array $bindings, array $options):
596
616
$ tag = $ this ->getRequestTag ();
597
617
if ($ tag !== null ) {
598
618
$ options ['requestOptions ' ] ??= [];
619
+ assert (is_array ($ options ['requestOptions ' ]));
599
620
$ options ['requestOptions ' ]['requestTag ' ] = $ tag ;
600
621
}
601
622
@@ -623,6 +644,7 @@ protected function executePartitionedQuery(string $query, array $options): Gener
623
644
624
645
foreach ($ snapshot ->partitionQuery ($ query , $ options ) as $ partition ) {
625
646
foreach ($ snapshot ->executePartition ($ partition ) as $ row ) {
647
+ /** @var array<array-key, mixed> $row */
626
648
yield $ row ;
627
649
}
628
650
}
@@ -675,7 +697,7 @@ protected function executeBatchDml(Transaction $transaction, string $query, arra
675
697
);
676
698
}
677
699
678
- $ rowCount = array_sum ($ result ->rowCounts () ?? [] );
700
+ $ rowCount = array_sum ($ result ->rowCounts ());
679
701
$ this ->recordsHaveBeenModified ($ rowCount > 0 );
680
702
return $ rowCount ;
681
703
}
@@ -742,5 +764,4 @@ protected function causedBySessionNotFound(Throwable $e): bool
742
764
return ($ e instanceof NotFoundException)
743
765
&& str_contains ($ e ->getMessage (), 'Session does not exist ' );
744
766
}
745
-
746
767
}
0 commit comments