Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
60 changes: 0 additions & 60 deletions analyzer-baseline.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2778,24 +2778,6 @@ code = "impossible-condition"
message = "This condition (type `false`) will always evaluate to false."
count = 1

[[issues]]
file = "src/Sql/Predicate/Predicate.php"
code = "imprecise-type"
message = "Type `array` in parameter `$identifier` is imprecise, equivalent to `array<array-key, mixed>`."
count = 2

[[issues]]
file = "src/Sql/Predicate/Predicate.php"
code = "imprecise-type"
message = "Type `array` in parameter `$maxValue` is imprecise, equivalent to `array<array-key, mixed>`."
count = 2

[[issues]]
file = "src/Sql/Predicate/Predicate.php"
code = "imprecise-type"
message = "Type `array` in parameter `$minValue` is imprecise, equivalent to `array<array-key, mixed>`."
count = 2

[[issues]]
file = "src/Sql/Predicate/Predicate.php"
code = "imprecise-type"
Expand Down Expand Up @@ -2826,54 +2808,12 @@ code = "less-specific-nested-argument-type"
message = 'Argument type mismatch for argument #2 of `PhpDb\Sql\Expression::__construct`: expected `PhpDb\Sql\ArgumentInterface|PhpDb\Sql\ExpressionInterface|array<array-key, PhpDb\Sql\ArgumentInterface|PhpDb\Sql\ExpressionInterface|list<bool|float|int|null|string>|null|scalar>|list<bool|float|int|null|string>|null|scalar`, but provided type `PhpDb\Sql\ArgumentInterface|PhpDb\Sql\ExpressionInterface|float|int|non-empty-array<array-key, mixed>|null|string` is less specific.'
count = 1

[[issues]]
file = "src/Sql/Predicate/Predicate.php"
code = "possibly-invalid-argument"
message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Predicate\Between::__construct`: expected `PhpDb\Sql\ArgumentInterface|null|string`, but possibly received `PhpDb\Sql\ArgumentInterface|array<array-key, mixed>|float|int|null|string`.'
count = 2

[[issues]]
file = "src/Sql/Predicate/Predicate.php"
code = "possibly-invalid-argument"
message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Predicate\In::__construct`: expected `PhpDb\Sql\ArgumentInterface|null|string`, but possibly received `PhpDb\Sql\ArgumentInterface|float|int|string`.'
count = 2

[[issues]]
file = "src/Sql/Predicate/Predicate.php"
code = "possibly-invalid-argument"
message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Predicate\IsNull::__construct`: expected `PhpDb\Sql\ArgumentInterface|null|string`, but possibly received `PhpDb\Sql\ArgumentInterface|float|int|string`.'
count = 2

[[issues]]
file = "src/Sql/Predicate/Predicate.php"
code = "possibly-invalid-argument"
message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Predicate\Like::__construct`: expected `PhpDb\Sql\ArgumentInterface|null|string`, but possibly received `PhpDb\Sql\ArgumentInterface|float|int|null|string`.'
count = 2

