1 | <?php |
||||
2 | |||||
3 | declare(strict_types=1); |
||||
4 | |||||
5 | namespace Koriym\AppStateDiagram; |
||||
6 | |||||
7 | use stdClass; |
||||
8 | |||||
9 | use function implode; |
||||
10 | use function is_array; |
||||
11 | use function strtoupper; |
||||
12 | use function usort; |
||||
13 | |||||
14 | use const PHP_EOL; |
||||
15 | |||||
16 | final class LinkRelations |
||||
17 | { |
||||
18 | /** @var list<LinkRelation> */ |
||||
0 ignored issues
–
show
|
|||||
19 | private $links; |
||||
20 | |||||
21 | /** @param list<stdClass>|stdClass|null $link */ |
||||
22 | public function __construct($link = null) |
||||
23 | { |
||||
24 | if ($link === null) { |
||||
25 | $this->links = []; |
||||
0 ignored issues
–
show
It seems like
array() of type array is incompatible with the declared type Koriym\AppStateDiagram\list of property $links .
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.. ![]() |
|||||
26 | |||||
27 | return; |
||||
28 | } |
||||
29 | |||||
30 | if (is_array($link)) { |
||||
31 | $this->links = $this->createLinkRelations($link); |
||||
32 | |||||
33 | return; |
||||
34 | } |
||||
35 | |||||
36 | $this->links = [new LinkRelation($link)]; |
||||
37 | } |
||||
38 | |||||
39 | /** |
||||
40 | * @param list<stdClass> $links |
||||
41 | * |
||||
42 | * @return list<LinkRelation> |
||||
43 | */ |
||||
44 | private function createLinkRelations(array $links): array |
||||
45 | { |
||||
46 | $linkRelations = []; |
||||
47 | foreach ($links as $link) { |
||||
48 | $linkRelations[] = new LinkRelation($link); |
||||
49 | } |
||||
50 | |||||
51 | usort($linkRelations, static function (LinkRelation $a, LinkRelation $b): int { |
||||
52 | return strtoupper($a->rel) <=> strtoupper($b->rel); |
||||
53 | }); |
||||
54 | |||||
55 | return $linkRelations; |
||||
56 | } |
||||
57 | |||||
58 | public function __toString(): string |
||||
59 | { |
||||
60 | return implode(PHP_EOL, $this->links); |
||||
0 ignored issues
–
show
$this->links of type Koriym\AppStateDiagram\list is incompatible with the type array expected by parameter $pieces of implode() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
61 | } |
||||
62 | } |
||||
63 |
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