Skip to content

Commit 051b235

Browse files
committed
clear validate function in time
1 parent 633303e commit 051b235

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/Controller.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ public function validate(): Controller {
174174
$this->par_validate->validate('URL', $this->par);
175175
$this->get_validate->validate('QUERY', $this->swoole_http_request->get);
176176
$this->post_validate->validate('POST', $this->swoole_http_request->post);
177+
$this->par_validate = $this->get_validate = $this->post_validate = null;
177178
$this->get = $this->swoole_http_request->get;
178179
$this->post = $this->swoole_http_request->post;
179180
return $this;

src/Validator.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ public function validate($key, &$value) {
6161
$this->check($key, $value);
6262
if (method_exists($this, 'validate_function'))
6363
$this->validate_function($value);
64-
foreach ($this->validate_function as $func)
64+
while ( ! $this->validate_function->isEmpty() ) {
65+
$func = $this->validate_function->dequeue();
6566
$func($value);
67+
unset($func);
68+
}
6669
}
6770
}

0 commit comments

Comments
 (0)