Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow "Expr\Func" as condition in join in PHPDoc #10202

Merged
merged 1 commit into from
Nov 10, 2022
Merged
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
16 changes: 8 additions & 8 deletions lib/Doctrine/ORM/Query/Expr/Join.php
Original file line number Diff line number Diff line change
@@ -37,19 +37,19 @@ class Join
*/
protected $conditionType;

/** @var string|Comparison|Composite|null */
/** @var string|Comparison|Composite|Func|null */
protected $condition;

/** @var string|null */
protected $indexBy;

/**
* @param string $joinType The condition type constant. Either INNER_JOIN or LEFT_JOIN.
* @param string $join The relationship to join.
* @param string|null $alias The alias of the join.
* @param string|null $conditionType The condition type constant. Either ON or WITH.
* @param string|Comparison|Composite|null $condition The condition for the join.
* @param string|null $indexBy The index for the join.
* @param string $joinType The condition type constant. Either INNER_JOIN or LEFT_JOIN.
* @param string $join The relationship to join.
* @param string|null $alias The alias of the join.
* @param string|null $conditionType The condition type constant. Either ON or WITH.
* @param string|Comparison|Composite|Func|null $condition The condition for the join.
* @param string|null $indexBy The index for the join.
* @psalm-param self::INNER_JOIN|self::LEFT_JOIN $joinType
* @psalm-param self::ON|self::WITH|null $conditionType
*/
@@ -93,7 +93,7 @@ public function getConditionType()
return $this->conditionType;
}

/** @return string|Comparison|Composite|null */
/** @return string|Comparison|Composite|Func|null */
public function getCondition()
{
return $this->condition;
30 changes: 15 additions & 15 deletions lib/Doctrine/ORM/QueryBuilder.php
Original file line number Diff line number Diff line change
@@ -992,11 +992,11 @@ public function indexBy($alias, $indexBy)
* ->join('u.Phonenumbers', 'p', Expr\Join::WITH, 'p.is_primary = 1');
* </code>
*
* @param string $join The relationship to join.
* @param string $alias The alias of the join.
* @param string|null $conditionType The condition type constant. Either ON or WITH.
* @param string|Expr\Comparison|Expr\Composite|null $condition The condition for the join.
* @param string|null $indexBy The index for the join.
* @param string $join The relationship to join.
* @param string $alias The alias of the join.
* @param string|null $conditionType The condition type constant. Either ON or WITH.
* @param string|Expr\Comparison|Expr\Composite|Expr\Func|null $condition The condition for the join.
* @param string|null $indexBy The index for the join.
* @psalm-param Expr\Join::ON|Expr\Join::WITH|null $conditionType
*
* @return $this
@@ -1019,11 +1019,11 @@ public function join($join, $alias, $conditionType = null, $condition = null, $i
* ->from('User', 'u')
* ->innerJoin('u.Phonenumbers', 'p', Expr\Join::WITH, 'p.is_primary = 1');
*
* @param string $join The relationship to join.
* @param string $alias The alias of the join.
* @param string|null $conditionType The condition type constant. Either ON or WITH.
* @param string|Expr\Comparison|Expr\Composite|null $condition The condition for the join.
* @param string|null $indexBy The index for the join.
* @param string $join The relationship to join.
* @param string $alias The alias of the join.
* @param string|null $conditionType The condition type constant. Either ON or WITH.
* @param string|Expr\Comparison|Expr\Composite|Expr\Func|null $condition The condition for the join.
* @param string|null $indexBy The index for the join.
* @psalm-param Expr\Join::ON|Expr\Join::WITH|null $conditionType
*
* @return $this
@@ -1060,11 +1060,11 @@ public function innerJoin($join, $alias, $conditionType = null, $condition = nul
* ->leftJoin('u.Phonenumbers', 'p', Expr\Join::WITH, 'p.is_primary = 1');
* </code>
*
* @param string $join The relationship to join.
* @param string $alias The alias of the join.
* @param string|null $conditionType The condition type constant. Either ON or WITH.
* @param string|Expr\Comparison|Expr\Composite|null $condition The condition for the join.
* @param string|null $indexBy The index for the join.
* @param string $join The relationship to join.
* @param string $alias The alias of the join.
* @param string|null $conditionType The condition type constant. Either ON or WITH.
* @param string|Expr\Comparison|Expr\Composite|Expr\Func|null $condition The condition for the join.
* @param string|null $indexBy The index for the join.
* @psalm-param Expr\Join::ON|Expr\Join::WITH|null $conditionType
*
* @return $this
17 changes: 17 additions & 0 deletions tests/Doctrine/Tests/ORM/QueryBuilderTest.php
Original file line number Diff line number Diff line change
@@ -183,6 +183,23 @@ public function testComplexInnerJoinWithCompositeCondition(): void
);
}

public function testComplexInnerJoinWithFuncCondition(): void
{
$qb = $this->entityManager->createQueryBuilder();
$qb
->select('u', 'a')
->from(CmsUser::class, 'u')
->innerJoin('u.articles', 'a', Join::WITH, $qb->expr()->in(
'u.id',
[1, 2, 3]
));

$this->assertValidQueryBuilder(
$qb,
'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a WITH u.id IN(1, 2, 3)'
);
}

public function testComplexInnerJoinWithIndexBy(): void
{
$qb = $this->entityManager->createQueryBuilder()