1 | <?php |
||
2 | |||
3 | /** |
||
4 | * Copyright © 2016-present Spryker Systems GmbH. All rights reserved. |
||
5 | * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
||
6 | */ |
||
7 | |||
8 | namespace Spryker\Zed\Category\Business\Validator; |
||
9 | |||
10 | use Generated\Shared\Transfer\CategoryClosureTableCollectionRequestTransfer; |
||
11 | use Generated\Shared\Transfer\CategoryClosureTableCollectionResponseTransfer; |
||
12 | use Generated\Shared\Transfer\ErrorCollectionTransfer; |
||
13 | use Spryker\Zed\Category\Business\Validator\Rule\TerminationAwareValidatorRuleInterface; |
||
14 | |||
15 | class CategoryClosureTableValidator implements CategoryClosureTableValidatorInterface |
||
16 | { |
||
17 | /** |
||
18 | * @var list<\Spryker\Zed\Category\Business\Validator\Rule\CategoryClosureTable\CategoryClosureTableValidatorRuleInterface> |
||
19 | */ |
||
20 | protected array $categoryClosureTableValidatorRules; |
||
21 | |||
22 | /** |
||
23 | * @param list<\Spryker\Zed\Category\Business\Validator\Rule\CategoryClosureTable\CategoryClosureTableValidatorRuleInterface> $categoryClosureTableValidatorRules |
||
24 | */ |
||
25 | public function __construct(array $categoryClosureTableValidatorRules) |
||
26 | { |
||
27 | $this->categoryClosureTableValidatorRules = $categoryClosureTableValidatorRules; |
||
0 ignored issues
–
show
|
|||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @param \Generated\Shared\Transfer\CategoryClosureTableCollectionRequestTransfer $categoryClosureTableCollectionRequestTransfer |
||
32 | * |
||
33 | * @return \Generated\Shared\Transfer\CategoryClosureTableCollectionResponseTransfer |
||
34 | */ |
||
35 | public function validateCollection( |
||
36 | CategoryClosureTableCollectionRequestTransfer $categoryClosureTableCollectionRequestTransfer |
||
37 | ): CategoryClosureTableCollectionResponseTransfer { |
||
38 | $NodeTransfers = $categoryClosureTableCollectionRequestTransfer->getCategoryNodes(); |
||
39 | $categoryClosureTableCollectionResponseTransfer = (new CategoryClosureTableCollectionResponseTransfer()) |
||
40 | ->setCategoryNodes($NodeTransfers); |
||
41 | |||
42 | $initialErrorCollectionTransfer = (new ErrorCollectionTransfer()); |
||
43 | foreach ($this->categoryClosureTableValidatorRules as $categoryUrlValidatorRule) { |
||
44 | $initialErrorCollectionTransfer->setErrors($categoryClosureTableCollectionResponseTransfer->getErrors()); |
||
45 | $postValidationErrorCollectionTransfer = $categoryUrlValidatorRule->validate($NodeTransfers); |
||
46 | |||
47 | $categoryClosureTableCollectionResponseTransfer = $this->mergeErrors( |
||
48 | $categoryClosureTableCollectionResponseTransfer, |
||
49 | $postValidationErrorCollectionTransfer, |
||
50 | ); |
||
51 | |||
52 | if ($categoryUrlValidatorRule instanceof TerminationAwareValidatorRuleInterface) { |
||
53 | $categoryUrlValidatorRule->isTerminated( |
||
54 | $initialErrorCollectionTransfer->getErrors(), |
||
55 | $postValidationErrorCollectionTransfer->getErrors(), |
||
56 | ); |
||
57 | |||
58 | break; |
||
59 | } |
||
60 | } |
||
61 | |||
62 | return $categoryClosureTableCollectionResponseTransfer; |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * @param \Generated\Shared\Transfer\CategoryClosureTableCollectionResponseTransfer $categoryUrlCollectionResponseTransfer |
||
67 | * @param \Generated\Shared\Transfer\ErrorCollectionTransfer $postValidationErrorCollectionTransfer |
||
68 | * |
||
69 | * @return \Generated\Shared\Transfer\CategoryClosureTableCollectionResponseTransfer |
||
70 | */ |
||
71 | protected function mergeErrors( |
||
72 | CategoryClosureTableCollectionResponseTransfer $categoryUrlCollectionResponseTransfer, |
||
73 | ErrorCollectionTransfer $postValidationErrorCollectionTransfer |
||
74 | ): CategoryClosureTableCollectionResponseTransfer { |
||
75 | foreach ($postValidationErrorCollectionTransfer->getErrors() as $errorTransfer) { |
||
76 | $categoryUrlCollectionResponseTransfer->addError($errorTransfer); |
||
77 | } |
||
78 | |||
79 | return $categoryUrlCollectionResponseTransfer; |
||
80 | } |
||
81 | } |
||
82 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..