Skip to content

Walk DDL column lists with foreach - #216

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

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

Conversation

@simon-mundy

Copy link
Copy Markdown
Member

Depends on #215. Until the earlier PRs in this series merge, this diff also shows their commits; the change here is the last commit, "Walk DDL column lists with foreach".

Removes 4 analyzer findings (possibly-null-argument, possibly-undefined-int-array-index) in src/Sql/Ddl.

Changes

  • AbstractConstraint::getExpressionData() and Index::getExpressionData() iterate their column lists with foreach instead of indexing from zero, which the analyzer cannot prove is in range.
  • The analyzer baseline is regenerated; only src/Sql entries change.

Breaking changes

None.

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

AbstractSql::processJoin() and Select read an aliased table's alias
with array_key_first() instead of key()/current(), so the result no
longer depends on the array's internal pointer and the analyzer can
see the alias is a string.

Signed-off-by: Simon Mundy <simon.mundy@peptolab.com>
AbstractConstraint and Index iterate their column lists with foreach
instead of indexing from zero, which the analyzer cannot prove is in
range.

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
@github-project-automation github-project-automation Bot moved this to Todo in @phpdb 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 and others added 3 commits October 6, 2026 11:57
Cover multi-column primary and unique keys, which a single column
could not distinguish from leaving the column specification unexpanded.

Ignore the array_fill() start-index mutants in getExpressionData(), as
already done for ForeignKey: implode() discards the keys, so the start
index cannot be observed.

Signed-off-by: Simon Mundy <simon.mundy@peptolab.com>
@simon-mundy
simon-mundy marked this pull request as ready for review October 6, 2026 02:18
@simon-mundy
simon-mundy requested a review from tyrsson October 6, 2026 02:19
@simon-mundy
simon-mundy merged commit 0de8956 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