ServerConfigGroup: do not assume that values are always bool|string

This commit is contained in:
Dylan K. Taylor 2021-10-07 20:02:21 +01:00
parent 847e24fc41
commit dc2e8e7e8f
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
2 changed files with 11 additions and 12 deletions

View File

@ -110,16 +110,20 @@ final class ServerConfigGroup{
}else{ }else{
$value = $this->serverProperties->exists($variable) ? $this->serverProperties->get($variable) : $defaultValue; $value = $this->serverProperties->exists($variable) ? $this->serverProperties->get($variable) : $defaultValue;
} }
if(is_bool($value)){ if(is_bool($value)){
return $value; return $value;
} }
switch(strtolower($value)){ if(is_int($value)){
case "on": return $value !== 0;
case "true": }
case "1": if(is_string($value)){
case "yes": switch(strtolower($value)){
return true; case "on":
case "true":
case "1":
case "yes":
return true;
}
} }
return false; return false;

View File

@ -40,11 +40,6 @@ parameters:
count: 2 count: 2
path: ../../../src/ServerConfigGroup.php path: ../../../src/ServerConfigGroup.php
-
message: "#^Parameter \\#1 \\$string of function strtolower expects string, mixed given\\.$#"
count: 1
path: ../../../src/ServerConfigGroup.php
- -
message: "#^Cannot access offset 'git' on mixed\\.$#" message: "#^Cannot access offset 'git' on mixed\\.$#"
count: 2 count: 2