[[issues]]
file = "src/Sql/Predicate/Predicate.php"
code = "possibly-invalid-argument"
message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Predicate\Operator::__construct`: expected `PhpDb\Sql\ArgumentInterface|PhpDb\Sql\ExpressionInterface|PhpDb\Sql\SqlInterface|null|string`, but possibly received `PhpDb\Sql\ArgumentInterface|float|int|null|string`.'
count = 6

[[issues]]
file = "src/Sql/Predicate/Predicate.php"
code = "possibly-invalid-argument"
message = 'Possible argument type mismatch for argument #2 of `PhpDb\Sql\Predicate\Between::__construct`: expected `PhpDb\Sql\ArgumentInterface|float|int|null|string`, but possibly received `PhpDb\Sql\ArgumentInterface|array<array-key, mixed>|float|int|null|string`.'
count = 2

[[issues]]
file = "src/Sql/Predicate/Predicate.php"
code = "possibly-invalid-argument"
message = 'Possible argument type mismatch for argument #2 of `PhpDb\Sql\Predicate\In::__construct`: expected `PhpDb\Sql\ArgumentInterface|PhpDb\Sql\Select|list<bool|float|int|null|string>|null`, but possibly received `PhpDb\Sql\ArgumentInterface|array<array-key, mixed>`.'
count = 2

[[issues]]
file = "src/Sql/Predicate/Predicate.php"
code = "possibly-invalid-argument"
message = 'Possible argument type mismatch for argument #3 of `PhpDb\Sql\Predicate\Between::__construct`: expected `PhpDb\Sql\ArgumentInterface|float|int|null|string`, but possibly received `PhpDb\Sql\ArgumentInterface|array<array-key, mixed>|float|int|null|string`.'
count = 2

[[issues]]
file = "src/Sql/Predicate/PredicateInterface.php"
code = "missing-api-or-internal"
Expand Down
45 changes: 27 additions & 18 deletions docs/book/sql/where-having.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,35 +132,35 @@ class Predicate extends PredicateSet
public function setUnnest(?Predicate $predicate = null) : void;
public function unnest() : Predicate;
public function equalTo(
null|float|int|string|ArgumentInterface $left,
null|string|ArgumentInterface $left,
null|float|int|string|ArgumentInterface $right
) : static;
public function notEqualTo(
null|float|int|string|ArgumentInterface $left,
null|string|ArgumentInterface $left,
null|float|int|string|ArgumentInterface $right
) : static;
public function lessThan(
null|float|int|string|ArgumentInterface $left,
null|string|ArgumentInterface $left,
null|float|int|string|ArgumentInterface $right
) : static;
public function greaterThan(
null|float|int|string|ArgumentInterface $left,
null|string|ArgumentInterface $left,
null|float|int|string|ArgumentInterface $right
) : static;
public function lessThanOrEqualTo(
null|float|int|string|ArgumentInterface $left,
null|string|ArgumentInterface $left,
null|float|int|string|ArgumentInterface $right
) : static;
public function greaterThanOrEqualTo(
null|float|int|string|ArgumentInterface $left,
null|string|ArgumentInterface $left,
null|float|int|string|ArgumentInterface $right
) : static;
public function like(
null|float|int|string|ArgumentInterface $identifier,
null|string|ArgumentInterface $identifier,
null|float|int|string|ArgumentInterface $like
) : static;
public function notLike(
null|float|int|string|ArgumentInterface $identifier,
null|string|ArgumentInterface $identifier,
null|float|int|string|ArgumentInterface $notLike
) : static;
public function literal(string $literal) : static;
Expand All @@ -170,28 +170,28 @@ class Predicate extends PredicateSet
|ExpressionInterface $parameters = []
) : static;
public function isNull(
float|int|string|ArgumentInterface $identifier
string|ArgumentInterface $identifier
) : static;
public function isNotNull(
float|int|string|ArgumentInterface $identifier
string|ArgumentInterface $identifier
) : static;
public function in(
float|int|string|ArgumentInterface $identifier,
string|ArgumentInterface $identifier,
array|ArgumentInterface $valueSet
) : static;
public function notIn(
float|int|string|ArgumentInterface $identifier,
string|ArgumentInterface $identifier,
array|ArgumentInterface $valueSet
) : static;
public function between(
null|float|int|string|array|ArgumentInterface $identifier,
null|float|int|string|array|ArgumentInterface $minValue,
null|float|int|string|array|ArgumentInterface $maxValue
null|string|ArgumentInterface $identifier,
null|float|int|string|ArgumentInterface $minValue,
null|float|int|string|ArgumentInterface $maxValue
) : static;
public function notBetween(
null|float|int|string|array|ArgumentInterface $identifier,
null|float|int|string|array|ArgumentInterface $minValue,
null|float|int|string|array|ArgumentInterface $maxValue
null|string|ArgumentInterface $identifier,
null|float|int|string|ArgumentInterface $minValue,
null|float|int|string|ArgumentInterface $maxValue
) : static;
public function predicate(PredicateInterface $predicate) : static;

Expand Down Expand Up @@ -222,6 +222,15 @@ class Predicate extends PredicateSet
> `ArgumentInterface` implementations. Pass an `Argument\Identifier` for
> column names, `Argument\Value` for values, or `Argument\Literal` for raw
> SQL fragments directly to control how values are treated.
>
> The left-hand side and identifier parameters accept a string (treated as an
> identifier) or an `ArgumentInterface`. To put a value on the left, wrap it in
> `Argument\Value`:
>
> ```php
> $where->equalTo(new Argument\Value(5), new Argument\Identifier('quantity'));
> // WHERE '5' = "quantity"
> ```

Each method in the API will produce a corresponding `Predicate` object
of a similarly named type, as described below.
Expand Down
36 changes: 18 additions & 18 deletions src/Sql/Predicate/Predicate.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class Predicate extends PredicateSet
* @return $this Provides a fluent interface
*/
public function between(
float|int|string|array|ArgumentInterface|null $identifier,
float|int|string|array|ArgumentInterface|null $minValue,
float|int|string|array|ArgumentInterface|null $maxValue,
string|ArgumentInterface|null $identifier,
float|int|string|ArgumentInterface|null $minValue,
float|int|string|ArgumentInterface|null $maxValue,
): static {
$this->addPredicate(
new Between($identifier, $minValue, $maxValue),
Expand All @@ -48,7 +48,7 @@ public function between(
* Utilizes Operator predicate
*/
public function equalTo(
float|int|string|ArgumentInterface|null $left,
string|ArgumentInterface|null $left,
float|int|string|ArgumentInterface|null $right,
): static {
$this->addPredicate(
Expand Down Expand Up @@ -83,7 +83,7 @@ public function expression(
* @return $this Provides a fluent interface
*/
public function greaterThan(
float|int|string|ArgumentInterface|null $left,
string|ArgumentInterface|null $left,
float|int|string|ArgumentInterface|null $right,
): static {
$this->addPredicate(
Expand All @@ -101,7 +101,7 @@ public function greaterThan(
* @return $this Provides a fluent interface
*/
public function greaterThanOrEqualTo(
float|int|string|ArgumentInterface|null $left,
string|ArgumentInterface|null $left,
float|int|string|ArgumentInterface|null $right,
): static {
$this->addPredicate(
Expand All @@ -118,7 +118,7 @@ public function greaterThanOrEqualTo(
*
* @return $this Provides a fluent interface
*/
public function in(float|int|string|ArgumentInterface $identifier, array|ArgumentInterface $valueSet): static
public function in(string|ArgumentInterface $identifier, array|ArgumentInterface $valueSet): static
{
$this->addPredicate(
new In($identifier, $valueSet),
Expand All @@ -134,7 +134,7 @@ public function in(float|int|string|ArgumentInterface $identifier, array|Argumen
*
* @return $this Provides a fluent interface
*/
public function isNotNull(float|int|string|ArgumentInterface $identifier): static
public function isNotNull(string|ArgumentInterface $identifier): static
{
$this->addPredicate(
new IsNotNull($identifier),
Expand All @@ -150,7 +150,7 @@ public function isNotNull(float|int|string|ArgumentInterface $identifier): stati
*
* @return $this Provides a fluent interface
*/
public function isNull(float|int|string|ArgumentInterface $identifier): static
public function isNull(string|ArgumentInterface $identifier): static
{
$this->addPredicate(
new IsNull($identifier),
Expand All @@ -165,7 +165,7 @@ public function isNull(float|int|string|ArgumentInterface $identifier): static
* Utilizes Operator predicate
*/
public function lessThan(
float|int|string|ArgumentInterface|null $left,
string|ArgumentInterface|null $left,
float|int|string|ArgumentInterface|null $right,
): static {
$this->addPredicate(
Expand All @@ -183,7 +183,7 @@ public function lessThan(
* @return $this Provides a fluent interface
*/
public function lessThanOrEqualTo(
float|int|string|ArgumentInterface|null $left,
string|ArgumentInterface|null $left,
float|int|string|ArgumentInterface|null $right,
): static {
$this->addPredicate(
Expand All @@ -201,7 +201,7 @@ public function lessThanOrEqualTo(
* @return $this Provides a fluent interface
*/
public function like(
float|int|string|ArgumentInterface|null $identifier,
string|ArgumentInterface|null $identifier,
float|int|string|ArgumentInterface|null $like,
): static {
$this->addPredicate(
Expand Down Expand Up @@ -248,9 +248,9 @@ public function nest(): self
* @return $this Provides a fluent interface
*/
public function notBetween(
float|int|string|array|ArgumentInterface|null $identifier,
float|int|string|array|ArgumentInterface|null $minValue,
float|int|string|array|ArgumentInterface|null $maxValue,
string|ArgumentInterface|null $identifier,
float|int|string|ArgumentInterface|null $minValue,
float|int|string|ArgumentInterface|null $maxValue,
): static {
$this->addPredicate(
new NotBetween($identifier, $minValue, $maxValue),
Expand All @@ -265,7 +265,7 @@ public function notBetween(
* Utilizes Operator predicate
*/
public function notEqualTo(
float|int|string|ArgumentInterface|null $left,
string|ArgumentInterface|null $left,
float|int|string|ArgumentInterface|null $right,
): static {
$this->addPredicate(
Expand All @@ -282,7 +282,7 @@ public function notEqualTo(
*
* @return $this Provides a fluent interface
*/
public function notIn(float|int|string|ArgumentInterface $identifier, array|ArgumentInterface $valueSet): static
public function notIn(string|ArgumentInterface $identifier, array|ArgumentInterface $valueSet): static
{
$this->addPredicate(
new NotIn($identifier, $valueSet),
Expand All @@ -299,7 +299,7 @@ public function notIn(float|int|string|ArgumentInterface $identifier, array|Argu
* @return $this Provides a fluent interface
*/
public function notLike(
float|int|string|ArgumentInterface|null $identifier,
string|ArgumentInterface|null $identifier,
float|int|string|ArgumentInterface|null $notLike,
): static {
$this->addPredicate(
Expand Down
Loading
Loading