Skip to content

Clear the Mago lint baseline across the test suite - #196

Merged
simon-mundy merged 3 commits into
php-db:0.6.xfrom
simon-mundy:chore/regenerate-mago-baselines
Sep 29, 2026
Merged

simon-mundy merged 3 commits into
php-db:0.6.xfrom
simon-mundy:chore/regenerate-mago-baselines

Conversation

@simon-mundy

@simon-mundy simon-mundy commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Applies the Mago lint fixes that can be made automatically, repairs the six sites where those fixes were wrong, and regenerates both baselines. Source files are untouched; every change is under test/ or in a baseline.

Result

Before After
Lint baseline (issues) 3948 348
Lint baseline (entries) 1398 227
— in test/ 3700 99
— in src/ 248 249
Analyzer baseline 1215 1215 (untouched)
PHPUnit 1988 tests, 3901 assertions 1988 tests, 3901 assertions

mago lint, mago analyze and mago format --check are clean. The assertion count is unchanged, so no assertion was weakened or dropped.

test/ fell from 94% of the suppressed issues to 28%.

Commits

  1. Regenerate the baselines under 1.50.0 — drops 18 entries for issues that no longer exist, left behind by the exception convention work in Introduce the named exception constructor convention #190 and the mutation coverage work in Close 68 escaped mutants across metadata, SQL and table gateway #188.
  2. Apply the safe lint fixes — assertion-style (2070), prefer-test-attribute (1007) and strict-assertions (515), plus the six manual repairs below.
  3. Import the Test attribute and regenerate — the first pass wrote the attribute fully qualified, trading those fixes for 1008 new no-fully-qualified-global-class-like issues.

The six repairs

Four test methods lost their test prefix and became count(), which overrides a final PHPUnit\Framework\TestCase::count() — a fatal error at load. They are renamed after the behaviour they cover: countsStoredParameters, countsRowsInDataSource, countsPopulatedColumns, countsJoinedTables.

assertAttributeEquals was rewritten to assertAttributeSame, which DeprecatedAssertionsTrait did not provide. The trait now has it.

ResultTest keeps its static fn() => uniqid() closure. As uniqid(...) it receives the three arguments PDOStatement::fetch() passes, and uniqid() takes at most two. The two other first class callable conversions in AbstractSqlFunctionalTestCase stub zero argument methods and are kept.

One real bug found

strict-assertions exposed LikeTest and NotLikeTest asserting that an unconfigured predicate returns '' from getIdentifier() and getLike(). Both return null; the assertions passed only because '' == null. They now assert null.

prefer-self-return-type must not be applied

Mago marks it safe, but in ArrayObjectResultSetInterface it rewrites ResultSetInterface&ArrayObjectResultSetInterface to ResultSetInterface&self, and self is not permitted inside an intersection type — the file stops parsing. It is still 5 findings in src, so anyone running --fix there will hit a fatal. Worth an upstream report or a mago.toml exclusion before the next pass. prefer-first-class-callable needs the same caution, since it ignores whether the closure was discarding arguments.

What remains

348 lint (249 src, 99 test) and 1215 analyzer findings, all still baselined. The analyzer set is where the real defects are, headed by AbstractResultSet calling rewind(), current() and valid() on a property typed to allow IteratorAggregate, which has none of them.

Drops 18 entries for issues that no longer exist: the seven per-component
ExceptionInterface files deleted in PR php-db#190, four exception classes that
are now final, three resolved unhandled-thrown-type and mixed-argument
sites, and the unfulfilled-expect and prefer-test-attribute entries
settled by the mutation coverage work in PR php-db#188.

Suppressed issue totals are unchanged at 3948 lint and 1215 analyzer, so
no new findings are masked.
Rewrites the assertion style, strict assertions and test attributes that
Mago can fix automatically. Six sites needed manual repair afterwards.

Four test methods lost their "test" prefix and collided with final
PHPUnit\Framework\TestCase methods, so they are renamed after the
behaviour they cover rather than the method they call. assertAttributeSame
joins DeprecatedAssertionsTrait, since the rewrite assumed it existed.

Like and NotLike assert null rather than the empty string for an
unconfigured predicate: getIdentifier() and getLike() return null, and the
old loose comparison only passed because '' == null.

The uniqid() callback in ResultTest keeps its closure. As a first class
callable it receives the three arguments PDOStatement::fetch() passes,
which uniqid() does not accept.

Source files are left untouched on this branch.
The first fix pass wrote the PHPUnit Test attribute fully qualified,
which traded 3592 assertion and attribute issues for 1008 new
no-fully-qualified-global-class-like ones. A second pass imports the
attribute instead.

The lint baseline now holds 348 issues, down from 3948. 249 sit in src
and 99 in test, so test is no longer the bulk of the suppression.

prefer-self-return-type is deliberately left unapplied: in
ArrayObjectResultSetInterface it rewrites an intersection type to use
self, which does not parse.
@codecov

codecov Bot commented Sep 29, 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 self-assigned this Sep 29, 2026
@simon-mundy simon-mundy added the qa Improvements in quality assurance of the project label Sep 29, 2026
@github-project-automation github-project-automation Bot moved this to Todo in @phpdb Sep 29, 2026
@simon-mundy simon-mundy added this to the 0.6.0 milestone Sep 29, 2026
@simon-mundy
simon-mundy merged commit ed4a407 into php-db:0.6.x Sep 29, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

qa Improvements in quality assurance of the project

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant