Skip to content

Commit 501a64f

Browse files
committed
fix: add setter/getter for limit/offset to avoid refelction usage
1 parent 35686b1 commit 501a64f

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

src/Migration/MigrationContext.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public function __construct(
2626
private ?GatewayInterface $gateway = null,
2727
private ?DataSet $dataSet = null,
2828
private readonly string $runUuid = '',
29-
private readonly int $offset = 0,
30-
private readonly int $limit = 0,
29+
private int $offset = 0,
30+
private int $limit = 0,
3131
) {
3232
}
3333

@@ -89,8 +89,18 @@ public function getOffset(): int
8989
return $this->offset;
9090
}
9191

92+
public function setOffset(int $offset): void
93+
{
94+
$this->offset = $offset;
95+
}
96+
9297
public function getLimit(): int
9398
{
9499
return $this->limit;
95100
}
101+
102+
public function setLimit(int $limit): void
103+
{
104+
$this->limit = $limit;
105+
}
96106
}

src/Migration/MigrationContextInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,9 @@ public function getDataSet(): ?DataSet;
3434

3535
public function getOffset(): int;
3636

37+
public function setOffset(int $offset): void;
38+
3739
public function getLimit(): int;
40+
41+
public function setLimit(int $limit): void;
3842
}

tests/LocalConnectionTestCase.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,8 @@ abstract protected function getDataSet(): DataSet;
7070

7171
protected function setLimitAndOffset(int $limit, int $offset): void
7272
{
73-
$reflectionClass = new \ReflectionClass($this->getMigrationContext());
74-
(new \ReflectionProperty($reflectionClass->getName(), 'limit'))->setValue($this->getMigrationContext(), $limit);
75-
(new \ReflectionProperty($reflectionClass->getName(), 'offset'))->setValue($this->getMigrationContext(), $offset);
73+
$this->getMigrationContext()->setLimit($limit);
74+
$this->getMigrationContext()->setOffset($offset);
7675
}
7776

7877
protected function getExternalConnection(): Connection

0 commit comments

Comments
 (0)