Skip to content

Fix Driver imports and untyped property; prune dead mago baseline entries - #85

Merged
tyrsson merged 2 commits into
0.5.xfrom
tyrsson-fix-driver-mysqli-result-import
Oct 7, 2026
Merged

tyrsson merged 2 commits into
0.5.xfrom
tyrsson-fix-driver-mysqli-result-import

Conversation

@tyrsson

@tyrsson tyrsson commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

What

Two mago-related fixes in src/Driver.php, plus the baseline regeneration they require:

  1. Adds the missing use mysqli_result; import.
  2. Gives $options the native array type hint it was missing.

analysis-baseline.toml was then regenerated by mago so the now-dead entries for that file are removed.

Fix 1 — missing mysqli_result import

src/Driver.php imported mysqli and mysqli_stmt but not mysqli_result, while the docblock for createResult() references it:

/**
 * Create result
 *
 * @param mysqli|mysqli_result|mysqli_stmt $resource
 */

Because the import was absent, the unqualified mysqli_result resolved relative to the current namespace as PhpDb\Mysql\mysqli_result, which does not exist. Adding use mysqli_result; in alphabetical position (between use mysqli; and use mysqli_stmt;) makes the reference resolve.

This clears 2 baselined findings:

  • non-existent-class-like — Cannot find class, interface, enum, or type alias PhpDb\Mysql\mysqli_result.
  • possibly-invalid-argument — argument base deps #1 of PhpDb\Mysql\Result::initialize

Fix 2 — untyped $options property

-    /** @var array */
-    protected $options = [
+    /** @var array $options */
+    protected array $options = [

The property carried only a docblock and no declared type, so mago reported missing-property-type ("Property $options is missing a type hint."). That check inspects declared property types, not annotations — verified by experiment: adding the variable name to the docblock alone left the finding in place, while declaring array cleared it. This matches src/Result.php, which uses natively-typed properties and never appears in the baseline.

This un-suppresses 3 findings — it does not add suppression

src/Driver.php had 6 baselined findings. These two changes clear exactly 3 of them, which mago then removed from the baseline:

  • non-existent-class-like — the unresolved PhpDb\Mysql\mysqli_result
  • possibly-invalid-argument — argument base deps #1 of PhpDb\Mysql\Result::initialize
  • missing-property-type — the untyped $options

Net effect: the baseline goes from 90 → 87 entries, with 3 remaining for this file. This is an improvement — real defects are no longer masked — rather than a new suppression.

Baseline note

The baseline was regenerated by mago (mago analyze --generate-baseline), never hand-edited. Besides the 3 removals, the only other change is the message text of the pre-existing incompatible-parameter-type entry for createResult(): its message embedded the unresolved unknown-ref(PhpDb\Mysql\mysqli_result), which is now mysqli_result. The entry's intent is unchanged and it remains baselined.

Deliberately out of scope

The remaining 3 baselined findings for src/Driver.php are intentionally left alone:

  • 2 × incompatible-parameter-type — Driver::createResult() / Driver::createStatement() narrow the parent interface's resource parameter to mysqli|.... This is a parameter-contravariance issue that belongs to phpdb core's DriverInterface (whose resource type is PHP-7-era), not to this repo. A real fix changes core, so this awaits a separate decision.
  • docblock-type-mismatch — the /** @var mysqli $resource */ annotation does not match what is assigned.

Verification

  • mago format --check — all files already formatted
  • mago lint — no issues found (no unused-import on the new import, no redundant-docblock complaint)
  • mago analyze — no issues found
  • mago guard — no guard configuration present; checks skipped, no issues
  • vendor/bin/phpunit --testsuite "unit test" — OK (193 tests, 385 assertions)

Diff: 2 files changed, 4 insertions(+), 21 deletions(-).

Does not reopen #71 — that issue is closed and its remaining findings are intentionally baselined.

…tries

src/Driver.php references mysqli_result in the docblock for createResult() but never imported it, so the unqualified name resolved to the non-existent PhpDb\Mysql\mysqli_result. Adding the import clears 2 of the 6 baselined findings for this file: non-existent-class-like and possibly-invalid-argument.

Regenerating the baseline with mago also refreshed the message on the pre-existing incompatible-parameter-type entry for createResult(), whose text embedded the unresolved unknown-ref(PhpDb\Mysql\mysqli_result). The entry itself is unchanged in intent and remains baselined.

The remaining 4 baselined findings for this file are deliberately left alone: two incompatible-parameter-type contravariance violations against DriverInterface::resource (a phpdb core concern), plus missing-property-type and docblock-type-mismatch.
@codecov

codecov Bot commented Oct 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

The property was untyped, so mago reported missing-property-type. Declaring `array` satisfies the check; the docblock now also names the variable. Regenerated the analysis baseline with mago, dropping the now-dead entry (88 -> 87 blocks; src/Driver.php 4 -> 3).
@tyrsson tyrsson changed the title Add missing mysqli_result import to Driver and prune dead baseline entries Fix Driver imports and untyped property; prune dead mago baseline entries Oct 7, 2026
@tyrsson
tyrsson merged commit 7685a95 into 0.5.x Oct 7, 2026
15 checks passed
@tyrsson
tyrsson deleted the tyrsson-fix-driver-mysqli-result-import branch October 10, 2026 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants