Skip to content

Commit 3ec804c

Browse files
committed
Add deprecation messages for two methods that were only annotated as being @deprecated
1 parent 28dd327 commit 3ec804c

File tree

6 files changed

+52
-3
lines changed

6 files changed

+52
-3
lines changed

src/Query/Exec/SingleSelectExecutor.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,27 @@
66

77
use Doctrine\DBAL\Connection;
88
use Doctrine\DBAL\Result;
9+
use Doctrine\Deprecations\Deprecation;
910
use Doctrine\ORM\Query\AST\SelectStatement;
1011
use Doctrine\ORM\Query\SqlWalker;
1112

1213
/**
1314
* Executor that executes the SQL statement for simple DQL SELECT statements.
1415
*
16+
* @deprecated This class is no longer needed by the ORM and will be removed in 4.0.
1517
* @link www.doctrine-project.org
1618
*/
1719
class SingleSelectExecutor extends AbstractSqlExecutor
1820
{
1921
public function __construct(SelectStatement $AST, SqlWalker $sqlWalker)
2022
{
23+
Deprecation::trigger(
24+
'doctrine/orm',
25+
'https://github.com/doctrine/orm/pull/11188/',
26+
'The %s is no longer needed by the ORM and will be removed in 4.0',
27+
self::class,
28+
);
29+
2130
$this->sqlStatements = $sqlWalker->walkSelectStatement($AST);
2231
}
2332

src/Query/ParserResult.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Doctrine\ORM\Query;
66

7+
use Doctrine\Deprecations\Deprecation;
78
use Doctrine\ORM\Query;
89
use Doctrine\ORM\Query\Exec\AbstractSqlExecutor;
910
use Doctrine\ORM\Query\Exec\SqlFinalizer;
@@ -71,20 +72,36 @@ public function setResultSetMapping(ResultSetMapping $rsm): void
7172
/**
7273
* Sets the SQL executor that should be used for this ParserResult.
7374
*
74-
* @deprecated
75+
* @deprecated The SqlExecutor will be removed from ParserResult in 4.0. Provide a SqlFinalizer instead that can create the executor.
7576
*/
7677
public function setSqlExecutor(AbstractSqlExecutor $executor): void
7778
{
79+
Deprecation::trigger(
80+
'doctrine/orm',
81+
'https://github.com/doctrine/orm/pull/11188',
82+
'The SqlExecutor will be removed from %s in 4.0. Provide a %s instead that can create the executor.',
83+
self::class,
84+
SqlFinalizer::class,
85+
);
86+
7887
$this->sqlExecutor = $executor;
7988
}
8089

8190
/**
8291
* Gets the SQL executor used by this ParserResult.
8392
*
84-
* @deprecated
93+
* @deprecated The SqlExecutor will be removed from ParserResult in 4.0. Provide a SqlFinalizer instead that can create the executor.
8594
*/
8695
public function getSqlExecutor(): AbstractSqlExecutor
8796
{
97+
Deprecation::trigger(
98+
'doctrine/orm',
99+
'https://github.com/doctrine/orm/pull/11188',
100+
'The SqlExecutor will be removed from %s in 4.0. Provide a %s instead that can create the executor.',
101+
self::class,
102+
SqlFinalizer::class,
103+
);
104+
88105
if ($this->sqlExecutor === null) {
89106
throw new LogicException(sprintf(
90107
'Executor not set yet. Call %s::setSqlExecutor() first.',

src/Query/SqlWalker.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Doctrine\DBAL\LockMode;
1010
use Doctrine\DBAL\Platforms\AbstractPlatform;
1111
use Doctrine\DBAL\Types\Type;
12+
use Doctrine\Deprecations\Deprecation;
1213
use Doctrine\ORM\EntityManagerInterface;
1314
use Doctrine\ORM\Mapping\ClassMetadata;
1415
use Doctrine\ORM\Mapping\QuoteStrategy;
@@ -230,6 +231,14 @@ public function setQueryComponent(string $dqlAlias, array $queryComponent): void
230231
*/
231232
public function getExecutor(AST\SelectStatement|AST\UpdateStatement|AST\DeleteStatement $statement): Exec\AbstractSqlExecutor
232233
{
234+
Deprecation::trigger(
235+
'doctrine/orm',
236+
'https://github.com/doctrine/orm/pull/11188/',
237+
'Output walkers should implement %s. That way, the %s method is no longer needed and will be removed in 4.0',
238+
OutputWalker::class,
239+
__METHOD__,
240+
);
241+
233242
return match (true) {
234243
$statement instanceof AST\UpdateStatement => $this->createUpdateStatementExecutor($statement),
235244
$statement instanceof AST\DeleteStatement => $this->createDeleteStatementExecutor($statement),

tests/Tests/ORM/Functional/ParserResultSerializationTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Doctrine\Tests\ORM\Functional;
66

77
use Closure;
8+
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
89
use Doctrine\ORM\Query;
910
use Doctrine\ORM\Query\Exec\FinalizedSelectExecutor;
1011
use Doctrine\ORM\Query\Exec\PreparedExecutorFinalizer;
@@ -26,6 +27,8 @@
2627

2728
class ParserResultSerializationTest extends OrmFunctionalTestCase
2829
{
30+
use VerifyDeprecations;
31+
2932
protected function setUp(): void
3033
{
3134
$this->useModelSet('company');
@@ -98,6 +101,8 @@ public function testUnserializeSingleSelectResult(string $serialized): void
98101
$this->assertInstanceOf(ParserResult::class, $unserialized);
99102
$this->assertInstanceOf(ResultSetMapping::class, $unserialized->getResultSetMapping());
100103
$this->assertEquals(['name' => [0]], $unserialized->getParameterMappings());
104+
105+
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/11188');
101106
$this->assertInstanceOf(SingleSelectExecutor::class, $unserialized->getSqlExecutor());
102107
$this->assertIsString($unserialized->getSqlExecutor()->getSqlStatements());
103108
}

tests/Tests/ORM/Functional/QueryCacheTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Doctrine\DBAL\Connection;
88
use Doctrine\ORM\Query;
99
use Doctrine\ORM\Query\Exec\AbstractSqlExecutor;
10+
use Doctrine\ORM\Query\Exec\SqlFinalizer;
1011
use Doctrine\ORM\Query\ParserResult;
1112
use Doctrine\Tests\OrmFunctionalTestCase;
1213
use PHPUnit\Framework\Attributes\Depends;
@@ -130,8 +131,11 @@ public function execute(Connection $conn, array $params, array $types): int
130131
}
131132
};
132133

134+
$sqlFinalizerMock = $this->createMock(SqlFinalizer::class);
135+
$sqlFinalizerMock->method('createExecutor')->with($query)->willReturn($sqlExecutorStub);
136+
133137
$parserResultMock = new ParserResult();
134-
$parserResultMock->setSqlExecutor($sqlExecutorStub);
138+
$parserResultMock->setSqlFinalizer($sqlFinalizerMock);
135139

136140
$cache = $this->createMock(CacheItemPoolInterface::class);
137141

tests/Tests/ORM/Query/ParserResultTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Doctrine\Tests\ORM\Query;
66

7+
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
78
use Doctrine\ORM\Query\Exec\AbstractSqlExecutor;
89
use Doctrine\ORM\Query\ParserResult;
910
use Doctrine\ORM\Query\ResultSetMapping;
@@ -12,6 +13,8 @@
1213

1314
class ParserResultTest extends TestCase
1415
{
16+
use VerifyDeprecations;
17+
1518
/** @var ParserResult */
1619
public $parserResult;
1720

@@ -37,6 +40,8 @@ public function testItThrowsWhenAttemptingToAccessTheExecutorBeforeItIsSet(): vo
3740

3841
public function testSetGetSqlExecutor(): void
3942
{
43+
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/11188');
44+
4045
$executor = $this->createMock(AbstractSqlExecutor::class);
4146
$this->parserResult->setSqlExecutor($executor);
4247
self::assertSame($executor, $this->parserResult->getSqlExecutor());

0 commit comments

Comments
 (0)