Skip to content

Commit

Permalink
使用 array_replace_recursive 代替 array_merge 修正数组数字下标合并键丢失
Browse files Browse the repository at this point in the history
  • Loading branch information
fengqi committed Jun 21, 2018
1 parent 4972178 commit 923d0af
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function bootstrap()
static::setInstance($this);

// 加载组件
$component = array_merge($this->component, $this->configGet('app.component'));
$component = array_replace_recursive($this->component, $this->configGet('app.component'));
foreach ($component as $item) {
$class = new $item;
if (!$class instanceof Component) continue;
Expand Down Expand Up @@ -277,7 +277,7 @@ protected function loadConfigure($item, $force = false)
$env_config = require $env_config_file;
}

$this->config[$item] = array_merge($config, $env_config);
$this->config[$item] = array_replace_recursive($config, $env_config);

return $this->config[$item];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function enableHttpRequestParameterOverride()
*/
public function input()
{
return array_merge($this->query->all(), $this->attributes->all(), $this->request->all());
return array_replace_recursive($this->query->all(), $this->attributes->all(), $this->request->all());
}

/**
Expand Down

0 comments on commit 923d0af

Please sign in to comment.