Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ed02b5a
Bring TableGateway and RowGateway to Mago compliance
simon-mundy Oct 11, 2026
b2bb593
Merge remote-tracking branch 'fork/qa/mago-sql-dml' into qa/mago-gate…
simon-mundy Oct 12, 2026
95c4b0e
Merge branch '0.6.x' into qa/mago-gateways
simon-mundy Oct 12, 2026
80da8c0
Merge remote-tracking branch 'fork/qa/mago-sql-dml' into qa/mago-gate…
simon-mundy Oct 12, 2026
7b82845
Merge remote-tracking branch 'fork/qa/mago-sql-dml' into qa/mago-gate…
simon-mundy Oct 12, 2026
3b42542
Merge remote-tracking branch 'fork/qa/mago-sql-dml' into qa/mago-gate…
simon-mundy Oct 12, 2026
02d88ed
Merge remote-tracking branch 'fork/qa/mago-sql-dml' into qa/mago-gate…
simon-mundy Oct 12, 2026
46b079a
Merge branch '0.6.x' into qa/mago-gateways
simon-mundy Oct 12, 2026
e9d25c0
Reinstate RowGateway FeatureSet's $magicSpecifications and tag it @api
simon-mundy Oct 12, 2026
b233546
Stop swapping aliased tables during gateway execution
simon-mundy Oct 12, 2026
36a8cee
Define the gateway table and where types on TableGatewayInterface
simon-mundy Oct 12, 2026
c200dce
Drop the coverage target for the removed AbstractTableGateway::unalia…
simon-mundy Oct 12, 2026
f2af463
Cover the abstract gateways by class rather than by method
simon-mundy Oct 12, 2026
608d9bb
Create gateway feature sets only when features are configured
simon-mundy Nov 4, 2026
3f363e3
Merge branch '0.6.x' into qa/mago-gateways
simon-mundy Nov 4, 2026
4eeae50
Clear the gateway test lint baseline entries
simon-mundy Nov 4, 2026
4bb3a79
Keep the table reference when cloning a table gateway
simon-mundy Nov 4, 2026
a478946
Test saving a composite-key row that is missing a key column
simon-mundy Nov 4, 2026
01f7686
Merge branch '0.6.x' into qa/mago-gateways
simon-mundy Nov 4, 2026
6cbedd1
Merge branch '0.6.x' into qa/mago-gateways
simon-mundy Nov 17, 2026
039b976
Merge branch '0.6.x' into qa/mago-gateways
simon-mundy Nov 17, 2026
d346046
Merge branch '0.6.x' into qa/mago-gateways
simon-mundy Nov 26, 2026
49c6d66
Merge branch '0.6.x' into qa/mago-gateways
simon-mundy Dec 2, 2026
2d80dc6
Create an empty feature set when a gateway initializes
simon-mundy Dec 2, 2026
e38728b
Accept keyed feature and join arrays in gateway docblocks
simon-mundy Dec 2, 2026
e637f29
Test the SQL a row gateway runs for save and delete
simon-mundy Dec 2, 2026
c7b5f57
Treat an empty primary key column list as missing
simon-mundy Dec 2, 2026
050c601
Clear the Mago 1.62 analyzer findings 0.6.x brings in
simon-mundy Dec 2, 2026
90bae70
Set default value for features parameter in constructor
simon-mundy Dec 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
612 changes: 3 additions & 609 deletions analyzer-baseline.toml

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions docs/book/table-gateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ constructor. The constructor can take features in 3 different forms:
- as a `FeatureSet` instance
- as an array of `Feature` instances

A gateway given no features creates an empty `FeatureSet` when it is
initialized, so `$this->featureSet` is always available to a subclass once
`initialize()` has run. A feature added to it afterwards, directly or through
`getFeatureSet()`, works like any other, except that it does not receive the
initialization events, which have already run.

There are a number of features built-in and shipped with laminas-db:

### GlobalAdapterFeature
Expand Down
120 changes: 3 additions & 117 deletions lint-baseline.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ code = "cyclomatic-complexity"
message = "Class has high complexity."
count = 1

[[issues]]
file = "src/RowGateway/AbstractRowGateway.php"
code = "halstead"
message = "Method has a high halstead difficulty"
count = 1

[[issues]]
file = "src/RowGateway/AbstractRowGateway.php"
code = "kan-defect"
Expand All @@ -54,60 +48,6 @@ code = "no-boolean-flag-parameter"
message = "Avoid boolean flag parameters."
count = 1

