|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* It's free open-source software released under the MIT License. |
|
5
|
|
|
* |
|
6
|
|
|
* @author Anatoly Nekhay <[email protected]> |
|
7
|
|
|
* @copyright Copyright (c) 2021, Anatoly Nekhay |
|
8
|
|
|
* @license https://github.com/sunrise-php/hydrator/blob/master/LICENSE |
|
9
|
|
|
* @link https://github.com/sunrise-php/hydrator |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace Sunrise\Hydrator\Exception; |
|
15
|
|
|
|
|
16
|
|
|
use Symfony\Component\Validator\ConstraintViolation; |
|
17
|
|
|
use Symfony\Component\Validator\ConstraintViolationList; |
|
18
|
|
|
use Symfony\Component\Validator\ConstraintViolationListInterface; |
|
19
|
|
|
use RuntimeException; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* InvalidDataException |
|
23
|
|
|
* |
|
24
|
|
|
* @since 3.0.0 |
|
25
|
|
|
*/ |
|
26
|
|
|
class InvalidDataException extends RuntimeException implements ExceptionInterface |
|
27
|
|
|
{ |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var list<InvalidValueException> |
|
|
|
|
|
|
31
|
|
|
*/ |
|
32
|
|
|
private array $exceptions; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Constructor of the class |
|
36
|
|
|
* |
|
37
|
|
|
* @param string $message |
|
38
|
|
|
* @param list<InvalidValueException> $exceptions |
|
39
|
|
|
*/ |
|
40
|
116 |
|
public function __construct(string $message, array $exceptions = []) |
|
41
|
|
|
{ |
|
42
|
116 |
|
parent::__construct($message); |
|
43
|
|
|
|
|
44
|
116 |
|
$this->exceptions = $exceptions; |
|
|
|
|
|
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @return list<InvalidValueException> |
|
49
|
|
|
*/ |
|
50
|
113 |
|
final public function getExceptions(): array |
|
51
|
|
|
{ |
|
52
|
113 |
|
return $this->exceptions; |
|
|
|
|
|
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @return ConstraintViolationListInterface |
|
57
|
|
|
*/ |
|
58
|
1 |
|
final public function getViolations(): ConstraintViolationListInterface |
|
59
|
|
|
{ |
|
60
|
1 |
|
$violations = []; |
|
61
|
1 |
|
foreach ($this->exceptions as $exception) { |
|
62
|
1 |
|
$violations[] = new ConstraintViolation( |
|
63
|
1 |
|
$exception->getMessage(), |
|
64
|
1 |
|
null, |
|
65
|
1 |
|
[], |
|
66
|
1 |
|
null, |
|
67
|
1 |
|
$exception->getPropertyPath(), |
|
68
|
1 |
|
null, |
|
69
|
1 |
|
null, |
|
70
|
1 |
|
$exception->getErrorCode() |
|
71
|
1 |
|
); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
1 |
|
return new ConstraintViolationList($violations); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|
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