1 | <?php |
||||
2 | |||||
3 | /** |
||||
4 | * This file is part of Dimtrovich/Validation. |
||||
5 | * |
||||
6 | * (c) 2023 Dimitri Sitchet Tomkeu <[email protected]> |
||||
7 | * |
||||
8 | * For the full copyright and license information, please view |
||||
9 | * the LICENSE file that was distributed with this source code. |
||||
10 | */ |
||||
11 | |||||
12 | namespace Dimtrovich\Validation\Rules; |
||||
13 | |||||
14 | use Rakit\Validation\Attribute; |
||||
15 | use Rakit\Validation\Rule as RakitRule; |
||||
16 | |||||
17 | class Prohibits extends AbstractRule |
||||
18 | { |
||||
19 | /** |
||||
20 | * {@inheritDoc} |
||||
21 | */ |
||||
22 | public function fillParameters(array $params): RakitRule |
||||
23 | { |
||||
24 | $this->params['fields'] = $params; |
||||
25 | |||||
26 | return $this; |
||||
27 | } |
||||
28 | |||||
29 | /** |
||||
30 | * {@inheritDoc} |
||||
31 | */ |
||||
32 | public function check($value): bool |
||||
33 | { |
||||
34 | $this->requireParameters(['fields']); |
||||
35 | |||||
36 | $parameters = $this->parameter('fields'); |
||||
37 | |||||
38 | $this->setParameterTextValues($parameters, 'other'); |
||||
39 | |||||
40 | $requiredValidator = $this->getRuleValidator('required'); |
||||
41 | $requiredValidator->setAttribute($this->attribute); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
42 | |||||
43 | if ($requiredValidator->check($value)) { |
||||
44 | foreach ($parameters as $parameter) { |
||||
45 | $requiredValidator->setAttribute(new Attribute($this->validation, $parameter)); |
||||
0 ignored issues
–
show
It seems like
$this->validation can also be of type null ; however, parameter $validation of Rakit\Validation\Attribute::__construct() does only seem to accept Rakit\Validation\Validation , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
46 | if ($requiredValidator->check($this->validation->getValue($parameter))) { |
||||
0 ignored issues
–
show
The method
getValue() does not exist on null .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||
47 | return false; |
||||
48 | } |
||||
49 | } |
||||
50 | } |
||||
51 | |||||
52 | return true; |
||||
53 | } |
||||
54 | } |
||||
55 |