Skip to content

Commit f746675

Browse files
Fixed type error when using Hyperf\Validation\Rules\Unique::__toString() in PHP8. (#3969)
Co-authored-by: 李铭昕 <715557344@qq.com>
1 parent 0492f91 commit f746675

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Rules/DatabaseRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public function queryCallbacks(): array
159159
protected function formatWheres(): string
160160
{
161161
return collect($this->wheres)->map(function ($where) {
162-
return $where['column'] . ',' . '"' . str_replace('"', '""', $where['value']) . '"';
162+
return $where['column'] . ',' . '"' . str_replace('"', '""', (string) $where['value']) . '"';
163163
})->implode(',');
164164
}
165165
}

tests/Cases/ValidationUniqueRuleTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ public function testItCorrectlyFormatsAStringVersionOfTheRule()
5959
$rule = new Unique('table');
6060
$rule->where('foo', '"bar"');
6161
$this->assertEquals('unique:table,NULL,NULL,id,foo,"""bar"""', (string) $rule);
62+
63+
$rule = new Unique('table');
64+
$rule->where('foo', 1);
65+
$this->assertEquals('unique:table,NULL,NULL,id,foo,"1"', (string) $rule);
6266
}
6367
}
6468

0 commit comments

Comments
 (0)