mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-09 11:16:57 +00:00
Added more missing native types according to 8.0 standards
This commit is contained in:
@ -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)){
|
||||
|
Reference in New Issue
Block a user