Skip to content

Commit bb0bdc2

Browse files
sukhwinder33445lippserd
authored andcommitted
Adapt to ipl-stdlib strict typing
`ipl-stdlib` introduces strict type declarations, requiring all classes implementing its interfaces to match the exact parameter and return types defined there. Updated affected classes and bumped the required `ipl-stdlib` version in `composer.json` accordingly. Remove the now obsolete `@throws InvalidArgumentException` annotation since the strict `arrayval()` function no longer throws this exception. Remove the now redundant `InAndNotInUtils` trait, which was originally added to suppress PHPStan errors before strict typing was introduced.
1 parent f916b29 commit bb0bdc2

10 files changed

Lines changed: 9 additions & 91 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"require": {
99
"php": ">=8.2",
1010
"ext-pdo": "*",
11-
"ipl/stdlib": ">=0.12.0"
11+
"ipl/stdlib": ">=0.15.0"
1212
},
1313
"require-dev": {
1414
"ipl/stdlib": "dev-main"

src/Connection.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,6 @@ public function select(Select $select): PDOStatement
429429
* @param iterable $data Row data in terms of column-value pairs
430430
*
431431
* @return PDOStatement
432-
*
433-
* @throws InvalidArgumentException If data type is invalid
434432
*/
435433
public function insert(string $table, iterable $data): PDOStatement
436434
{
@@ -470,8 +468,6 @@ public function lastInsertId(?string $name = null): false|string
470468
* @param string $operator The operator to combine multiple conditions with, if the condition is in the array format
471469
*
472470
* @return PDOStatement
473-
*
474-
* @throws InvalidArgumentException If data type is invalid
475471
*/
476472
public function update(
477473
string|array $table,

src/Cursor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function getLimit(): ?int
7575
return $this->select->getLimit();
7676
}
7777

78-
public function limit($limit)
78+
public function limit(?int $limit): static
7979
{
8080
$this->select->limit($limit);
8181

@@ -92,7 +92,7 @@ public function getOffset(): ?int
9292
return $this->select->getOffset();
9393
}
9494

95-
public function offset($offset)
95+
public function offset(?int $offset): static
9696
{
9797
$this->select->offset($offset);
9898

src/Filter/In.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
class In extends Filter\Condition
99
{
10-
use InAndNotInUtils;
11-
1210
/**
1311
* Create a new sql IN condition
1412
*
@@ -17,8 +15,6 @@ class In extends Filter\Condition
1715
*/
1816
public function __construct(string|array $column, Select $select)
1917
{
20-
$this
21-
->setColumn($column)
22-
->setValue($select);
18+
parent::__construct($column, $select);
2319
}
2420
}

src/Filter/InAndNotInUtils.php

Lines changed: 0 additions & 62 deletions
This file was deleted.

src/Filter/NotIn.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
class NotIn extends Filter\Condition
99
{
10-
use InAndNotInUtils;
11-
1210
/**
1311
* Create a new sql NOT IN condition
1412
*
@@ -17,8 +15,6 @@ class NotIn extends Filter\Condition
1715
*/
1816
public function __construct(string|array $column, Select $select)
1917
{
20-
$this
21-
->setColumn($column)
22-
->setValue($select);
18+
parent::__construct($column, $select);
2319
}
2420
}

src/Insert.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace ipl\Sql;
44

5-
use InvalidArgumentException;
6-
75
use function ipl\Stdlib\arrayval;
86

97
/**
@@ -118,8 +116,6 @@ public function getValues(): array
118116
* @param iterable $values List of values or associative set of column-value pairs
119117
*
120118
* @return $this
121-
*
122-
* @throws InvalidArgumentException If values type is invalid
123119
*/
124120
public function values(iterable $values): static
125121
{

src/LimitOffset.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function getLimit(): ?int
3535
return $this->limit;
3636
}
3737

38-
public function limit($limit)
38+
public function limit(?int $limit): static
3939
{
4040
$this->limit = $limit < 0 ? null : $limit;
4141

@@ -59,7 +59,7 @@ public function getOffset(): ?int
5959
return $this->offset;
6060
}
6161

62-
public function offset($offset)
62+
public function offset(?int $offset): static
6363
{
6464
$this->offset = $offset <= 0 ? null : $offset;
6565

src/LimitOffsetInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function getLimit(): ?int;
2828
*
2929
* @return $this
3030
*/
31-
public function limit($limit);
31+
public function limit(?int $limit): static;
3232

3333
/**
3434
* Reset the limit
@@ -59,7 +59,7 @@ public function getOffset(): ?int;
5959
*
6060
* @return $this
6161
*/
62-
public function offset($offset);
62+
public function offset(?int $offset): static;
6363

6464
/**
6565
* Reset the offset

src/Update.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace ipl\Sql;
44

5-
use InvalidArgumentException;
6-
75
use function ipl\Stdlib\arrayval;
86

97
/**
@@ -75,8 +73,6 @@ public function getSet(): ?array
7573
* @param iterable $set Associative set of column-value pairs
7674
*
7775
* @return $this
78-
*
79-
* @throws InvalidArgumentException If set type is invalid
8076
*/
8177
public function set(iterable $set): static
8278
{

0 commit comments

Comments
 (0)