Skip to content

Commit

Permalink
Deprecate the `\Doctrine\ORM\Query\Parser::setCustomOutputTreeWalker(…
Browse files Browse the repository at this point in the history
…)` method (#11641)

We use this method only from within one of our own test cases, and I don't see how it would be useful to anybody else outside – it has to be called on the `Parser` instance which exists internally in the `Query` only.

Deprecating and removing it in 3.x allows for a slight simplification in the `Parser` there, since we do no longer need the field (it can be a local variable).
  • Loading branch information
mpdude authored Oct 9, 2024
1 parent d80a831 commit 896c655
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ Progress on this is tracked at https://github.com/doctrine/orm/issues/11624 .
Use of the PARTIAL keyword is not deprecated anymore in DQL when used with a hydrator
that is not creating entities, such as the ArrayHydrator.

## Deprecate `\Doctrine\ORM\Query\Parser::setCustomOutputTreeWalker()`

Use the `\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER` query hint to set the output walker
class instead of setting it through the `\Doctrine\ORM\Query\Parser::setCustomOutputTreeWalker()` method
on the parser instance.

# Upgrade to 2.19

## Deprecate calling `ClassMetadata::getAssociationMappedByTargetField()` with the owning side of an association
Expand Down
7 changes: 7 additions & 0 deletions src/Query/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ public function __construct(Query $query)
*/
public function setCustomOutputTreeWalker($className)
{
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/pull/11641',
'%s is deprecated, set the output walker class with the \Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER query hint instead',
__METHOD__
);

$this->customOutputWalker = $className;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Tests/ORM/Query/LanguageRecognitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function parseDql(string $dql, array $hints = []): ParserResult
$parser = new Query\Parser($query);

// We do NOT test SQL output here. That only unnecessarily slows down the tests!
$parser->setCustomOutputTreeWalker(NullSqlWalker::class);
$query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, NullSqlWalker::class);

return $parser->parse();
}
Expand Down

0 comments on commit 896c655

Please sign in to comment.