Skip to content

fix: import the phpdb exception marker from its current location - #97

Merged
tyrsson merged 1 commit into
2.0.xfrom
fix/phpdb-exception-interface
Oct 10, 2026
Merged

tyrsson merged 1 commit into
2.0.xfrom
fix/phpdb-exception-interface

Conversation

@tyrsson

@tyrsson tyrsson commented Oct 10, 2026

Copy link
Copy Markdown
Member

PhpDb\Sql\Exception\ExceptionInterface no longer exists. Commit 01a9406b in php-db/phpdb, "Make PhpDb\Exception\ExceptionInterface the only marker, extending Throwable", removed the Sql namespaced one.

This is a prerequisite for #92, which crosses that commit and currently fails mago analyze:

error[non-existent-use-import]: Imported class, interface, trait, or enum
`PhpDb\Sql\Exception\ExceptionInterface` does not exist.

Why the import cannot simply be left alone

The removed interface was not a supertype of the new one. When the import cannot resolve, analyze has no type to match against, so every throwable in the hierarchy becomes unhandled and no @throws tag can cover it. The unhandled-thrown-type error follows from the missing class, not from a separate defect.

Two files, not one

File Use
src/Console/InitDbCommand.php aliased as SqlException
src/Handler/PhpDbHandler.php direct import, used by the write() docblock

The second only surfaced after fixing the first, because analyze reports the first failure and the earlier CI log tail showed only the handler.

The replacement is stricter, not looser

PhpDb\Exception\ExceptionInterface extends Throwable, and every exception in the hierarchy implements it. The Sql namespaced subclasses extend their PhpDb\Exception counterparts:

class InvalidArgumentException extends Exception\InvalidArgumentException
class RuntimeException extends Exception\RuntimeException

so PhpDb\Sql\Exception\InvalidArgumentException is still covered by a @throws PhpDb\Exception\ExceptionInterface tag.

Verified against the failure, not just the current pin

  • confirmed the old interface is absent at 7d1b659 and present at 69c8da3, and that 01a9406b is not an ancestor of the current pin, which is why 2.0.x is green today
  • temporarily moved php-db/phpdb to 7d1b659 and reproduced the CI failure, then confirmed analyze clean with the fix
  • mago analyze at 7d1b659: no issues
  • restored the lock, so this PR is source only and does not collide with Lock file maintenance #92

Gates at the current pin, phpdb 69c8da3:

  • mago format --check: already formatted
  • mago lint: no issues
  • mago analyze: no issues
  • mago guard: no issues
  • composer test: 100 tests, 179 assertions, OK

PhpDb\Sql\Exception\ExceptionInterface no longer exists. Commit 01a9406b
in php-db/phpdb made PhpDb\Exception\ExceptionInterface the only marker
and removed the Sql namespaced one.

The removed interface is not a supertype of the new one, so an import
pointing at it leaves analyze with nothing to match: the class cannot be
resolved, and every throwable in the hierarchy becomes unhandled because
no @throws tag can cover it.

Two files referenced it. InitDbCommand aliases it as SqlException, and
PhpDbHandler used it directly for the write() docblock.

The replacement is a stricter marker, not a looser one. Every exception in
the hierarchy now implements PhpDb\Exception\ExceptionInterface, including
PhpDb\Sql\Exception\InvalidArgumentException and RuntimeException, which
extend their PhpDb\Exception counterparts, and that interface extends
Throwable.

This is a prerequisite for the lock file maintenance PR, which crosses the
removal commit and currently fails analyze for these two imports.
@codecov

codecov Bot commented Oct 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@tyrsson
tyrsson merged commit 029f797 into 2.0.x Oct 10, 2026
12 checks passed
@tyrsson
tyrsson deleted the fix/phpdb-exception-interface branch October 10, 2026 08:56
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.

1 participant