Skip to content

Commit

Permalink
Clean up phpstan output.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Dec 27, 2023
1 parent bc23881 commit 6b8d237
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
27 changes: 11 additions & 16 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,24 @@ parameters:
path: src/Command/BakeMigrationSnapshotCommand.php

-
message: "#^Parameter \\#1 \\$table of method Phinx\\\\Db\\\\Adapter\\\\AdapterInterface\\:\\:createTable\\(\\) expects Phinx\\\\Db\\\\Table\\\\Table, Migrations\\\\Db\\\\Table\\\\Table given\\.$#"
message: "#^Offset 'id' on non\\-empty\\-array\\<string, mixed\\> in isset\\(\\) always exists and is not nullable\\.$#"
count: 2
path: src/Db/Plan/Plan.php
path: src/Db/Adapter/MysqlAdapter.php

-
message: "#^Parameter \\#1 \\$table of method Phinx\\\\Db\\\\Adapter\\\\AdapterInterface\\:\\:executeActions\\(\\) expects Phinx\\\\Db\\\\Table\\\\Table, Migrations\\\\Db\\\\Table\\\\Table given\\.$#"
count: 2
path: src/Db/Plan/Plan.php

-
message: "#^Parameter \\#2 \\$actions of method Phinx\\\\Db\\\\Adapter\\\\AdapterInterface\\:\\:executeActions\\(\\) expects array\\<Phinx\\\\Db\\\\Action\\\\Action\\>, array\\<Migrations\\\\Db\\\\Action\\\\Action\\> given\\.$#"
count: 2
path: src/Db/Plan/Plan.php
message: "#^Parameter \\#4 \\$options of method Migrations\\\\Db\\\\Adapter\\\\PdoAdapter\\:\\:createPdoConnection\\(\\) expects array\\<int, mixed\\>, array\\<int\\|string, mixed\\> given\\.$#"
count: 1
path: src/Db/Adapter/MysqlAdapter.php

-
message: "#^Parameter \\#2 \\$columns of method Phinx\\\\Db\\\\Adapter\\\\AdapterInterface\\:\\:createTable\\(\\) expects array\\<Phinx\\\\Db\\\\Table\\\\Column\\>, array\\<Migrations\\\\Db\\\\Table\\\\Column\\> given\\.$#"
count: 2
path: src/Db/Plan/Plan.php
message: "#^Right side of && is always true\\.$#"
count: 1
path: src/Db/Adapter/MysqlAdapter.php

-
message: "#^Parameter \\#3 \\$indexes of method Phinx\\\\Db\\\\Adapter\\\\AdapterInterface\\:\\:createTable\\(\\) expects array\\<Phinx\\\\Db\\\\Table\\\\Index\\>, array\\<Migrations\\\\Db\\\\Table\\\\Index\\> given\\.$#"
count: 2
path: src/Db/Plan/Plan.php
message: "#^Access to an undefined property PDO\\:\\:\\$connection\\.$#"
count: 1
path: src/Db/Adapter/PdoAdapter.php

-
message: "#^Possibly invalid array key type Cake\\\\Database\\\\Schema\\\\TableSchemaInterface\\|string\\.$#"
Expand Down
4 changes: 2 additions & 2 deletions src/Db/Adapter/MysqlAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ protected function getColumnSqlDefinition(Column $column): string

$def .= $column->getEncoding() ? ' CHARACTER SET ' . $column->getEncoding() : '';
$def .= $column->getCollation() ? ' COLLATE ' . $column->getCollation() : '';
$def .= !$column->isSigned() && isset($this->signedColumnTypes[$column->getType()]) ? ' unsigned' : '';
$def .= !$column->isSigned() && isset($this->signedColumnTypes[(string)$column->getType()]) ? ' unsigned' : '';
$def .= $column->isNull() ? ' NULL' : ' NOT NULL';

Check warning on line 1366 in src/Db/Adapter/MysqlAdapter.php

View check run for this annotation

Codecov / codecov/patch

src/Db/Adapter/MysqlAdapter.php#L1363-L1366

Added lines #L1363 - L1366 were not covered by tests

if (
Expand Down Expand Up @@ -1450,7 +1450,7 @@ protected function getIndexSqlDefinition(Index $index): string
$def .= ' (';
foreach ($columns as $column) {
$limit = !isset($limits[$column]) || $limits[$column] <= 0 ? '' : '(' . $limits[$column] . ')';
$columnSort = isset($order[$column]) ?? '';
$columnSort = $order[$column] ?? '';
$def .= '`' . $column . '`' . $limit . ' ' . $columnSort . ', ';

Check warning on line 1454 in src/Db/Adapter/MysqlAdapter.php

View check run for this annotation

Codecov / codecov/patch

src/Db/Adapter/MysqlAdapter.php#L1448-L1454

Added lines #L1448 - L1454 were not covered by tests
}
$def = rtrim($def, ', ');
Expand Down
8 changes: 6 additions & 2 deletions src/Db/Adapter/PdoAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ public function execute(string $sql, array $params = []): int
}

if (empty($params)) {
return $this->getConnection()->exec($sql);
$result = $this->getConnection()->exec($sql);

return is_int($result) ? $result : 0;
}

$stmt = $this->getConnection()->prepare($sql);
Expand Down Expand Up @@ -347,7 +349,9 @@ public function bulkinsert(Table $table, array $rows): void
);
$current = current($rows);
$keys = array_keys($current);

Check warning on line 351 in src/Db/Adapter/PdoAdapter.php

View check run for this annotation

Codecov / codecov/patch

src/Db/Adapter/PdoAdapter.php#L346-L351

Added lines #L346 - L351 were not covered by tests
$sql .= '(' . implode(', ', array_map([$this, 'quoteColumnName'], $keys)) . ') VALUES ';

$callback = fn ($key) => $this->quoteColumnName($key);
$sql .= '(' . implode(', ', array_map($callback, $keys)) . ') VALUES ';

Check warning on line 354 in src/Db/Adapter/PdoAdapter.php

View check run for this annotation

Codecov / codecov/patch

src/Db/Adapter/PdoAdapter.php#L353-L354

Added lines #L353 - L354 were not covered by tests

if ($this->isDryRunEnabled()) {
$values = array_map(function ($row) {
Expand Down

0 comments on commit 6b8d237

Please sign in to comment.