Added more missing native types according to 8.0 standards

This commit is contained in:
Dylan K. Taylor
2022-11-23 14:21:38 +00:00
parent 3b6ff3c42b
commit fdb07cdbcd
14 changed files with 31 additions and 108 deletions

View File

@ -341,11 +341,7 @@ class Config{
$this->remove($k);
}
/**
* @param string $key
* @param mixed $value
*/
public function setNested($key, $value) : void{
public function setNested(string $key, mixed $value) : void{
$vars = explode(".", $key);
$base = array_shift($vars);
@ -368,13 +364,7 @@ class Config{
$this->changed = true;
}
/**
* @param string $key
* @param mixed $default
*
* @return mixed
*/
public function getNested($key, $default = null){
public function getNested(string $key, mixed $default = null) : mixed{
if(isset($this->nestedCache[$key])){
return $this->nestedCache[$key];
}
@ -420,21 +410,11 @@ class Config{
}
}
/**
* @param string $k
* @param mixed $default
*
* @return bool|mixed
*/
public function get($k, $default = false){
public function get(string $k, mixed $default = false) : mixed{
return $this->config[$k] ?? $default;
}
/**
* @param string $k key to be set
* @param mixed $v value to set key
*/
public function set($k, $v = true) : void{
public function set(string $k, mixed $v = true) : void{
$this->config[$k] = $v;
$this->changed = true;
foreach(Utils::stringifyKeys($this->nestedCache) as $nestedKey => $nvalue){
@ -454,10 +434,9 @@ class Config{
}
/**
* @param string $k
* @param bool $lowercase If set, searches Config in single-case / lowercase.
* @param bool $lowercase If set, searches Config in single-case / lowercase.
*/
public function exists($k, bool $lowercase = false) : bool{
public function exists(string $k, bool $lowercase = false) : bool{
if($lowercase){
$k = strtolower($k); //Convert requested key to lower
$array = array_change_key_case($this->config, CASE_LOWER); //Change all keys in array to lower
@ -467,10 +446,7 @@ class Config{
}
}
/**
* @param string $k
*/
public function remove($k) : void{
public function remove(string $k) : void{
unset($this->config[$k]);
$this->changed = true;
}
@ -498,7 +474,7 @@ class Config{
* @phpstan-param array<string, mixed> $data
* @phpstan-param-out array<string, mixed> $data
*/
private function fillDefaults(array $default, &$data) : int{
private function fillDefaults(array $default, array &$data) : int{
$changed = 0;
foreach(Utils::stringifyKeys($default) as $k => $v){
if(is_array($v)){