From 0721c56797596e07507e7d73af7edbcd8a792fe9 Mon Sep 17 00:00:00 2001 From: Victor Westerlund Date: Wed, 29 Nov 2023 09:23:55 +0100 Subject: [PATCH] fix: bool true bug --- src/Rules.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Rules.php b/src/Rules.php index ca28972..c498ccb 100644 --- a/src/Rules.php +++ b/src/Rules.php @@ -78,6 +78,10 @@ // Add Type constraint with optional argument public function type(Type $type, mixed $arg = null): self { if ($type === Type::ENUM) { + if (!is_array($arg)) { + throw new \Exception("Expected type 'array' of ENUM values as second argument"); + } + $this->enum = $arg; } @@ -129,7 +133,8 @@ } 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); } /*