mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-11-29 18:27:44 +08:00
Fixed type error when using Hyperf\Validation\Rules\Unique::__toString()
in PHP8. (#3969)
Co-authored-by: 李铭昕 <715557344@qq.com>
This commit is contained in:
parent
fb2a0536d1
commit
cf1bc96e28
@ -1,5 +1,9 @@
|
||||
# v2.2.6 - TBD
|
||||
|
||||
## Fixed
|
||||
|
||||
- [#3969](https://github.com/hyperf/hyperf/pull/3969) Fixed type error when using `Hyperf\Validation\Rules\Unique::__toString()` in PHP8.
|
||||
|
||||
# v2.2.5 - 2021-08-23
|
||||
|
||||
## Fixed
|
||||
|
@ -159,7 +159,7 @@ trait DatabaseRule
|
||||
protected function formatWheres(): string
|
||||
{
|
||||
return collect($this->wheres)->map(function ($where) {
|
||||
return $where['column'] . ',' . '"' . str_replace('"', '""', $where['value']) . '"';
|
||||
return $where['column'] . ',' . '"' . str_replace('"', '""', (string) $where['value']) . '"';
|
||||
})->implode(',');
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,10 @@ class ValidationUniqueRuleTest extends TestCase
|
||||
$rule = new Unique('table');
|
||||
$rule->where('foo', '"bar"');
|
||||
$this->assertEquals('unique:table,NULL,NULL,id,foo,"""bar"""', (string) $rule);
|
||||
|
||||
$rule = new Unique('table');
|
||||
$rule->where('foo', 1);
|
||||
$this->assertEquals('unique:table,NULL,NULL,id,foo,"1"', (string) $rule);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user