1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace ApiSkeletons\Doctrine\ORM\GraphQL\Event; |
||
6 | |||
7 | use Doctrine\Common\Collections\Collection; |
||
8 | use Doctrine\Common\Collections\Criteria as DoctrineCriteria; |
||
9 | use Doctrine\ORM\PersistentCollection; |
||
10 | use GraphQL\Type\Definition\ResolveInfo; |
||
11 | use League\Event\HasEventName; |
||
12 | |||
13 | /** |
||
14 | * This event is dispatched when a Doctrine Criteria is created. |
||
15 | * Define an event using the Association::$criteriaEventName |
||
16 | */ |
||
17 | class Criteria implements |
||
18 | HasEventName |
||
19 | { |
||
20 | /** |
||
21 | * @param PersistentCollection<array-key, mixed> $collection |
||
22 | * @param mixed[] $args |
||
23 | */ |
||
24 | public function __construct( |
||
25 | protected readonly string $eventName, |
||
26 | protected readonly DoctrineCriteria $criteria, |
||
27 | protected Collection $collection, |
||
28 | protected readonly int $offset, |
||
29 | protected readonly int $limit, |
||
30 | protected readonly mixed $objectValue, |
||
31 | protected readonly array $args, |
||
32 | protected readonly mixed $context, |
||
33 | protected readonly ResolveInfo $info, |
||
34 | ) { |
||
35 | } |
||
36 | |||
37 | public function eventName(): string |
||
38 | { |
||
39 | return $this->eventName; |
||
40 | } |
||
41 | |||
42 | public function getCriteria(): DoctrineCriteria |
||
43 | { |
||
44 | return $this->criteria; |
||
45 | } |
||
46 | |||
47 | /** @return PersistentCollection<array-key, mixed> */ |
||
48 | public function getCollection(): Collection |
||
49 | { |
||
50 | return $this->collection; |
||
51 | } |
||
52 | |||
53 | /** @param Collection<array-key, mixed> $collection */ |
||
54 | public function setCollection(Collection $collection): void |
||
55 | { |
||
56 | $this->collection = $collection; |
||
0 ignored issues
–
show
|
|||
57 | } |
||
58 | |||
59 | public function getOffset(): int |
||
60 | { |
||
61 | return $this->offset; |
||
62 | } |
||
63 | |||
64 | public function getLimit(): int |
||
65 | { |
||
66 | return $this->limit; |
||
67 | } |
||
68 | |||
69 | public function getObjectValue(): mixed |
||
70 | { |
||
71 | return $this->objectValue; |
||
72 | } |
||
73 | |||
74 | /** @return mixed[] */ |
||
75 | public function getArgs(): array |
||
76 | { |
||
77 | return $this->args; |
||
78 | } |
||
79 | |||
80 | public function getContext(): mixed |
||
81 | { |
||
82 | return $this->context; |
||
83 | } |
||
84 | |||
85 | public function getInfo(): ResolveInfo |
||
86 | { |
||
87 | return $this->info; |
||
88 | } |
||
89 | } |
||
90 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.