Skip to content

Commit

Permalink
fix(Validate): PHP8 method_exists 需传入对象或类名字符串
Browse files Browse the repository at this point in the history
TypeError : method_exists(): Argument #1 ($object_or_class) must be of type object|string, array given
  • Loading branch information
twinh committed Jan 8, 2021
1 parent f02a3ef commit 174ca14
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Validate.php
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ public function validateOne($rule, $input, $options = [], &$validator = null, $p
$options = [$options];
}

// dd('xxx', $options, $input);
// dd('xxx', $options, $input);

if (is_int(key($options))) {
array_unshift($options, $input);
Expand Down Expand Up @@ -1010,7 +1010,7 @@ private function getDataByPaths($data, array $paths)
return null;
} elseif (isset($data->{$path})) {
$data = $data->{$path};
} elseif (method_exists($data, 'get' . $path)) {
} elseif (is_object($data) && method_exists($data, 'get' . $path)) {
$data = $data->{'get' . $path}();
} else {
return null;
Expand Down

0 comments on commit 174ca14

Please sign in to comment.