Skip to content

Commit 0114c7c

Browse files
committed
used PHP 8.2 features
1 parent 1a84d3e commit 0114c7c

3 files changed

Lines changed: 4 additions & 12 deletions

File tree

src/Database/SqlPreprocessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ private function formatMultiInsert(array $groups): string
242242
throw new Nette\InvalidArgumentException('Automaticaly detected multi-insert, but values aren\'t array. If you need try to change ?mode.');
243243
}
244244

245-
$cols = array_keys(is_array($groups[0]) ? $groups[0] : iterator_to_array($groups[0]));
245+
$cols = array_keys(iterator_to_array($groups[0]));
246246
$vals = [];
247247
foreach ($groups as $group) {
248248
$rowVals = [];

src/Database/Table/ActiveRow.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,7 @@ public function related(string $key, ?string $throughColumn = null): GroupedSele
136136
*/
137137
public function update(iterable $data): bool
138138
{
139-
if ($data instanceof \Traversable) {
140-
$data = iterator_to_array($data);
141-
}
139+
$data = iterator_to_array($data);
142140

143141
$primary = $this->getPrimary();
144142
if (!is_array($primary)) {

src/Database/Table/Selection.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -800,10 +800,7 @@ public function insert(iterable $data): ActiveRow|array|int|bool
800800
$return = $this->explorer->query($this->sqlBuilder->buildInsertQuery() . ' ' . $data->getSql(), ...$data->getSqlBuilder()->getParameters());
801801

802802
} else {
803-
if ($data instanceof \Traversable) {
804-
$data = iterator_to_array($data);
805-
}
806-
803+
$data = iterator_to_array($data);
807804
$return = $this->explorer->query($this->sqlBuilder->buildInsertQuery() . ' ?values', $data);
808805
}
809806

@@ -873,10 +870,7 @@ public function insert(iterable $data): ActiveRow|array|int|bool
873870
*/
874871
public function update(iterable $data): int
875872
{
876-
if ($data instanceof \Traversable) {
877-
$data = iterator_to_array($data);
878-
}
879-
873+
$data = iterator_to_array($data);
880874
if (!$data) {
881875
return 0;
882876
}

0 commit comments

Comments
 (0)