From 896c65504d8bfba1cdcf58ee9a9946f171400baa Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Wed, 9 Oct 2024 16:12:41 +0200 Subject: [PATCH] Deprecate the `\Doctrine\ORM\Query\Parser::setCustomOutputTreeWalker()` method (#11641) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- UPGRADE.md | 6 ++++++ src/Query/Parser.php | 7 +++++++ tests/Tests/ORM/Query/LanguageRecognitionTest.php | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/UPGRADE.md b/UPGRADE.md index 9ffc7d0f3e4..a42be6a4378 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -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 diff --git a/src/Query/Parser.php b/src/Query/Parser.php index 8852c8eef82..7d0a0176f4e 100644 --- a/src/Query/Parser.php +++ b/src/Query/Parser.php @@ -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; } diff --git a/tests/Tests/ORM/Query/LanguageRecognitionTest.php b/tests/Tests/ORM/Query/LanguageRecognitionTest.php index a2e0e600969..37aac27f260 100644 --- a/tests/Tests/ORM/Query/LanguageRecognitionTest.php +++ b/tests/Tests/ORM/Query/LanguageRecognitionTest.php @@ -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(); }