Skip to content

Commit

Permalink
改进依赖注入的数组判断
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Oct 15, 2024
1 parent 1ca27f4 commit 9a82e1e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/think/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,7 @@ protected function bindParams(ReflectionFunctionAbstract $reflect, array $vars =
}

// 判断数组类型 数字数组时按顺序绑定参数
reset($vars);
$type = key($vars) === 0 ? 1 : 0;
$type = array_is_list($vars) ? 1 : 0;
$params = $reflect->getParameters();
$args = [];

Expand Down
8 changes: 6 additions & 2 deletions src/think/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,9 @@ public function method(bool $origin = false): string
if ($origin) {
// 获取原始请求类型
return $this->server('REQUEST_METHOD') ?: 'GET';
} elseif (!$this->method) {
}

if (!$this->method) {
if (isset($this->post[$this->varMethod])) {
$method = strtolower($this->post[$this->varMethod]);
if (in_array($method, ['get', 'post', 'put', 'patch', 'delete'])) {
Expand Down Expand Up @@ -1029,7 +1031,9 @@ protected function getInputData(string $content): array
if ('application/x-www-form-urlencoded' == $contentType) {
parse_str($content, $data);
return $data;
} elseif (str_contains($contentType, 'json')) {
}

if (str_contains($contentType, 'json')) {
return (array) json_decode($content, true);
}

Expand Down

0 comments on commit 9a82e1e

Please sign in to comment.