Skip to content

Type the Sql class constants as string - #221

Merged
simon-mundy merged 5 commits into
php-db:0.6.xfrom
simon-mundy:qa/mago-sql-typed-constants
Oct 9, 2026
Merged

simon-mundy merged 5 commits into
php-db:0.6.xfrom
simon-mundy:qa/mago-sql-typed-constants

Conversation

@simon-mundy

Copy link
Copy Markdown
Member

Depends on #220. Until the earlier PRs in this series merge, this diff also shows their commits; the change here is the last commit, "Type the Sql class constants as string".

Clears the 85 missing-constant-type Mago analyzer findings in src/Sql.

Changes

  • Every untyped class constant in src/Sql is declared const string. All of them hold strings, including those that alias other constants (Select::JOIN_*, PredicateSet::COMBINED_BY_*).
  • The DeleteIgnore, UpdateIgnore and Replace test assets, which redeclare SPECIFICATION_* constants, declare them const string too.
  • The analyzer baseline is regenerated; only src/Sql entries change.

Breaking changes

  • A subclass that redeclares one of these constants must declare it const string. PHP rejects an untyped override of a typed constant: Type of X::SPECIFICATION_DELETE must be compatible with PhpDb\Sql\Delete::SPECIFICATION_DELETE of type string.

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

Test assets that redeclare SPECIFICATION_* constants now carry the
type too, as PHP rejects an untyped override of a typed constant.

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 added documentation Improvements or additions to documentation qa Improvements in quality assurance of the project Lang Feature Refactor Refactoring to new language features labels Oct 4, 2026
@simon-mundy simon-mundy added this to the 0.6.0 milestone Oct 4, 2026
@simon-mundy simon-mundy self-assigned this Oct 4, 2026
@simon-mundy
simon-mundy requested a review from tyrsson October 6, 2026 02:21
@simon-mundy
simon-mundy marked this pull request as ready for review October 6, 2026 02:22
tyrsson
tyrsson previously approved these changes Oct 8, 2026
@simon-mundy
simon-mundy merged commit 685862a into php-db:0.6.x Oct 9, 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