Skip to content

Commit e9da42e

Browse files
authored
Merge branch 'feature/phpstan-support-part1' into feature/phpstan-support-part2
2 parents e2c93f8 + 7f25ab0 commit e9da42e

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

phpstan.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ parameters:
44
- src
55
ignoreErrors:
66
- identifier: missingType.iterableValue
7-
- '#^Access to an undefined property Colopl\\Spanner\\Schema\\IndexDefinition.*$#'
87
- '#^Return type \(void\) of method .*? should be compatible with return type \(.*?\) of method .*?$#'
98
- message: '#^Method Colopl\\Spanner\\Connection::runPartitionedDml\(\) should return int but returns mixed\.$#'
109
path: src/Concerns/ManagesPartitionedDml.php

src/Schema/Grammar.php

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ protected function formatChangeStreamOptions(ChangeStreamDefinition $definition)
354354
protected function addInterleaveToTable(Blueprint $blueprint)
355355
{
356356
if (! is_null($command = $this->getCommandByName($blueprint, 'interleaveInParent'))) {
357+
assert($command instanceof InterleaveDefinition);
357358
$schema = ", interleave in parent {$this->wrap($command->table)}";
358359
if (! is_null($command->onDelete)) {
359360
$schema .= " on delete {$command->onDelete}";
@@ -403,27 +404,21 @@ public function compileUnique(Blueprint $blueprint, Fluent $command)
403404
*/
404405
public function compileIndex(Blueprint $blueprint, Fluent $command)
405406
{
406-
$columnsAsString = null;
407-
408407
// if index is defined as assoc array, key is treated as column name and value as order
409408
// if index is defined as numeric array, then values are read as column names
410-
$keys = array_keys($command->columns);
411-
if (array_keys($keys) !== $keys) {
412-
$columns = [];
413-
foreach ($command->columns as $column => $order) {
414-
$columns[] = $this->wrap($column).' '.$order;
415-
}
416-
$columnsAsString = implode(', ', $columns);
417-
} else {
418-
$columnsAsString = $this->columnize($command->columns);
409+
$columns = [];
410+
foreach ($command->columns as $column => $order) {
411+
$columns[] = is_string($column)
412+
? $this->wrap($column) . ' ' . $order
413+
: $this->wrap($order);
419414
}
420415

421416
return sprintf('create %s%sindex %s on %s (%s)%s%s',
422417
empty($command->indexType) ? '' : trim($command->indexType).' ',
423418
empty($command->nullFiltered) ? '' :'null_filtered ',
424419
$this->wrap($command->index),
425420
$this->wrapTable($blueprint),
426-
$columnsAsString,
421+
implode(', ', $columns),
427422
$this->addStoringToIndex($command),
428423
$this->addInterleaveToIndex($command)
429424
);
@@ -458,7 +453,7 @@ protected function addStoringToIndex(Fluent $indexCommand): string
458453

459454
/**
460455
* @param Blueprint $blueprint
461-
* @param Fluent<string, mixed> $command
456+
* @param IndexDefinition $command
462457
* @return string
463458
* @see https://cloud.google.com/spanner/docs/data-definition-language?hl=en
464459
*/
@@ -471,7 +466,7 @@ public function compileDropIndex(Blueprint $blueprint, Fluent $command)
471466

472467
/**
473468
* @param Blueprint $blueprint
474-
* @param Fluent<string, mixed> $command
469+
* @param IndexDefinition $command
475470
* @return string
476471
* @see https://cloud.google.com/spanner/docs/data-definition-language?hl=en
477472
*/
@@ -484,7 +479,7 @@ public function compileDropUnique(Blueprint $blueprint, Fluent $command)
484479
* Compile a drop foreign key command.
485480
*
486481
* @param Blueprint $blueprint
487-
* @param Fluent<string, mixed> $command
482+
* @param IndexDefinition $command
488483
* @return string
489484
*/
490485
public function compileDropForeign(Blueprint $blueprint, Fluent $command)

src/Schema/IndexDefinition.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
use LogicException;
2323

2424
/**
25+
* @property string $indexType
26+
* @property string $index
27+
* @property list<string>|array<string, string> $columns
28+
* @property string|null $interleaveIn
29+
* @property string|null $nullFiltered
30+
* @property list<string>|null $storing
2531
* @method $this interleaveIn(string $table)
2632
* @method $this nullFiltered()
2733
* @method $this storing(string[] $columns)

src/Schema/InterleaveDefinition.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
use Illuminate\Support\Fluent;
2222

2323
/**
24+
* @property string $table
25+
* @property string|null $onDelete
2426
* @method $this onDelete(string $action) Add an ON DELETE action
2527
* @extends Fluent<string, mixed>
2628
*/

0 commit comments

Comments
 (0)