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{
$value = $this->serverProperties->exists($variable) ? $this->serverProperties->get($variable) : $defaultValue;
}
if(is_bool($value)){
return $value;
}
switch(strtolower($value)){
case "on":
case "true":
case "1":
case "yes":
return true;
if(is_int($value)){
return $value !== 0;
}
if(is_string($value)){
switch(strtolower($value)){
case "on":
case "true":
case "1":
case "yes":
return true;
}
}
return false;

View File

@ -40,11 +40,6 @@ parameters:
count: 2
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\\.$#"
count: 2