Repository navigation
Route the TableGateway and RowGateway throw sites through named constructors - #193
Merged
simon-mundy merged 4 commits intoSep 29, 2026
Merged
Conversation
This was referenced Sep 28, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced Sep 28, 2026
simon-mundy
force-pushed
the
exception/pr-4-table-gateway
branch
from
September 28, 2026 22:52
27d546d to
960343b
Compare
…ructors All 36 throw sites in src/TableGateway and src/RowGateway now call a named constructor. Message text is byte-identical apart from the magic-access messages noted below, verified template by template against the originals. - Add 19 templates and factories to TableGateway\Exception\RuntimeException, 4 to its InvalidArgumentException, 5 to RowGateway\Exception\RuntimeException and 2 to its InvalidArgumentException - Cover PrimaryReplicaFeature, added by php-db#187. Its first guard reuses MISSING_SQL_INSTANCE; its second reports the primary rather than the master, so MISSING_MASTER_SQL becomes MISSING_PRIMARY_SQL. MasterSlaveFeature no longer throws, since php-db#187 left it delegating to the replacement - Collapse the four "table name of the provided X object" copies onto one template taking the statement name - Report the concrete class in the magic access messages: AbstractTableGateway interpolated self::class, so a TableGateway named its abstract parent. The three messages now carry static::class - Point SequenceFeature at TableGateway\Exception\RuntimeException; it was throwing the root PhpDb\Exception\RuntimeException from inside the component - Rename the test__* methods to testMagicGet, testMagicSet and testMagicCall forms and drop the codingStandardsIgnore pairs they needed - Cover every factory with a template test, and derive the message assertions from the templates rather than restating them - Re-attribute the baselined mixed-operand concatenation entry in AbstractRowGateway to the factory that now receives the argument, exclude src/TableGateway/Exception/ from too-many-methods, and baseline the halstead reading AbstractTableGateway shifts Signed-off-by: Simon Mundy <simon.mundy@peptolab.com>
simon-mundy
force-pushed
the
exception/pr-4-table-gateway
branch
from
September 29, 2026 03:34
960343b to
61047e7
Compare
Signed-off-by: Simon Mundy <simon.mundy@peptolab.com>
simon-mundy
force-pushed
the
exception/pr-4-table-gateway
branch
from
September 29, 2026 04:08
468dae9 to
fe2d578
Compare
tyrsson
approved these changes
Sep 29, 2026
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.
Types of changes
Checklist:
Description
PR 4 of 6 from #189: all 36 throw sites in
src/TableGatewayandsrc/RowGateway.Message text is byte-identical apart from the magic-access messages below, verified template by template against the original literals.
TableGateway\Exception\RuntimeException, 4 on itsInvalidArgumentException, 5 onRowGateway\Exception\RuntimeException, 2 on itsInvalidArgumentException.'The table name of the provided X object must match that of the table'copies collapse onto one template taking the statement name.PrimaryReplicaFeatureis covered. #187 added it and leftMasterSlaveFeaturedelegating to it, soMasterSlaveFeatureno longer throws at all. Its first guard reusesMISSING_SQL_INSTANCE; its second reports the primary rather than the master, soMISSING_MASTER_SQLbecameMISSING_PRIMARY_SQL.The magic-access messages now name the concrete class.
AbstractTableGatewayinterpolatedself::class, so aTableGatewayinstance reported its abstract parent:All three now carry
static::class. This changes the message for every subclass, which is the point. The three tests asserted a substring that excluded the class name, so they passed either way; they now assert the full rendered message against$this->table::class, which fails if the code reverts toself::class.SequenceFeaturewas throwing the rootPhpDb\Exception\RuntimeExceptionfrom inside the component, bypassingTableGateway\Exception. It now throws the component type, which extends the root one, so nothing catching the old type breaks.Test tidy-up in the two files this PR rewrites: the
test__call,test__getandtest__setmethods are renamed totestMagicCall,testMagicGetandtestMagicSetforms, and the@codingStandardsIgnorepairs they needed are gone. The stalemethod-namebaseline entries go with them.Motivation and Context
Refs #189. Depends on #190 for the convention, the constant naming rule and the structural guards.
Nothing here is a BC break. The component exception classes already extended the root ones, and the retypes only narrow within that chain.
How has this been tested?
mago format --check,mago lintandmago analyzeall exit 0. Full unit suite passes: 1709 tests, 3608 assertions.Every factory is covered: 19/19, 4/4, 5/5 and 2/2. All 30 templates verified byte-identical against the original literals by a throwaway script before the call sites were touched.
Baseline and configuration changes
mixed-operandentry onAbstractRowGateway("Invalid middle operand: typemixedcannot be reliably used in string concatenation") is re-attributed, not added to: the same unsoundness now reports as amixed-argumentagainstforMissingPrimaryKeyData, count unchanged at 1.src/TableGateway/Exception/is added to thetoo-many-methodsexclude inmago.toml, as Route the Sql throw sites through named constructors #192 does forsrc/Sql/Exception/. The threshold is 10 and the catalogue holds 19. This will conflict with Route the Sql throw sites through named constructors #192 on the same line — whichever merges second needs the two paths merged into one array.halsteadreading onAbstractTableGatewayis baselined. Removing long string literals reduces distinct operands, which raises halstead difficulty, so simplifying the method moved the metric the wrong way.