Skip to content

Commit 7a59c3d

Browse files
committed
Remove unnecessary comments from Part classes, keep only type annotations
Signed-off-by: Simon Mundy <simon.mundy@peptolab.com>
1 parent 09ba680 commit 7a59c3d

21 files changed

+10
-196
lines changed

src/Sql/Part/Columns.php

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,14 @@
1616
use function is_string;
1717
use function key;
1818

19-
/**
20-
* Holds column definitions and renders the column list for SELECT statements.
21-
* Includes both main table columns and join columns.
22-
*
23-
* Columns are normalized to ColumnRef[] at set time. Rendering is inlined
24-
* with instanceof fast-paths for Identifier (hot path) and Literal (star).
25-
*/
2619
class Columns extends AbstractPart
2720
{
28-
/** @var ColumnRef[] Normalized column references */
21+
/** @var ColumnRef[] */
2922
private array $columnRefs = [];
30-
31-
/** @var array Raw columns for getRawState() backward compatibility */
3223
private array $rawColumns = [Select::SQL_STAR];
33-
3424
private bool $prefixColumnsWithTable = true;
35-
36-
/**
37-
* Set during preparePartsForBuild -- the resolved table prefix (e.g. "table".)
38-
*/
3925
private string $fromTablePrefix = '';
40-
41-
/** @var JoinSpec[] Join specs for column resolution */
26+
/** @var JoinSpec[] */
4227
private array $joinSpecs = [];
4328

4429
public function __construct()
@@ -149,9 +134,6 @@ public function add(array|ExpressionInterface|string $column, ?string $alias = n
149134
return $this;
150135
}
151136

152-
/**
153-
* Reconstruct the original format for getRawState() compatibility.
154-
*/
155137
public function get(): array
156138
{
157139
return $this->rawColumns;
@@ -168,29 +150,19 @@ public function getPrefixColumnsWithTable(): bool
168150
return $this->prefixColumnsWithTable;
169151
}
170152

171-
/**
172-
* Set the table prefix for column resolution (e.g. "table".)
173-
*/
174153
public function setFromTablePrefix(string $prefix): static
175154
{
176155
$this->fromTablePrefix = $prefix;
177156
return $this;
178157
}
179158

180-
/**
181-
* Set join specs for column resolution during rendering.
182-
*
183-
* @param JoinSpec[] $specs
184-
*/
159+
/** @param JoinSpec[] $specs */
185160
public function setJoinSpecs(array $specs): static
186161
{
187162
$this->joinSpecs = $specs;
188163
return $this;
189164
}
190165

191-
/**
192-
* Normalize the raw columns array into ColumnRef[].
193-
*/
194166
private function normalizeColumns(): void
195167
{
196168
$this->columnRefs = [];

src/Sql/Part/Combine.php

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

77
use PhpDb\Sql\Select;
88

9-
/**
10-
* Holds and renders UNION/EXCEPT/INTERSECT clause for SELECT statements.
11-
*/
129
class Combine extends AbstractPart
1310
{
1411
private array $combine = [];

src/Sql/Part/From.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77
use PhpDb\Sql\Select;
88
use PhpDb\Sql\TableIdentifier;
99

10-
/**
11-
* Holds and renders a table reference with optional alias.
12-
* Used by Select (FROM), Insert (INTO), Update (UPDATE), Delete (DELETE FROM).
13-
* Normalizes input to TableRef at set time — alias extraction happens once, not at render time.
14-
*/
1510
class From extends AbstractPart
1611
{
1712
private ?TableRef $ref = null;
@@ -56,9 +51,6 @@ public function set(string|array|TableIdentifier|Select|null $table): static
5651
return $this;
5752
}
5853

59-
/**
60-
* Reconstruct the original format for getRawState() compatibility.
61-
*/
6254
public function get(): string|array|TableIdentifier|Select|null
6355
{
6456
if ($this->ref === null) {
@@ -72,10 +64,6 @@ public function get(): string|array|TableIdentifier|Select|null
7264
return $this->ref->table;
7365
}
7466

75-
/**
76-
* Get the quoted table prefix for column prefixing (e.g. "table".)
77-
* Returns the alias if one is set, otherwise the table name.
78-
*/
7967
public function getQuotedPrefix(SqlProcessor $processor): string
8068
{
8169
if ($this->ref === null) {

src/Sql/Part/GroupBy.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
use function is_array;
1212
use function is_string;
1313

14-
/**
15-
* Holds and renders GROUP BY clause.
16-
* Normalizes columns to ColumnRef at add time.
17-
*/
1814
class GroupBy extends AbstractPart
1915
{
2016
/** @var ColumnRef[]|null */
@@ -60,9 +56,6 @@ public function add(mixed $group): static
6056
return $this;
6157
}
6258

63-
/**
64-
* Reconstruct the original format for getRawState() compatibility.
65-
*/
6659
public function get(): ?array
6760
{
6861
if ($this->group === null) {

src/Sql/Part/Having.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
use PhpDb\Sql\Predicate\PredicateInterface;
1010
use PhpDb\Sql\Predicate\PredicateSet;
1111

12-
/**
13-
* Wraps a Having predicate model and renders it as a HAVING clause.
14-
*/
1512
class Having extends AbstractPart
1613
{
1714
public ?HavingModel $model = null;
@@ -30,9 +27,6 @@ public function isEmpty(): bool
3027
return $this->model === null || $this->model->count() === 0;
3128
}
3229

33-
/**
34-
* Add predicates to the having clause, or replace with a Having instance.
35-
*/
3630
public function addPredicates(
3731
PredicateInterface|HavingModel|array|Closure|string $predicate,
3832
string $combination = PredicateSet::OP_AND

src/Sql/Part/InsertColumnValue.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66

77
use PhpDb\Sql\ArgumentInterface;
88

9-
/**
10-
* Normalized INSERT column=value pair.
11-
* The value is stored as an ArgumentInterface (Parameter for scalars, Select for expressions/subqueries).
12-
*/
139
final readonly class InsertColumnValue
1410
{
1511
public function __construct(

src/Sql/Part/InsertSelect.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,13 @@
99
use function array_keys;
1010
use function implode;
1111

12-
/**
13-
* Renders an INSERT INTO table (columns) SELECT ... statement.
14-
* Mutually exclusive with InsertValues -- only one renders.
15-
*/
1612
class InsertSelect extends AbstractPart
1713
{
1814
private string $keyword = 'INSERT INTO';
1915
private From $table;
2016
private ?Select $select = null;
2117

22-
/** @var array<string, mixed> Column names (keys) from the columns array */
18+
/** @var array<string, mixed> */
2319
private array $columns = [];
2420

2521
public function __construct(From $table)

src/Sql/Part/InsertValues.php

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,12 @@
1616

1717
use function implode;
1818

19-
/**
20-
* Renders an INSERT INTO table (columns) VALUES (values) statement.
21-
* Mutually exclusive with InsertSelect -- only one renders.
22-
* Normalizes values to ArgumentInterface at setColumns time.
23-
*/
2419
class InsertValues extends AbstractPart
2520
{
2621
private string $keyword = 'INSERT INTO';
2722
private From $table;
2823

29-
/** @var InsertColumnValue[] Normalized column-value pairs */
24+
/** @var InsertColumnValue[] */
3025
private array $columnValues = [];
3126

3227
private bool $hasSelect = false;
@@ -87,11 +82,7 @@ public function getKeyword(): string
8782
return $this->keyword;
8883
}
8984

90-
/**
91-
* Set columns with values, normalizing to InsertColumnValue[].
92-
*
93-
* @param array<string, mixed> $columns Column-to-value mapping
94-
*/
85+
/** @param array<string, mixed> $columns */
9586
public function setColumns(array $columns): void
9687
{
9788
$this->columnValues = [];
@@ -100,9 +91,6 @@ public function setColumns(array $columns): void
10091
}
10192
}
10293

103-
/**
104-
* Reconstruct the raw column-to-value mapping for compatibility.
105-
*/
10694
public function getColumns(): array
10795
{
10896
$result = [];
@@ -117,9 +105,6 @@ public function setHasSelect(bool $hasSelect): void
117105
$this->hasSelect = $hasSelect;
118106
}
119107

120-
/**
121-
* Normalize a raw value to an ArgumentInterface.
122-
*/
123108
private function normalizeValue(string $column, mixed $value): ArgumentInterface
124109
{
125110
if ($value instanceof ArgumentInterface) {
@@ -138,7 +123,6 @@ private function normalizeValue(string $column, mixed $value): ArgumentInterface
138123
return new Literal('NULL');
139124
}
140125

141-
// Scalar — bind as parameter
142126
return new Parameter($value, preferredName: $column);
143127
}
144128
}

src/Sql/Part/JoinSpec.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@
1818
use function key;
1919
use function sprintf;
2020

21-
/**
22-
* Normalized join specification.
23-
* All type discrimination (array alias, table type, expression ON)
24-
* happens at construction time.
25-
*/
2621
final readonly class JoinSpec
2722
{
2823
public string|TableIdentifier|Select|ExpressionInterface $table;
@@ -32,7 +27,7 @@
3227
public bool $isExpressionOn;
3328
public string $type;
3429

35-
/** @var ColumnRef[] Pre-normalized column references */
30+
/** @var ColumnRef[] */
3631
public array $columnRefs;
3732

3833
/** @param array{name: array|string|TableIdentifier, on: PredicateInterface|string, columns: array, type: string} $join */

src/Sql/Part/JoinTableType.php

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

55
namespace PhpDb\Sql\Part;
66

7-
/**
8-
* Discriminator for join table variants.
9-
* Set at JoinSpec construction time so the render loop uses a match
10-
* instead of an instanceof chain.
11-
*/
127
enum JoinTableType
138
{
149
case Expression;

0 commit comments

Comments
 (0)