mirror of
https://codeberg.org/reflect/reflect-rules-plugin.git
synced 2025-09-14 00:43:42 +02:00
fix: bool true bug
This commit is contained in:
parent
1f39f31b4c
commit
0721c56797
1 changed files with 6 additions and 1 deletions
|
@ -78,6 +78,10 @@
|
||||||
// Add Type constraint with optional argument
|
// Add Type constraint with optional argument
|
||||||
public function type(Type $type, mixed $arg = null): self {
|
public function type(Type $type, mixed $arg = null): self {
|
||||||
if ($type === Type::ENUM) {
|
if ($type === Type::ENUM) {
|
||||||
|
if (!is_array($arg)) {
|
||||||
|
throw new \Exception("Expected type 'array' of ENUM values as second argument");
|
||||||
|
}
|
||||||
|
|
||||||
$this->enum = $arg;
|
$this->enum = $arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +133,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private function eval_type_enum(mixed $value): bool {
|
private function eval_type_enum(mixed $value): bool {
|
||||||
return in_array($value, $this->enum);
|
// Return true if value isn't boolean and exists in enum array
|
||||||
|
return !is_bool($value) && in_array($value, $this->enum);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Reference in a new issue