Repository navigation
Configure mago guard to enforce the library's layering - #249
Open
simon-mundy wants to merge 1 commit into
Open
simon-mundy wants to merge 1 commit into
simon-mundy wants to merge 1 commit into
Conversation
mago guard had no perimeter or structural rules, so it passed without checking anything. Add five perimeter restrictions that forbid upward dependencies between the library's layers, and three naming rules the codebase already follows. Restrictions forbid only the dependencies they name, so everything else stays allowed; the two known back-edges are permitted on purpose. Tests are excluded, since they may depend on anything.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Configure guard in
mago.toml.PhpDb\Container\PhpDb(ConfigProvider),ContainerPhpDb\TableGateway\TableGateway,ContainerPhpDb\RowGateway\RowGateway,TableGateway,ContainerPhpDb\Metadata\Metadata,TableGateway,ContainerPhpDb\Sql\Sqland the layers above it,Adapter\Platform,PhpDbThese use restrictions, not
layering. A layering list denies every dependency it doesn't explicitly permit, including PHP built-ins such as#[Override]. Restrictions forbid only what they name and leave everything else allowed. The two known back-edges are permitted explicitly, so they are documented in the config and cannot spread to other namespaces.Structural inclusions: Codebase baseline rules/conventions.
Exceptionnamespace are named*Exception;*Interface;PhpDb\Containerare named*Factory, apart fromAdapterInterfaceDelegator.Tests are excluded: Test code may depend on anything.
Omissions
must-be-final: making public classesfinalis an API decision.must-implement: it only checks a class's ownimplementsclause, not inherited interfaces.Verification
mago guardreports no issues on this branch, and with Bring src/Adapter to Mago compliance #248 (Adapter) merged in.PhpDb\Sqlthat takes and returns aTableGateway:disallowed-use,disallowed-parameter-typeanddisallowed-return-type;*Interface:must-be-named.mago format --check,mago lint,mago analyzeandmago guardrun correctly on PHP 8.3, 8.4 and 8.5.mago.tomlchanges.