Skip to content

Commit 3836fa9

Browse files
Fix 3: Better naming var, fix phpdoc, code style. (#386)
* Fix 3: Better naming var, fix phpdoc, code style.
1 parent 9d2b63c commit 3836fa9

8 files changed

Lines changed: 57 additions & 52 deletions

File tree

src/Constraint/DefaultValueConstraint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
final class DefaultValueConstraint extends Constraint
1111
{
12-
private mixed $value;
12+
private mixed $value = null;
1313

1414
public function getValue(): mixed
1515
{

src/Driver/PDO/ConnectionPDO.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ public function getActivePDO(string|null $sql = '', bool|null $forRead = null):
143143
public function getLastInsertID(string $sequenceName = null): string
144144
{
145145
if ($this->isActive() && $this->pdo) {
146-
return $this->pdo->lastInsertID($sequenceName === null
147-
? null : $this->getQuoter()->quoteTableName($sequenceName));
146+
return $this->pdo->lastInsertID(
147+
$sequenceName === null ? null : $this->getQuoter()->quoteTableName($sequenceName)
148+
);
148149
}
149150

150151
throw new InvalidCallException('DB Connection is not active.');

src/QueryBuilder/Conditions/BetweenColumnsCondition.php

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -83,48 +83,52 @@ public static function fromArrayDefinition(string $operator, array $operands): s
8383

8484
private static function validateValue(
8585
string $operator,
86-
mixed $operand
86+
mixed $value
8787
): array|int|string|Iterator|ExpressionInterface {
8888
if (
89-
!is_array($operand) &&
90-
!is_int($operand) &&
91-
!is_string($operand) &&
92-
!($operand instanceof Iterator) &&
93-
!($operand instanceof ExpressionInterface)
89+
!is_array($value) &&
90+
!is_int($value) &&
91+
!is_string($value) &&
92+
!($value instanceof Iterator) &&
93+
!($value instanceof ExpressionInterface)
9494
) {
9595
throw new InvalidArgumentException(
9696
"Operator '$operator' requires value to be array, int, string, Iterator or ExpressionInterface."
9797
);
9898
}
9999

100-
return $operand;
100+
return $value;
101101
}
102102

103-
private static function validateIntervalStartColumn(string $operator, mixed $operand): string|ExpressionInterface
104-
{
103+
private static function validateIntervalStartColumn(
104+
string $operator,
105+
mixed $intervalStartColumn
106+
): string|ExpressionInterface {
105107
if (
106-
!is_string($operand) &&
107-
!($operand instanceof ExpressionInterface)
108+
!is_string($intervalStartColumn) &&
109+
!($intervalStartColumn instanceof ExpressionInterface)
108110
) {
109111
throw new InvalidArgumentException(
110112
"Operator '$operator' requires interval start column to be string or ExpressionInterface."
111113
);
112114
}
113115

114-
return $operand;
116+
return $intervalStartColumn;
115117
}
116118

117-
private static function validateIntervalEndColumn(string $operator, mixed $operand): string|ExpressionInterface
118-
{
119+
private static function validateIntervalEndColumn(
120+
string $operator,
121+
mixed $intervalEndColumn
122+
): string|ExpressionInterface {
119123
if (
120-
!is_string($operand) &&
121-
!($operand instanceof ExpressionInterface)
124+
!is_string($intervalEndColumn) &&
125+
!($intervalEndColumn instanceof ExpressionInterface)
122126
) {
123127
throw new InvalidArgumentException(
124128
"Operator '$operator' requires interval end column to be string or ExpressionInterface."
125129
);
126130
}
127131

128-
return $operand;
132+
return $intervalEndColumn;
129133
}
130134
}

src/QueryBuilder/Conditions/BetweenCondition.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ public static function fromArrayDefinition(string $operator, array $operands): s
5353
return new self(self::validateColumn($operator, $operands[0]), $operator, $operands[1], $operands[2]);
5454
}
5555

56-
private static function validateColumn(string $operator, mixed $operand): string|Expression
56+
private static function validateColumn(string $operator, mixed $column): string|Expression
5757
{
58-
if (!is_string($operand) && !($operand instanceof Expression)) {
58+
if (!is_string($column) && !($column instanceof Expression)) {
5959
throw new InvalidArgumentException(
6060
"Operator '$operator' requires column to be string or ExpressionInterface."
6161
);
6262
}
6363

64-
return $operand;
64+
return $column;
6565
}
6666
}

src/QueryBuilder/Conditions/InCondition.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,23 @@ public static function fromArrayDefinition(string $operator, array $operands): s
5252
);
5353
}
5454

55-
private static function validateColumn(string $operator, mixed $operand): array|string|Iterator
55+
private static function validateColumn(string $operator, mixed $column): array|string|Iterator
5656
{
57-
if (!is_string($operand) && !is_array($operand) && !$operand instanceof Iterator) {
57+
if (!is_string($column) && !is_array($column) && !$column instanceof Iterator) {
5858
throw new InvalidArgumentException("Operator '$operator' requires column to be string, array or Iterator.");
5959
}
6060

61-
return $operand;
61+
return $column;
6262
}
6363

64-
private static function validateValues(string $operator, mixed $operand): int|iterable|Iterator|QueryInterface
64+
private static function validateValues(string $operator, mixed $values): int|iterable|Iterator|QueryInterface
6565
{
66-
if (!is_array($operand) && !$operand instanceof Iterator && !is_int($operand) && !$operand instanceof QueryInterface) {
66+
if (!is_array($values) && !$values instanceof Iterator && !is_int($values) && !$values instanceof QueryInterface) {
6767
throw new InvalidArgumentException(
6868
"Operator '$operator' requires values to be array, Iterator, int or QueryInterface."
6969
);
7070
}
7171

72-
return $operand;
72+
return $values;
7373
}
7474
}

src/QueryBuilder/Conditions/LikeCondition.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,32 +71,32 @@ public static function fromArrayDefinition(string $operator, array $operands): s
7171
return $condition;
7272
}
7373

74-
private static function validateColumn(string $operator, mixed $operand): string|Expression
74+
private static function validateColumn(string $operator, mixed $column): string|Expression
7575
{
76-
if (!is_string($operand) && !$operand instanceof Expression) {
76+
if (!is_string($column) && !$column instanceof Expression) {
7777
throw new InvalidArgumentException("Operator '$operator' requires column to be string or Expression.");
7878
}
7979

80-
return $operand;
80+
return $column;
8181
}
8282

8383
private static function validateValue(
8484
string $operator,
85-
mixed $operand
85+
mixed $value
8686
): array|int|string|Iterator|ExpressionInterface|null {
8787
if (
88-
!is_string($operand) &&
89-
!is_array($operand) &&
90-
!is_int($operand) &&
91-
!$operand instanceof Iterator &&
92-
!$operand instanceof ExpressionInterface &&
93-
$operand !== null
88+
!is_string($value) &&
89+
!is_array($value) &&
90+
!is_int($value) &&
91+
!$value instanceof Iterator &&
92+
!$value instanceof ExpressionInterface &&
93+
$value !== null
9494
) {
9595
throw new InvalidArgumentException(
9696
"Operator '$operator' requires value to be string, array, Iterator or ExpressionInterface."
9797
);
9898
}
9999

100-
return $operand;
100+
return $value;
101101
}
102102
}

src/QueryBuilder/Conditions/NotCondition.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,26 @@ public static function fromArrayDefinition(string $operator, array $operands): s
3333
return new self(self::validateCondition($operator, $operands));
3434
}
3535

36-
private static function validateCondition(string $operator, array $operands): ExpressionInterface|array|null|string
36+
private static function validateCondition(string $operator, array $condition): ExpressionInterface|array|null|string
3737
{
38-
if (count($operands) !== 1) {
38+
if (count($condition) !== 1) {
3939
throw new InvalidArgumentException("Operator '$operator' requires exactly one operand.");
4040
}
4141

42-
/** @var mixed $operands */
43-
$operands = array_shift($operands);
42+
/** @var mixed $condition */
43+
$condition = array_shift($condition);
4444

4545
if (
46-
!is_array($operands) &&
47-
!($operands instanceof ExpressionInterface) &&
48-
!is_string($operands) &&
49-
$operands !== null
46+
!is_array($condition) &&
47+
!($condition instanceof ExpressionInterface) &&
48+
!is_string($condition) &&
49+
$condition !== null
5050
) {
5151
throw new InvalidArgumentException(
5252
"Operator '$operator' requires condition to be array, string, null or ExpressionInterface."
5353
);
5454
}
5555

56-
return $operands;
56+
return $condition;
5757
}
5858
}

src/QueryBuilder/DDLQueryBuilderInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ public function addUnique(string $name, string $table, array|string $columns): s
146146
* @param string $table the table whose column is to be changed. The table name will be properly quoted by the
147147
* method.
148148
* @param string $column the name of the column to be changed. The name will be properly quoted by the method.
149-
* @param ColumnSchemaBuilder|string $type the new column type. The {@see getColumnType()} method will be invoked to convert abstract
150-
* column type (if any) into the physical one. Anything that is not recognized as abstract type will be kept
151-
* in the generated SQL.
149+
* @param ColumnSchemaBuilder|string $type the new column type. The {@see getColumnType()} method will be invoked
150+
* to convert abstract column type (if any) into the physical one. Anything that is not recognized as abstract type
151+
* will be kept in the generated SQL.
152152
*
153153
* For example, 'string' will be turned into 'varchar(255)', while 'string not null'
154154
* will become 'varchar(255) not null'.

0 commit comments

Comments
 (0)