Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kevindees committed Aug 4, 2022
1 parent 64fbe9e commit bac282d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Database/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ public function add(string $name, \wpdb $wpdb)
}

/**
* @param string $name
* @param null|string $name
* @return $this
*/
public function addFromConfig(string $name, ?array $config = null)
public function addFromConfig(?string $name, ?array $config = null)
{
if(is_null($config)) {
if(is_null($config) || is_null($name)) {
$drivers = Config::getFromContainer()->locate('database.drivers');
$config = $drivers[$name];
$config = $drivers[$name] ?? Config::getFromContainer()->locate('database.default');
}

/** @var DatabaseConnector $connector */
Expand All @@ -71,10 +71,10 @@ public function getOrAddFromConfig(string $name, ?array $config = null)
}

/**
* @param string $name
* @param ?string $name
* @return \wpdb
*/
public function get(string $name, ?string $fallback = null)
public function get(?string $name, ?string $fallback = null)
{
if(!array_key_exists($name, $this->connections) && is_null($fallback)) {
$this->addFromConfig($name);
Expand Down Expand Up @@ -111,7 +111,7 @@ public function close(string $name)
*/
public function default()
{
$default = Config::getFromContainer()->locate('database.default');
$default = Config::getFromContainer()->locate('database.default', 'wp');
return $this->get($default);
}

Expand Down

0 comments on commit bac282d

Please sign in to comment.