Skip to content

Commit a6310ac

Browse files
craigfrancisondrejmirtes
authored andcommitted
Add int to the between x/y values, and don't treat as a literal-string
1 parent a664b2a commit a6310ac

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

stubs/ORM/Query/Expr.stub

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class Expr
2323

2424
/**
2525
* @param string $val
26-
* @param string $x
27-
* @param string $y
26+
* @param int|string $x
27+
* @param int|string $y
2828
* @return ($val is literal-string ? ($x is literal-string ? ($y is literal-string ? literal-string&non-empty-string : string) : string) : string)
2929
*/
3030
public function between($val, $x, $y)

tests/Type/Doctrine/data/QueryResult/expressionBuilderGetQuery.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ private function nonLiteralString(string $value): string {
1414
return $value; // Using the 'string' return type to provide a non `literal-string`, e.g. $_POST['field'];
1515
}
1616

17+
private function nonLiteralInteger(int $value): int {
18+
return $value;
19+
}
20+
1721
public function isNullLiteralString(EntityManagerInterface $em): void
1822
{
1923
$result = $em->createQueryBuilder()->expr()->isNull('field');
@@ -67,6 +71,13 @@ public function betweenNonLiteralString3(EntityManagerInterface $em): void
6771
assertType('string', $result);
6872
}
6973

74+
public function betweenNonLiteralString4(EntityManagerInterface $em): void
75+
{
76+
$value = $this->nonLiteralInteger(2); // Integers are not literal-strings
77+
$result = $em->createQueryBuilder()->expr()->between('field', '1', $value);
78+
assertType('string', $result);
79+
}
80+
7081
public function countDistinctLiteralString(EntityManagerInterface $em): void
7182
{
7283
$result = $em->createQueryBuilder()->expr()->countDistinct('A', 'B', 'C');

tests/Type/Doctrine/data/QueryResult/expressionBuilderGetQueryNoObjectManager.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ public function betweenNonLiteralString3(EntityManagerInterface $em): void
6767
assertType('string', $result);
6868
}
6969

70+
public function betweenNonLiteralString4(EntityManagerInterface $em): void
71+
{
72+
$result = $em->createQueryBuilder()->expr()->between('field', '1', 2); // Integers are not literal-strings
73+
assertType('string', $result);
74+
}
75+
7076
public function countDistinctLiteralString(EntityManagerInterface $em): void
7177
{
7278
$result = $em->createQueryBuilder()->expr()->countDistinct('A', 'B', 'C');

0 commit comments

Comments
 (0)