[[issues]]
file = "src/RowGateway/AbstractRowGateway.php"
code = "no-dead-store"
message = "Variable `$rowsAffected` is overwritten before its value is read."
count = 1

[[issues]]
file = "src/RowGateway/AbstractRowGateway.php"
code = "no-else-clause"
message = "Avoid `else` clauses."
count = 4

[[issues]]
file = "src/RowGateway/AbstractRowGateway.php"
code = "no-isset"
message = "Use of the `isset` construct."
count = 1

[[issues]]
file = "src/RowGateway/AbstractRowGateway.php"
code = "prefer-early-continue"
message = "Consider using early continue pattern to reduce nesting."
count = 1

[[issues]]
file = "src/RowGateway/AbstractRowGateway.php"
code = "too-many-methods"
message = "Class has too many methods."
count = 1

[[issues]]
file = "src/RowGateway/AbstractRowGateway.php"
code = "yoda-conditions"
message = "Use Yoda condition style for safer comparisons"
count = 6

[[issues]]
file = "src/RowGateway/Feature/FeatureSet.php"
code = "too-many-methods"
message = "Class has too many methods."
count = 1

[[issues]]
file = "src/RowGateway/RowGateway.php"
code = "no-else-clause"
message = "Avoid `else` clauses."
count = 1

[[issues]]
file = "src/RowGateway/RowGateway.php"
code = "no-negated-ternary"
message = "Negated ternary condition."
count = 1

[[issues]]
file = "src/Sql/Combine.php"
code = "cyclomatic-complexity"
Expand Down Expand Up @@ -156,64 +96,22 @@ code = "cyclomatic-complexity"
message = "Class has high complexity."
count = 1

[[issues]]
file = "src/TableGateway/AbstractTableGateway.php"
code = "halstead"
message = "Method has a high halstead difficulty"
count = 1

[[issues]]
file = "src/TableGateway/AbstractTableGateway.php"
code = "kan-defect"
message = "Class has a high kan defect score."
count = 1

[[issues]]
file = "src/TableGateway/AbstractTableGateway.php"
code = "no-else-clause"
message = "Avoid `else` clauses."
count = 1

[[issues]]
file = "src/TableGateway/AbstractTableGateway.php"
code = "no-else-clause"
message = "Avoid `elseif` clauses."
count = 2

[[issues]]
file = "src/TableGateway/AbstractTableGateway.php"
code = "no-isset"
message = "Use of the `isset` construct."
count = 3

[[issues]]
file = "src/TableGateway/AbstractTableGateway.php"
code = "too-many-methods"
message = "Class has too many methods."
count = 1

[[issues]]
file = "src/TableGateway/Feature/EventFeature.php"
code = "too-many-methods"
message = "Class has too many methods."
count = 1

[[issues]]
file = "src/TableGateway/Feature/FeatureSet.php"
code = "kan-defect"
message = "Class has a high kan defect score."
count = 1

[[issues]]
file = "src/TableGateway/Feature/FeatureSet.php"
code = "too-many-methods"
message = "Class has too many methods."
count = 1

[[issues]]
file = "src/TableGateway/TableGateway.php"
code = "no-shorthand-ternary"
message = "Use of the shorthand ternary operator."
file = "src/TableGateway/Feature/RowGatewayFeature.php"
code = "cyclomatic-complexity"
message = "Class has high complexity."
count = 1

[[issues]]
Expand All @@ -222,12 +120,6 @@ code = "no-isset"
message = "Use of the `isset` construct."
count = 2

[[issues]]
file = "test/unit/RowGateway/AbstractRowGatewayTest.php"
code = "no-isset"
message = "Use of the `isset` construct."
count = 4

[[issues]]
file = "test/unit/Sql/AbstractSqlFunctionalTestCase.php"
code = "halstead"
Expand Down Expand Up @@ -263,9 +155,3 @@ file = "test/unit/Sql/SelectTest.php"
code = "no-boolean-flag-parameter"
message = "Avoid boolean flag parameters."
count = 1

