Skip to content

Bring Metadata, Exception and Feature to full Mago compliance - #197

Merged
simon-mundy merged 2 commits into
php-db:0.6.xfrom
simon-mundy:compliance/metadata-exception-feature
Oct 5, 2026
Merged

simon-mundy merged 2 commits into
php-db:0.6.xfrom
simon-mundy:compliance/metadata-exception-feature

Conversation

@simon-mundy

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

Copy link
Copy Markdown
Member

Clears every remaining Mago finding in src/Metadata, src/Exception and src/Feature. All three now leave both baselines entirely, taking the count of fully compliant components from one to three.

Before After
Lint baseline 348 345
Analyzer baseline 1215 1206
PHPUnit 1988 tests, 3901 assertions 1988 tests, 3901 assertions

Both baselines are regenerated, so the twelve findings are removed rather than suppressed. mago lint, mago analyze and mago format --check are clean.

src/Exception (4 → 0)

Three no-fully-qualified-global-class-like: the root exception classes named their parent fully qualified, as extends \InvalidArgumentException. A plain import is not available, since each class shadows the name of the class it extends, so each imports the parent under a Base alias. That follows the existing convention in TableGateway\Feature\FeatureInterface and Sql\Predicate\Expression.

One missing-api-or-internal: ExceptionInterface is marked @api, matching the fourteen files already carrying the tag.

src/Metadata (8 → 0)

Six missing-constant-type: explicit string types on the five FK_* constants in ConstraintKeyObject and on AbstractSource::DEFAULT_SCHEMA. Typed constants require PHP 8.3, which is the floor (~8.3.0 || ~8.4.0 || ~8.5.0), and TableGateway\Feature\EventFeatureEventsInterface already uses the syntax.

Two class-must-be-final: Metadata\Exception\InvalidArgumentException and RuntimeException are marked final. Nothing in src or test subclasses either.

Note on the final exception classes

The remaining twenty exception classes in src stay non-final, so the convention is mixed until each component is visited on its own. Sealing all of them at once is a BC break for anyone subclassing, and is better decided deliberately than as a side effect of this branch.

Worth flagging for whoever picks up the next component: class-must-be-final is not simply flagging empty {} exception classes. Metadata\Exception\RuntimeException has six constants and six named constructors and was still flagged, while the Sql and Sql\Predicate exception classes are not flagged despite also being non-final. The reason is not yet understood, so do not assume those are exempt by design.

Declares the constant types Mago asks for on the ConstraintKeyObject
foreign key actions and on AbstractSource::DEFAULT_SCHEMA. Typed
constants need PHP 8.3, which is the floor, and EventFeatureEventsInterface
already uses them.

The three root exception classes import their parent under a Base alias
rather than naming it fully qualified. A plain import is not available:
each class shadows the name of the class it extends.

ExceptionInterface is marked @api, matching the fourteen files that
already carry the tag.

The two Metadata exception classes are marked final. Nothing subclasses
them. The remaining exception classes are left alone, so the convention
is mixed until each component is visited.

Feature was already clean. All three components now leave both baselines
entirely: lint falls to 345 and the analyzer to 1206.
@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 Oct 4, 2026
@simon-mundy simon-mundy added documentation Improvements or additions to documentation enhancement New feature or request qa Improvements in quality assurance of the project labels Oct 4, 2026
@simon-mundy simon-mundy added this to the 0.6.0 milestone Oct 4, 2026
@simon-mundy
simon-mundy requested a review from tyrsson October 4, 2026 23:05
@simon-mundy
simon-mundy merged commit e01caf6 into php-db:0.6.x Oct 5, 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 enhancement New feature or request qa Improvements in quality assurance of the project

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants