Skip to content

Commit 9320d8e

Browse files
Fix #642: Remove unsed Stringable in Query::class (#644)
1 parent 1d1b646 commit 9320d8e

4 files changed

Lines changed: 8 additions & 30 deletions

File tree

src/Query/Query.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
use function preg_match;
3030
use function preg_split;
3131
use function reset;
32-
use function serialize;
3332
use function str_contains;
3433
use function strcasecmp;
3534
use function strlen;
@@ -93,14 +92,6 @@ public function __construct(protected ConnectionInterface $db)
9392
{
9493
}
9594

96-
/**
97-
* Returns the SQL representation of Query.
98-
*/
99-
public function __toString(): string
100-
{
101-
return serialize($this);
102-
}
103-
10495
public function addGroupBy(array|string|ExpressionInterface $columns): static
10596
{
10697
if ($columns instanceof ExpressionInterface) {

src/Query/QueryInterface.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Yiisoft\Db\Query;
66

77
use Closure;
8-
use Stringable;
98
use Throwable;
109
use Yiisoft\Db\Command\CommandInterface;
1110
use Yiisoft\Db\Exception\Exception;
@@ -27,7 +26,7 @@
2726
*
2827
* Sorting is supported via {@see orderBy()} and items can be limited to match some conditions using {@see where()}.
2928
*/
30-
interface QueryInterface extends ExpressionInterface, QueryPartsInterface, QueryFunctionsInterface, Stringable
29+
interface QueryInterface extends ExpressionInterface, QueryPartsInterface, QueryFunctionsInterface
3130
{
3231
/**
3332
* Adds more parameters to biun to the query.

src/QueryBuilder/AbstractDQLQueryBuilder.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -382,14 +382,13 @@ public function buildUnion(array $unions, array &$params): string
382382

383383
$result = '';
384384

385-
/** @psalm-var array<array{query:Query|string, all:bool}> $unions */
386-
foreach ($unions as $i => $union) {
387-
$query = $union['query'];
388-
if ($query instanceof QueryInterface) {
389-
[$unions[$i]['query'], $params] = $this->build($query, $params);
385+
/** @psalm-var array<array{query:string|Query, all:bool}> $unions */
386+
foreach ($unions as $union) {
387+
if ($union['query'] instanceof QueryInterface) {
388+
[$union['query'], $params] = $this->build($union['query'], $params);
390389
}
391390

392-
$result .= 'UNION ' . ($union['all'] ? 'ALL ' : '') . '( ' . $unions[$i]['query'] . ' ) ';
391+
$result .= 'UNION ' . ($union['all'] ? 'ALL ' : '') . '( ' . $union['query'] . ' ) ';
393392
}
394393

395394
return trim($result);
@@ -418,9 +417,8 @@ public function buildWithQueries(array $withs, array &$params): string
418417
$recursive = true;
419418
}
420419

421-
$query = $with['query'];
422-
if ($query instanceof QueryInterface) {
423-
[$with['query'], $params] = $this->build($query, $params);
420+
if ($with['query'] instanceof QueryInterface) {
421+
[$with['query'], $params] = $this->build($with['query'], $params);
424422
}
425423

426424
$result[] = $with['alias'] . ' AS (' . $with['query'] . ')';

tests/AbstractQueryTest.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -696,16 +696,6 @@ public function testShouldEmulateExecution(): void
696696
$this->assertTrue($query->shouldEmulateExecution());
697697
}
698698

699-
public function testToString(): void
700-
{
701-
$db = $this->getConnection();
702-
703-
$query = new Query($db);
704-
$query->select('id')->from('user')->where(['id' => 1]);
705-
706-
$this->assertSame(serialize($query), (string)$query);
707-
}
708-
709699
public function testWhere(): void
710700
{
711701
$db = $this->getConnection();

0 commit comments

Comments
 (0)