diff --git a/psalm.xml b/psalm.xml
index 23bfcce17..54a52e176 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -14,4 +14,7 @@
+
+
+
diff --git a/src/Command/CommandInterface.php b/src/Command/CommandInterface.php
index 955e28c3b..bd3ac08a7 100644
--- a/src/Command/CommandInterface.php
+++ b/src/Command/CommandInterface.php
@@ -177,6 +177,8 @@ public function alterColumn(string $table, string $column, ColumnInterface|strin
* @throws Exception
* @throws InvalidArgumentException
*
+ * @psalm-param iterable> $rows
+ *
* Note: The method will quote the `table` and `column` parameters before using them in the generated SQL.
*/
public function batchInsert(string $table, array $columns, iterable $rows): static;
diff --git a/src/QueryBuilder/AbstractDMLQueryBuilder.php b/src/QueryBuilder/AbstractDMLQueryBuilder.php
index 1d6ea3f49..884a5a1b2 100644
--- a/src/QueryBuilder/AbstractDMLQueryBuilder.php
+++ b/src/QueryBuilder/AbstractDMLQueryBuilder.php
@@ -58,14 +58,12 @@ public function batchInsert(string $table, array $columns, iterable $rows, array
$columns = $this->getNormalizeColumnNames($columns);
$columnSchemas = $this->schema->getTableSchema($table)?->getColumns() ?? [];
- /** @psalm-var array[] $rows */
foreach ($rows as $row) {
$i = 0;
$placeholders = [];
- /** @psalm-var mixed $value */
+
foreach ($row as $value) {
if (isset($columns[$i], $columnSchemas[$columns[$i]])) {
- /** @psalm-var mixed $value */
$value = $columnSchemas[$columns[$i]]->dbTypecast($value);
}
@@ -213,15 +211,10 @@ protected function prepareInsertValues(string $table, array|QueryInterface $colu
$columns = $this->normalizeColumnNames($columns);
$columnSchemas = $this->schema->getTableSchema($table)?->getColumns() ?? [];
- /**
- * @psalm-var mixed $value
- * @psalm-var array $columns
- */
foreach ($columns as $name => $value) {
$names[] = $this->quoter->quoteColumnName($name);
if (isset($columnSchemas[$name])) {
- /** @var mixed $value */
$value = $columnSchemas[$name]->dbTypecast($value);
}
@@ -251,13 +244,8 @@ protected function prepareUpdateSets(string $table, array $columns, array $param
$columns = $this->normalizeColumnNames($columns);
$columnSchemas = $this->schema->getTableSchema($table)?->getColumns() ?? [];
- /**
- * @psalm-var array $columns
- * @psalm-var mixed $value
- */
foreach ($columns as $name => $value) {
if (isset($columnSchemas[$name])) {
- /** @psalm-var mixed $value */
$value = $columnSchemas[$name]->dbTypecast($value);
}
@@ -282,6 +270,7 @@ protected function prepareUpdateSets(string $table, array $columns, array $param
* @throws JsonException
* @throws NotSupportedException
*
+ * @psalm-param array|QueryInterface $insertColumns
* @psalm-param Constraint[] $constraints
*
* @return array Array of unique, insert and update quoted column names.
@@ -296,7 +285,6 @@ protected function prepareUpsertColumns(
if ($insertColumns instanceof QueryInterface) {
[$insertNames] = $this->prepareInsertSelectSubQuery($insertColumns);
} else {
- /** @psalm-var array $insertColumns */
$insertNames = $this->getNormalizeColumnNames(array_keys($insertColumns));
$insertNames = array_map(
@@ -305,7 +293,6 @@ protected function prepareUpsertColumns(
);
}
- /** @psalm-var string[] $uniqueNames */
$uniqueNames = $this->getTableUniqueColumnNames($table, $insertNames, $constraints);
if ($updateColumns === true) {
@@ -328,7 +315,7 @@ protected function prepareUpsertColumns(
*
* @throws JsonException
*
- * @return array The quoted column names.
+ * @return string[] The quoted column names.
*
* @psalm-param Constraint[] $constraints
*/
@@ -405,6 +392,8 @@ static function (Constraint $constraint) use ($quoter, $columns, &$columnNames):
* @param array $columns The column data (name => value).
*
* @return array The normalized column names (name => value).
+ *
+ * @psalm-return array
*/
protected function normalizeColumnNames(array $columns): array
{
diff --git a/src/QueryBuilder/DMLQueryBuilderInterface.php b/src/QueryBuilder/DMLQueryBuilderInterface.php
index 31b8043cd..b877ac568 100644
--- a/src/QueryBuilder/DMLQueryBuilderInterface.php
+++ b/src/QueryBuilder/DMLQueryBuilderInterface.php
@@ -43,6 +43,7 @@ interface DMLQueryBuilderInterface
* @return string The batch INSERT SQL statement.
*
* @psalm-param string[] $columns
+ * @psalm-param iterable> $rows
*
* Note:
* - That the values in each row must match the corresponding column names.