Skip to content

Sql docblock typing - #204

Merged
simon-mundy merged 2 commits into
php-db:0.6.xfrom
simon-mundy:qa/mago-sql-docblocks
Oct 6, 2026
Merged

simon-mundy merged 2 commits into
php-db:0.6.xfrom
simon-mundy:qa/mago-sql-docblocks

Conversation

@simon-mundy

Copy link
Copy Markdown
Member

Depends on #203. Until it merges, this diff also shows #203's two commits; the change here is the last commit, "Describe Sql shapes in docblocks".

Adds docblock types across src/Sql, reducing Mago analyzer findings there from 636 to 423 (counted without the baseline). Docblocks only: with comments and whitespace stripped, every changed file has the same PHP token stream as before.

Changes

  • AbstractSql declares Specification, SqlParameters and ColumnReference type aliases. Join declares JoinName and JoinSpecification, and implements Iterator<int, JoinSpecification>.
  • Subclasses import Specification, so $specifications keeps one invariant type across Select, Insert, InsertIgnore, Update, Delete, Combine, CreateTable, AlterTable and DropTable.
  • Select, Insert, Update, Delete and Sql type their table references, column lists, predicates and combine state. Each process* method describes the array it returns.
  • DDL classes type their pending columns, constraints, drops, table options, column options and constraint/index column lists. The unresolvable @psalm-return tags on AlterTable's process* methods are replaced.
  • Expression declares an ExpressionParameter alias. ExpressionInterface::getExpressionData() returns values as a list. PredicateSet types its predicate list, and In and Argument::values() type their value sets.
  • The analyzer baseline is regenerated. Beyond the src/Sql entries, it gains entries for TableGateway, which passes untyped values into the newly typed parameters.

Breaking changes

None.

mago format, mago lint, mago analyze and the unit tests pass.

AbstractSql declares Specification, SqlParameters and ColumnReference
aliases and Join declares JoinSpecification, which subclasses import so
$specifications keeps one invariant type. Select, Insert, Update,
Delete, Combine, the DDL classes, Expression, PredicateSet and Sql type
their tables, columns, predicates, options and process* output.

Docblocks only; no code changes.

Signed-off-by: Simon Mundy <simon.mundy@peptolab.com>
@codecov

codecov Bot commented Oct 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@simon-mundy
simon-mundy marked this pull request as ready for review October 6, 2026 01:25
@simon-mundy
simon-mundy merged commit 783540e into php-db:0.6.x Oct 6, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation Lang Feature Refactor Refactoring to new language features qa Improvements in quality assurance of the project

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants