Framework Update

This commit is contained in:
2024-01-31 22:15:08 +08:00
parent b5ff5e8b5f
commit 20678a6a0c
1459 changed files with 25954 additions and 16153 deletions
+16 -7
View File
@@ -1,27 +1,27 @@
<?php
/*
* This file is part of Respect/Validation.
*
* (c) Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Validation\Rules;
use Respect\Validation\Exceptions\ComponentException;
use Respect\Validation\Exceptions\ValidationException;
use Respect\Validation\NonNegatable;
use Respect\Validation\Validatable;
use function array_shift;
use function count;
use function current;
use function get_class;
use function sprintf;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Alexandre Gomes Gaigalas <alganet@gmail.com>
* @author Caio César Tavares <caiotava@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
@@ -101,6 +101,15 @@ final class Not extends AbstractRule
private function extractNegatedRule(Validatable $rule): Validatable
{
if ($rule instanceof NonNegatable) {
throw new ComponentException(
sprintf(
'"%s" can not be wrapped in Not()',
get_class($rule)
)
);
}
if ($rule instanceof self && $rule->getNegatedRule() instanceof self) {
return $this->extractNegatedRule($rule->getNegatedRule()->getNegatedRule());
}