Skip to content

Commit 5e3b774

Browse files
committed
Support PHP 8.4 (unfinished)
1 parent 1614e43 commit 5e3b774

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/Options.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ public function __construct(
5050
} elseif ($this->driver === 'pgsql') {
5151
$this->binarySelectedAsStream = true;
5252
$this->nativeBoolColumns = true;
53-
$this->floatSelectedAsString = true;
53+
54+
if (PHP_VERSION_ID < 80_400) {
55+
$this->floatSelectedAsString = true;
56+
}
5457
}
5558
}
5659
}

test/DbTestCase.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,13 @@ public function testInsertBulk(): void
250250
if ($options->binarySelectedAsStream || $options->nativeBoolColumns || $options->floatSelectedAsString) {
251251
/** @var array{weight: float|string, is_disabled: int|bool, uuid: string|resource} $row */
252252
foreach ($rows as &$row) {
253-
if (!is_float($row['weight'])) {
253+
if ($options->floatSelectedAsString) {
254254
$row['weight'] = (float) $row['weight'];
255255
}
256-
if (!is_int($row['is_disabled'])) {
256+
if ($options->nativeBoolColumns) {
257257
$row['is_disabled'] = (int) $row['is_disabled'];
258258
}
259-
if (!is_string($row['uuid'])) {
259+
if ($options->binarySelectedAsStream) {
260260
/** @psalm-suppress InvalidArgument */
261261
$row['uuid'] = stream_get_contents($row['uuid']);
262262
}
@@ -274,12 +274,13 @@ public function testInsertBulk(): void
274274
$userId = $ids[0];
275275
$set = ['uuid' => $peachySql->makeBinaryParam($newUuid)];
276276
$peachySql->updateRows($this->table, $set, ['user_id' => $userId]);
277-
/** @var array{uuid: string|resource} $updatedRow */
278277
$updatedRow = $peachySql->selectFrom("SELECT uuid FROM {$this->table}")
279278
->where(['user_id' => $userId])->query()->getFirst();
280279

281-
if (!is_string($updatedRow['uuid'])) {
282-
$updatedRow['uuid'] = stream_get_contents($updatedRow['uuid']); // needed for PostgreSQL
280+
if ($updatedRow === null) {
281+
throw new \Exception('Failed to select updated UUID');
282+
} elseif ($options->binarySelectedAsStream && is_resource($updatedRow['uuid'])) {
283+
$updatedRow['uuid'] = stream_get_contents($updatedRow['uuid']);
283284
}
284285

285286
$this->assertSame($newUuid, $updatedRow['uuid']);

0 commit comments

Comments
 (0)