Skip to content

Commit

Permalink
修复param引用
Browse files Browse the repository at this point in the history
  • Loading branch information
kiss291323003 committed Oct 11, 2023
1 parent 9e5a530 commit 16c7634
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/AnnotationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ private function paramValidate(Param $param,array $allDefineParams,Request $requ
$rules = $param->validate;
/** @var AbstractValidator $rule */
foreach ($rules as $rule){
$rule = clone $rule;
$rule->allCheckParams($allDefineParams);
$ret = $rule->execute($param,$request);
if(!$ret){
Expand Down
13 changes: 7 additions & 6 deletions src/Attributes/Param.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,13 @@ public function hasSet():bool

function __clone()
{
$temp = [];
/** @var AbstractValidator $item */
foreach ($this->validate as $item){
$temp[$item->ruleName()] = clone $item;
}
$this->validate = $temp;
//规则在调用层做克隆,不然循环引用。
// $temp = [];
// /** @var AbstractValidator $item */
// foreach ($this->validate as $item){
// $temp[$item->ruleName()] = clone $item;
// }
// $this->validate = $temp;

$temp = [];
/** @var Param $item */
Expand Down

0 comments on commit 16c7634

Please sign in to comment.