|
8 | 8 | use Doctrine\Common\Collections\Criteria; |
9 | 9 | use Doctrine\DBAL\ArrayParameterType; |
10 | 10 | use Doctrine\DBAL\ParameterType; |
| 11 | +use Doctrine\Deprecations\Deprecation; |
11 | 12 | use Doctrine\ORM\Internal\NoUnknownNamedArguments; |
12 | 13 | use Doctrine\ORM\Query\Expr; |
13 | 14 | use Doctrine\ORM\Query\Parameter; |
@@ -305,8 +306,13 @@ private function findRootAlias(string $alias, string $parentAlias): string |
305 | 306 | } else { |
306 | 307 | // Should never happen with correct joining order. Might be |
307 | 308 | // thoughtful to throw exception instead. |
308 | | - // @phpstan-ignore method.deprecated |
309 | | - $rootAlias = $this->getRootAlias(); |
| 309 | + $aliases = $this->getRootAliases(); |
| 310 | + |
| 311 | + if (! isset($aliases[0])) { |
| 312 | + throw new RuntimeException('No alias was set before invoking getRootAlias().'); |
| 313 | + } |
| 314 | + |
| 315 | + $rootAlias = $aliases[0]; |
310 | 316 | } |
311 | 317 |
|
312 | 318 | $this->joinRootAliases[$alias] = $rootAlias; |
@@ -582,14 +588,25 @@ public function add(string $dqlPartName, string|object|array $dqlPart, bool $app |
582 | 588 | $dqlPart = reset($dqlPart); |
583 | 589 | } |
584 | 590 |
|
585 | | - // This is introduced for backwards compatibility reasons. |
586 | | - // TODO: Remove for 3.0 |
587 | 591 | if ($dqlPartName === 'join') { |
588 | 592 | $newDqlPart = []; |
589 | 593 |
|
590 | 594 | foreach ($dqlPart as $k => $v) { |
591 | | - // @phpstan-ignore method.deprecated |
592 | | - $k = is_numeric($k) ? $this->getRootAlias() : $k; |
| 595 | + if (is_numeric($k)) { |
| 596 | + Deprecation::trigger( |
| 597 | + 'doctrine/orm', |
| 598 | + 'https://github.com/doctrine/orm/pull/12051', |
| 599 | + 'Using numeric keys in %s for join parts is deprecated and will not be supported in 4.0. Use an associative array with the root alias as key instead.', |
| 600 | + __METHOD__, |
| 601 | + ); |
| 602 | + $aliases = $this->getRootAliases(); |
| 603 | + |
| 604 | + if (! isset($aliases[0])) { |
| 605 | + throw new RuntimeException('No alias was set before invoking add().'); |
| 606 | + } |
| 607 | + |
| 608 | + $k = $aliases[0]; |
| 609 | + } |
593 | 610 |
|
594 | 611 | $newDqlPart[$k] = $v; |
595 | 612 | } |
|
0 commit comments