[[issues]]
file = "test/unit/TableGateway/TableGatewayTest.php"
code = "no-assign-in-argument"
message = "Avoid assignments in function call arguments."
count = 3
9 changes: 9 additions & 0 deletions mago.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ baseline = "lint-baseline.toml"
# Countable and ResultInterface, and ParameterContainer implements Iterator, ArrayAccess and
# Countable beside its errata and max-length accessors: in both, the count is fixed by the
# interfaces and the public API.
# AbstractTableGateway and AbstractRowGateway expose one public method per gateway operation
# plus the ArrayAccess and magic-property contracts, the two FeatureSets one method per hook
# and magic dispatch they forward to features, and EventFeature one listener per gateway event,
# so their method count is the size of their public API as well.
# "test/" repeats the phpdb-qa-tools default, which this key replaces.
too-many-methods = { exclude = [
"test/",
Expand All @@ -41,6 +45,11 @@ too-many-methods = { exclude = [
"src/Sql/Select.php",
"src/Sql/Insert.php",
"src/Sql/Update.php",
"src/TableGateway/AbstractTableGateway.php",
"src/TableGateway/Feature/EventFeature.php",
"src/TableGateway/Feature/FeatureSet.php",
"src/RowGateway/AbstractRowGateway.php",
"src/RowGateway/Feature/FeatureSet.php",
] }

# Select holds one property per clause of a SELECT statement.
Expand Down
9 changes: 1 addition & 8 deletions src/ResultSet/AbstractResultSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,16 @@
*/
private static function resolveIterator(Traversable $dataSource): Iterator
{
$depth = 0;

Check warning on line 115 in src/ResultSet/AbstractResultSet.php

View workflow job for this annotation

GitHub Actions / qa / Mutation testing

Escaped Mutant for Mutator "DecrementInteger": @@ @@ */ private static function resolveIterator(Traversable $dataSource): Iterator { - $depth = 0; + $depth = -1; while ($dataSource instanceof IteratorAggregate) { if (++$depth > self::MAX_ITERATOR_DEPTH) { throw InvalidArgumentException::forUnresolvableIterator(self::MAX_ITERATOR_DEPTH);
while ($dataSource instanceof IteratorAggregate) {
if (++$depth > self::MAX_ITERATOR_DEPTH) {

Check warning on line 117 in src/ResultSet/AbstractResultSet.php

View workflow job for this annotation

GitHub Actions / qa / Mutation testing

Escaped Mutant for Mutator "GreaterThan": @@ @@ { $depth = 0; while ($dataSource instanceof IteratorAggregate) { - if (++$depth > self::MAX_ITERATOR_DEPTH) { + if (++$depth >= self::MAX_ITERATOR_DEPTH) { throw InvalidArgumentException::forUnresolvableIterator(self::MAX_ITERATOR_DEPTH); }
throw InvalidArgumentException::forUnresolvableIterator(self::MAX_ITERATOR_DEPTH);
}

$dataSource = $dataSource->getIterator();
}

if ($dataSource instanceof Iterator) {
return $dataSource;
}

// @codeCoverageIgnoreStart
throw InvalidArgumentException::forNonIteratorDataSource($dataSource::class);

// @codeCoverageIgnoreEnd
return $dataSource;
}

/**
Expand All @@ -141,14 +134,14 @@
}

if (RowBufferState::Pending !== $this->bufferState) {
return $this;

Check warning on line 137 in src/ResultSet/AbstractResultSet.php

View workflow job for this annotation

GitHub Actions / qa / Mutation testing

Escaped Mutant for Mutator "ReturnRemoval": @@ @@ } if (RowBufferState::Pending !== $this->bufferState) { - return $this; + } $this->setBufferState(RowBufferState::Storing);
}

$this->setBufferState(RowBufferState::Storing);
$this->sourcePosition = 0;

if ($this->dataSource instanceof ResultInterface) {
$this->dataSource->rewind();

Check warning on line 144 in src/ResultSet/AbstractResultSet.php

View workflow job for this annotation

GitHub Actions / qa / Mutation testing

Escaped Mutant for Mutator "MethodCallRemoval": @@ @@ $this->sourcePosition = 0; if ($this->dataSource instanceof ResultInterface) { - $this->dataSource->rewind(); + } return $this;
}

return $this;
Expand All @@ -162,7 +155,7 @@
public function count(): ?int
{
if (null !== $this->count) {
return $this->count;

Check warning on line 158 in src/ResultSet/AbstractResultSet.php

View workflow job for this annotation

GitHub Actions / qa / Mutation testing

Escaped Mutant for Mutator "ReturnRemoval": @@ @@ public function count(): ?int { if (null !== $this->count) { - return $this->count; + } if ($this->dataSource instanceof Countable) {
}

if ($this->dataSource instanceof Countable) {
Expand Down
Loading
Loading