From 9045f65a2198bc993286368be43c067a79c7f022 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 6 Jan 2025 14:55:19 +0100 Subject: [PATCH] Fix wrong type received by "KeySet" rule I've defined the type that `KeySet` would receive as `Key` because, in fact, it should only accept `Key` rules. However, the `Validator::__callStatic()` method (called when you run `v::key(...)`) will create an instance of itself, not the instance of `Key`, and that's because you might want to add more rules to the chain. Knowing that, we did some workaround in which `KeySet` will check if the given rules are either a `Key` or a `Validator` with only one Key rule. This commit will replace the type from `Key` to `Validatable`, and let the implementation deal with the wrong type. --- library/ChainedValidator.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/ChainedValidator.php b/library/ChainedValidator.php index 18c257800..c56cee985 100644 --- a/library/ChainedValidator.php +++ b/library/ChainedValidator.php @@ -10,7 +10,6 @@ namespace Respect\Validation; use finfo; -use Respect\Validation\Rules\Key; interface ChainedValidator extends Validatable { @@ -199,7 +198,7 @@ public function keyNested( bool $mandatory = true ): ChainedValidator; - public function keySet(Key ...$rule): ChainedValidator; + public function keySet(Validatable ...$rule): ChainedValidator; public function keyValue(string $comparedKey, string $ruleName, string $baseKey): ChainedValidator;