|
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 mixed $objectValue, |
|
29
|
|
|
protected readonly array $args, |
|
30
|
|
|
protected readonly mixed $context, |
|
31
|
|
|
protected readonly ResolveInfo $info, |
|
32
|
|
|
) { |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function eventName(): string |
|
36
|
|
|
{ |
|
37
|
|
|
return $this->eventName; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function getCriteria(): DoctrineCriteria |
|
41
|
|
|
{ |
|
42
|
|
|
return $this->criteria; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** @return PersistentCollection<array-key, mixed> */ |
|
46
|
|
|
public function getCollection(): Collection |
|
47
|
|
|
{ |
|
48
|
|
|
return $this->collection; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** @param Collection<array-key, mixed> $collection */ |
|
52
|
|
|
public function setCollection(Collection $collection): void |
|
53
|
|
|
{ |
|
54
|
|
|
$this->collection = $collection; |
|
|
|
|
|
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function getObjectValue(): mixed |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->objectValue; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** @return mixed[] */ |
|
63
|
|
|
public function getArgs(): array |
|
64
|
|
|
{ |
|
65
|
|
|
return $this->args; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function getContext(): mixed |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->context; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function getInfo(): ResolveInfo |
|
74
|
|
|
{ |
|
75
|
|
|
return $this->info; |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
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.