Issues (54)

src/Exception/InvalidDataException.php (3 issues)

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\ConstraintViolationList;
17
use Symfony\Component\Validator\ConstraintViolationListInterface;
18
use RuntimeException;
19
20
/**
21
 * @since 3.0.0
22
 */
23
class InvalidDataException extends RuntimeException implements ExceptionInterface
24
{
25
    /**
26
     * @var list<InvalidValueException>
0 ignored issues
show
The type Sunrise\Hydrator\Exception\list was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
27
     */
28
    private array $exceptions;
29
30
    /**
31
     * @param list<InvalidValueException> $exceptions
32
     */
33 249
    public function __construct(string $message, array $exceptions = [])
34
    {
35 249
        parent::__construct($message);
36
37 249
        $this->exceptions = $exceptions;
0 ignored issues
show
Documentation Bug introduced by
It seems like $exceptions of type array is incompatible with the declared type Sunrise\Hydrator\Exception\list of property $exceptions.

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..

Loading history...
38
    }
39
40
    /**
41
     * @return list<InvalidValueException>
42
     */
43 246
    final public function getExceptions(): array
44
    {
45 246
        return $this->exceptions;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->exceptions returns the type array which is incompatible with the documented return type Sunrise\Hydrator\Exception\list.
Loading history...
46
    }
47
48 1
    final public function getViolations(): ConstraintViolationListInterface
49
    {
50 1
        $violations = new ConstraintViolationList();
51 1
        foreach ($this->exceptions as $exception) {
52 1
            $violations->add($exception->getViolation());
53
        }
54
55 1
        return $violations;
56
    }
57
}
58