1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Yiisoft\Validator\Helper; |
6
|
|
|
|
7
|
|
|
use Yiisoft\Validator\PropagateOptionsInterface; |
8
|
|
|
use Yiisoft\Validator\RuleInterface; |
9
|
|
|
use Yiisoft\Validator\SkipOnEmptyInterface; |
10
|
|
|
use Yiisoft\Validator\SkipOnErrorInterface; |
11
|
|
|
use Yiisoft\Validator\WhenInterface; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* A helper class used to propagate options' values from a single parent rule to its child rules at all nesting levels |
15
|
|
|
* recursively. |
16
|
|
|
*/ |
17
|
|
|
final class PropagateOptionsHelper |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* Propagates options' values from a single parent rule to its child rules at all nesting levels recursively. The |
21
|
|
|
* following options' values are propagated: |
22
|
|
|
* |
23
|
|
|
* - `$skipOnEmpty` (both rules must implement {@see SkipOnEmptyInterface}). |
24
|
|
|
* - `$skipOnError` (both rules must implement {@see SkipOnErrorInterface}). |
25
|
|
|
* - `$when` (both rules must implement {@see WhenInterface}). |
26
|
|
|
* |
27
|
|
|
* @param RuleInterface $parentRule A parent rule which options' values need to be propagated. |
28
|
|
|
* @param iterable<RuleInterface> $childRules Direct child rules (located at the first nesting level) which options' |
29
|
|
|
* values must be changed to be the same as in parent. |
30
|
|
|
* |
31
|
|
|
* @return list<RuleInterface> A list of child rules of the same nesting level with changed options' values or |
|
|
|
|
32
|
|
|
* unchanged if none of the required interfaces were implemented. The order is preserved. |
33
|
|
|
*/ |
34
|
|
|
public static function propagate(RuleInterface $parentRule, iterable $childRules): array |
35
|
|
|
{ |
36
|
|
|
$rules = []; |
37
|
|
|
foreach ($childRules as $childRule) { |
38
|
|
|
if ($parentRule instanceof SkipOnEmptyInterface && $childRule instanceof SkipOnEmptyInterface) { |
39
|
|
|
$childRule = $childRule->skipOnEmpty($parentRule->getSkipOnEmpty()); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
if ($parentRule instanceof SkipOnErrorInterface && $childRule instanceof SkipOnErrorInterface) { |
43
|
|
|
$childRule = $childRule->skipOnError($parentRule->shouldSkipOnError()); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
if ($parentRule instanceof WhenInterface && $childRule instanceof WhenInterface) { |
47
|
|
|
$childRule = $childRule->when($parentRule->getWhen()); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
if ($childRule instanceof PropagateOptionsInterface) { |
51
|
|
|
$childRule->propagateOptions(); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
$rules[] = $childRule; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
return $rules; |
|
|
|
|
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths