Repository navigation
Reject laminas-db operand types in comparison predicates - #267
Merged
simon-mundy merged 1 commit intoDec 1, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
simon-mundy
force-pushed
the
fix/263-comparison-type-arguments
branch
from
November 30, 2026 09:56
8ab66f3 to
3027d7b
Compare
laminas-db's equalTo(), notEqualTo(), lessThan(), lessThanOrEqualTo(), greaterThan(), greaterThanOrEqualTo() and the Operator constructor took $leftType and $rightType. Those parameters are gone, but PHP accepts surplus positional arguments, so migrated code that still passes them keeps running and silently compares a column with a string literal instead of two columns. Throw InvalidArgumentException::forRemovedOperandTypes() when the extra arguments are passed, naming the method and pointing to the Identifier and Value arguments that replace them. Fixes php-db#263 Signed-off-by: Simon Mundy <simon.mundy@peptolab.com>
simon-mundy
force-pushed
the
fix/263-comparison-type-arguments
branch
from
December 1, 2026 02:38
3027d7b to
0ef2b36
Compare
tyrsson
approved these changes
Dec 1, 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.
Fixes #263
Problem
laminas-db's comparison methods took
$leftTypeand$rightType. phpdb's take two arguments, and PHP ignores surplus arguments to a userland method, so migrated code such asequalTo('a', 'b', 'identifier', 'identifier')runs without error but compares columnawith the string'b'.new Operator($left, $op, $right, $leftType, $rightType)has the same problem.Fix
equalTo(),notEqualTo(),lessThan(),lessThanOrEqualTo(),greaterThan()andgreaterThanOrEqualTo()throw when given more than two arguments;Operator::__construct()throws when given more than three.Predicate\Exception\InvalidArgumentException::forRemovedOperandTypes(). Its message names the method and points toArgument::identifier()/Argument::value().where-having.mdalready notes that the type arguments were removed; it now also says that passing them throws.What stays the same
Operator, includingArgumentoperands.leftType:already fails with "Unknown named parameter".Tests
PredicateTest: a data provider over the six methods checks the exception class and message for four arguments and for a third argument alone, and that two-argument calls still work.OperatorTest: four and five arguments are rejected; three are accepted.mago lintis clean andmago analyzereports nothing new.mago formatalso realigned two existingmatchblocks inOperator.php, which were already unformatted on 0.6.x.